babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665
  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. * Gets or sets the size of the texture what stores the shadows
  18494. */
  18495. get mapSize(): number;
  18496. set mapSize(size: number);
  18497. /**
  18498. * Creates a ShadowGenerator object.
  18499. * A ShadowGenerator is the required tool to use the shadows.
  18500. * Each light casting shadows needs to use its own ShadowGenerator.
  18501. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18502. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18503. * @param light The light object generating the shadows.
  18504. * @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.
  18505. */
  18506. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18507. protected _initializeGenerator(): void;
  18508. protected _createTargetRenderTexture(): void;
  18509. protected _initializeShadowMap(): void;
  18510. protected _initializeBlurRTTAndPostProcesses(): void;
  18511. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18512. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18513. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18514. protected _applyFilterValues(): void;
  18515. /**
  18516. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18517. * @param onCompiled Callback triggered at the and of the effects compilation
  18518. * @param options Sets of optional options forcing the compilation with different modes
  18519. */
  18520. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18521. useInstances: boolean;
  18522. }>): void;
  18523. /**
  18524. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18525. * @param options Sets of optional options forcing the compilation with different modes
  18526. * @returns A promise that resolves when the compilation completes
  18527. */
  18528. forceCompilationAsync(options?: Partial<{
  18529. useInstances: boolean;
  18530. }>): Promise<void>;
  18531. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18532. private _prepareShadowDefines;
  18533. /**
  18534. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18535. * @param subMesh The submesh we want to render in the shadow map
  18536. * @param useInstances Defines wether will draw in the map using instances
  18537. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18538. * @returns true if ready otherwise, false
  18539. */
  18540. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18541. /**
  18542. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18543. * @param defines Defines of the material we want to update
  18544. * @param lightIndex Index of the light in the enabled light list of the material
  18545. */
  18546. prepareDefines(defines: any, lightIndex: number): void;
  18547. /**
  18548. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18549. * defined in the generator but impacting the effect).
  18550. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18551. * @param effect The effect we are binfing the information for
  18552. */
  18553. bindShadowLight(lightIndex: string, effect: Effect): void;
  18554. /**
  18555. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18556. * (eq to shadow prjection matrix * light transform matrix)
  18557. * @returns The transform matrix used to create the shadow map
  18558. */
  18559. getTransformMatrix(): Matrix;
  18560. /**
  18561. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18562. * Cube and 2D textures for instance.
  18563. */
  18564. recreateShadowMap(): void;
  18565. protected _disposeBlurPostProcesses(): void;
  18566. protected _disposeRTTandPostProcesses(): void;
  18567. /**
  18568. * Disposes the ShadowGenerator.
  18569. * Returns nothing.
  18570. */
  18571. dispose(): void;
  18572. /**
  18573. * Serializes the shadow generator setup to a json object.
  18574. * @returns The serialized JSON object
  18575. */
  18576. serialize(): any;
  18577. /**
  18578. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18579. * @param parsedShadowGenerator The JSON object to parse
  18580. * @param scene The scene to create the shadow map for
  18581. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18582. * @returns The parsed shadow generator
  18583. */
  18584. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18585. }
  18586. }
  18587. declare module "babylonjs/Lights/light" {
  18588. import { Nullable } from "babylonjs/types";
  18589. import { Scene } from "babylonjs/scene";
  18590. import { Vector3 } from "babylonjs/Maths/math.vector";
  18591. import { Color3 } from "babylonjs/Maths/math.color";
  18592. import { Node } from "babylonjs/node";
  18593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18594. import { Effect } from "babylonjs/Materials/effect";
  18595. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18596. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18597. /**
  18598. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18599. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18600. * 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.
  18601. */
  18602. export abstract class Light extends Node {
  18603. /**
  18604. * Falloff Default: light is falling off following the material specification:
  18605. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18606. */
  18607. static readonly FALLOFF_DEFAULT: number;
  18608. /**
  18609. * Falloff Physical: light is falling off following the inverse squared distance law.
  18610. */
  18611. static readonly FALLOFF_PHYSICAL: number;
  18612. /**
  18613. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18614. * to enhance interoperability with other engines.
  18615. */
  18616. static readonly FALLOFF_GLTF: number;
  18617. /**
  18618. * Falloff Standard: light is falling off like in the standard material
  18619. * to enhance interoperability with other materials.
  18620. */
  18621. static readonly FALLOFF_STANDARD: number;
  18622. /**
  18623. * If every light affecting the material is in this lightmapMode,
  18624. * material.lightmapTexture adds or multiplies
  18625. * (depends on material.useLightmapAsShadowmap)
  18626. * after every other light calculations.
  18627. */
  18628. static readonly LIGHTMAP_DEFAULT: number;
  18629. /**
  18630. * material.lightmapTexture as only diffuse lighting from this light
  18631. * adds only specular lighting from this light
  18632. * adds dynamic shadows
  18633. */
  18634. static readonly LIGHTMAP_SPECULAR: number;
  18635. /**
  18636. * material.lightmapTexture as only lighting
  18637. * no light calculation from this light
  18638. * only adds dynamic shadows from this light
  18639. */
  18640. static readonly LIGHTMAP_SHADOWSONLY: number;
  18641. /**
  18642. * Each light type uses the default quantity according to its type:
  18643. * point/spot lights use luminous intensity
  18644. * directional lights use illuminance
  18645. */
  18646. static readonly INTENSITYMODE_AUTOMATIC: number;
  18647. /**
  18648. * lumen (lm)
  18649. */
  18650. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18651. /**
  18652. * candela (lm/sr)
  18653. */
  18654. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18655. /**
  18656. * lux (lm/m^2)
  18657. */
  18658. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18659. /**
  18660. * nit (cd/m^2)
  18661. */
  18662. static readonly INTENSITYMODE_LUMINANCE: number;
  18663. /**
  18664. * Light type const id of the point light.
  18665. */
  18666. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18667. /**
  18668. * Light type const id of the directional light.
  18669. */
  18670. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18671. /**
  18672. * Light type const id of the spot light.
  18673. */
  18674. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18675. /**
  18676. * Light type const id of the hemispheric light.
  18677. */
  18678. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18679. /**
  18680. * Diffuse gives the basic color to an object.
  18681. */
  18682. diffuse: Color3;
  18683. /**
  18684. * Specular produces a highlight color on an object.
  18685. * Note: This is note affecting PBR materials.
  18686. */
  18687. specular: Color3;
  18688. /**
  18689. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18690. * falling off base on range or angle.
  18691. * This can be set to any values in Light.FALLOFF_x.
  18692. *
  18693. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18694. * other types of materials.
  18695. */
  18696. falloffType: number;
  18697. /**
  18698. * Strength of the light.
  18699. * Note: By default it is define in the framework own unit.
  18700. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18701. */
  18702. intensity: number;
  18703. private _range;
  18704. protected _inverseSquaredRange: 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. get range(): number;
  18710. /**
  18711. * Defines how far from the source the light is impacting in scene units.
  18712. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18713. */
  18714. set range(value: number);
  18715. /**
  18716. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18717. * of light.
  18718. */
  18719. private _photometricScale;
  18720. private _intensityMode;
  18721. /**
  18722. * Gets 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. get intensityMode(): number;
  18726. /**
  18727. * Sets the photometric scale used to interpret the intensity.
  18728. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18729. */
  18730. set intensityMode(value: number);
  18731. private _radius;
  18732. /**
  18733. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18734. */
  18735. get radius(): number;
  18736. /**
  18737. * sets the light radius used by PBR Materials to simulate soft area lights.
  18738. */
  18739. set radius(value: number);
  18740. private _renderPriority;
  18741. /**
  18742. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18743. * exceeding the number allowed of the materials.
  18744. */
  18745. renderPriority: number;
  18746. private _shadowEnabled;
  18747. /**
  18748. * Gets 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. get shadowEnabled(): boolean;
  18752. /**
  18753. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18754. * the current shadow generator.
  18755. */
  18756. set shadowEnabled(value: boolean);
  18757. private _includedOnlyMeshes;
  18758. /**
  18759. * Gets the only meshes impacted by this light.
  18760. */
  18761. get includedOnlyMeshes(): AbstractMesh[];
  18762. /**
  18763. * Sets the only meshes impacted by this light.
  18764. */
  18765. set includedOnlyMeshes(value: AbstractMesh[]);
  18766. private _excludedMeshes;
  18767. /**
  18768. * Gets the meshes not impacted by this light.
  18769. */
  18770. get excludedMeshes(): AbstractMesh[];
  18771. /**
  18772. * Sets the meshes not impacted by this light.
  18773. */
  18774. set excludedMeshes(value: AbstractMesh[]);
  18775. private _excludeWithLayerMask;
  18776. /**
  18777. * Gets the layer id use to find what meshes are not impacted by the light.
  18778. * Inactive if 0
  18779. */
  18780. get excludeWithLayerMask(): number;
  18781. /**
  18782. * Sets the layer id use to find what meshes are not impacted by the light.
  18783. * Inactive if 0
  18784. */
  18785. set excludeWithLayerMask(value: number);
  18786. private _includeOnlyWithLayerMask;
  18787. /**
  18788. * Gets the layer id use to find what meshes are impacted by the light.
  18789. * Inactive if 0
  18790. */
  18791. get includeOnlyWithLayerMask(): number;
  18792. /**
  18793. * Sets the layer id use to find what meshes are impacted by the light.
  18794. * Inactive if 0
  18795. */
  18796. set includeOnlyWithLayerMask(value: number);
  18797. private _lightmapMode;
  18798. /**
  18799. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18800. */
  18801. get lightmapMode(): number;
  18802. /**
  18803. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18804. */
  18805. set lightmapMode(value: number);
  18806. /**
  18807. * Shadow generator associted to the light.
  18808. * @hidden Internal use only.
  18809. */
  18810. _shadowGenerator: Nullable<IShadowGenerator>;
  18811. /**
  18812. * @hidden Internal use only.
  18813. */
  18814. _excludedMeshesIds: string[];
  18815. /**
  18816. * @hidden Internal use only.
  18817. */
  18818. _includedOnlyMeshesIds: string[];
  18819. /**
  18820. * The current light unifom buffer.
  18821. * @hidden Internal use only.
  18822. */
  18823. _uniformBuffer: UniformBuffer;
  18824. /** @hidden */
  18825. _renderId: number;
  18826. /**
  18827. * Creates a Light object in the scene.
  18828. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18829. * @param name The firendly name of the light
  18830. * @param scene The scene the light belongs too
  18831. */
  18832. constructor(name: string, scene: Scene);
  18833. protected abstract _buildUniformLayout(): void;
  18834. /**
  18835. * Sets the passed Effect "effect" with the Light information.
  18836. * @param effect The effect to update
  18837. * @param lightIndex The index of the light in the effect to update
  18838. * @returns The light
  18839. */
  18840. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18841. /**
  18842. * Sets the passed Effect "effect" with the Light textures.
  18843. * @param effect The effect to update
  18844. * @param lightIndex The index of the light in the effect to update
  18845. * @returns The light
  18846. */
  18847. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18848. /**
  18849. * Binds the lights information from the scene to the effect for the given mesh.
  18850. * @param lightIndex Light index
  18851. * @param scene The scene where the light belongs to
  18852. * @param effect The effect we are binding the data to
  18853. * @param useSpecular Defines if specular is supported
  18854. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18855. */
  18856. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18857. /**
  18858. * Sets the passed Effect "effect" with the Light information.
  18859. * @param effect The effect to update
  18860. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18861. * @returns The light
  18862. */
  18863. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18864. /**
  18865. * Returns the string "Light".
  18866. * @returns the class name
  18867. */
  18868. getClassName(): string;
  18869. /** @hidden */
  18870. readonly _isLight: boolean;
  18871. /**
  18872. * Converts the light information to a readable string for debug purpose.
  18873. * @param fullDetails Supports for multiple levels of logging within scene loading
  18874. * @returns the human readable light info
  18875. */
  18876. toString(fullDetails?: boolean): string;
  18877. /** @hidden */
  18878. protected _syncParentEnabledState(): void;
  18879. /**
  18880. * Set the enabled state of this node.
  18881. * @param value - the new enabled state
  18882. */
  18883. setEnabled(value: boolean): void;
  18884. /**
  18885. * Returns the Light associated shadow generator if any.
  18886. * @return the associated shadow generator.
  18887. */
  18888. getShadowGenerator(): Nullable<IShadowGenerator>;
  18889. /**
  18890. * Returns a Vector3, the absolute light position in the World.
  18891. * @returns the world space position of the light
  18892. */
  18893. getAbsolutePosition(): Vector3;
  18894. /**
  18895. * Specifies if the light will affect the passed mesh.
  18896. * @param mesh The mesh to test against the light
  18897. * @return true the mesh is affected otherwise, false.
  18898. */
  18899. canAffectMesh(mesh: AbstractMesh): boolean;
  18900. /**
  18901. * Sort function to order lights for rendering.
  18902. * @param a First Light object to compare to second.
  18903. * @param b Second Light object to compare first.
  18904. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18905. */
  18906. static CompareLightsPriority(a: Light, b: Light): number;
  18907. /**
  18908. * Releases resources associated with this node.
  18909. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18910. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18911. */
  18912. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18913. /**
  18914. * Returns the light type ID (integer).
  18915. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18916. */
  18917. getTypeID(): number;
  18918. /**
  18919. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18920. * @returns the scaled intensity in intensity mode unit
  18921. */
  18922. getScaledIntensity(): number;
  18923. /**
  18924. * Returns a new Light object, named "name", from the current one.
  18925. * @param name The name of the cloned light
  18926. * @param newParent The parent of this light, if it has one
  18927. * @returns the new created light
  18928. */
  18929. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18930. /**
  18931. * Serializes the current light into a Serialization object.
  18932. * @returns the serialized object.
  18933. */
  18934. serialize(): any;
  18935. /**
  18936. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18937. * This new light is named "name" and added to the passed scene.
  18938. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18939. * @param name The friendly name of the light
  18940. * @param scene The scene the new light will belong to
  18941. * @returns the constructor function
  18942. */
  18943. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18944. /**
  18945. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18946. * @param parsedLight The JSON representation of the light
  18947. * @param scene The scene to create the parsed light in
  18948. * @returns the created light after parsing
  18949. */
  18950. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18951. private _hookArrayForExcluded;
  18952. private _hookArrayForIncludedOnly;
  18953. private _resyncMeshes;
  18954. /**
  18955. * Forces the meshes to update their light related information in their rendering used effects
  18956. * @hidden Internal Use Only
  18957. */
  18958. _markMeshesAsLightDirty(): void;
  18959. /**
  18960. * Recomputes the cached photometric scale if needed.
  18961. */
  18962. private _computePhotometricScale;
  18963. /**
  18964. * Returns the Photometric Scale according to the light type and intensity mode.
  18965. */
  18966. private _getPhotometricScale;
  18967. /**
  18968. * Reorder the light in the scene according to their defined priority.
  18969. * @hidden Internal Use Only
  18970. */
  18971. _reorderLightsInScene(): void;
  18972. /**
  18973. * Prepares the list of defines specific to the light type.
  18974. * @param defines the list of defines
  18975. * @param lightIndex defines the index of the light for the effect
  18976. */
  18977. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18978. }
  18979. }
  18980. declare module "babylonjs/Materials/prePassConfiguration" {
  18981. import { Matrix } from "babylonjs/Maths/math.vector";
  18982. import { Mesh } from "babylonjs/Meshes/mesh";
  18983. import { Scene } from "babylonjs/scene";
  18984. import { Effect } from "babylonjs/Materials/effect";
  18985. /**
  18986. * Configuration needed for prepass-capable materials
  18987. */
  18988. export class PrePassConfiguration {
  18989. /**
  18990. * Previous world matrices of meshes carrying this material
  18991. * Used for computing velocity
  18992. */
  18993. previousWorldMatrices: {
  18994. [index: number]: Matrix;
  18995. };
  18996. /**
  18997. * Previous view project matrix
  18998. * Used for computing velocity
  18999. */
  19000. previousViewProjection: Matrix;
  19001. /**
  19002. * Previous bones of meshes carrying this material
  19003. * Used for computing velocity
  19004. */
  19005. previousBones: {
  19006. [index: number]: Float32Array;
  19007. };
  19008. /**
  19009. * Add the required uniforms to the current list.
  19010. * @param uniforms defines the current uniform list.
  19011. */
  19012. static AddUniforms(uniforms: string[]): void;
  19013. /**
  19014. * Add the required samplers to the current list.
  19015. * @param samplers defines the current sampler list.
  19016. */
  19017. static AddSamplers(samplers: string[]): void;
  19018. /**
  19019. * Binds the material data.
  19020. * @param effect defines the effect to update
  19021. * @param scene defines the scene the material belongs to.
  19022. * @param mesh The mesh
  19023. * @param world World matrix of this mesh
  19024. * @param isFrozen Is the material frozen
  19025. */
  19026. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  19027. }
  19028. }
  19029. declare module "babylonjs/Cameras/targetCamera" {
  19030. import { Nullable } from "babylonjs/types";
  19031. import { Camera } from "babylonjs/Cameras/camera";
  19032. import { Scene } from "babylonjs/scene";
  19033. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  19034. /**
  19035. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  19036. * This is the base of the follow, arc rotate cameras and Free camera
  19037. * @see https://doc.babylonjs.com/features/cameras
  19038. */
  19039. export class TargetCamera extends Camera {
  19040. private static _RigCamTransformMatrix;
  19041. private static _TargetTransformMatrix;
  19042. private static _TargetFocalPoint;
  19043. private _tmpUpVector;
  19044. private _tmpTargetVector;
  19045. /**
  19046. * Define the current direction the camera is moving to
  19047. */
  19048. cameraDirection: Vector3;
  19049. /**
  19050. * Define the current rotation the camera is rotating to
  19051. */
  19052. cameraRotation: Vector2;
  19053. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  19054. ignoreParentScaling: boolean;
  19055. /**
  19056. * When set, the up vector of the camera will be updated by the rotation of the camera
  19057. */
  19058. updateUpVectorFromRotation: boolean;
  19059. private _tmpQuaternion;
  19060. /**
  19061. * Define the current rotation of the camera
  19062. */
  19063. rotation: Vector3;
  19064. /**
  19065. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  19066. */
  19067. rotationQuaternion: Quaternion;
  19068. /**
  19069. * Define the current speed of the camera
  19070. */
  19071. speed: number;
  19072. /**
  19073. * Add constraint to the camera to prevent it to move freely in all directions and
  19074. * around all axis.
  19075. */
  19076. noRotationConstraint: boolean;
  19077. /**
  19078. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  19079. * panning
  19080. */
  19081. invertRotation: boolean;
  19082. /**
  19083. * Speed multiplier for inverse camera panning
  19084. */
  19085. inverseRotationSpeed: number;
  19086. /**
  19087. * Define the current target of the camera as an object or a position.
  19088. */
  19089. lockedTarget: any;
  19090. /** @hidden */
  19091. _currentTarget: Vector3;
  19092. /** @hidden */
  19093. _initialFocalDistance: number;
  19094. /** @hidden */
  19095. _viewMatrix: Matrix;
  19096. /** @hidden */
  19097. _camMatrix: Matrix;
  19098. /** @hidden */
  19099. _cameraTransformMatrix: Matrix;
  19100. /** @hidden */
  19101. _cameraRotationMatrix: Matrix;
  19102. /** @hidden */
  19103. _referencePoint: Vector3;
  19104. /** @hidden */
  19105. _transformedReferencePoint: Vector3;
  19106. /** @hidden */
  19107. _reset: () => void;
  19108. private _defaultUp;
  19109. /**
  19110. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19111. * This is the base of the follow, arc rotate cameras and Free camera
  19112. * @see https://doc.babylonjs.com/features/cameras
  19113. * @param name Defines the name of the camera in the scene
  19114. * @param position Defines the start position of the camera in the scene
  19115. * @param scene Defines the scene the camera belongs to
  19116. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19117. */
  19118. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19119. /**
  19120. * Gets the position in front of the camera at a given distance.
  19121. * @param distance The distance from the camera we want the position to be
  19122. * @returns the position
  19123. */
  19124. getFrontPosition(distance: number): Vector3;
  19125. /** @hidden */
  19126. _getLockedTargetPosition(): Nullable<Vector3>;
  19127. private _storedPosition;
  19128. private _storedRotation;
  19129. private _storedRotationQuaternion;
  19130. /**
  19131. * Store current camera state of the camera (fov, position, rotation, etc..)
  19132. * @returns the camera
  19133. */
  19134. storeState(): Camera;
  19135. /**
  19136. * Restored camera state. You must call storeState() first
  19137. * @returns whether it was successful or not
  19138. * @hidden
  19139. */
  19140. _restoreStateValues(): boolean;
  19141. /** @hidden */
  19142. _initCache(): void;
  19143. /** @hidden */
  19144. _updateCache(ignoreParentClass?: boolean): void;
  19145. /** @hidden */
  19146. _isSynchronizedViewMatrix(): boolean;
  19147. /** @hidden */
  19148. _computeLocalCameraSpeed(): number;
  19149. /**
  19150. * Defines the target the camera should look at.
  19151. * @param target Defines the new target as a Vector or a mesh
  19152. */
  19153. setTarget(target: Vector3): void;
  19154. /**
  19155. * Defines the target point of the camera.
  19156. * The camera looks towards it form the radius distance.
  19157. */
  19158. get target(): Vector3;
  19159. set target(value: Vector3);
  19160. /**
  19161. * Return the current target position of the camera. This value is expressed in local space.
  19162. * @returns the target position
  19163. */
  19164. getTarget(): Vector3;
  19165. /** @hidden */
  19166. _decideIfNeedsToMove(): boolean;
  19167. /** @hidden */
  19168. _updatePosition(): void;
  19169. /** @hidden */
  19170. _checkInputs(): void;
  19171. protected _updateCameraRotationMatrix(): void;
  19172. /**
  19173. * 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)
  19174. * @returns the current camera
  19175. */
  19176. private _rotateUpVectorWithCameraRotationMatrix;
  19177. private _cachedRotationZ;
  19178. private _cachedQuaternionRotationZ;
  19179. /** @hidden */
  19180. _getViewMatrix(): Matrix;
  19181. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19182. /**
  19183. * @hidden
  19184. */
  19185. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19186. /**
  19187. * @hidden
  19188. */
  19189. _updateRigCameras(): void;
  19190. private _getRigCamPositionAndTarget;
  19191. /**
  19192. * Gets the current object class name.
  19193. * @return the class name
  19194. */
  19195. getClassName(): string;
  19196. }
  19197. }
  19198. declare module "babylonjs/Events/keyboardEvents" {
  19199. /**
  19200. * Gather the list of keyboard event types as constants.
  19201. */
  19202. export class KeyboardEventTypes {
  19203. /**
  19204. * The keydown event is fired when a key becomes active (pressed).
  19205. */
  19206. static readonly KEYDOWN: number;
  19207. /**
  19208. * The keyup event is fired when a key has been released.
  19209. */
  19210. static readonly KEYUP: number;
  19211. }
  19212. /**
  19213. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19214. */
  19215. export class KeyboardInfo {
  19216. /**
  19217. * Defines the type of event (KeyboardEventTypes)
  19218. */
  19219. type: number;
  19220. /**
  19221. * Defines the related dom event
  19222. */
  19223. event: KeyboardEvent;
  19224. /**
  19225. * Instantiates a new keyboard info.
  19226. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19227. * @param type Defines the type of event (KeyboardEventTypes)
  19228. * @param event Defines the related dom event
  19229. */
  19230. constructor(
  19231. /**
  19232. * Defines the type of event (KeyboardEventTypes)
  19233. */
  19234. type: number,
  19235. /**
  19236. * Defines the related dom event
  19237. */
  19238. event: KeyboardEvent);
  19239. }
  19240. /**
  19241. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19242. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19243. */
  19244. export class KeyboardInfoPre extends KeyboardInfo {
  19245. /**
  19246. * Defines the type of event (KeyboardEventTypes)
  19247. */
  19248. type: number;
  19249. /**
  19250. * Defines the related dom event
  19251. */
  19252. event: KeyboardEvent;
  19253. /**
  19254. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19255. */
  19256. skipOnPointerObservable: boolean;
  19257. /**
  19258. * Instantiates a new keyboard pre info.
  19259. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19260. * @param type Defines the type of event (KeyboardEventTypes)
  19261. * @param event Defines the related dom event
  19262. */
  19263. constructor(
  19264. /**
  19265. * Defines the type of event (KeyboardEventTypes)
  19266. */
  19267. type: number,
  19268. /**
  19269. * Defines the related dom event
  19270. */
  19271. event: KeyboardEvent);
  19272. }
  19273. }
  19274. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19275. import { Nullable } from "babylonjs/types";
  19276. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19277. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19278. /**
  19279. * Manage the keyboard inputs to control the movement of a free camera.
  19280. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19281. */
  19282. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19283. /**
  19284. * Defines the camera the input is attached to.
  19285. */
  19286. camera: FreeCamera;
  19287. /**
  19288. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19289. */
  19290. keysUp: number[];
  19291. /**
  19292. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19293. */
  19294. keysUpward: number[];
  19295. /**
  19296. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19297. */
  19298. keysDown: number[];
  19299. /**
  19300. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19301. */
  19302. keysDownward: number[];
  19303. /**
  19304. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19305. */
  19306. keysLeft: number[];
  19307. /**
  19308. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19309. */
  19310. keysRight: number[];
  19311. private _keys;
  19312. private _onCanvasBlurObserver;
  19313. private _onKeyboardObserver;
  19314. private _engine;
  19315. private _scene;
  19316. /**
  19317. * Attach the input controls to a specific dom element to get the input from.
  19318. * @param element Defines the element the controls should be listened from
  19319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19320. */
  19321. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19322. /**
  19323. * Detach the current controls from the specified dom element.
  19324. * @param element Defines the element to stop listening the inputs from
  19325. */
  19326. detachControl(element: Nullable<HTMLElement>): void;
  19327. /**
  19328. * Update the current camera state depending on the inputs that have been used this frame.
  19329. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19330. */
  19331. checkInputs(): void;
  19332. /**
  19333. * Gets the class name of the current intput.
  19334. * @returns the class name
  19335. */
  19336. getClassName(): string;
  19337. /** @hidden */
  19338. _onLostFocus(): void;
  19339. /**
  19340. * Get the friendly name associated with the input class.
  19341. * @returns the input friendly name
  19342. */
  19343. getSimpleName(): string;
  19344. }
  19345. }
  19346. declare module "babylonjs/Events/pointerEvents" {
  19347. import { Nullable } from "babylonjs/types";
  19348. import { Vector2 } from "babylonjs/Maths/math.vector";
  19349. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19350. import { Ray } from "babylonjs/Culling/ray";
  19351. /**
  19352. * Gather the list of pointer event types as constants.
  19353. */
  19354. export class PointerEventTypes {
  19355. /**
  19356. * 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.
  19357. */
  19358. static readonly POINTERDOWN: number;
  19359. /**
  19360. * The pointerup event is fired when a pointer is no longer active.
  19361. */
  19362. static readonly POINTERUP: number;
  19363. /**
  19364. * The pointermove event is fired when a pointer changes coordinates.
  19365. */
  19366. static readonly POINTERMOVE: number;
  19367. /**
  19368. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19369. */
  19370. static readonly POINTERWHEEL: number;
  19371. /**
  19372. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19373. */
  19374. static readonly POINTERPICK: number;
  19375. /**
  19376. * The pointertap event is fired when a the object has been touched and released without drag.
  19377. */
  19378. static readonly POINTERTAP: number;
  19379. /**
  19380. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19381. */
  19382. static readonly POINTERDOUBLETAP: number;
  19383. }
  19384. /**
  19385. * Base class of pointer info types.
  19386. */
  19387. export class PointerInfoBase {
  19388. /**
  19389. * Defines the type of event (PointerEventTypes)
  19390. */
  19391. type: number;
  19392. /**
  19393. * Defines the related dom event
  19394. */
  19395. event: PointerEvent | MouseWheelEvent;
  19396. /**
  19397. * Instantiates the base class of pointers info.
  19398. * @param type Defines the type of event (PointerEventTypes)
  19399. * @param event Defines the related dom event
  19400. */
  19401. constructor(
  19402. /**
  19403. * Defines the type of event (PointerEventTypes)
  19404. */
  19405. type: number,
  19406. /**
  19407. * Defines the related dom event
  19408. */
  19409. event: PointerEvent | MouseWheelEvent);
  19410. }
  19411. /**
  19412. * This class is used to store pointer related info for the onPrePointerObservable event.
  19413. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19414. */
  19415. export class PointerInfoPre extends PointerInfoBase {
  19416. /**
  19417. * Ray from a pointer if availible (eg. 6dof controller)
  19418. */
  19419. ray: Nullable<Ray>;
  19420. /**
  19421. * Defines the local position of the pointer on the canvas.
  19422. */
  19423. localPosition: Vector2;
  19424. /**
  19425. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19426. */
  19427. skipOnPointerObservable: boolean;
  19428. /**
  19429. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19430. * @param type Defines the type of event (PointerEventTypes)
  19431. * @param event Defines the related dom event
  19432. * @param localX Defines the local x coordinates of the pointer when the event occured
  19433. * @param localY Defines the local y coordinates of the pointer when the event occured
  19434. */
  19435. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19436. }
  19437. /**
  19438. * This type contains all the data related to a pointer event in Babylon.js.
  19439. * 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.
  19440. */
  19441. export class PointerInfo extends PointerInfoBase {
  19442. /**
  19443. * Defines the picking info associated to the info (if any)\
  19444. */
  19445. pickInfo: Nullable<PickingInfo>;
  19446. /**
  19447. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19448. * @param type Defines the type of event (PointerEventTypes)
  19449. * @param event Defines the related dom event
  19450. * @param pickInfo Defines the picking info associated to the info (if any)\
  19451. */
  19452. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19453. /**
  19454. * Defines the picking info associated to the info (if any)\
  19455. */
  19456. pickInfo: Nullable<PickingInfo>);
  19457. }
  19458. /**
  19459. * Data relating to a touch event on the screen.
  19460. */
  19461. export interface PointerTouch {
  19462. /**
  19463. * X coordinate of touch.
  19464. */
  19465. x: number;
  19466. /**
  19467. * Y coordinate of touch.
  19468. */
  19469. y: number;
  19470. /**
  19471. * Id of touch. Unique for each finger.
  19472. */
  19473. pointerId: number;
  19474. /**
  19475. * Event type passed from DOM.
  19476. */
  19477. type: any;
  19478. }
  19479. }
  19480. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19481. import { Observable } from "babylonjs/Misc/observable";
  19482. import { Nullable } from "babylonjs/types";
  19483. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19484. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19485. /**
  19486. * Manage the mouse inputs to control the movement of a free camera.
  19487. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19488. */
  19489. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19490. /**
  19491. * Define if touch is enabled in the mouse input
  19492. */
  19493. touchEnabled: boolean;
  19494. /**
  19495. * Defines the camera the input is attached to.
  19496. */
  19497. camera: FreeCamera;
  19498. /**
  19499. * Defines the buttons associated with the input to handle camera move.
  19500. */
  19501. buttons: number[];
  19502. /**
  19503. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19504. */
  19505. angularSensibility: number;
  19506. private _pointerInput;
  19507. private _onMouseMove;
  19508. private _observer;
  19509. private previousPosition;
  19510. /**
  19511. * Observable for when a pointer move event occurs containing the move offset
  19512. */
  19513. onPointerMovedObservable: Observable<{
  19514. offsetX: number;
  19515. offsetY: number;
  19516. }>;
  19517. /**
  19518. * @hidden
  19519. * If the camera should be rotated automatically based on pointer movement
  19520. */
  19521. _allowCameraRotation: boolean;
  19522. /**
  19523. * Manage the mouse inputs to control the movement of a free camera.
  19524. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19525. * @param touchEnabled Defines if touch is enabled or not
  19526. */
  19527. constructor(
  19528. /**
  19529. * Define if touch is enabled in the mouse input
  19530. */
  19531. touchEnabled?: boolean);
  19532. /**
  19533. * Attach the input controls to a specific dom element to get the input from.
  19534. * @param element Defines the element the controls should be listened from
  19535. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19536. */
  19537. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19538. /**
  19539. * Called on JS contextmenu event.
  19540. * Override this method to provide functionality.
  19541. */
  19542. protected onContextMenu(evt: PointerEvent): void;
  19543. /**
  19544. * Detach the current controls from the specified dom element.
  19545. * @param element Defines the element to stop listening the inputs from
  19546. */
  19547. detachControl(element: Nullable<HTMLElement>): void;
  19548. /**
  19549. * Gets the class name of the current intput.
  19550. * @returns the class name
  19551. */
  19552. getClassName(): string;
  19553. /**
  19554. * Get the friendly name associated with the input class.
  19555. * @returns the input friendly name
  19556. */
  19557. getSimpleName(): string;
  19558. }
  19559. }
  19560. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19561. import { Nullable } from "babylonjs/types";
  19562. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19563. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19564. /**
  19565. * Manage the touch inputs to control the movement of a free camera.
  19566. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19567. */
  19568. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19569. /**
  19570. * Define if mouse events can be treated as touch events
  19571. */
  19572. allowMouse: boolean;
  19573. /**
  19574. * Defines the camera the input is attached to.
  19575. */
  19576. camera: FreeCamera;
  19577. /**
  19578. * Defines the touch sensibility for rotation.
  19579. * The higher the faster.
  19580. */
  19581. touchAngularSensibility: number;
  19582. /**
  19583. * Defines the touch sensibility for move.
  19584. * The higher the faster.
  19585. */
  19586. touchMoveSensibility: number;
  19587. private _offsetX;
  19588. private _offsetY;
  19589. private _pointerPressed;
  19590. private _pointerInput;
  19591. private _observer;
  19592. private _onLostFocus;
  19593. /**
  19594. * Manage the touch inputs to control the movement of a free camera.
  19595. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19596. * @param allowMouse Defines if mouse events can be treated as touch events
  19597. */
  19598. constructor(
  19599. /**
  19600. * Define if mouse events can be treated as touch events
  19601. */
  19602. allowMouse?: boolean);
  19603. /**
  19604. * Attach the input controls to a specific dom element to get the input from.
  19605. * @param element Defines the element the controls should be listened from
  19606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19607. */
  19608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19609. /**
  19610. * Detach the current controls from the specified dom element.
  19611. * @param element Defines the element to stop listening the inputs from
  19612. */
  19613. detachControl(element: Nullable<HTMLElement>): void;
  19614. /**
  19615. * Update the current camera state depending on the inputs that have been used this frame.
  19616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19617. */
  19618. checkInputs(): void;
  19619. /**
  19620. * Gets the class name of the current intput.
  19621. * @returns the class name
  19622. */
  19623. getClassName(): string;
  19624. /**
  19625. * Get the friendly name associated with the input class.
  19626. * @returns the input friendly name
  19627. */
  19628. getSimpleName(): string;
  19629. }
  19630. }
  19631. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19632. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19633. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19634. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19635. import { Nullable } from "babylonjs/types";
  19636. /**
  19637. * Default Inputs manager for the FreeCamera.
  19638. * It groups all the default supported inputs for ease of use.
  19639. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19640. */
  19641. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19642. /**
  19643. * @hidden
  19644. */
  19645. _mouseInput: Nullable<FreeCameraMouseInput>;
  19646. /**
  19647. * Instantiates a new FreeCameraInputsManager.
  19648. * @param camera Defines the camera the inputs belong to
  19649. */
  19650. constructor(camera: FreeCamera);
  19651. /**
  19652. * Add keyboard input support to the input manager.
  19653. * @returns the current input manager
  19654. */
  19655. addKeyboard(): FreeCameraInputsManager;
  19656. /**
  19657. * Add mouse input support to the input manager.
  19658. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19659. * @returns the current input manager
  19660. */
  19661. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19662. /**
  19663. * Removes the mouse input support from the manager
  19664. * @returns the current input manager
  19665. */
  19666. removeMouse(): FreeCameraInputsManager;
  19667. /**
  19668. * Add touch input support to the input manager.
  19669. * @returns the current input manager
  19670. */
  19671. addTouch(): FreeCameraInputsManager;
  19672. /**
  19673. * Remove all attached input methods from a camera
  19674. */
  19675. clear(): void;
  19676. }
  19677. }
  19678. declare module "babylonjs/Cameras/freeCamera" {
  19679. import { Vector3 } from "babylonjs/Maths/math.vector";
  19680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19681. import { Scene } from "babylonjs/scene";
  19682. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19683. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19684. /**
  19685. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19686. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19687. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19688. */
  19689. export class FreeCamera extends TargetCamera {
  19690. /**
  19691. * Define the collision ellipsoid of the camera.
  19692. * This is helpful to simulate a camera body like the player body around the camera
  19693. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19694. */
  19695. ellipsoid: Vector3;
  19696. /**
  19697. * Define an offset for the position of the ellipsoid around the camera.
  19698. * This can be helpful to determine the center of the body near the gravity center of the body
  19699. * instead of its head.
  19700. */
  19701. ellipsoidOffset: Vector3;
  19702. /**
  19703. * Enable or disable collisions of the camera with the rest of the scene objects.
  19704. */
  19705. checkCollisions: boolean;
  19706. /**
  19707. * Enable or disable gravity on the camera.
  19708. */
  19709. applyGravity: boolean;
  19710. /**
  19711. * Define the input manager associated to the camera.
  19712. */
  19713. inputs: FreeCameraInputsManager;
  19714. /**
  19715. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19716. * Higher values reduce sensitivity.
  19717. */
  19718. get angularSensibility(): number;
  19719. /**
  19720. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19721. * Higher values reduce sensitivity.
  19722. */
  19723. set angularSensibility(value: number);
  19724. /**
  19725. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19726. */
  19727. get keysUp(): number[];
  19728. set keysUp(value: number[]);
  19729. /**
  19730. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19731. */
  19732. get keysUpward(): number[];
  19733. set keysUpward(value: number[]);
  19734. /**
  19735. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19736. */
  19737. get keysDown(): number[];
  19738. set keysDown(value: number[]);
  19739. /**
  19740. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19741. */
  19742. get keysDownward(): number[];
  19743. set keysDownward(value: number[]);
  19744. /**
  19745. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19746. */
  19747. get keysLeft(): number[];
  19748. set keysLeft(value: number[]);
  19749. /**
  19750. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19751. */
  19752. get keysRight(): number[];
  19753. set keysRight(value: number[]);
  19754. /**
  19755. * Event raised when the camera collide with a mesh in the scene.
  19756. */
  19757. onCollide: (collidedMesh: AbstractMesh) => void;
  19758. private _collider;
  19759. private _needMoveForGravity;
  19760. private _oldPosition;
  19761. private _diffPosition;
  19762. private _newPosition;
  19763. /** @hidden */
  19764. _localDirection: Vector3;
  19765. /** @hidden */
  19766. _transformedDirection: Vector3;
  19767. /**
  19768. * Instantiates a Free Camera.
  19769. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19770. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19771. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19772. * @param name Define the name of the camera in the scene
  19773. * @param position Define the start position of the camera in the scene
  19774. * @param scene Define the scene the camera belongs to
  19775. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19776. */
  19777. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19778. /**
  19779. * Attached controls to the current camera.
  19780. * @param element Defines the element the controls should be listened from
  19781. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19782. */
  19783. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19784. /**
  19785. * Detach the current controls from the camera.
  19786. * The camera will stop reacting to inputs.
  19787. * @param element Defines the element to stop listening the inputs from
  19788. */
  19789. detachControl(element: HTMLElement): void;
  19790. private _collisionMask;
  19791. /**
  19792. * Define a collision mask to limit the list of object the camera can collide with
  19793. */
  19794. get collisionMask(): number;
  19795. set collisionMask(mask: number);
  19796. /** @hidden */
  19797. _collideWithWorld(displacement: Vector3): void;
  19798. private _onCollisionPositionChange;
  19799. /** @hidden */
  19800. _checkInputs(): void;
  19801. /** @hidden */
  19802. _decideIfNeedsToMove(): boolean;
  19803. /** @hidden */
  19804. _updatePosition(): void;
  19805. /**
  19806. * Destroy the camera and release the current resources hold by it.
  19807. */
  19808. dispose(): void;
  19809. /**
  19810. * Gets the current object class name.
  19811. * @return the class name
  19812. */
  19813. getClassName(): string;
  19814. }
  19815. }
  19816. declare module "babylonjs/Gamepads/gamepad" {
  19817. import { Observable } from "babylonjs/Misc/observable";
  19818. /**
  19819. * Represents a gamepad control stick position
  19820. */
  19821. export class StickValues {
  19822. /**
  19823. * The x component of the control stick
  19824. */
  19825. x: number;
  19826. /**
  19827. * The y component of the control stick
  19828. */
  19829. y: number;
  19830. /**
  19831. * Initializes the gamepad x and y control stick values
  19832. * @param x The x component of the gamepad control stick value
  19833. * @param y The y component of the gamepad control stick value
  19834. */
  19835. constructor(
  19836. /**
  19837. * The x component of the control stick
  19838. */
  19839. x: number,
  19840. /**
  19841. * The y component of the control stick
  19842. */
  19843. y: number);
  19844. }
  19845. /**
  19846. * An interface which manages callbacks for gamepad button changes
  19847. */
  19848. export interface GamepadButtonChanges {
  19849. /**
  19850. * Called when a gamepad has been changed
  19851. */
  19852. changed: boolean;
  19853. /**
  19854. * Called when a gamepad press event has been triggered
  19855. */
  19856. pressChanged: boolean;
  19857. /**
  19858. * Called when a touch event has been triggered
  19859. */
  19860. touchChanged: boolean;
  19861. /**
  19862. * Called when a value has changed
  19863. */
  19864. valueChanged: boolean;
  19865. }
  19866. /**
  19867. * Represents a gamepad
  19868. */
  19869. export class Gamepad {
  19870. /**
  19871. * The id of the gamepad
  19872. */
  19873. id: string;
  19874. /**
  19875. * The index of the gamepad
  19876. */
  19877. index: number;
  19878. /**
  19879. * The browser gamepad
  19880. */
  19881. browserGamepad: any;
  19882. /**
  19883. * Specifies what type of gamepad this represents
  19884. */
  19885. type: number;
  19886. private _leftStick;
  19887. private _rightStick;
  19888. /** @hidden */
  19889. _isConnected: boolean;
  19890. private _leftStickAxisX;
  19891. private _leftStickAxisY;
  19892. private _rightStickAxisX;
  19893. private _rightStickAxisY;
  19894. /**
  19895. * Triggered when the left control stick has been changed
  19896. */
  19897. private _onleftstickchanged;
  19898. /**
  19899. * Triggered when the right control stick has been changed
  19900. */
  19901. private _onrightstickchanged;
  19902. /**
  19903. * Represents a gamepad controller
  19904. */
  19905. static GAMEPAD: number;
  19906. /**
  19907. * Represents a generic controller
  19908. */
  19909. static GENERIC: number;
  19910. /**
  19911. * Represents an XBox controller
  19912. */
  19913. static XBOX: number;
  19914. /**
  19915. * Represents a pose-enabled controller
  19916. */
  19917. static POSE_ENABLED: number;
  19918. /**
  19919. * Represents an Dual Shock controller
  19920. */
  19921. static DUALSHOCK: number;
  19922. /**
  19923. * Specifies whether the left control stick should be Y-inverted
  19924. */
  19925. protected _invertLeftStickY: boolean;
  19926. /**
  19927. * Specifies if the gamepad has been connected
  19928. */
  19929. get isConnected(): boolean;
  19930. /**
  19931. * Initializes the gamepad
  19932. * @param id The id of the gamepad
  19933. * @param index The index of the gamepad
  19934. * @param browserGamepad The browser gamepad
  19935. * @param leftStickX The x component of the left joystick
  19936. * @param leftStickY The y component of the left joystick
  19937. * @param rightStickX The x component of the right joystick
  19938. * @param rightStickY The y component of the right joystick
  19939. */
  19940. constructor(
  19941. /**
  19942. * The id of the gamepad
  19943. */
  19944. id: string,
  19945. /**
  19946. * The index of the gamepad
  19947. */
  19948. index: number,
  19949. /**
  19950. * The browser gamepad
  19951. */
  19952. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19953. /**
  19954. * Callback triggered when the left joystick has changed
  19955. * @param callback
  19956. */
  19957. onleftstickchanged(callback: (values: StickValues) => void): void;
  19958. /**
  19959. * Callback triggered when the right joystick has changed
  19960. * @param callback
  19961. */
  19962. onrightstickchanged(callback: (values: StickValues) => void): void;
  19963. /**
  19964. * Gets the left joystick
  19965. */
  19966. get leftStick(): StickValues;
  19967. /**
  19968. * Sets the left joystick values
  19969. */
  19970. set leftStick(newValues: StickValues);
  19971. /**
  19972. * Gets the right joystick
  19973. */
  19974. get rightStick(): StickValues;
  19975. /**
  19976. * Sets the right joystick value
  19977. */
  19978. set rightStick(newValues: StickValues);
  19979. /**
  19980. * Updates the gamepad joystick positions
  19981. */
  19982. update(): void;
  19983. /**
  19984. * Disposes the gamepad
  19985. */
  19986. dispose(): void;
  19987. }
  19988. /**
  19989. * Represents a generic gamepad
  19990. */
  19991. export class GenericPad extends Gamepad {
  19992. private _buttons;
  19993. private _onbuttondown;
  19994. private _onbuttonup;
  19995. /**
  19996. * Observable triggered when a button has been pressed
  19997. */
  19998. onButtonDownObservable: Observable<number>;
  19999. /**
  20000. * Observable triggered when a button has been released
  20001. */
  20002. onButtonUpObservable: Observable<number>;
  20003. /**
  20004. * Callback triggered when a button has been pressed
  20005. * @param callback Called when a button has been pressed
  20006. */
  20007. onbuttondown(callback: (buttonPressed: number) => void): void;
  20008. /**
  20009. * Callback triggered when a button has been released
  20010. * @param callback Called when a button has been released
  20011. */
  20012. onbuttonup(callback: (buttonReleased: number) => void): void;
  20013. /**
  20014. * Initializes the generic gamepad
  20015. * @param id The id of the generic gamepad
  20016. * @param index The index of the generic gamepad
  20017. * @param browserGamepad The browser gamepad
  20018. */
  20019. constructor(id: string, index: number, browserGamepad: any);
  20020. private _setButtonValue;
  20021. /**
  20022. * Updates the generic gamepad
  20023. */
  20024. update(): void;
  20025. /**
  20026. * Disposes the generic gamepad
  20027. */
  20028. dispose(): void;
  20029. }
  20030. }
  20031. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  20032. import { Observable } from "babylonjs/Misc/observable";
  20033. import { Nullable } from "babylonjs/types";
  20034. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20035. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20037. import { Ray } from "babylonjs/Culling/ray";
  20038. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  20039. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  20040. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  20041. /**
  20042. * Defines the types of pose enabled controllers that are supported
  20043. */
  20044. export enum PoseEnabledControllerType {
  20045. /**
  20046. * HTC Vive
  20047. */
  20048. VIVE = 0,
  20049. /**
  20050. * Oculus Rift
  20051. */
  20052. OCULUS = 1,
  20053. /**
  20054. * Windows mixed reality
  20055. */
  20056. WINDOWS = 2,
  20057. /**
  20058. * Samsung gear VR
  20059. */
  20060. GEAR_VR = 3,
  20061. /**
  20062. * Google Daydream
  20063. */
  20064. DAYDREAM = 4,
  20065. /**
  20066. * Generic
  20067. */
  20068. GENERIC = 5
  20069. }
  20070. /**
  20071. * Defines the MutableGamepadButton interface for the state of a gamepad button
  20072. */
  20073. export interface MutableGamepadButton {
  20074. /**
  20075. * Value of the button/trigger
  20076. */
  20077. value: number;
  20078. /**
  20079. * If the button/trigger is currently touched
  20080. */
  20081. touched: boolean;
  20082. /**
  20083. * If the button/trigger is currently pressed
  20084. */
  20085. pressed: boolean;
  20086. }
  20087. /**
  20088. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20089. * @hidden
  20090. */
  20091. export interface ExtendedGamepadButton extends GamepadButton {
  20092. /**
  20093. * If the button/trigger is currently pressed
  20094. */
  20095. readonly pressed: boolean;
  20096. /**
  20097. * If the button/trigger is currently touched
  20098. */
  20099. readonly touched: boolean;
  20100. /**
  20101. * Value of the button/trigger
  20102. */
  20103. readonly value: number;
  20104. }
  20105. /** @hidden */
  20106. export interface _GamePadFactory {
  20107. /**
  20108. * Returns whether or not the current gamepad can be created for this type of controller.
  20109. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20110. * @returns true if it can be created, otherwise false
  20111. */
  20112. canCreate(gamepadInfo: any): boolean;
  20113. /**
  20114. * Creates a new instance of the Gamepad.
  20115. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20116. * @returns the new gamepad instance
  20117. */
  20118. create(gamepadInfo: any): Gamepad;
  20119. }
  20120. /**
  20121. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20122. */
  20123. export class PoseEnabledControllerHelper {
  20124. /** @hidden */
  20125. static _ControllerFactories: _GamePadFactory[];
  20126. /** @hidden */
  20127. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20128. /**
  20129. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20130. * @param vrGamepad the gamepad to initialized
  20131. * @returns a vr controller of the type the gamepad identified as
  20132. */
  20133. static InitiateController(vrGamepad: any): Gamepad;
  20134. }
  20135. /**
  20136. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20137. */
  20138. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20139. /**
  20140. * If the controller is used in a webXR session
  20141. */
  20142. isXR: boolean;
  20143. private _deviceRoomPosition;
  20144. private _deviceRoomRotationQuaternion;
  20145. /**
  20146. * The device position in babylon space
  20147. */
  20148. devicePosition: Vector3;
  20149. /**
  20150. * The device rotation in babylon space
  20151. */
  20152. deviceRotationQuaternion: Quaternion;
  20153. /**
  20154. * The scale factor of the device in babylon space
  20155. */
  20156. deviceScaleFactor: number;
  20157. /**
  20158. * (Likely devicePosition should be used instead) The device position in its room space
  20159. */
  20160. position: Vector3;
  20161. /**
  20162. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20163. */
  20164. rotationQuaternion: Quaternion;
  20165. /**
  20166. * The type of controller (Eg. Windows mixed reality)
  20167. */
  20168. controllerType: PoseEnabledControllerType;
  20169. protected _calculatedPosition: Vector3;
  20170. private _calculatedRotation;
  20171. /**
  20172. * The raw pose from the device
  20173. */
  20174. rawPose: DevicePose;
  20175. private _trackPosition;
  20176. private _maxRotationDistFromHeadset;
  20177. private _draggedRoomRotation;
  20178. /**
  20179. * @hidden
  20180. */
  20181. _disableTrackPosition(fixedPosition: Vector3): void;
  20182. /**
  20183. * Internal, the mesh attached to the controller
  20184. * @hidden
  20185. */
  20186. _mesh: Nullable<AbstractMesh>;
  20187. private _poseControlledCamera;
  20188. private _leftHandSystemQuaternion;
  20189. /**
  20190. * Internal, matrix used to convert room space to babylon space
  20191. * @hidden
  20192. */
  20193. _deviceToWorld: Matrix;
  20194. /**
  20195. * Node to be used when casting a ray from the controller
  20196. * @hidden
  20197. */
  20198. _pointingPoseNode: Nullable<TransformNode>;
  20199. /**
  20200. * Name of the child mesh that can be used to cast a ray from the controller
  20201. */
  20202. static readonly POINTING_POSE: string;
  20203. /**
  20204. * Creates a new PoseEnabledController from a gamepad
  20205. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20206. */
  20207. constructor(browserGamepad: any);
  20208. private _workingMatrix;
  20209. /**
  20210. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20211. */
  20212. update(): void;
  20213. /**
  20214. * Updates only the pose device and mesh without doing any button event checking
  20215. */
  20216. protected _updatePoseAndMesh(): void;
  20217. /**
  20218. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20219. * @param poseData raw pose fromthe device
  20220. */
  20221. updateFromDevice(poseData: DevicePose): void;
  20222. /**
  20223. * @hidden
  20224. */
  20225. _meshAttachedObservable: Observable<AbstractMesh>;
  20226. /**
  20227. * Attaches a mesh to the controller
  20228. * @param mesh the mesh to be attached
  20229. */
  20230. attachToMesh(mesh: AbstractMesh): void;
  20231. /**
  20232. * Attaches the controllers mesh to a camera
  20233. * @param camera the camera the mesh should be attached to
  20234. */
  20235. attachToPoseControlledCamera(camera: TargetCamera): void;
  20236. /**
  20237. * Disposes of the controller
  20238. */
  20239. dispose(): void;
  20240. /**
  20241. * The mesh that is attached to the controller
  20242. */
  20243. get mesh(): Nullable<AbstractMesh>;
  20244. /**
  20245. * Gets the ray of the controller in the direction the controller is pointing
  20246. * @param length the length the resulting ray should be
  20247. * @returns a ray in the direction the controller is pointing
  20248. */
  20249. getForwardRay(length?: number): Ray;
  20250. }
  20251. }
  20252. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20253. import { Observable } from "babylonjs/Misc/observable";
  20254. import { Scene } from "babylonjs/scene";
  20255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20256. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20257. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20258. import { Nullable } from "babylonjs/types";
  20259. /**
  20260. * Defines the WebVRController object that represents controllers tracked in 3D space
  20261. */
  20262. export abstract class WebVRController extends PoseEnabledController {
  20263. /**
  20264. * Internal, the default controller model for the controller
  20265. */
  20266. protected _defaultModel: Nullable<AbstractMesh>;
  20267. /**
  20268. * Fired when the trigger state has changed
  20269. */
  20270. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20271. /**
  20272. * Fired when the main button state has changed
  20273. */
  20274. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20275. /**
  20276. * Fired when the secondary button state has changed
  20277. */
  20278. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20279. /**
  20280. * Fired when the pad state has changed
  20281. */
  20282. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20283. /**
  20284. * Fired when controllers stick values have changed
  20285. */
  20286. onPadValuesChangedObservable: Observable<StickValues>;
  20287. /**
  20288. * Array of button availible on the controller
  20289. */
  20290. protected _buttons: Array<MutableGamepadButton>;
  20291. private _onButtonStateChange;
  20292. /**
  20293. * Fired when a controller button's state has changed
  20294. * @param callback the callback containing the button that was modified
  20295. */
  20296. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20297. /**
  20298. * X and Y axis corresponding to the controllers joystick
  20299. */
  20300. pad: StickValues;
  20301. /**
  20302. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20303. */
  20304. hand: string;
  20305. /**
  20306. * The default controller model for the controller
  20307. */
  20308. get defaultModel(): Nullable<AbstractMesh>;
  20309. /**
  20310. * Creates a new WebVRController from a gamepad
  20311. * @param vrGamepad the gamepad that the WebVRController should be created from
  20312. */
  20313. constructor(vrGamepad: any);
  20314. /**
  20315. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20316. */
  20317. update(): void;
  20318. /**
  20319. * Function to be called when a button is modified
  20320. */
  20321. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20322. /**
  20323. * Loads a mesh and attaches it to the controller
  20324. * @param scene the scene the mesh should be added to
  20325. * @param meshLoaded callback for when the mesh has been loaded
  20326. */
  20327. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20328. private _setButtonValue;
  20329. private _changes;
  20330. private _checkChanges;
  20331. /**
  20332. * Disposes of th webVRCOntroller
  20333. */
  20334. dispose(): void;
  20335. }
  20336. }
  20337. declare module "babylonjs/Lights/hemisphericLight" {
  20338. import { Nullable } from "babylonjs/types";
  20339. import { Scene } from "babylonjs/scene";
  20340. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20341. import { Color3 } from "babylonjs/Maths/math.color";
  20342. import { Effect } from "babylonjs/Materials/effect";
  20343. import { Light } from "babylonjs/Lights/light";
  20344. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20345. /**
  20346. * The HemisphericLight simulates the ambient environment light,
  20347. * so the passed direction is the light reflection direction, not the incoming direction.
  20348. */
  20349. export class HemisphericLight extends Light {
  20350. /**
  20351. * The groundColor is the light in the opposite direction to the one specified during creation.
  20352. * 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.
  20353. */
  20354. groundColor: Color3;
  20355. /**
  20356. * The light reflection direction, not the incoming direction.
  20357. */
  20358. direction: Vector3;
  20359. /**
  20360. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20361. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20362. * The HemisphericLight can't cast shadows.
  20363. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20364. * @param name The friendly name of the light
  20365. * @param direction The direction of the light reflection
  20366. * @param scene The scene the light belongs to
  20367. */
  20368. constructor(name: string, direction: Vector3, scene: Scene);
  20369. protected _buildUniformLayout(): void;
  20370. /**
  20371. * Returns the string "HemisphericLight".
  20372. * @return The class name
  20373. */
  20374. getClassName(): string;
  20375. /**
  20376. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20377. * Returns the updated direction.
  20378. * @param target The target the direction should point to
  20379. * @return The computed direction
  20380. */
  20381. setDirectionToTarget(target: Vector3): Vector3;
  20382. /**
  20383. * Returns the shadow generator associated to the light.
  20384. * @returns Always null for hemispheric lights because it does not support shadows.
  20385. */
  20386. getShadowGenerator(): Nullable<IShadowGenerator>;
  20387. /**
  20388. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20389. * @param effect The effect to update
  20390. * @param lightIndex The index of the light in the effect to update
  20391. * @returns The hemispheric light
  20392. */
  20393. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20394. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20395. /**
  20396. * Computes the world matrix of the node
  20397. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20398. * @param useWasUpdatedFlag defines a reserved property
  20399. * @returns the world matrix
  20400. */
  20401. computeWorldMatrix(): Matrix;
  20402. /**
  20403. * Returns the integer 3.
  20404. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20405. */
  20406. getTypeID(): number;
  20407. /**
  20408. * Prepares the list of defines specific to the light type.
  20409. * @param defines the list of defines
  20410. * @param lightIndex defines the index of the light for the effect
  20411. */
  20412. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20413. }
  20414. }
  20415. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20416. /** @hidden */
  20417. export var vrMultiviewToSingleviewPixelShader: {
  20418. name: string;
  20419. shader: string;
  20420. };
  20421. }
  20422. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20423. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20424. import { Scene } from "babylonjs/scene";
  20425. /**
  20426. * Renders to multiple views with a single draw call
  20427. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20428. */
  20429. export class MultiviewRenderTarget extends RenderTargetTexture {
  20430. /**
  20431. * Creates a multiview render target
  20432. * @param scene scene used with the render target
  20433. * @param size the size of the render target (used for each view)
  20434. */
  20435. constructor(scene: Scene, size?: number | {
  20436. width: number;
  20437. height: number;
  20438. } | {
  20439. ratio: number;
  20440. });
  20441. /**
  20442. * @hidden
  20443. * @param faceIndex the face index, if its a cube texture
  20444. */
  20445. _bindFrameBuffer(faceIndex?: number): void;
  20446. /**
  20447. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20448. * @returns the view count
  20449. */
  20450. getViewCount(): number;
  20451. }
  20452. }
  20453. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20454. import { Camera } from "babylonjs/Cameras/camera";
  20455. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20456. import { Nullable } from "babylonjs/types";
  20457. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20458. import { Matrix } from "babylonjs/Maths/math.vector";
  20459. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20460. module "babylonjs/Engines/engine" {
  20461. interface Engine {
  20462. /**
  20463. * Creates a new multiview render target
  20464. * @param width defines the width of the texture
  20465. * @param height defines the height of the texture
  20466. * @returns the created multiview texture
  20467. */
  20468. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20469. /**
  20470. * Binds a multiview framebuffer to be drawn to
  20471. * @param multiviewTexture texture to bind
  20472. */
  20473. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20474. }
  20475. }
  20476. module "babylonjs/Cameras/camera" {
  20477. interface Camera {
  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. _useMultiviewToSingleView: boolean;
  20483. /**
  20484. * @hidden
  20485. * 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)
  20486. */
  20487. _multiviewTexture: Nullable<RenderTargetTexture>;
  20488. /**
  20489. * @hidden
  20490. * ensures the multiview texture of the camera exists and has the specified width/height
  20491. * @param width height to set on the multiview texture
  20492. * @param height width to set on the multiview texture
  20493. */
  20494. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20495. }
  20496. }
  20497. module "babylonjs/scene" {
  20498. interface Scene {
  20499. /** @hidden */
  20500. _transformMatrixR: Matrix;
  20501. /** @hidden */
  20502. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20503. /** @hidden */
  20504. _createMultiviewUbo(): void;
  20505. /** @hidden */
  20506. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20507. /** @hidden */
  20508. _renderMultiviewToSingleView(camera: Camera): void;
  20509. }
  20510. }
  20511. }
  20512. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20513. import { Camera } from "babylonjs/Cameras/camera";
  20514. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20515. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20516. import "babylonjs/Engines/Extensions/engine.multiview";
  20517. /**
  20518. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20519. * This will not be used for webXR as it supports displaying texture arrays directly
  20520. */
  20521. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20522. /**
  20523. * Gets a string identifying the name of the class
  20524. * @returns "VRMultiviewToSingleviewPostProcess" string
  20525. */
  20526. getClassName(): string;
  20527. /**
  20528. * Initializes a VRMultiviewToSingleview
  20529. * @param name name of the post process
  20530. * @param camera camera to be applied to
  20531. * @param scaleFactor scaling factor to the size of the output texture
  20532. */
  20533. constructor(name: string, camera: Camera, scaleFactor: number);
  20534. }
  20535. }
  20536. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20537. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20538. import { Nullable } from "babylonjs/types";
  20539. import { Size } from "babylonjs/Maths/math.size";
  20540. import { Observable } from "babylonjs/Misc/observable";
  20541. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20542. /**
  20543. * Interface used to define additional presentation attributes
  20544. */
  20545. export interface IVRPresentationAttributes {
  20546. /**
  20547. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20548. */
  20549. highRefreshRate: boolean;
  20550. /**
  20551. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20552. */
  20553. foveationLevel: number;
  20554. }
  20555. module "babylonjs/Engines/engine" {
  20556. interface Engine {
  20557. /** @hidden */
  20558. _vrDisplay: any;
  20559. /** @hidden */
  20560. _vrSupported: boolean;
  20561. /** @hidden */
  20562. _oldSize: Size;
  20563. /** @hidden */
  20564. _oldHardwareScaleFactor: number;
  20565. /** @hidden */
  20566. _vrExclusivePointerMode: boolean;
  20567. /** @hidden */
  20568. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20569. /** @hidden */
  20570. _onVRDisplayPointerRestricted: () => void;
  20571. /** @hidden */
  20572. _onVRDisplayPointerUnrestricted: () => void;
  20573. /** @hidden */
  20574. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20575. /** @hidden */
  20576. _onVrDisplayDisconnect: Nullable<() => void>;
  20577. /** @hidden */
  20578. _onVrDisplayPresentChange: Nullable<() => void>;
  20579. /**
  20580. * Observable signaled when VR display mode changes
  20581. */
  20582. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20583. /**
  20584. * Observable signaled when VR request present is complete
  20585. */
  20586. onVRRequestPresentComplete: Observable<boolean>;
  20587. /**
  20588. * Observable signaled when VR request present starts
  20589. */
  20590. onVRRequestPresentStart: Observable<Engine>;
  20591. /**
  20592. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20593. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20594. */
  20595. isInVRExclusivePointerMode: boolean;
  20596. /**
  20597. * Gets a boolean indicating if a webVR device was detected
  20598. * @returns true if a webVR device was detected
  20599. */
  20600. isVRDevicePresent(): boolean;
  20601. /**
  20602. * Gets the current webVR device
  20603. * @returns the current webVR device (or null)
  20604. */
  20605. getVRDevice(): any;
  20606. /**
  20607. * Initializes a webVR display and starts listening to display change events
  20608. * The onVRDisplayChangedObservable will be notified upon these changes
  20609. * @returns A promise containing a VRDisplay and if vr is supported
  20610. */
  20611. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20612. /** @hidden */
  20613. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20614. /**
  20615. * Gets or sets the presentation attributes used to configure VR rendering
  20616. */
  20617. vrPresentationAttributes?: IVRPresentationAttributes;
  20618. /**
  20619. * Call this function to switch to webVR mode
  20620. * Will do nothing if webVR is not supported or if there is no webVR device
  20621. * @param options the webvr options provided to the camera. mainly used for multiview
  20622. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20623. */
  20624. enableVR(options: WebVROptions): void;
  20625. /** @hidden */
  20626. _onVRFullScreenTriggered(): void;
  20627. }
  20628. }
  20629. }
  20630. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20631. import { Nullable } from "babylonjs/types";
  20632. import { Observable } from "babylonjs/Misc/observable";
  20633. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20634. import { Scene } from "babylonjs/scene";
  20635. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20636. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20637. import { Node } from "babylonjs/node";
  20638. import { Ray } from "babylonjs/Culling/ray";
  20639. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20640. import "babylonjs/Engines/Extensions/engine.webVR";
  20641. /**
  20642. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20643. * IMPORTANT!! The data is right-hand data.
  20644. * @export
  20645. * @interface DevicePose
  20646. */
  20647. export interface DevicePose {
  20648. /**
  20649. * The position of the device, values in array are [x,y,z].
  20650. */
  20651. readonly position: Nullable<Float32Array>;
  20652. /**
  20653. * The linearVelocity of the device, values in array are [x,y,z].
  20654. */
  20655. readonly linearVelocity: Nullable<Float32Array>;
  20656. /**
  20657. * The linearAcceleration of the device, values in array are [x,y,z].
  20658. */
  20659. readonly linearAcceleration: Nullable<Float32Array>;
  20660. /**
  20661. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20662. */
  20663. readonly orientation: Nullable<Float32Array>;
  20664. /**
  20665. * The angularVelocity of the device, values in array are [x,y,z].
  20666. */
  20667. readonly angularVelocity: Nullable<Float32Array>;
  20668. /**
  20669. * The angularAcceleration of the device, values in array are [x,y,z].
  20670. */
  20671. readonly angularAcceleration: Nullable<Float32Array>;
  20672. }
  20673. /**
  20674. * Interface representing a pose controlled object in Babylon.
  20675. * A pose controlled object has both regular pose values as well as pose values
  20676. * from an external device such as a VR head mounted display
  20677. */
  20678. export interface PoseControlled {
  20679. /**
  20680. * The position of the object in babylon space.
  20681. */
  20682. position: Vector3;
  20683. /**
  20684. * The rotation quaternion of the object in babylon space.
  20685. */
  20686. rotationQuaternion: Quaternion;
  20687. /**
  20688. * The position of the device in babylon space.
  20689. */
  20690. devicePosition?: Vector3;
  20691. /**
  20692. * The rotation quaternion of the device in babylon space.
  20693. */
  20694. deviceRotationQuaternion: Quaternion;
  20695. /**
  20696. * The raw pose coming from the device.
  20697. */
  20698. rawPose: Nullable<DevicePose>;
  20699. /**
  20700. * The scale of the device to be used when translating from device space to babylon space.
  20701. */
  20702. deviceScaleFactor: number;
  20703. /**
  20704. * Updates the poseControlled values based on the input device pose.
  20705. * @param poseData the pose data to update the object with
  20706. */
  20707. updateFromDevice(poseData: DevicePose): void;
  20708. }
  20709. /**
  20710. * Set of options to customize the webVRCamera
  20711. */
  20712. export interface WebVROptions {
  20713. /**
  20714. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20715. */
  20716. trackPosition?: boolean;
  20717. /**
  20718. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20719. */
  20720. positionScale?: number;
  20721. /**
  20722. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20723. */
  20724. displayName?: string;
  20725. /**
  20726. * Should the native controller meshes be initialized. (default: true)
  20727. */
  20728. controllerMeshes?: boolean;
  20729. /**
  20730. * Creating a default HemiLight only on controllers. (default: true)
  20731. */
  20732. defaultLightingOnControllers?: boolean;
  20733. /**
  20734. * If you don't want to use the default VR button of the helper. (default: false)
  20735. */
  20736. useCustomVRButton?: boolean;
  20737. /**
  20738. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20739. */
  20740. customVRButton?: HTMLButtonElement;
  20741. /**
  20742. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20743. */
  20744. rayLength?: number;
  20745. /**
  20746. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20747. */
  20748. defaultHeight?: number;
  20749. /**
  20750. * If multiview should be used if availible (default: false)
  20751. */
  20752. useMultiview?: boolean;
  20753. }
  20754. /**
  20755. * This represents a WebVR camera.
  20756. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20757. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20758. */
  20759. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20760. private webVROptions;
  20761. /**
  20762. * @hidden
  20763. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20764. */
  20765. _vrDevice: any;
  20766. /**
  20767. * The rawPose of the vrDevice.
  20768. */
  20769. rawPose: Nullable<DevicePose>;
  20770. private _onVREnabled;
  20771. private _specsVersion;
  20772. private _attached;
  20773. private _frameData;
  20774. protected _descendants: Array<Node>;
  20775. private _deviceRoomPosition;
  20776. /** @hidden */
  20777. _deviceRoomRotationQuaternion: Quaternion;
  20778. private _standingMatrix;
  20779. /**
  20780. * Represents device position in babylon space.
  20781. */
  20782. devicePosition: Vector3;
  20783. /**
  20784. * Represents device rotation in babylon space.
  20785. */
  20786. deviceRotationQuaternion: Quaternion;
  20787. /**
  20788. * The scale of the device to be used when translating from device space to babylon space.
  20789. */
  20790. deviceScaleFactor: number;
  20791. private _deviceToWorld;
  20792. private _worldToDevice;
  20793. /**
  20794. * References to the webVR controllers for the vrDevice.
  20795. */
  20796. controllers: Array<WebVRController>;
  20797. /**
  20798. * Emits an event when a controller is attached.
  20799. */
  20800. onControllersAttachedObservable: Observable<WebVRController[]>;
  20801. /**
  20802. * Emits an event when a controller's mesh has been loaded;
  20803. */
  20804. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20805. /**
  20806. * Emits an event when the HMD's pose has been updated.
  20807. */
  20808. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20809. private _poseSet;
  20810. /**
  20811. * If the rig cameras be used as parent instead of this camera.
  20812. */
  20813. rigParenting: boolean;
  20814. private _lightOnControllers;
  20815. private _defaultHeight?;
  20816. /**
  20817. * Instantiates a WebVRFreeCamera.
  20818. * @param name The name of the WebVRFreeCamera
  20819. * @param position The starting anchor position for the camera
  20820. * @param scene The scene the camera belongs to
  20821. * @param webVROptions a set of customizable options for the webVRCamera
  20822. */
  20823. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20824. /**
  20825. * Gets the device distance from the ground in meters.
  20826. * @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.
  20827. */
  20828. deviceDistanceToRoomGround(): number;
  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. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20832. */
  20833. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20834. /**
  20835. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20836. * @returns A promise with a boolean set to if the standing matrix is supported.
  20837. */
  20838. useStandingMatrixAsync(): Promise<boolean>;
  20839. /**
  20840. * Disposes the camera
  20841. */
  20842. dispose(): void;
  20843. /**
  20844. * Gets a vrController by name.
  20845. * @param name The name of the controller to retreive
  20846. * @returns the controller matching the name specified or null if not found
  20847. */
  20848. getControllerByName(name: string): Nullable<WebVRController>;
  20849. private _leftController;
  20850. /**
  20851. * The controller corresponding to the users left hand.
  20852. */
  20853. get leftController(): Nullable<WebVRController>;
  20854. private _rightController;
  20855. /**
  20856. * The controller corresponding to the users right hand.
  20857. */
  20858. get rightController(): Nullable<WebVRController>;
  20859. /**
  20860. * Casts a ray forward from the vrCamera's gaze.
  20861. * @param length Length of the ray (default: 100)
  20862. * @returns the ray corresponding to the gaze
  20863. */
  20864. getForwardRay(length?: number): Ray;
  20865. /**
  20866. * @hidden
  20867. * Updates the camera based on device's frame data
  20868. */
  20869. _checkInputs(): void;
  20870. /**
  20871. * Updates the poseControlled values based on the input device pose.
  20872. * @param poseData Pose coming from the device
  20873. */
  20874. updateFromDevice(poseData: DevicePose): void;
  20875. private _htmlElementAttached;
  20876. private _detachIfAttached;
  20877. /**
  20878. * WebVR's attach control will start broadcasting frames to the device.
  20879. * Note that in certain browsers (chrome for example) this function must be called
  20880. * within a user-interaction callback. Example:
  20881. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20882. *
  20883. * @param element html element to attach the vrDevice to
  20884. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20885. */
  20886. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20887. /**
  20888. * Detaches the camera from the html element and disables VR
  20889. *
  20890. * @param element html element to detach from
  20891. */
  20892. detachControl(element: HTMLElement): void;
  20893. /**
  20894. * @returns the name of this class
  20895. */
  20896. getClassName(): string;
  20897. /**
  20898. * Calls resetPose on the vrDisplay
  20899. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20900. */
  20901. resetToCurrentRotation(): void;
  20902. /**
  20903. * @hidden
  20904. * Updates the rig cameras (left and right eye)
  20905. */
  20906. _updateRigCameras(): void;
  20907. private _workingVector;
  20908. private _oneVector;
  20909. private _workingMatrix;
  20910. private updateCacheCalled;
  20911. private _correctPositionIfNotTrackPosition;
  20912. /**
  20913. * @hidden
  20914. * Updates the cached values of the camera
  20915. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20916. */
  20917. _updateCache(ignoreParentClass?: boolean): void;
  20918. /**
  20919. * @hidden
  20920. * Get current device position in babylon world
  20921. */
  20922. _computeDevicePosition(): void;
  20923. /**
  20924. * Updates the current device position and rotation in the babylon world
  20925. */
  20926. update(): void;
  20927. /**
  20928. * @hidden
  20929. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20930. * @returns an identity matrix
  20931. */
  20932. _getViewMatrix(): Matrix;
  20933. private _tmpMatrix;
  20934. /**
  20935. * This function is called by the two RIG cameras.
  20936. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20937. * @hidden
  20938. */
  20939. _getWebVRViewMatrix(): Matrix;
  20940. /** @hidden */
  20941. _getWebVRProjectionMatrix(): Matrix;
  20942. private _onGamepadConnectedObserver;
  20943. private _onGamepadDisconnectedObserver;
  20944. private _updateCacheWhenTrackingDisabledObserver;
  20945. /**
  20946. * Initializes the controllers and their meshes
  20947. */
  20948. initControllers(): void;
  20949. }
  20950. }
  20951. declare module "babylonjs/Materials/materialHelper" {
  20952. import { Nullable } from "babylonjs/types";
  20953. import { Scene } from "babylonjs/scene";
  20954. import { Engine } from "babylonjs/Engines/engine";
  20955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20956. import { Light } from "babylonjs/Lights/light";
  20957. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  20958. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20959. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20960. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20961. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20962. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20963. /**
  20964. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20965. *
  20966. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20967. *
  20968. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20969. */
  20970. export class MaterialHelper {
  20971. /**
  20972. * Bind the current view position to an effect.
  20973. * @param effect The effect to be bound
  20974. * @param scene The scene the eyes position is used from
  20975. * @param variableName name of the shader variable that will hold the eye position
  20976. */
  20977. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20978. /**
  20979. * Helps preparing the defines values about the UVs in used in the effect.
  20980. * UVs are shared as much as we can accross channels in the shaders.
  20981. * @param texture The texture we are preparing the UVs for
  20982. * @param defines The defines to update
  20983. * @param key The channel key "diffuse", "specular"... used in the shader
  20984. */
  20985. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20986. /**
  20987. * Binds a texture matrix value to its corrsponding uniform
  20988. * @param texture The texture to bind the matrix for
  20989. * @param uniformBuffer The uniform buffer receivin the data
  20990. * @param key The channel key "diffuse", "specular"... used in the shader
  20991. */
  20992. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20993. /**
  20994. * Gets the current status of the fog (should it be enabled?)
  20995. * @param mesh defines the mesh to evaluate for fog support
  20996. * @param scene defines the hosting scene
  20997. * @returns true if fog must be enabled
  20998. */
  20999. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  21000. /**
  21001. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  21002. * @param mesh defines the current mesh
  21003. * @param scene defines the current scene
  21004. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  21005. * @param pointsCloud defines if point cloud rendering has to be turned on
  21006. * @param fogEnabled defines if fog has to be turned on
  21007. * @param alphaTest defines if alpha testing has to be turned on
  21008. * @param defines defines the current list of defines
  21009. */
  21010. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  21011. /**
  21012. * Helper used to prepare the list of defines associated with frame values for shader compilation
  21013. * @param scene defines the current scene
  21014. * @param engine defines the current engine
  21015. * @param defines specifies the list of active defines
  21016. * @param useInstances defines if instances have to be turned on
  21017. * @param useClipPlane defines if clip plane have to be turned on
  21018. * @param useInstances defines if instances have to be turned on
  21019. * @param useThinInstances defines if thin instances have to be turned on
  21020. */
  21021. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  21022. /**
  21023. * Prepares the defines for bones
  21024. * @param mesh The mesh containing the geometry data we will draw
  21025. * @param defines The defines to update
  21026. */
  21027. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  21028. /**
  21029. * Prepares the defines for morph targets
  21030. * @param mesh The mesh containing the geometry data we will draw
  21031. * @param defines The defines to update
  21032. */
  21033. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  21034. /**
  21035. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  21036. * @param mesh The mesh containing the geometry data we will draw
  21037. * @param defines The defines to update
  21038. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  21039. * @param useBones Precise whether bones should be used or not (override mesh info)
  21040. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  21041. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  21042. * @returns false if defines are considered not dirty and have not been checked
  21043. */
  21044. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  21045. /**
  21046. * Prepares the defines related to multiview
  21047. * @param scene The scene we are intending to draw
  21048. * @param defines The defines to update
  21049. */
  21050. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  21051. /**
  21052. * Prepares the defines related to the prepass
  21053. * @param scene The scene we are intending to draw
  21054. * @param defines The defines to update
  21055. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  21056. */
  21057. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  21058. /**
  21059. * Prepares the defines related to the light information passed in parameter
  21060. * @param scene The scene we are intending to draw
  21061. * @param mesh The mesh the effect is compiling for
  21062. * @param light The light the effect is compiling for
  21063. * @param lightIndex The index of the light
  21064. * @param defines The defines to update
  21065. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21066. * @param state Defines the current state regarding what is needed (normals, etc...)
  21067. */
  21068. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  21069. needNormals: boolean;
  21070. needRebuild: boolean;
  21071. shadowEnabled: boolean;
  21072. specularEnabled: boolean;
  21073. lightmapMode: boolean;
  21074. }): void;
  21075. /**
  21076. * Prepares the defines related to the light information passed in parameter
  21077. * @param scene The scene we are intending to draw
  21078. * @param mesh The mesh the effect is compiling for
  21079. * @param defines The defines to update
  21080. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21081. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21082. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21083. * @returns true if normals will be required for the rest of the effect
  21084. */
  21085. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21086. /**
  21087. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21088. * @param lightIndex defines the light index
  21089. * @param uniformsList The uniform list
  21090. * @param samplersList The sampler list
  21091. * @param projectedLightTexture defines if projected texture must be used
  21092. * @param uniformBuffersList defines an optional list of uniform buffers
  21093. */
  21094. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21095. /**
  21096. * Prepares the uniforms and samplers list to be used in the effect
  21097. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21098. * @param samplersList The sampler list
  21099. * @param defines The defines helping in the list generation
  21100. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21101. */
  21102. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21103. /**
  21104. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21105. * @param defines The defines to update while falling back
  21106. * @param fallbacks The authorized effect fallbacks
  21107. * @param maxSimultaneousLights The maximum number of lights allowed
  21108. * @param rank the current rank of the Effect
  21109. * @returns The newly affected rank
  21110. */
  21111. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21112. private static _TmpMorphInfluencers;
  21113. /**
  21114. * Prepares the list of attributes required for morph targets according to the effect defines.
  21115. * @param attribs The current list of supported attribs
  21116. * @param mesh The mesh to prepare the morph targets attributes for
  21117. * @param influencers The number of influencers
  21118. */
  21119. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21120. /**
  21121. * Prepares the list of attributes required for morph targets according to the effect defines.
  21122. * @param attribs The current list of supported attribs
  21123. * @param mesh The mesh to prepare the morph targets attributes for
  21124. * @param defines The current Defines of the effect
  21125. */
  21126. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21127. /**
  21128. * Prepares the list of attributes required for bones according to the effect defines.
  21129. * @param attribs The current list of supported attribs
  21130. * @param mesh The mesh to prepare the bones attributes for
  21131. * @param defines The current Defines of the effect
  21132. * @param fallbacks The current efffect fallback strategy
  21133. */
  21134. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21135. /**
  21136. * Check and prepare the list of attributes required for instances according to the effect defines.
  21137. * @param attribs The current list of supported attribs
  21138. * @param defines The current MaterialDefines of the effect
  21139. */
  21140. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21141. /**
  21142. * Add the list of attributes required for instances to the attribs array.
  21143. * @param attribs The current list of supported attribs
  21144. */
  21145. static PushAttributesForInstances(attribs: string[]): void;
  21146. /**
  21147. * Binds the light information to the effect.
  21148. * @param light The light containing the generator
  21149. * @param effect The effect we are binding the data to
  21150. * @param lightIndex The light index in the effect used to render
  21151. */
  21152. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21153. /**
  21154. * Binds the lights information from the scene to the effect for the given mesh.
  21155. * @param light Light to bind
  21156. * @param lightIndex Light index
  21157. * @param scene The scene where the light belongs to
  21158. * @param effect The effect we are binding the data to
  21159. * @param useSpecular Defines if specular is supported
  21160. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21161. */
  21162. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21163. /**
  21164. * Binds the lights information from the scene to the effect for the given mesh.
  21165. * @param scene The scene the lights belongs to
  21166. * @param mesh The mesh we are binding the information to render
  21167. * @param effect The effect we are binding the data to
  21168. * @param defines The generated defines for the effect
  21169. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21170. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21171. */
  21172. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21173. private static _tempFogColor;
  21174. /**
  21175. * Binds the fog information from the scene to the effect for the given mesh.
  21176. * @param scene The scene the lights belongs to
  21177. * @param mesh The mesh we are binding the information to render
  21178. * @param effect The effect we are binding the data to
  21179. * @param linearSpace Defines if the fog effect is applied in linear space
  21180. */
  21181. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21182. /**
  21183. * Binds the bones information from the mesh to the effect.
  21184. * @param mesh The mesh we are binding the information to render
  21185. * @param effect The effect we are binding the data to
  21186. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  21187. */
  21188. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  21189. private static _CopyBonesTransformationMatrices;
  21190. /**
  21191. * Binds the morph targets information from the mesh to the effect.
  21192. * @param abstractMesh The mesh we are binding the information to render
  21193. * @param effect The effect we are binding the data to
  21194. */
  21195. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21196. /**
  21197. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21198. * @param defines The generated defines used in the effect
  21199. * @param effect The effect we are binding the data to
  21200. * @param scene The scene we are willing to render with logarithmic scale for
  21201. */
  21202. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21203. /**
  21204. * Binds the clip plane information from the scene to the effect.
  21205. * @param scene The scene the clip plane information are extracted from
  21206. * @param effect The effect we are binding the data to
  21207. */
  21208. static BindClipPlane(effect: Effect, scene: Scene): void;
  21209. }
  21210. }
  21211. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21212. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21213. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21214. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21215. import { Nullable } from "babylonjs/types";
  21216. import { Effect } from "babylonjs/Materials/effect";
  21217. import { Matrix } from "babylonjs/Maths/math.vector";
  21218. import { Scene } from "babylonjs/scene";
  21219. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21221. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21222. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21223. import { Observable } from "babylonjs/Misc/observable";
  21224. /**
  21225. * Block used to expose an input value
  21226. */
  21227. export class InputBlock extends NodeMaterialBlock {
  21228. private _mode;
  21229. private _associatedVariableName;
  21230. private _storedValue;
  21231. private _valueCallback;
  21232. private _type;
  21233. private _animationType;
  21234. /** Gets or set a value used to limit the range of float values */
  21235. min: number;
  21236. /** Gets or set a value used to limit the range of float values */
  21237. max: number;
  21238. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21239. isBoolean: boolean;
  21240. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21241. matrixMode: number;
  21242. /** @hidden */
  21243. _systemValue: Nullable<NodeMaterialSystemValues>;
  21244. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21245. isConstant: boolean;
  21246. /** Gets or sets the group to use to display this block in the Inspector */
  21247. groupInInspector: string;
  21248. /** Gets an observable raised when the value is changed */
  21249. onValueChangedObservable: Observable<InputBlock>;
  21250. /**
  21251. * Gets or sets the connection point type (default is float)
  21252. */
  21253. get type(): NodeMaterialBlockConnectionPointTypes;
  21254. /**
  21255. * Creates a new InputBlock
  21256. * @param name defines the block name
  21257. * @param target defines the target of that block (Vertex by default)
  21258. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21259. */
  21260. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21261. /**
  21262. * Validates if a name is a reserve word.
  21263. * @param newName the new name to be given to the node.
  21264. * @returns false if the name is a reserve word, else true.
  21265. */
  21266. validateBlockName(newName: string): boolean;
  21267. /**
  21268. * Gets the output component
  21269. */
  21270. get output(): NodeMaterialConnectionPoint;
  21271. /**
  21272. * Set the source of this connection point to a vertex attribute
  21273. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21274. * @returns the current connection point
  21275. */
  21276. setAsAttribute(attributeName?: string): InputBlock;
  21277. /**
  21278. * Set the source of this connection point to a system value
  21279. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21280. * @returns the current connection point
  21281. */
  21282. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21283. /**
  21284. * Gets or sets the value of that point.
  21285. * Please note that this value will be ignored if valueCallback is defined
  21286. */
  21287. get value(): any;
  21288. set value(value: any);
  21289. /**
  21290. * Gets or sets a callback used to get the value of that point.
  21291. * Please note that setting this value will force the connection point to ignore the value property
  21292. */
  21293. get valueCallback(): () => any;
  21294. set valueCallback(value: () => any);
  21295. /**
  21296. * Gets or sets the associated variable name in the shader
  21297. */
  21298. get associatedVariableName(): string;
  21299. set associatedVariableName(value: string);
  21300. /** Gets or sets the type of animation applied to the input */
  21301. get animationType(): AnimatedInputBlockTypes;
  21302. set animationType(value: AnimatedInputBlockTypes);
  21303. /**
  21304. * Gets a boolean indicating that this connection point not defined yet
  21305. */
  21306. get isUndefined(): boolean;
  21307. /**
  21308. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21309. * In this case the connection point name must be the name of the uniform to use.
  21310. * Can only be set on inputs
  21311. */
  21312. get isUniform(): boolean;
  21313. set isUniform(value: boolean);
  21314. /**
  21315. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21316. * In this case the connection point name must be the name of the attribute to use
  21317. * Can only be set on inputs
  21318. */
  21319. get isAttribute(): boolean;
  21320. set isAttribute(value: boolean);
  21321. /**
  21322. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21323. * Can only be set on exit points
  21324. */
  21325. get isVarying(): boolean;
  21326. set isVarying(value: boolean);
  21327. /**
  21328. * Gets a boolean indicating that the current connection point is a system value
  21329. */
  21330. get isSystemValue(): boolean;
  21331. /**
  21332. * Gets or sets the current well known value or null if not defined as a system value
  21333. */
  21334. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21335. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21336. /**
  21337. * Gets the current class name
  21338. * @returns the class name
  21339. */
  21340. getClassName(): string;
  21341. /**
  21342. * Animate the input if animationType !== None
  21343. * @param scene defines the rendering scene
  21344. */
  21345. animate(scene: Scene): void;
  21346. private _emitDefine;
  21347. initialize(state: NodeMaterialBuildState): void;
  21348. /**
  21349. * Set the input block to its default value (based on its type)
  21350. */
  21351. setDefaultValue(): void;
  21352. private _emitConstant;
  21353. /** @hidden */
  21354. get _noContextSwitch(): boolean;
  21355. private _emit;
  21356. /** @hidden */
  21357. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21358. /** @hidden */
  21359. _transmit(effect: Effect, scene: Scene): void;
  21360. protected _buildBlock(state: NodeMaterialBuildState): void;
  21361. protected _dumpPropertiesCode(): string;
  21362. dispose(): void;
  21363. serialize(): any;
  21364. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21365. }
  21366. }
  21367. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21368. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21369. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21370. import { Nullable } from "babylonjs/types";
  21371. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21372. import { Observable } from "babylonjs/Misc/observable";
  21373. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21374. /**
  21375. * Enum used to define the compatibility state between two connection points
  21376. */
  21377. export enum NodeMaterialConnectionPointCompatibilityStates {
  21378. /** Points are compatibles */
  21379. Compatible = 0,
  21380. /** Points are incompatible because of their types */
  21381. TypeIncompatible = 1,
  21382. /** Points are incompatible because of their targets (vertex vs fragment) */
  21383. TargetIncompatible = 2
  21384. }
  21385. /**
  21386. * Defines the direction of a connection point
  21387. */
  21388. export enum NodeMaterialConnectionPointDirection {
  21389. /** Input */
  21390. Input = 0,
  21391. /** Output */
  21392. Output = 1
  21393. }
  21394. /**
  21395. * Defines a connection point for a block
  21396. */
  21397. export class NodeMaterialConnectionPoint {
  21398. /** @hidden */
  21399. _ownerBlock: NodeMaterialBlock;
  21400. /** @hidden */
  21401. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21402. private _endpoints;
  21403. private _associatedVariableName;
  21404. private _direction;
  21405. /** @hidden */
  21406. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21407. /** @hidden */
  21408. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21409. private _type;
  21410. /** @hidden */
  21411. _enforceAssociatedVariableName: boolean;
  21412. /** Gets the direction of the point */
  21413. get direction(): NodeMaterialConnectionPointDirection;
  21414. /** Indicates that this connection point needs dual validation before being connected to another point */
  21415. needDualDirectionValidation: boolean;
  21416. /**
  21417. * Gets or sets the additional types supported by this connection point
  21418. */
  21419. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21420. /**
  21421. * Gets or sets the additional types excluded by this connection point
  21422. */
  21423. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21424. /**
  21425. * Observable triggered when this point is connected
  21426. */
  21427. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21428. /**
  21429. * Gets or sets the associated variable name in the shader
  21430. */
  21431. get associatedVariableName(): string;
  21432. set associatedVariableName(value: string);
  21433. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21434. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21435. /**
  21436. * Gets or sets the connection point type (default is float)
  21437. */
  21438. get type(): NodeMaterialBlockConnectionPointTypes;
  21439. set type(value: NodeMaterialBlockConnectionPointTypes);
  21440. /**
  21441. * Gets or sets the connection point name
  21442. */
  21443. name: string;
  21444. /**
  21445. * Gets or sets the connection point name
  21446. */
  21447. displayName: string;
  21448. /**
  21449. * Gets or sets a boolean indicating that this connection point can be omitted
  21450. */
  21451. isOptional: boolean;
  21452. /**
  21453. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21454. */
  21455. isExposedOnFrame: boolean;
  21456. /**
  21457. * Gets or sets number indicating the position that the port is exposed to on a frame
  21458. */
  21459. exposedPortPosition: number;
  21460. /**
  21461. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21462. */
  21463. define: string;
  21464. /** @hidden */
  21465. _prioritizeVertex: boolean;
  21466. private _target;
  21467. /** Gets or sets the target of that connection point */
  21468. get target(): NodeMaterialBlockTargets;
  21469. set target(value: NodeMaterialBlockTargets);
  21470. /**
  21471. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21472. */
  21473. get isConnected(): boolean;
  21474. /**
  21475. * Gets a boolean indicating that the current point is connected to an input block
  21476. */
  21477. get isConnectedToInputBlock(): boolean;
  21478. /**
  21479. * Gets a the connected input block (if any)
  21480. */
  21481. get connectInputBlock(): Nullable<InputBlock>;
  21482. /** Get the other side of the connection (if any) */
  21483. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21484. /** Get the block that owns this connection point */
  21485. get ownerBlock(): NodeMaterialBlock;
  21486. /** Get the block connected on the other side of this connection (if any) */
  21487. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21488. /** Get the block connected on the endpoints of this connection (if any) */
  21489. get connectedBlocks(): Array<NodeMaterialBlock>;
  21490. /** Gets the list of connected endpoints */
  21491. get endpoints(): NodeMaterialConnectionPoint[];
  21492. /** Gets a boolean indicating if that output point is connected to at least one input */
  21493. get hasEndpoints(): boolean;
  21494. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21495. get isConnectedInVertexShader(): boolean;
  21496. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21497. get isConnectedInFragmentShader(): boolean;
  21498. /**
  21499. * Creates a block suitable to be used as an input for this input point.
  21500. * If null is returned, a block based on the point type will be created.
  21501. * @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
  21502. */
  21503. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21504. /**
  21505. * Creates a new connection point
  21506. * @param name defines the connection point name
  21507. * @param ownerBlock defines the block hosting this connection point
  21508. * @param direction defines the direction of the connection point
  21509. */
  21510. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21511. /**
  21512. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21513. * @returns the class name
  21514. */
  21515. getClassName(): string;
  21516. /**
  21517. * Gets a boolean indicating if the current point can be connected to another point
  21518. * @param connectionPoint defines the other connection point
  21519. * @returns a boolean
  21520. */
  21521. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21522. /**
  21523. * Gets a number indicating if the current point can be connected to another point
  21524. * @param connectionPoint defines the other connection point
  21525. * @returns a number defining the compatibility state
  21526. */
  21527. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21528. /**
  21529. * Connect this point to another connection point
  21530. * @param connectionPoint defines the other connection point
  21531. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21532. * @returns the current connection point
  21533. */
  21534. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21535. /**
  21536. * Disconnect this point from one of his endpoint
  21537. * @param endpoint defines the other connection point
  21538. * @returns the current connection point
  21539. */
  21540. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21541. /**
  21542. * Serializes this point in a JSON representation
  21543. * @param isInput defines if the connection point is an input (default is true)
  21544. * @returns the serialized point object
  21545. */
  21546. serialize(isInput?: boolean): any;
  21547. /**
  21548. * Release resources
  21549. */
  21550. dispose(): void;
  21551. }
  21552. }
  21553. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21554. /**
  21555. * Enum used to define the material modes
  21556. */
  21557. export enum NodeMaterialModes {
  21558. /** Regular material */
  21559. Material = 0,
  21560. /** For post process */
  21561. PostProcess = 1,
  21562. /** For particle system */
  21563. Particle = 2,
  21564. /** For procedural texture */
  21565. ProceduralTexture = 3
  21566. }
  21567. }
  21568. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21569. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21570. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21571. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21572. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21574. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21575. import { Effect } from "babylonjs/Materials/effect";
  21576. import { Mesh } from "babylonjs/Meshes/mesh";
  21577. import { Nullable } from "babylonjs/types";
  21578. import { Texture } from "babylonjs/Materials/Textures/texture";
  21579. import { Scene } from "babylonjs/scene";
  21580. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21581. /**
  21582. * Block used to read a texture from a sampler
  21583. */
  21584. export class TextureBlock extends NodeMaterialBlock {
  21585. private _defineName;
  21586. private _linearDefineName;
  21587. private _gammaDefineName;
  21588. private _tempTextureRead;
  21589. private _samplerName;
  21590. private _transformedUVName;
  21591. private _textureTransformName;
  21592. private _textureInfoName;
  21593. private _mainUVName;
  21594. private _mainUVDefineName;
  21595. private _fragmentOnly;
  21596. /**
  21597. * Gets or sets the texture associated with the node
  21598. */
  21599. texture: Nullable<Texture>;
  21600. /**
  21601. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21602. */
  21603. convertToGammaSpace: boolean;
  21604. /**
  21605. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21606. */
  21607. convertToLinearSpace: boolean;
  21608. /**
  21609. * Create a new TextureBlock
  21610. * @param name defines the block name
  21611. */
  21612. constructor(name: string, fragmentOnly?: boolean);
  21613. /**
  21614. * Gets the current class name
  21615. * @returns the class name
  21616. */
  21617. getClassName(): string;
  21618. /**
  21619. * Gets the uv input component
  21620. */
  21621. get uv(): NodeMaterialConnectionPoint;
  21622. /**
  21623. * Gets the rgba output component
  21624. */
  21625. get rgba(): NodeMaterialConnectionPoint;
  21626. /**
  21627. * Gets the rgb output component
  21628. */
  21629. get rgb(): NodeMaterialConnectionPoint;
  21630. /**
  21631. * Gets the r output component
  21632. */
  21633. get r(): NodeMaterialConnectionPoint;
  21634. /**
  21635. * Gets the g output component
  21636. */
  21637. get g(): NodeMaterialConnectionPoint;
  21638. /**
  21639. * Gets the b output component
  21640. */
  21641. get b(): NodeMaterialConnectionPoint;
  21642. /**
  21643. * Gets the a output component
  21644. */
  21645. get a(): NodeMaterialConnectionPoint;
  21646. get target(): NodeMaterialBlockTargets;
  21647. autoConfigure(material: NodeMaterial): void;
  21648. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21649. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21650. isReady(): boolean;
  21651. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21652. private get _isMixed();
  21653. private _injectVertexCode;
  21654. private _writeTextureRead;
  21655. private _writeOutput;
  21656. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21657. protected _dumpPropertiesCode(): string;
  21658. serialize(): any;
  21659. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21660. }
  21661. }
  21662. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21663. /** @hidden */
  21664. export var reflectionFunction: {
  21665. name: string;
  21666. shader: string;
  21667. };
  21668. }
  21669. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21670. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21671. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21672. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21673. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21675. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21676. import { Effect } from "babylonjs/Materials/effect";
  21677. import { Mesh } from "babylonjs/Meshes/mesh";
  21678. import { Nullable } from "babylonjs/types";
  21679. import { Scene } from "babylonjs/scene";
  21680. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21681. /**
  21682. * Base block used to read a reflection texture from a sampler
  21683. */
  21684. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21685. /** @hidden */
  21686. _define3DName: string;
  21687. /** @hidden */
  21688. _defineCubicName: string;
  21689. /** @hidden */
  21690. _defineExplicitName: string;
  21691. /** @hidden */
  21692. _defineProjectionName: string;
  21693. /** @hidden */
  21694. _defineLocalCubicName: string;
  21695. /** @hidden */
  21696. _defineSphericalName: string;
  21697. /** @hidden */
  21698. _definePlanarName: string;
  21699. /** @hidden */
  21700. _defineEquirectangularName: string;
  21701. /** @hidden */
  21702. _defineMirroredEquirectangularFixedName: string;
  21703. /** @hidden */
  21704. _defineEquirectangularFixedName: string;
  21705. /** @hidden */
  21706. _defineSkyboxName: string;
  21707. /** @hidden */
  21708. _defineOppositeZ: string;
  21709. /** @hidden */
  21710. _cubeSamplerName: string;
  21711. /** @hidden */
  21712. _2DSamplerName: string;
  21713. protected _positionUVWName: string;
  21714. protected _directionWName: string;
  21715. protected _reflectionVectorName: string;
  21716. /** @hidden */
  21717. _reflectionCoordsName: string;
  21718. /** @hidden */
  21719. _reflectionMatrixName: string;
  21720. protected _reflectionColorName: string;
  21721. /**
  21722. * Gets or sets the texture associated with the node
  21723. */
  21724. texture: Nullable<BaseTexture>;
  21725. /**
  21726. * Create a new ReflectionTextureBaseBlock
  21727. * @param name defines the block name
  21728. */
  21729. constructor(name: string);
  21730. /**
  21731. * Gets the current class name
  21732. * @returns the class name
  21733. */
  21734. getClassName(): string;
  21735. /**
  21736. * Gets the world position input component
  21737. */
  21738. abstract get position(): NodeMaterialConnectionPoint;
  21739. /**
  21740. * Gets the world position input component
  21741. */
  21742. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21743. /**
  21744. * Gets the world normal input component
  21745. */
  21746. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21747. /**
  21748. * Gets the world input component
  21749. */
  21750. abstract get world(): NodeMaterialConnectionPoint;
  21751. /**
  21752. * Gets the camera (or eye) position component
  21753. */
  21754. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21755. /**
  21756. * Gets the view input component
  21757. */
  21758. abstract get view(): NodeMaterialConnectionPoint;
  21759. protected _getTexture(): Nullable<BaseTexture>;
  21760. autoConfigure(material: NodeMaterial): void;
  21761. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21762. isReady(): boolean;
  21763. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21764. /**
  21765. * Gets the code to inject in the vertex shader
  21766. * @param state current state of the node material building
  21767. * @returns the shader code
  21768. */
  21769. handleVertexSide(state: NodeMaterialBuildState): string;
  21770. /**
  21771. * Handles the inits for the fragment code path
  21772. * @param state node material build state
  21773. */
  21774. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21775. /**
  21776. * Generates the reflection coords code for the fragment code path
  21777. * @param worldNormalVarName name of the world normal variable
  21778. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21779. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21780. * @returns the shader code
  21781. */
  21782. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21783. /**
  21784. * Generates the reflection color code for the fragment code path
  21785. * @param lodVarName name of the lod variable
  21786. * @param swizzleLookupTexture swizzle to use for the final color variable
  21787. * @returns the shader code
  21788. */
  21789. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21790. /**
  21791. * Generates the code corresponding to the connected output points
  21792. * @param state node material build state
  21793. * @param varName name of the variable to output
  21794. * @returns the shader code
  21795. */
  21796. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21797. protected _buildBlock(state: NodeMaterialBuildState): this;
  21798. protected _dumpPropertiesCode(): string;
  21799. serialize(): any;
  21800. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21801. }
  21802. }
  21803. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21804. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21805. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21806. import { Nullable } from "babylonjs/types";
  21807. /**
  21808. * Defines a connection point to be used for points with a custom object type
  21809. */
  21810. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21811. private _blockType;
  21812. private _blockName;
  21813. private _nameForCheking?;
  21814. /**
  21815. * Creates a new connection point
  21816. * @param name defines the connection point name
  21817. * @param ownerBlock defines the block hosting this connection point
  21818. * @param direction defines the direction of the connection point
  21819. */
  21820. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21821. /**
  21822. * Gets a number indicating if the current point can be connected to another point
  21823. * @param connectionPoint defines the other connection point
  21824. * @returns a number defining the compatibility state
  21825. */
  21826. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21827. /**
  21828. * Creates a block suitable to be used as an input for this input point.
  21829. * If null is returned, a block based on the point type will be created.
  21830. * @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
  21831. */
  21832. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21833. }
  21834. }
  21835. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21836. /**
  21837. * Enum defining the type of properties that can be edited in the property pages in the NME
  21838. */
  21839. export enum PropertyTypeForEdition {
  21840. /** property is a boolean */
  21841. Boolean = 0,
  21842. /** property is a float */
  21843. Float = 1,
  21844. /** property is a Vector2 */
  21845. Vector2 = 2,
  21846. /** property is a list of values */
  21847. List = 3
  21848. }
  21849. /**
  21850. * Interface that defines an option in a variable of type list
  21851. */
  21852. export interface IEditablePropertyListOption {
  21853. /** label of the option */
  21854. "label": string;
  21855. /** value of the option */
  21856. "value": number;
  21857. }
  21858. /**
  21859. * Interface that defines the options available for an editable property
  21860. */
  21861. export interface IEditablePropertyOption {
  21862. /** min value */
  21863. "min"?: number;
  21864. /** max value */
  21865. "max"?: number;
  21866. /** notifiers: indicates which actions to take when the property is changed */
  21867. "notifiers"?: {
  21868. /** the material should be rebuilt */
  21869. "rebuild"?: boolean;
  21870. /** the preview should be updated */
  21871. "update"?: boolean;
  21872. };
  21873. /** list of the options for a variable of type list */
  21874. "options"?: IEditablePropertyListOption[];
  21875. }
  21876. /**
  21877. * Interface that describes an editable property
  21878. */
  21879. export interface IPropertyDescriptionForEdition {
  21880. /** name of the property */
  21881. "propertyName": string;
  21882. /** display name of the property */
  21883. "displayName": string;
  21884. /** type of the property */
  21885. "type": PropertyTypeForEdition;
  21886. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21887. "groupName": string;
  21888. /** options for the property */
  21889. "options": IEditablePropertyOption;
  21890. }
  21891. /**
  21892. * Decorator that flags a property in a node material block as being editable
  21893. */
  21894. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21895. }
  21896. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21897. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21898. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21899. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21901. import { Nullable } from "babylonjs/types";
  21902. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21903. import { Mesh } from "babylonjs/Meshes/mesh";
  21904. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21905. import { Effect } from "babylonjs/Materials/effect";
  21906. import { Scene } from "babylonjs/scene";
  21907. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21908. /**
  21909. * Block used to implement the refraction part of the sub surface module of the PBR material
  21910. */
  21911. export class RefractionBlock extends NodeMaterialBlock {
  21912. /** @hidden */
  21913. _define3DName: string;
  21914. /** @hidden */
  21915. _refractionMatrixName: string;
  21916. /** @hidden */
  21917. _defineLODRefractionAlpha: string;
  21918. /** @hidden */
  21919. _defineLinearSpecularRefraction: string;
  21920. /** @hidden */
  21921. _defineOppositeZ: string;
  21922. /** @hidden */
  21923. _cubeSamplerName: string;
  21924. /** @hidden */
  21925. _2DSamplerName: string;
  21926. /** @hidden */
  21927. _vRefractionMicrosurfaceInfosName: string;
  21928. /** @hidden */
  21929. _vRefractionInfosName: string;
  21930. private _scene;
  21931. /**
  21932. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21933. * Materials half opaque for instance using refraction could benefit from this control.
  21934. */
  21935. linkRefractionWithTransparency: boolean;
  21936. /**
  21937. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21938. */
  21939. invertRefractionY: boolean;
  21940. /**
  21941. * Gets or sets the texture associated with the node
  21942. */
  21943. texture: Nullable<BaseTexture>;
  21944. /**
  21945. * Create a new RefractionBlock
  21946. * @param name defines the block name
  21947. */
  21948. constructor(name: string);
  21949. /**
  21950. * Gets the current class name
  21951. * @returns the class name
  21952. */
  21953. getClassName(): string;
  21954. /**
  21955. * Gets the intensity input component
  21956. */
  21957. get intensity(): NodeMaterialConnectionPoint;
  21958. /**
  21959. * Gets the index of refraction input component
  21960. */
  21961. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21962. /**
  21963. * Gets the tint at distance input component
  21964. */
  21965. get tintAtDistance(): NodeMaterialConnectionPoint;
  21966. /**
  21967. * Gets the view input component
  21968. */
  21969. get view(): NodeMaterialConnectionPoint;
  21970. /**
  21971. * Gets the refraction object output component
  21972. */
  21973. get refraction(): NodeMaterialConnectionPoint;
  21974. /**
  21975. * Returns true if the block has a texture
  21976. */
  21977. get hasTexture(): boolean;
  21978. protected _getTexture(): Nullable<BaseTexture>;
  21979. autoConfigure(material: NodeMaterial): void;
  21980. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21981. isReady(): boolean;
  21982. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21983. /**
  21984. * Gets the main code of the block (fragment side)
  21985. * @param state current state of the node material building
  21986. * @returns the shader code
  21987. */
  21988. getCode(state: NodeMaterialBuildState): string;
  21989. protected _buildBlock(state: NodeMaterialBuildState): this;
  21990. protected _dumpPropertiesCode(): string;
  21991. serialize(): any;
  21992. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21993. }
  21994. }
  21995. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21996. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21997. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21998. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21999. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22001. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22002. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22003. import { Nullable } from "babylonjs/types";
  22004. import { Scene } from "babylonjs/scene";
  22005. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22006. /**
  22007. * Base block used as input for post process
  22008. */
  22009. export class CurrentScreenBlock extends NodeMaterialBlock {
  22010. private _samplerName;
  22011. private _linearDefineName;
  22012. private _gammaDefineName;
  22013. private _mainUVName;
  22014. private _tempTextureRead;
  22015. /**
  22016. * Gets or sets the texture associated with the node
  22017. */
  22018. texture: Nullable<BaseTexture>;
  22019. /**
  22020. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22021. */
  22022. convertToGammaSpace: boolean;
  22023. /**
  22024. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22025. */
  22026. convertToLinearSpace: boolean;
  22027. /**
  22028. * Create a new CurrentScreenBlock
  22029. * @param name defines the block name
  22030. */
  22031. constructor(name: string);
  22032. /**
  22033. * Gets the current class name
  22034. * @returns the class name
  22035. */
  22036. getClassName(): string;
  22037. /**
  22038. * Gets the uv input component
  22039. */
  22040. get uv(): NodeMaterialConnectionPoint;
  22041. /**
  22042. * Gets the rgba output component
  22043. */
  22044. get rgba(): NodeMaterialConnectionPoint;
  22045. /**
  22046. * Gets the rgb output component
  22047. */
  22048. get rgb(): NodeMaterialConnectionPoint;
  22049. /**
  22050. * Gets the r output component
  22051. */
  22052. get r(): NodeMaterialConnectionPoint;
  22053. /**
  22054. * Gets the g output component
  22055. */
  22056. get g(): NodeMaterialConnectionPoint;
  22057. /**
  22058. * Gets the b output component
  22059. */
  22060. get b(): NodeMaterialConnectionPoint;
  22061. /**
  22062. * Gets the a output component
  22063. */
  22064. get a(): NodeMaterialConnectionPoint;
  22065. /**
  22066. * Initialize the block and prepare the context for build
  22067. * @param state defines the state that will be used for the build
  22068. */
  22069. initialize(state: NodeMaterialBuildState): void;
  22070. get target(): NodeMaterialBlockTargets;
  22071. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22072. isReady(): boolean;
  22073. private _injectVertexCode;
  22074. private _writeTextureRead;
  22075. private _writeOutput;
  22076. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22077. serialize(): any;
  22078. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22079. }
  22080. }
  22081. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  22082. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22083. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22084. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22086. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22087. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22088. import { Nullable } from "babylonjs/types";
  22089. import { Scene } from "babylonjs/scene";
  22090. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22091. /**
  22092. * Base block used for the particle texture
  22093. */
  22094. export class ParticleTextureBlock extends NodeMaterialBlock {
  22095. private _samplerName;
  22096. private _linearDefineName;
  22097. private _gammaDefineName;
  22098. private _tempTextureRead;
  22099. /**
  22100. * Gets or sets the texture associated with the node
  22101. */
  22102. texture: Nullable<BaseTexture>;
  22103. /**
  22104. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22105. */
  22106. convertToGammaSpace: boolean;
  22107. /**
  22108. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22109. */
  22110. convertToLinearSpace: boolean;
  22111. /**
  22112. * Create a new ParticleTextureBlock
  22113. * @param name defines the block name
  22114. */
  22115. constructor(name: string);
  22116. /**
  22117. * Gets the current class name
  22118. * @returns the class name
  22119. */
  22120. getClassName(): string;
  22121. /**
  22122. * Gets the uv input component
  22123. */
  22124. get uv(): NodeMaterialConnectionPoint;
  22125. /**
  22126. * Gets the rgba output component
  22127. */
  22128. get rgba(): NodeMaterialConnectionPoint;
  22129. /**
  22130. * Gets the rgb output component
  22131. */
  22132. get rgb(): NodeMaterialConnectionPoint;
  22133. /**
  22134. * Gets the r output component
  22135. */
  22136. get r(): NodeMaterialConnectionPoint;
  22137. /**
  22138. * Gets the g output component
  22139. */
  22140. get g(): NodeMaterialConnectionPoint;
  22141. /**
  22142. * Gets the b output component
  22143. */
  22144. get b(): NodeMaterialConnectionPoint;
  22145. /**
  22146. * Gets the a output component
  22147. */
  22148. get a(): NodeMaterialConnectionPoint;
  22149. /**
  22150. * Initialize the block and prepare the context for build
  22151. * @param state defines the state that will be used for the build
  22152. */
  22153. initialize(state: NodeMaterialBuildState): void;
  22154. autoConfigure(material: NodeMaterial): void;
  22155. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22156. isReady(): boolean;
  22157. private _writeOutput;
  22158. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22159. serialize(): any;
  22160. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22161. }
  22162. }
  22163. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22164. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22165. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22166. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22167. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22168. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22169. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22170. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22171. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22172. import { Scene } from "babylonjs/scene";
  22173. /**
  22174. * Class used to store shared data between 2 NodeMaterialBuildState
  22175. */
  22176. export class NodeMaterialBuildStateSharedData {
  22177. /**
  22178. * Gets the list of emitted varyings
  22179. */
  22180. temps: string[];
  22181. /**
  22182. * Gets the list of emitted varyings
  22183. */
  22184. varyings: string[];
  22185. /**
  22186. * Gets the varying declaration string
  22187. */
  22188. varyingDeclaration: string;
  22189. /**
  22190. * Input blocks
  22191. */
  22192. inputBlocks: InputBlock[];
  22193. /**
  22194. * Input blocks
  22195. */
  22196. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22197. /**
  22198. * Bindable blocks (Blocks that need to set data to the effect)
  22199. */
  22200. bindableBlocks: NodeMaterialBlock[];
  22201. /**
  22202. * List of blocks that can provide a compilation fallback
  22203. */
  22204. blocksWithFallbacks: NodeMaterialBlock[];
  22205. /**
  22206. * List of blocks that can provide a define update
  22207. */
  22208. blocksWithDefines: NodeMaterialBlock[];
  22209. /**
  22210. * List of blocks that can provide a repeatable content
  22211. */
  22212. repeatableContentBlocks: NodeMaterialBlock[];
  22213. /**
  22214. * List of blocks that can provide a dynamic list of uniforms
  22215. */
  22216. dynamicUniformBlocks: NodeMaterialBlock[];
  22217. /**
  22218. * List of blocks that can block the isReady function for the material
  22219. */
  22220. blockingBlocks: NodeMaterialBlock[];
  22221. /**
  22222. * Gets the list of animated inputs
  22223. */
  22224. animatedInputs: InputBlock[];
  22225. /**
  22226. * Build Id used to avoid multiple recompilations
  22227. */
  22228. buildId: number;
  22229. /** List of emitted variables */
  22230. variableNames: {
  22231. [key: string]: number;
  22232. };
  22233. /** List of emitted defines */
  22234. defineNames: {
  22235. [key: string]: number;
  22236. };
  22237. /** Should emit comments? */
  22238. emitComments: boolean;
  22239. /** Emit build activity */
  22240. verbose: boolean;
  22241. /** Gets or sets the hosting scene */
  22242. scene: Scene;
  22243. /**
  22244. * Gets the compilation hints emitted at compilation time
  22245. */
  22246. hints: {
  22247. needWorldViewMatrix: boolean;
  22248. needWorldViewProjectionMatrix: boolean;
  22249. needAlphaBlending: boolean;
  22250. needAlphaTesting: boolean;
  22251. };
  22252. /**
  22253. * List of compilation checks
  22254. */
  22255. checks: {
  22256. emitVertex: boolean;
  22257. emitFragment: boolean;
  22258. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22259. };
  22260. /**
  22261. * Is vertex program allowed to be empty?
  22262. */
  22263. allowEmptyVertexProgram: boolean;
  22264. /** Creates a new shared data */
  22265. constructor();
  22266. /**
  22267. * Emits console errors and exceptions if there is a failing check
  22268. */
  22269. emitErrors(): void;
  22270. }
  22271. }
  22272. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22273. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22274. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22275. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22276. /**
  22277. * Class used to store node based material build state
  22278. */
  22279. export class NodeMaterialBuildState {
  22280. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22281. supportUniformBuffers: boolean;
  22282. /**
  22283. * Gets the list of emitted attributes
  22284. */
  22285. attributes: string[];
  22286. /**
  22287. * Gets the list of emitted uniforms
  22288. */
  22289. uniforms: string[];
  22290. /**
  22291. * Gets the list of emitted constants
  22292. */
  22293. constants: string[];
  22294. /**
  22295. * Gets the list of emitted samplers
  22296. */
  22297. samplers: string[];
  22298. /**
  22299. * Gets the list of emitted functions
  22300. */
  22301. functions: {
  22302. [key: string]: string;
  22303. };
  22304. /**
  22305. * Gets the list of emitted extensions
  22306. */
  22307. extensions: {
  22308. [key: string]: string;
  22309. };
  22310. /**
  22311. * Gets the target of the compilation state
  22312. */
  22313. target: NodeMaterialBlockTargets;
  22314. /**
  22315. * Gets the list of emitted counters
  22316. */
  22317. counters: {
  22318. [key: string]: number;
  22319. };
  22320. /**
  22321. * Shared data between multiple NodeMaterialBuildState instances
  22322. */
  22323. sharedData: NodeMaterialBuildStateSharedData;
  22324. /** @hidden */
  22325. _vertexState: NodeMaterialBuildState;
  22326. /** @hidden */
  22327. _attributeDeclaration: string;
  22328. /** @hidden */
  22329. _uniformDeclaration: string;
  22330. /** @hidden */
  22331. _constantDeclaration: string;
  22332. /** @hidden */
  22333. _samplerDeclaration: string;
  22334. /** @hidden */
  22335. _varyingTransfer: string;
  22336. /** @hidden */
  22337. _injectAtEnd: string;
  22338. private _repeatableContentAnchorIndex;
  22339. /** @hidden */
  22340. _builtCompilationString: string;
  22341. /**
  22342. * Gets the emitted compilation strings
  22343. */
  22344. compilationString: string;
  22345. /**
  22346. * Finalize the compilation strings
  22347. * @param state defines the current compilation state
  22348. */
  22349. finalize(state: NodeMaterialBuildState): void;
  22350. /** @hidden */
  22351. get _repeatableContentAnchor(): string;
  22352. /** @hidden */
  22353. _getFreeVariableName(prefix: string): string;
  22354. /** @hidden */
  22355. _getFreeDefineName(prefix: string): string;
  22356. /** @hidden */
  22357. _excludeVariableName(name: string): void;
  22358. /** @hidden */
  22359. _emit2DSampler(name: string): void;
  22360. /** @hidden */
  22361. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22362. /** @hidden */
  22363. _emitExtension(name: string, extension: string, define?: string): void;
  22364. /** @hidden */
  22365. _emitFunction(name: string, code: string, comments: string): void;
  22366. /** @hidden */
  22367. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22368. replaceStrings?: {
  22369. search: RegExp;
  22370. replace: string;
  22371. }[];
  22372. repeatKey?: string;
  22373. }): string;
  22374. /** @hidden */
  22375. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22376. repeatKey?: string;
  22377. removeAttributes?: boolean;
  22378. removeUniforms?: boolean;
  22379. removeVaryings?: boolean;
  22380. removeIfDef?: boolean;
  22381. replaceStrings?: {
  22382. search: RegExp;
  22383. replace: string;
  22384. }[];
  22385. }, storeKey?: string): void;
  22386. /** @hidden */
  22387. _registerTempVariable(name: string): boolean;
  22388. /** @hidden */
  22389. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22390. /** @hidden */
  22391. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22392. /** @hidden */
  22393. _emitFloat(value: number): string;
  22394. }
  22395. }
  22396. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22397. /**
  22398. * Helper class used to generate session unique ID
  22399. */
  22400. export class UniqueIdGenerator {
  22401. private static _UniqueIdCounter;
  22402. /**
  22403. * Gets an unique (relatively to the current scene) Id
  22404. */
  22405. static get UniqueId(): number;
  22406. }
  22407. }
  22408. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22409. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22410. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22411. import { Nullable } from "babylonjs/types";
  22412. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22413. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22414. import { Effect } from "babylonjs/Materials/effect";
  22415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22416. import { Mesh } from "babylonjs/Meshes/mesh";
  22417. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22418. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22419. import { Scene } from "babylonjs/scene";
  22420. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22421. /**
  22422. * Defines a block that can be used inside a node based material
  22423. */
  22424. export class NodeMaterialBlock {
  22425. private _buildId;
  22426. private _buildTarget;
  22427. private _target;
  22428. private _isFinalMerger;
  22429. private _isInput;
  22430. private _name;
  22431. protected _isUnique: boolean;
  22432. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22433. inputsAreExclusive: boolean;
  22434. /** @hidden */
  22435. _codeVariableName: string;
  22436. /** @hidden */
  22437. _inputs: NodeMaterialConnectionPoint[];
  22438. /** @hidden */
  22439. _outputs: NodeMaterialConnectionPoint[];
  22440. /** @hidden */
  22441. _preparationId: number;
  22442. /**
  22443. * Gets the name of the block
  22444. */
  22445. get name(): string;
  22446. /**
  22447. * Sets the name of the block. Will check if the name is valid.
  22448. */
  22449. set name(newName: string);
  22450. /**
  22451. * Gets or sets the unique id of the node
  22452. */
  22453. uniqueId: number;
  22454. /**
  22455. * Gets or sets the comments associated with this block
  22456. */
  22457. comments: string;
  22458. /**
  22459. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22460. */
  22461. get isUnique(): boolean;
  22462. /**
  22463. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22464. */
  22465. get isFinalMerger(): boolean;
  22466. /**
  22467. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22468. */
  22469. get isInput(): boolean;
  22470. /**
  22471. * Gets or sets the build Id
  22472. */
  22473. get buildId(): number;
  22474. set buildId(value: number);
  22475. /**
  22476. * Gets or sets the target of the block
  22477. */
  22478. get target(): NodeMaterialBlockTargets;
  22479. set target(value: NodeMaterialBlockTargets);
  22480. /**
  22481. * Gets the list of input points
  22482. */
  22483. get inputs(): NodeMaterialConnectionPoint[];
  22484. /** Gets the list of output points */
  22485. get outputs(): NodeMaterialConnectionPoint[];
  22486. /**
  22487. * Find an input by its name
  22488. * @param name defines the name of the input to look for
  22489. * @returns the input or null if not found
  22490. */
  22491. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22492. /**
  22493. * Find an output by its name
  22494. * @param name defines the name of the outputto look for
  22495. * @returns the output or null if not found
  22496. */
  22497. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22498. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22499. visibleInInspector: boolean;
  22500. /**
  22501. * Creates a new NodeMaterialBlock
  22502. * @param name defines the block name
  22503. * @param target defines the target of that block (Vertex by default)
  22504. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22505. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22506. */
  22507. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22508. /**
  22509. * Initialize the block and prepare the context for build
  22510. * @param state defines the state that will be used for the build
  22511. */
  22512. initialize(state: NodeMaterialBuildState): void;
  22513. /**
  22514. * Bind data to effect. Will only be called for blocks with isBindable === true
  22515. * @param effect defines the effect to bind data to
  22516. * @param nodeMaterial defines the hosting NodeMaterial
  22517. * @param mesh defines the mesh that will be rendered
  22518. * @param subMesh defines the submesh that will be rendered
  22519. */
  22520. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22521. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22522. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22523. protected _writeFloat(value: number): string;
  22524. /**
  22525. * Gets the current class name e.g. "NodeMaterialBlock"
  22526. * @returns the class name
  22527. */
  22528. getClassName(): string;
  22529. /**
  22530. * Register a new input. Must be called inside a block constructor
  22531. * @param name defines the connection point name
  22532. * @param type defines the connection point type
  22533. * @param isOptional defines a boolean indicating that this input can be omitted
  22534. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22535. * @param point an already created connection point. If not provided, create a new one
  22536. * @returns the current block
  22537. */
  22538. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22539. /**
  22540. * Register a new output. Must be called inside a block constructor
  22541. * @param name defines the connection point name
  22542. * @param type defines the connection point type
  22543. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22544. * @param point an already created connection point. If not provided, create a new one
  22545. * @returns the current block
  22546. */
  22547. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22548. /**
  22549. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22550. * @param forOutput defines an optional connection point to check compatibility with
  22551. * @returns the first available input or null
  22552. */
  22553. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22554. /**
  22555. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22556. * @param forBlock defines an optional block to check compatibility with
  22557. * @returns the first available input or null
  22558. */
  22559. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22560. /**
  22561. * Gets the sibling of the given output
  22562. * @param current defines the current output
  22563. * @returns the next output in the list or null
  22564. */
  22565. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22566. /**
  22567. * Connect current block with another block
  22568. * @param other defines the block to connect with
  22569. * @param options define the various options to help pick the right connections
  22570. * @returns the current block
  22571. */
  22572. connectTo(other: NodeMaterialBlock, options?: {
  22573. input?: string;
  22574. output?: string;
  22575. outputSwizzle?: string;
  22576. }): this | undefined;
  22577. protected _buildBlock(state: NodeMaterialBuildState): void;
  22578. /**
  22579. * Add uniforms, samplers and uniform buffers at compilation time
  22580. * @param state defines the state to update
  22581. * @param nodeMaterial defines the node material requesting the update
  22582. * @param defines defines the material defines to update
  22583. * @param uniformBuffers defines the list of uniform buffer names
  22584. */
  22585. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22586. /**
  22587. * Add potential fallbacks if shader compilation fails
  22588. * @param mesh defines the mesh to be rendered
  22589. * @param fallbacks defines the current prioritized list of fallbacks
  22590. */
  22591. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22592. /**
  22593. * Initialize defines for shader compilation
  22594. * @param mesh defines the mesh to be rendered
  22595. * @param nodeMaterial defines the node material requesting the update
  22596. * @param defines defines the material defines to update
  22597. * @param useInstances specifies that instances should be used
  22598. */
  22599. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22600. /**
  22601. * Update defines for shader compilation
  22602. * @param mesh defines the mesh to be rendered
  22603. * @param nodeMaterial defines the node material requesting the update
  22604. * @param defines defines the material defines to update
  22605. * @param useInstances specifies that instances should be used
  22606. * @param subMesh defines which submesh to render
  22607. */
  22608. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22609. /**
  22610. * Lets the block try to connect some inputs automatically
  22611. * @param material defines the hosting NodeMaterial
  22612. */
  22613. autoConfigure(material: NodeMaterial): void;
  22614. /**
  22615. * Function called when a block is declared as repeatable content generator
  22616. * @param vertexShaderState defines the current compilation state for the vertex shader
  22617. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22618. * @param mesh defines the mesh to be rendered
  22619. * @param defines defines the material defines to update
  22620. */
  22621. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22622. /**
  22623. * Checks if the block is ready
  22624. * @param mesh defines the mesh to be rendered
  22625. * @param nodeMaterial defines the node material requesting the update
  22626. * @param defines defines the material defines to update
  22627. * @param useInstances specifies that instances should be used
  22628. * @returns true if the block is ready
  22629. */
  22630. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22631. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22632. private _processBuild;
  22633. /**
  22634. * Validates the new name for the block node.
  22635. * @param newName the new name to be given to the node.
  22636. * @returns false if the name is a reserve word, else true.
  22637. */
  22638. validateBlockName(newName: string): boolean;
  22639. /**
  22640. * Compile the current node and generate the shader code
  22641. * @param state defines the current compilation state (uniforms, samplers, current string)
  22642. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22643. * @returns true if already built
  22644. */
  22645. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22646. protected _inputRename(name: string): string;
  22647. protected _outputRename(name: string): string;
  22648. protected _dumpPropertiesCode(): string;
  22649. /** @hidden */
  22650. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22651. /** @hidden */
  22652. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22653. /**
  22654. * Clone the current block to a new identical block
  22655. * @param scene defines the hosting scene
  22656. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22657. * @returns a copy of the current block
  22658. */
  22659. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22660. /**
  22661. * Serializes this block in a JSON representation
  22662. * @returns the serialized block object
  22663. */
  22664. serialize(): any;
  22665. /** @hidden */
  22666. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22667. private _deserializePortDisplayNamesAndExposedOnFrame;
  22668. /**
  22669. * Release resources
  22670. */
  22671. dispose(): void;
  22672. }
  22673. }
  22674. declare module "babylonjs/Materials/pushMaterial" {
  22675. import { Nullable } from "babylonjs/types";
  22676. import { Scene } from "babylonjs/scene";
  22677. import { Matrix } from "babylonjs/Maths/math.vector";
  22678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22679. import { Mesh } from "babylonjs/Meshes/mesh";
  22680. import { Material } from "babylonjs/Materials/material";
  22681. import { Effect } from "babylonjs/Materials/effect";
  22682. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22683. /**
  22684. * Base class of materials working in push mode in babylon JS
  22685. * @hidden
  22686. */
  22687. export class PushMaterial extends Material {
  22688. protected _activeEffect: Effect;
  22689. protected _normalMatrix: Matrix;
  22690. constructor(name: string, scene: Scene);
  22691. getEffect(): Effect;
  22692. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22693. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22694. /**
  22695. * Binds the given world matrix to the active effect
  22696. *
  22697. * @param world the matrix to bind
  22698. */
  22699. bindOnlyWorldMatrix(world: Matrix): void;
  22700. /**
  22701. * Binds the given normal matrix to the active effect
  22702. *
  22703. * @param normalMatrix the matrix to bind
  22704. */
  22705. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22706. bind(world: Matrix, mesh?: Mesh): void;
  22707. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22708. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22709. }
  22710. }
  22711. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22713. /**
  22714. * Root class for all node material optimizers
  22715. */
  22716. export class NodeMaterialOptimizer {
  22717. /**
  22718. * Function used to optimize a NodeMaterial graph
  22719. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22720. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22721. */
  22722. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22723. }
  22724. }
  22725. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22726. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22727. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22728. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22729. import { Scene } from "babylonjs/scene";
  22730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22731. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22732. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22733. /**
  22734. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22735. */
  22736. export class TransformBlock extends NodeMaterialBlock {
  22737. /**
  22738. * Defines the value to use to complement W value to transform it to a Vector4
  22739. */
  22740. complementW: number;
  22741. /**
  22742. * Defines the value to use to complement z value to transform it to a Vector4
  22743. */
  22744. complementZ: number;
  22745. /**
  22746. * Creates a new TransformBlock
  22747. * @param name defines the block name
  22748. */
  22749. constructor(name: string);
  22750. /**
  22751. * Gets the current class name
  22752. * @returns the class name
  22753. */
  22754. getClassName(): string;
  22755. /**
  22756. * Gets the vector input
  22757. */
  22758. get vector(): NodeMaterialConnectionPoint;
  22759. /**
  22760. * Gets the output component
  22761. */
  22762. get output(): NodeMaterialConnectionPoint;
  22763. /**
  22764. * Gets the xyz output component
  22765. */
  22766. get xyz(): NodeMaterialConnectionPoint;
  22767. /**
  22768. * Gets the matrix transform input
  22769. */
  22770. get transform(): NodeMaterialConnectionPoint;
  22771. protected _buildBlock(state: NodeMaterialBuildState): this;
  22772. /**
  22773. * Update defines for shader compilation
  22774. * @param mesh defines the mesh to be rendered
  22775. * @param nodeMaterial defines the node material requesting the update
  22776. * @param defines defines the material defines to update
  22777. * @param useInstances specifies that instances should be used
  22778. * @param subMesh defines which submesh to render
  22779. */
  22780. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22781. serialize(): any;
  22782. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22783. protected _dumpPropertiesCode(): string;
  22784. }
  22785. }
  22786. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22787. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22788. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22789. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22790. /**
  22791. * Block used to output the vertex position
  22792. */
  22793. export class VertexOutputBlock extends NodeMaterialBlock {
  22794. /**
  22795. * Creates a new VertexOutputBlock
  22796. * @param name defines the block name
  22797. */
  22798. constructor(name: string);
  22799. /**
  22800. * Gets the current class name
  22801. * @returns the class name
  22802. */
  22803. getClassName(): string;
  22804. /**
  22805. * Gets the vector input component
  22806. */
  22807. get vector(): NodeMaterialConnectionPoint;
  22808. protected _buildBlock(state: NodeMaterialBuildState): this;
  22809. }
  22810. }
  22811. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22812. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22813. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22814. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22815. /**
  22816. * Block used to output the final color
  22817. */
  22818. export class FragmentOutputBlock extends NodeMaterialBlock {
  22819. /**
  22820. * Create a new FragmentOutputBlock
  22821. * @param name defines the block name
  22822. */
  22823. constructor(name: string);
  22824. /**
  22825. * Gets the current class name
  22826. * @returns the class name
  22827. */
  22828. getClassName(): string;
  22829. /**
  22830. * Gets the rgba input component
  22831. */
  22832. get rgba(): NodeMaterialConnectionPoint;
  22833. /**
  22834. * Gets the rgb input component
  22835. */
  22836. get rgb(): NodeMaterialConnectionPoint;
  22837. /**
  22838. * Gets the a input component
  22839. */
  22840. get a(): NodeMaterialConnectionPoint;
  22841. protected _buildBlock(state: NodeMaterialBuildState): this;
  22842. }
  22843. }
  22844. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22845. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22846. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22847. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22848. /**
  22849. * Block used for the particle ramp gradient section
  22850. */
  22851. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22852. /**
  22853. * Create a new ParticleRampGradientBlock
  22854. * @param name defines the block name
  22855. */
  22856. constructor(name: string);
  22857. /**
  22858. * Gets the current class name
  22859. * @returns the class name
  22860. */
  22861. getClassName(): string;
  22862. /**
  22863. * Gets the color input component
  22864. */
  22865. get color(): NodeMaterialConnectionPoint;
  22866. /**
  22867. * Gets the rampColor output component
  22868. */
  22869. get rampColor(): NodeMaterialConnectionPoint;
  22870. /**
  22871. * Initialize the block and prepare the context for build
  22872. * @param state defines the state that will be used for the build
  22873. */
  22874. initialize(state: NodeMaterialBuildState): void;
  22875. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22876. }
  22877. }
  22878. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22879. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22880. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22881. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22882. /**
  22883. * Block used for the particle blend multiply section
  22884. */
  22885. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22886. /**
  22887. * Create a new ParticleBlendMultiplyBlock
  22888. * @param name defines the block name
  22889. */
  22890. constructor(name: string);
  22891. /**
  22892. * Gets the current class name
  22893. * @returns the class name
  22894. */
  22895. getClassName(): string;
  22896. /**
  22897. * Gets the color input component
  22898. */
  22899. get color(): NodeMaterialConnectionPoint;
  22900. /**
  22901. * Gets the alphaTexture input component
  22902. */
  22903. get alphaTexture(): NodeMaterialConnectionPoint;
  22904. /**
  22905. * Gets the alphaColor input component
  22906. */
  22907. get alphaColor(): NodeMaterialConnectionPoint;
  22908. /**
  22909. * Gets the blendColor output component
  22910. */
  22911. get blendColor(): NodeMaterialConnectionPoint;
  22912. /**
  22913. * Initialize the block and prepare the context for build
  22914. * @param state defines the state that will be used for the build
  22915. */
  22916. initialize(state: NodeMaterialBuildState): void;
  22917. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22918. }
  22919. }
  22920. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22924. /**
  22925. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22926. */
  22927. export class VectorMergerBlock extends NodeMaterialBlock {
  22928. /**
  22929. * Create a new VectorMergerBlock
  22930. * @param name defines the block name
  22931. */
  22932. constructor(name: string);
  22933. /**
  22934. * Gets the current class name
  22935. * @returns the class name
  22936. */
  22937. getClassName(): string;
  22938. /**
  22939. * Gets the xyz component (input)
  22940. */
  22941. get xyzIn(): NodeMaterialConnectionPoint;
  22942. /**
  22943. * Gets the xy component (input)
  22944. */
  22945. get xyIn(): NodeMaterialConnectionPoint;
  22946. /**
  22947. * Gets the x component (input)
  22948. */
  22949. get x(): NodeMaterialConnectionPoint;
  22950. /**
  22951. * Gets the y component (input)
  22952. */
  22953. get y(): NodeMaterialConnectionPoint;
  22954. /**
  22955. * Gets the z component (input)
  22956. */
  22957. get z(): NodeMaterialConnectionPoint;
  22958. /**
  22959. * Gets the w component (input)
  22960. */
  22961. get w(): NodeMaterialConnectionPoint;
  22962. /**
  22963. * Gets the xyzw component (output)
  22964. */
  22965. get xyzw(): NodeMaterialConnectionPoint;
  22966. /**
  22967. * Gets the xyz component (output)
  22968. */
  22969. get xyzOut(): NodeMaterialConnectionPoint;
  22970. /**
  22971. * Gets the xy component (output)
  22972. */
  22973. get xyOut(): NodeMaterialConnectionPoint;
  22974. /**
  22975. * Gets the xy component (output)
  22976. * @deprecated Please use xyOut instead.
  22977. */
  22978. get xy(): NodeMaterialConnectionPoint;
  22979. /**
  22980. * Gets the xyz component (output)
  22981. * @deprecated Please use xyzOut instead.
  22982. */
  22983. get xyz(): NodeMaterialConnectionPoint;
  22984. protected _buildBlock(state: NodeMaterialBuildState): this;
  22985. }
  22986. }
  22987. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22988. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22989. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22990. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22991. import { Vector2 } from "babylonjs/Maths/math.vector";
  22992. import { Scene } from "babylonjs/scene";
  22993. /**
  22994. * Block used to remap a float from a range to a new one
  22995. */
  22996. export class RemapBlock extends NodeMaterialBlock {
  22997. /**
  22998. * Gets or sets the source range
  22999. */
  23000. sourceRange: Vector2;
  23001. /**
  23002. * Gets or sets the target range
  23003. */
  23004. targetRange: Vector2;
  23005. /**
  23006. * Creates a new RemapBlock
  23007. * @param name defines the block name
  23008. */
  23009. constructor(name: string);
  23010. /**
  23011. * Gets the current class name
  23012. * @returns the class name
  23013. */
  23014. getClassName(): string;
  23015. /**
  23016. * Gets the input component
  23017. */
  23018. get input(): NodeMaterialConnectionPoint;
  23019. /**
  23020. * Gets the source min input component
  23021. */
  23022. get sourceMin(): NodeMaterialConnectionPoint;
  23023. /**
  23024. * Gets the source max input component
  23025. */
  23026. get sourceMax(): NodeMaterialConnectionPoint;
  23027. /**
  23028. * Gets the target min input component
  23029. */
  23030. get targetMin(): NodeMaterialConnectionPoint;
  23031. /**
  23032. * Gets the target max input component
  23033. */
  23034. get targetMax(): NodeMaterialConnectionPoint;
  23035. /**
  23036. * Gets the output component
  23037. */
  23038. get output(): NodeMaterialConnectionPoint;
  23039. protected _buildBlock(state: NodeMaterialBuildState): this;
  23040. protected _dumpPropertiesCode(): string;
  23041. serialize(): any;
  23042. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23043. }
  23044. }
  23045. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  23046. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23047. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23048. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23049. /**
  23050. * Block used to multiply 2 values
  23051. */
  23052. export class MultiplyBlock extends NodeMaterialBlock {
  23053. /**
  23054. * Creates a new MultiplyBlock
  23055. * @param name defines the block name
  23056. */
  23057. constructor(name: string);
  23058. /**
  23059. * Gets the current class name
  23060. * @returns the class name
  23061. */
  23062. getClassName(): string;
  23063. /**
  23064. * Gets the left operand input component
  23065. */
  23066. get left(): NodeMaterialConnectionPoint;
  23067. /**
  23068. * Gets the right operand input component
  23069. */
  23070. get right(): NodeMaterialConnectionPoint;
  23071. /**
  23072. * Gets the output component
  23073. */
  23074. get output(): NodeMaterialConnectionPoint;
  23075. protected _buildBlock(state: NodeMaterialBuildState): this;
  23076. }
  23077. }
  23078. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  23079. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23080. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23081. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23082. /**
  23083. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23084. */
  23085. export class ColorSplitterBlock extends NodeMaterialBlock {
  23086. /**
  23087. * Create a new ColorSplitterBlock
  23088. * @param name defines the block name
  23089. */
  23090. constructor(name: string);
  23091. /**
  23092. * Gets the current class name
  23093. * @returns the class name
  23094. */
  23095. getClassName(): string;
  23096. /**
  23097. * Gets the rgba component (input)
  23098. */
  23099. get rgba(): NodeMaterialConnectionPoint;
  23100. /**
  23101. * Gets the rgb component (input)
  23102. */
  23103. get rgbIn(): NodeMaterialConnectionPoint;
  23104. /**
  23105. * Gets the rgb component (output)
  23106. */
  23107. get rgbOut(): NodeMaterialConnectionPoint;
  23108. /**
  23109. * Gets the r component (output)
  23110. */
  23111. get r(): NodeMaterialConnectionPoint;
  23112. /**
  23113. * Gets the g component (output)
  23114. */
  23115. get g(): NodeMaterialConnectionPoint;
  23116. /**
  23117. * Gets the b component (output)
  23118. */
  23119. get b(): NodeMaterialConnectionPoint;
  23120. /**
  23121. * Gets the a component (output)
  23122. */
  23123. get a(): NodeMaterialConnectionPoint;
  23124. protected _inputRename(name: string): string;
  23125. protected _outputRename(name: string): string;
  23126. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23127. }
  23128. }
  23129. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23130. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23131. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23132. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23133. import { Scene } from "babylonjs/scene";
  23134. /**
  23135. * Operations supported by the Trigonometry block
  23136. */
  23137. export enum TrigonometryBlockOperations {
  23138. /** Cos */
  23139. Cos = 0,
  23140. /** Sin */
  23141. Sin = 1,
  23142. /** Abs */
  23143. Abs = 2,
  23144. /** Exp */
  23145. Exp = 3,
  23146. /** Exp2 */
  23147. Exp2 = 4,
  23148. /** Round */
  23149. Round = 5,
  23150. /** Floor */
  23151. Floor = 6,
  23152. /** Ceiling */
  23153. Ceiling = 7,
  23154. /** Square root */
  23155. Sqrt = 8,
  23156. /** Log */
  23157. Log = 9,
  23158. /** Tangent */
  23159. Tan = 10,
  23160. /** Arc tangent */
  23161. ArcTan = 11,
  23162. /** Arc cosinus */
  23163. ArcCos = 12,
  23164. /** Arc sinus */
  23165. ArcSin = 13,
  23166. /** Fraction */
  23167. Fract = 14,
  23168. /** Sign */
  23169. Sign = 15,
  23170. /** To radians (from degrees) */
  23171. Radians = 16,
  23172. /** To degrees (from radians) */
  23173. Degrees = 17
  23174. }
  23175. /**
  23176. * Block used to apply trigonometry operation to floats
  23177. */
  23178. export class TrigonometryBlock extends NodeMaterialBlock {
  23179. /**
  23180. * Gets or sets the operation applied by the block
  23181. */
  23182. operation: TrigonometryBlockOperations;
  23183. /**
  23184. * Creates a new TrigonometryBlock
  23185. * @param name defines the block name
  23186. */
  23187. constructor(name: string);
  23188. /**
  23189. * Gets the current class name
  23190. * @returns the class name
  23191. */
  23192. getClassName(): string;
  23193. /**
  23194. * Gets the input component
  23195. */
  23196. get input(): NodeMaterialConnectionPoint;
  23197. /**
  23198. * Gets the output component
  23199. */
  23200. get output(): NodeMaterialConnectionPoint;
  23201. protected _buildBlock(state: NodeMaterialBuildState): this;
  23202. serialize(): any;
  23203. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23204. protected _dumpPropertiesCode(): string;
  23205. }
  23206. }
  23207. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23208. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23209. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23210. import { Scene } from "babylonjs/scene";
  23211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23212. import { Matrix } from "babylonjs/Maths/math.vector";
  23213. import { Mesh } from "babylonjs/Meshes/mesh";
  23214. import { Engine } from "babylonjs/Engines/engine";
  23215. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23216. import { Observable } from "babylonjs/Misc/observable";
  23217. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23218. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23219. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23220. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23221. import { Nullable } from "babylonjs/types";
  23222. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23223. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23224. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23225. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23226. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23227. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23228. import { Effect } from "babylonjs/Materials/effect";
  23229. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23230. import { Camera } from "babylonjs/Cameras/camera";
  23231. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23232. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23233. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23234. /**
  23235. * Interface used to configure the node material editor
  23236. */
  23237. export interface INodeMaterialEditorOptions {
  23238. /** Define the URl to load node editor script */
  23239. editorURL?: string;
  23240. }
  23241. /** @hidden */
  23242. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23243. NORMAL: boolean;
  23244. TANGENT: boolean;
  23245. UV1: boolean;
  23246. /** BONES */
  23247. NUM_BONE_INFLUENCERS: number;
  23248. BonesPerMesh: number;
  23249. BONETEXTURE: boolean;
  23250. /** MORPH TARGETS */
  23251. MORPHTARGETS: boolean;
  23252. MORPHTARGETS_NORMAL: boolean;
  23253. MORPHTARGETS_TANGENT: boolean;
  23254. MORPHTARGETS_UV: boolean;
  23255. NUM_MORPH_INFLUENCERS: number;
  23256. /** IMAGE PROCESSING */
  23257. IMAGEPROCESSING: boolean;
  23258. VIGNETTE: boolean;
  23259. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23260. VIGNETTEBLENDMODEOPAQUE: boolean;
  23261. TONEMAPPING: boolean;
  23262. TONEMAPPING_ACES: boolean;
  23263. CONTRAST: boolean;
  23264. EXPOSURE: boolean;
  23265. COLORCURVES: boolean;
  23266. COLORGRADING: boolean;
  23267. COLORGRADING3D: boolean;
  23268. SAMPLER3DGREENDEPTH: boolean;
  23269. SAMPLER3DBGRMAP: boolean;
  23270. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23271. /** MISC. */
  23272. BUMPDIRECTUV: number;
  23273. constructor();
  23274. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23275. }
  23276. /**
  23277. * Class used to configure NodeMaterial
  23278. */
  23279. export interface INodeMaterialOptions {
  23280. /**
  23281. * Defines if blocks should emit comments
  23282. */
  23283. emitComments: boolean;
  23284. }
  23285. /**
  23286. * Class used to create a node based material built by assembling shader blocks
  23287. */
  23288. export class NodeMaterial extends PushMaterial {
  23289. private static _BuildIdGenerator;
  23290. private _options;
  23291. private _vertexCompilationState;
  23292. private _fragmentCompilationState;
  23293. private _sharedData;
  23294. private _buildId;
  23295. private _buildWasSuccessful;
  23296. private _cachedWorldViewMatrix;
  23297. private _cachedWorldViewProjectionMatrix;
  23298. private _optimizers;
  23299. private _animationFrame;
  23300. /** Define the Url to load node editor script */
  23301. static EditorURL: string;
  23302. /** Define the Url to load snippets */
  23303. static SnippetUrl: string;
  23304. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23305. static IgnoreTexturesAtLoadTime: boolean;
  23306. private BJSNODEMATERIALEDITOR;
  23307. /** Get the inspector from bundle or global */
  23308. private _getGlobalNodeMaterialEditor;
  23309. /**
  23310. * Snippet ID if the material was created from the snippet server
  23311. */
  23312. snippetId: string;
  23313. /**
  23314. * Gets or sets data used by visual editor
  23315. * @see https://nme.babylonjs.com
  23316. */
  23317. editorData: any;
  23318. /**
  23319. * 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)
  23320. */
  23321. ignoreAlpha: boolean;
  23322. /**
  23323. * Defines the maximum number of lights that can be used in the material
  23324. */
  23325. maxSimultaneousLights: number;
  23326. /**
  23327. * Observable raised when the material is built
  23328. */
  23329. onBuildObservable: Observable<NodeMaterial>;
  23330. /**
  23331. * Gets or sets the root nodes of the material vertex shader
  23332. */
  23333. _vertexOutputNodes: NodeMaterialBlock[];
  23334. /**
  23335. * Gets or sets the root nodes of the material fragment (pixel) shader
  23336. */
  23337. _fragmentOutputNodes: NodeMaterialBlock[];
  23338. /** Gets or sets options to control the node material overall behavior */
  23339. get options(): INodeMaterialOptions;
  23340. set options(options: INodeMaterialOptions);
  23341. /**
  23342. * Default configuration related to image processing available in the standard Material.
  23343. */
  23344. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23345. /**
  23346. * Gets the image processing configuration used either in this material.
  23347. */
  23348. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23349. /**
  23350. * Sets the Default image processing configuration used either in the this material.
  23351. *
  23352. * If sets to null, the scene one is in use.
  23353. */
  23354. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23355. /**
  23356. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23357. */
  23358. attachedBlocks: NodeMaterialBlock[];
  23359. /**
  23360. * Specifies the mode of the node material
  23361. * @hidden
  23362. */
  23363. _mode: NodeMaterialModes;
  23364. /**
  23365. * Gets the mode property
  23366. */
  23367. get mode(): NodeMaterialModes;
  23368. /**
  23369. * Create a new node based material
  23370. * @param name defines the material name
  23371. * @param scene defines the hosting scene
  23372. * @param options defines creation option
  23373. */
  23374. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23375. /**
  23376. * Gets the current class name of the material e.g. "NodeMaterial"
  23377. * @returns the class name
  23378. */
  23379. getClassName(): string;
  23380. /**
  23381. * Keep track of the image processing observer to allow dispose and replace.
  23382. */
  23383. private _imageProcessingObserver;
  23384. /**
  23385. * Attaches a new image processing configuration to the Standard Material.
  23386. * @param configuration
  23387. */
  23388. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23389. /**
  23390. * Get a block by its name
  23391. * @param name defines the name of the block to retrieve
  23392. * @returns the required block or null if not found
  23393. */
  23394. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23395. /**
  23396. * Get a block by its name
  23397. * @param predicate defines the predicate used to find the good candidate
  23398. * @returns the required block or null if not found
  23399. */
  23400. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23401. /**
  23402. * Get an input block by its name
  23403. * @param predicate defines the predicate used to find the good candidate
  23404. * @returns the required input block or null if not found
  23405. */
  23406. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23407. /**
  23408. * Gets the list of input blocks attached to this material
  23409. * @returns an array of InputBlocks
  23410. */
  23411. getInputBlocks(): InputBlock[];
  23412. /**
  23413. * Adds a new optimizer to the list of optimizers
  23414. * @param optimizer defines the optimizers to add
  23415. * @returns the current material
  23416. */
  23417. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23418. /**
  23419. * Remove an optimizer from the list of optimizers
  23420. * @param optimizer defines the optimizers to remove
  23421. * @returns the current material
  23422. */
  23423. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23424. /**
  23425. * Add a new block to the list of output nodes
  23426. * @param node defines the node to add
  23427. * @returns the current material
  23428. */
  23429. addOutputNode(node: NodeMaterialBlock): this;
  23430. /**
  23431. * Remove a block from the list of root nodes
  23432. * @param node defines the node to remove
  23433. * @returns the current material
  23434. */
  23435. removeOutputNode(node: NodeMaterialBlock): this;
  23436. private _addVertexOutputNode;
  23437. private _removeVertexOutputNode;
  23438. private _addFragmentOutputNode;
  23439. private _removeFragmentOutputNode;
  23440. /**
  23441. * Specifies if the material will require alpha blending
  23442. * @returns a boolean specifying if alpha blending is needed
  23443. */
  23444. needAlphaBlending(): boolean;
  23445. /**
  23446. * Specifies if this material should be rendered in alpha test mode
  23447. * @returns a boolean specifying if an alpha test is needed.
  23448. */
  23449. needAlphaTesting(): boolean;
  23450. private _initializeBlock;
  23451. private _resetDualBlocks;
  23452. /**
  23453. * Remove a block from the current node material
  23454. * @param block defines the block to remove
  23455. */
  23456. removeBlock(block: NodeMaterialBlock): void;
  23457. /**
  23458. * Build the material and generates the inner effect
  23459. * @param verbose defines if the build should log activity
  23460. */
  23461. build(verbose?: boolean): void;
  23462. /**
  23463. * Runs an otpimization phase to try to improve the shader code
  23464. */
  23465. optimize(): void;
  23466. private _prepareDefinesForAttributes;
  23467. /**
  23468. * Create a post process from the material
  23469. * @param camera The camera to apply the render pass to.
  23470. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23472. * @param engine The engine which the post process will be applied. (default: current engine)
  23473. * @param reusable If the post process can be reused on the same frame. (default: false)
  23474. * @param textureType Type of textures used when performing the post process. (default: 0)
  23475. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23476. * @returns the post process created
  23477. */
  23478. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23479. /**
  23480. * Create the post process effect from the material
  23481. * @param postProcess The post process to create the effect for
  23482. */
  23483. createEffectForPostProcess(postProcess: PostProcess): void;
  23484. private _createEffectForPostProcess;
  23485. /**
  23486. * Create a new procedural texture based on this node material
  23487. * @param size defines the size of the texture
  23488. * @param scene defines the hosting scene
  23489. * @returns the new procedural texture attached to this node material
  23490. */
  23491. createProceduralTexture(size: number | {
  23492. width: number;
  23493. height: number;
  23494. layers?: number;
  23495. }, scene: Scene): Nullable<ProceduralTexture>;
  23496. private _createEffectForParticles;
  23497. private _checkInternals;
  23498. /**
  23499. * Create the effect to be used as the custom effect for a particle system
  23500. * @param particleSystem Particle system to create the effect for
  23501. * @param onCompiled defines a function to call when the effect creation is successful
  23502. * @param onError defines a function to call when the effect creation has failed
  23503. */
  23504. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23505. private _processDefines;
  23506. /**
  23507. * Get if the submesh is ready to be used and all its information available.
  23508. * Child classes can use it to update shaders
  23509. * @param mesh defines the mesh to check
  23510. * @param subMesh defines which submesh to check
  23511. * @param useInstances specifies that instances should be used
  23512. * @returns a boolean indicating that the submesh is ready or not
  23513. */
  23514. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23515. /**
  23516. * Get a string representing the shaders built by the current node graph
  23517. */
  23518. get compiledShaders(): string;
  23519. /**
  23520. * Binds the world matrix to the material
  23521. * @param world defines the world transformation matrix
  23522. */
  23523. bindOnlyWorldMatrix(world: Matrix): void;
  23524. /**
  23525. * Binds the submesh to this material by preparing the effect and shader to draw
  23526. * @param world defines the world transformation matrix
  23527. * @param mesh defines the mesh containing the submesh
  23528. * @param subMesh defines the submesh to bind the material to
  23529. */
  23530. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23531. /**
  23532. * Gets the active textures from the material
  23533. * @returns an array of textures
  23534. */
  23535. getActiveTextures(): BaseTexture[];
  23536. /**
  23537. * Gets the list of texture blocks
  23538. * @returns an array of texture blocks
  23539. */
  23540. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23541. /**
  23542. * Specifies if the material uses a texture
  23543. * @param texture defines the texture to check against the material
  23544. * @returns a boolean specifying if the material uses the texture
  23545. */
  23546. hasTexture(texture: BaseTexture): boolean;
  23547. /**
  23548. * Disposes the material
  23549. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23550. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23551. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23552. */
  23553. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23554. /** Creates the node editor window. */
  23555. private _createNodeEditor;
  23556. /**
  23557. * Launch the node material editor
  23558. * @param config Define the configuration of the editor
  23559. * @return a promise fulfilled when the node editor is visible
  23560. */
  23561. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23562. /**
  23563. * Clear the current material
  23564. */
  23565. clear(): void;
  23566. /**
  23567. * Clear the current material and set it to a default state
  23568. */
  23569. setToDefault(): void;
  23570. /**
  23571. * Clear the current material and set it to a default state for post process
  23572. */
  23573. setToDefaultPostProcess(): void;
  23574. /**
  23575. * Clear the current material and set it to a default state for procedural texture
  23576. */
  23577. setToDefaultProceduralTexture(): void;
  23578. /**
  23579. * Clear the current material and set it to a default state for particle
  23580. */
  23581. setToDefaultParticle(): void;
  23582. /**
  23583. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23584. * @param url defines the url to load from
  23585. * @returns a promise that will fullfil when the material is fully loaded
  23586. */
  23587. loadAsync(url: string): Promise<void>;
  23588. private _gatherBlocks;
  23589. /**
  23590. * Generate a string containing the code declaration required to create an equivalent of this material
  23591. * @returns a string
  23592. */
  23593. generateCode(): string;
  23594. /**
  23595. * Serializes this material in a JSON representation
  23596. * @returns the serialized material object
  23597. */
  23598. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23599. private _restoreConnections;
  23600. /**
  23601. * Clear the current graph and load a new one from a serialization object
  23602. * @param source defines the JSON representation of the material
  23603. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23604. * @param merge defines whether or not the source must be merged or replace the current content
  23605. */
  23606. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23607. /**
  23608. * Makes a duplicate of the current material.
  23609. * @param name - name to use for the new material.
  23610. */
  23611. clone(name: string): NodeMaterial;
  23612. /**
  23613. * Creates a node material from parsed material data
  23614. * @param source defines the JSON representation of the material
  23615. * @param scene defines the hosting scene
  23616. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23617. * @returns a new node material
  23618. */
  23619. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23620. /**
  23621. * Creates a node material from a snippet saved in a remote file
  23622. * @param name defines the name of the material to create
  23623. * @param url defines the url to load from
  23624. * @param scene defines the hosting scene
  23625. * @returns a promise that will resolve to the new node material
  23626. */
  23627. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23628. /**
  23629. * Creates a node material from a snippet saved by the node material editor
  23630. * @param snippetId defines the snippet to load
  23631. * @param scene defines the hosting scene
  23632. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23633. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23634. * @returns a promise that will resolve to the new node material
  23635. */
  23636. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23637. /**
  23638. * Creates a new node material set to default basic configuration
  23639. * @param name defines the name of the material
  23640. * @param scene defines the hosting scene
  23641. * @returns a new NodeMaterial
  23642. */
  23643. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23644. }
  23645. }
  23646. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  23647. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23648. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  23649. import { Nullable } from "babylonjs/types";
  23650. module "babylonjs/Engines/thinEngine" {
  23651. interface ThinEngine {
  23652. /**
  23653. * Unbind a list of render target textures from the webGL context
  23654. * This is used only when drawBuffer extension or webGL2 are active
  23655. * @param textures defines the render target textures to unbind
  23656. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23657. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23658. */
  23659. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23660. /**
  23661. * Create a multi render target texture
  23662. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23663. * @param size defines the size of the texture
  23664. * @param options defines the creation options
  23665. * @returns the cube texture as an InternalTexture
  23666. */
  23667. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23668. /**
  23669. * Update the sample count for a given multiple render target texture
  23670. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23671. * @param textures defines the textures to update
  23672. * @param samples defines the sample count to set
  23673. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23674. */
  23675. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23676. /**
  23677. * Select a subsets of attachments to draw to.
  23678. * @param attachments gl attachments
  23679. */
  23680. bindAttachments(attachments: number[]): void;
  23681. /**
  23682. * Creates a layout object to draw/clear on specific textures in a MRT
  23683. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23684. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23685. */
  23686. buildTextureLayout(textureStatus: boolean[]): number[];
  23687. /**
  23688. * Restores the webgl state to only draw on the main color attachment
  23689. */
  23690. restoreSingleAttachment(): void;
  23691. }
  23692. }
  23693. }
  23694. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  23695. import { Scene } from "babylonjs/scene";
  23696. import { Engine } from "babylonjs/Engines/engine";
  23697. import { Texture } from "babylonjs/Materials/Textures/texture";
  23698. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23699. import "babylonjs/Engines/Extensions/engine.multiRender";
  23700. /**
  23701. * Creation options of the multi render target texture.
  23702. */
  23703. export interface IMultiRenderTargetOptions {
  23704. /**
  23705. * Define if the texture needs to create mip maps after render.
  23706. */
  23707. generateMipMaps?: boolean;
  23708. /**
  23709. * Define the types of all the draw buffers we want to create
  23710. */
  23711. types?: number[];
  23712. /**
  23713. * Define the sampling modes of all the draw buffers we want to create
  23714. */
  23715. samplingModes?: number[];
  23716. /**
  23717. * Define if a depth buffer is required
  23718. */
  23719. generateDepthBuffer?: boolean;
  23720. /**
  23721. * Define if a stencil buffer is required
  23722. */
  23723. generateStencilBuffer?: boolean;
  23724. /**
  23725. * Define if a depth texture is required instead of a depth buffer
  23726. */
  23727. generateDepthTexture?: boolean;
  23728. /**
  23729. * Define the number of desired draw buffers
  23730. */
  23731. textureCount?: number;
  23732. /**
  23733. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23734. */
  23735. doNotChangeAspectRatio?: boolean;
  23736. /**
  23737. * Define the default type of the buffers we are creating
  23738. */
  23739. defaultType?: number;
  23740. }
  23741. /**
  23742. * A multi render target, like a render target provides the ability to render to a texture.
  23743. * Unlike the render target, it can render to several draw buffers in one draw.
  23744. * This is specially interesting in deferred rendering or for any effects requiring more than
  23745. * just one color from a single pass.
  23746. */
  23747. export class MultiRenderTarget extends RenderTargetTexture {
  23748. private _internalTextures;
  23749. private _textures;
  23750. private _multiRenderTargetOptions;
  23751. private _count;
  23752. /**
  23753. * Get if draw buffers are currently supported by the used hardware and browser.
  23754. */
  23755. get isSupported(): boolean;
  23756. /**
  23757. * Get the list of textures generated by the multi render target.
  23758. */
  23759. get textures(): Texture[];
  23760. /**
  23761. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23762. */
  23763. get count(): number;
  23764. /**
  23765. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23766. */
  23767. get depthTexture(): Texture;
  23768. /**
  23769. * Set the wrapping mode on U 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 wrapU(wrap: number);
  23773. /**
  23774. * Set the wrapping mode on V of all the textures we are rendering to.
  23775. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23776. */
  23777. set wrapV(wrap: number);
  23778. /**
  23779. * Instantiate a new multi render target texture.
  23780. * A multi render target, like a render target provides the ability to render to a texture.
  23781. * Unlike the render target, it can render to several draw buffers in one draw.
  23782. * This is specially interesting in deferred rendering or for any effects requiring more than
  23783. * just one color from a single pass.
  23784. * @param name Define the name of the texture
  23785. * @param size Define the size of the buffers to render to
  23786. * @param count Define the number of target we are rendering into
  23787. * @param scene Define the scene the texture belongs to
  23788. * @param options Define the options used to create the multi render target
  23789. */
  23790. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23791. private _initTypes;
  23792. /** @hidden */
  23793. _rebuild(forceFullRebuild?: boolean): void;
  23794. private _createInternalTextures;
  23795. private _createTextures;
  23796. /**
  23797. * Replaces a texture within the MRT.
  23798. * @param texture The new texture to insert in the MRT
  23799. * @param index The index of the texture to replace
  23800. */
  23801. replaceTexture(texture: Texture, index: number): void;
  23802. /**
  23803. * Define the number of samples used if MSAA is enabled.
  23804. */
  23805. get samples(): number;
  23806. set samples(value: number);
  23807. /**
  23808. * Resize all the textures in the multi render target.
  23809. * Be careful as it will recreate all the data in the new texture.
  23810. * @param size Define the new size
  23811. */
  23812. resize(size: any): void;
  23813. /**
  23814. * Changes the number of render targets in this MRT
  23815. * Be careful as it will recreate all the data in the new texture.
  23816. * @param count new texture count
  23817. * @param options Specifies texture types and sampling modes for new textures
  23818. */
  23819. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23820. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23821. /**
  23822. * Dispose the render targets and their associated resources
  23823. */
  23824. dispose(): void;
  23825. /**
  23826. * Release all the underlying texture used as draw buffers.
  23827. */
  23828. releaseInternalTextures(): void;
  23829. }
  23830. }
  23831. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  23832. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  23833. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  23834. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  23835. /** @hidden */
  23836. export var imageProcessingPixelShader: {
  23837. name: string;
  23838. shader: string;
  23839. };
  23840. }
  23841. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  23842. import { Nullable } from "babylonjs/types";
  23843. import { Color4 } from "babylonjs/Maths/math.color";
  23844. import { Camera } from "babylonjs/Cameras/camera";
  23845. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23846. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  23847. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  23848. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23849. import { Engine } from "babylonjs/Engines/engine";
  23850. import "babylonjs/Shaders/imageProcessing.fragment";
  23851. import "babylonjs/Shaders/postprocess.vertex";
  23852. /**
  23853. * ImageProcessingPostProcess
  23854. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23855. */
  23856. export class ImageProcessingPostProcess extends PostProcess {
  23857. /**
  23858. * Default configuration related to image processing available in the PBR Material.
  23859. */
  23860. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23861. /**
  23862. * Gets the image processing configuration used either in this material.
  23863. */
  23864. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23865. /**
  23866. * Sets the Default image processing configuration used either in the this material.
  23867. *
  23868. * If sets to null, the scene one is in use.
  23869. */
  23870. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23871. /**
  23872. * Keep track of the image processing observer to allow dispose and replace.
  23873. */
  23874. private _imageProcessingObserver;
  23875. /**
  23876. * Attaches a new image processing configuration to the PBR Material.
  23877. * @param configuration
  23878. */
  23879. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23880. /**
  23881. * If the post process is supported.
  23882. */
  23883. get isSupported(): boolean;
  23884. /**
  23885. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23886. */
  23887. get colorCurves(): Nullable<ColorCurves>;
  23888. /**
  23889. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23890. */
  23891. set colorCurves(value: Nullable<ColorCurves>);
  23892. /**
  23893. * Gets wether the color curves effect is enabled.
  23894. */
  23895. get colorCurvesEnabled(): boolean;
  23896. /**
  23897. * Sets wether the color curves effect is enabled.
  23898. */
  23899. set colorCurvesEnabled(value: boolean);
  23900. /**
  23901. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23902. */
  23903. get colorGradingTexture(): Nullable<BaseTexture>;
  23904. /**
  23905. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23906. */
  23907. set colorGradingTexture(value: Nullable<BaseTexture>);
  23908. /**
  23909. * Gets wether the color grading effect is enabled.
  23910. */
  23911. get colorGradingEnabled(): boolean;
  23912. /**
  23913. * Gets wether the color grading effect is enabled.
  23914. */
  23915. set colorGradingEnabled(value: boolean);
  23916. /**
  23917. * Gets exposure used in the effect.
  23918. */
  23919. get exposure(): number;
  23920. /**
  23921. * Sets exposure used in the effect.
  23922. */
  23923. set exposure(value: number);
  23924. /**
  23925. * Gets wether tonemapping is enabled or not.
  23926. */
  23927. get toneMappingEnabled(): boolean;
  23928. /**
  23929. * Sets wether tonemapping is enabled or not
  23930. */
  23931. set toneMappingEnabled(value: boolean);
  23932. /**
  23933. * Gets the type of tone mapping effect.
  23934. */
  23935. get toneMappingType(): number;
  23936. /**
  23937. * Sets the type of tone mapping effect.
  23938. */
  23939. set toneMappingType(value: number);
  23940. /**
  23941. * Gets contrast used in the effect.
  23942. */
  23943. get contrast(): number;
  23944. /**
  23945. * Sets contrast used in the effect.
  23946. */
  23947. set contrast(value: number);
  23948. /**
  23949. * Gets Vignette stretch size.
  23950. */
  23951. get vignetteStretch(): number;
  23952. /**
  23953. * Sets Vignette stretch size.
  23954. */
  23955. set vignetteStretch(value: number);
  23956. /**
  23957. * Gets Vignette centre X Offset.
  23958. */
  23959. get vignetteCentreX(): number;
  23960. /**
  23961. * Sets Vignette centre X Offset.
  23962. */
  23963. set vignetteCentreX(value: number);
  23964. /**
  23965. * Gets Vignette centre Y Offset.
  23966. */
  23967. get vignetteCentreY(): number;
  23968. /**
  23969. * Sets Vignette centre Y Offset.
  23970. */
  23971. set vignetteCentreY(value: number);
  23972. /**
  23973. * Gets Vignette weight or intensity of the vignette effect.
  23974. */
  23975. get vignetteWeight(): number;
  23976. /**
  23977. * Sets Vignette weight or intensity of the vignette effect.
  23978. */
  23979. set vignetteWeight(value: number);
  23980. /**
  23981. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23982. * if vignetteEnabled is set to true.
  23983. */
  23984. get vignetteColor(): Color4;
  23985. /**
  23986. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23987. * if vignetteEnabled is set to true.
  23988. */
  23989. set vignetteColor(value: Color4);
  23990. /**
  23991. * Gets Camera field of view used by the Vignette effect.
  23992. */
  23993. get vignetteCameraFov(): number;
  23994. /**
  23995. * Sets Camera field of view used by the Vignette effect.
  23996. */
  23997. set vignetteCameraFov(value: number);
  23998. /**
  23999. * Gets the vignette blend mode allowing different kind of effect.
  24000. */
  24001. get vignetteBlendMode(): number;
  24002. /**
  24003. * Sets the vignette blend mode allowing different kind of effect.
  24004. */
  24005. set vignetteBlendMode(value: number);
  24006. /**
  24007. * Gets wether the vignette effect is enabled.
  24008. */
  24009. get vignetteEnabled(): boolean;
  24010. /**
  24011. * Sets wether the vignette effect is enabled.
  24012. */
  24013. set vignetteEnabled(value: boolean);
  24014. private _fromLinearSpace;
  24015. /**
  24016. * Gets wether the input of the processing is in Gamma or Linear Space.
  24017. */
  24018. get fromLinearSpace(): boolean;
  24019. /**
  24020. * Sets wether the input of the processing is in Gamma or Linear Space.
  24021. */
  24022. set fromLinearSpace(value: boolean);
  24023. /**
  24024. * Defines cache preventing GC.
  24025. */
  24026. private _defines;
  24027. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24028. /**
  24029. * "ImageProcessingPostProcess"
  24030. * @returns "ImageProcessingPostProcess"
  24031. */
  24032. getClassName(): string;
  24033. /**
  24034. * @hidden
  24035. */
  24036. _updateParameters(): void;
  24037. dispose(camera?: Camera): void;
  24038. }
  24039. }
  24040. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24041. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24042. /**
  24043. * Interface for defining prepass effects in the prepass post-process pipeline
  24044. */
  24045. export interface PrePassEffectConfiguration {
  24046. /**
  24047. * Name of the effect
  24048. */
  24049. name: string;
  24050. /**
  24051. * Post process to attach for this effect
  24052. */
  24053. postProcess?: PostProcess;
  24054. /**
  24055. * Textures required in the MRT
  24056. */
  24057. texturesRequired: number[];
  24058. /**
  24059. * Is the effect enabled
  24060. */
  24061. enabled: boolean;
  24062. /**
  24063. * Disposes the effect configuration
  24064. */
  24065. dispose?: () => void;
  24066. /**
  24067. * Creates the associated post process
  24068. */
  24069. createPostProcess?: () => PostProcess;
  24070. }
  24071. }
  24072. declare module "babylonjs/Materials/fresnelParameters" {
  24073. import { DeepImmutable } from "babylonjs/types";
  24074. import { Color3 } from "babylonjs/Maths/math.color";
  24075. /**
  24076. * Options to be used when creating a FresnelParameters.
  24077. */
  24078. export type IFresnelParametersCreationOptions = {
  24079. /**
  24080. * Define the color used on edges (grazing angle)
  24081. */
  24082. leftColor?: Color3;
  24083. /**
  24084. * Define the color used on center
  24085. */
  24086. rightColor?: Color3;
  24087. /**
  24088. * Define bias applied to computed fresnel term
  24089. */
  24090. bias?: number;
  24091. /**
  24092. * Defined the power exponent applied to fresnel term
  24093. */
  24094. power?: number;
  24095. /**
  24096. * Define if the fresnel effect is enable or not.
  24097. */
  24098. isEnabled?: boolean;
  24099. };
  24100. /**
  24101. * Serialized format for FresnelParameters.
  24102. */
  24103. export type IFresnelParametersSerialized = {
  24104. /**
  24105. * Define the color used on edges (grazing angle) [as an array]
  24106. */
  24107. leftColor: number[];
  24108. /**
  24109. * Define the color used on center [as an array]
  24110. */
  24111. rightColor: number[];
  24112. /**
  24113. * Define bias applied to computed fresnel term
  24114. */
  24115. bias: number;
  24116. /**
  24117. * Defined the power exponent applied to fresnel term
  24118. */
  24119. power?: number;
  24120. /**
  24121. * Define if the fresnel effect is enable or not.
  24122. */
  24123. isEnabled: boolean;
  24124. };
  24125. /**
  24126. * This represents all the required information to add a fresnel effect on a material:
  24127. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24128. */
  24129. export class FresnelParameters {
  24130. private _isEnabled;
  24131. /**
  24132. * Define if the fresnel effect is enable or not.
  24133. */
  24134. get isEnabled(): boolean;
  24135. set isEnabled(value: boolean);
  24136. /**
  24137. * Define the color used on edges (grazing angle)
  24138. */
  24139. leftColor: Color3;
  24140. /**
  24141. * Define the color used on center
  24142. */
  24143. rightColor: Color3;
  24144. /**
  24145. * Define bias applied to computed fresnel term
  24146. */
  24147. bias: number;
  24148. /**
  24149. * Defined the power exponent applied to fresnel term
  24150. */
  24151. power: number;
  24152. /**
  24153. * Creates a new FresnelParameters object.
  24154. *
  24155. * @param options provide your own settings to optionally to override defaults
  24156. */
  24157. constructor(options?: IFresnelParametersCreationOptions);
  24158. /**
  24159. * Clones the current fresnel and its valuues
  24160. * @returns a clone fresnel configuration
  24161. */
  24162. clone(): FresnelParameters;
  24163. /**
  24164. * Determines equality between FresnelParameters objects
  24165. * @param otherFresnelParameters defines the second operand
  24166. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  24167. */
  24168. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  24169. /**
  24170. * Serializes the current fresnel parameters to a JSON representation.
  24171. * @return the JSON serialization
  24172. */
  24173. serialize(): IFresnelParametersSerialized;
  24174. /**
  24175. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  24176. * @param parsedFresnelParameters Define the JSON representation
  24177. * @returns the parsed parameters
  24178. */
  24179. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  24180. }
  24181. }
  24182. declare module "babylonjs/Materials/materialFlags" {
  24183. /**
  24184. * This groups all the flags used to control the materials channel.
  24185. */
  24186. export class MaterialFlags {
  24187. private static _DiffuseTextureEnabled;
  24188. /**
  24189. * Are diffuse textures enabled in the application.
  24190. */
  24191. static get DiffuseTextureEnabled(): boolean;
  24192. static set DiffuseTextureEnabled(value: boolean);
  24193. private static _DetailTextureEnabled;
  24194. /**
  24195. * Are detail textures enabled in the application.
  24196. */
  24197. static get DetailTextureEnabled(): boolean;
  24198. static set DetailTextureEnabled(value: boolean);
  24199. private static _AmbientTextureEnabled;
  24200. /**
  24201. * Are ambient textures enabled in the application.
  24202. */
  24203. static get AmbientTextureEnabled(): boolean;
  24204. static set AmbientTextureEnabled(value: boolean);
  24205. private static _OpacityTextureEnabled;
  24206. /**
  24207. * Are opacity textures enabled in the application.
  24208. */
  24209. static get OpacityTextureEnabled(): boolean;
  24210. static set OpacityTextureEnabled(value: boolean);
  24211. private static _ReflectionTextureEnabled;
  24212. /**
  24213. * Are reflection textures enabled in the application.
  24214. */
  24215. static get ReflectionTextureEnabled(): boolean;
  24216. static set ReflectionTextureEnabled(value: boolean);
  24217. private static _EmissiveTextureEnabled;
  24218. /**
  24219. * Are emissive textures enabled in the application.
  24220. */
  24221. static get EmissiveTextureEnabled(): boolean;
  24222. static set EmissiveTextureEnabled(value: boolean);
  24223. private static _SpecularTextureEnabled;
  24224. /**
  24225. * Are specular textures enabled in the application.
  24226. */
  24227. static get SpecularTextureEnabled(): boolean;
  24228. static set SpecularTextureEnabled(value: boolean);
  24229. private static _BumpTextureEnabled;
  24230. /**
  24231. * Are bump textures enabled in the application.
  24232. */
  24233. static get BumpTextureEnabled(): boolean;
  24234. static set BumpTextureEnabled(value: boolean);
  24235. private static _LightmapTextureEnabled;
  24236. /**
  24237. * Are lightmap textures enabled in the application.
  24238. */
  24239. static get LightmapTextureEnabled(): boolean;
  24240. static set LightmapTextureEnabled(value: boolean);
  24241. private static _RefractionTextureEnabled;
  24242. /**
  24243. * Are refraction textures enabled in the application.
  24244. */
  24245. static get RefractionTextureEnabled(): boolean;
  24246. static set RefractionTextureEnabled(value: boolean);
  24247. private static _ColorGradingTextureEnabled;
  24248. /**
  24249. * Are color grading textures enabled in the application.
  24250. */
  24251. static get ColorGradingTextureEnabled(): boolean;
  24252. static set ColorGradingTextureEnabled(value: boolean);
  24253. private static _FresnelEnabled;
  24254. /**
  24255. * Are fresnels enabled in the application.
  24256. */
  24257. static get FresnelEnabled(): boolean;
  24258. static set FresnelEnabled(value: boolean);
  24259. private static _ClearCoatTextureEnabled;
  24260. /**
  24261. * Are clear coat textures enabled in the application.
  24262. */
  24263. static get ClearCoatTextureEnabled(): boolean;
  24264. static set ClearCoatTextureEnabled(value: boolean);
  24265. private static _ClearCoatBumpTextureEnabled;
  24266. /**
  24267. * Are clear coat bump textures enabled in the application.
  24268. */
  24269. static get ClearCoatBumpTextureEnabled(): boolean;
  24270. static set ClearCoatBumpTextureEnabled(value: boolean);
  24271. private static _ClearCoatTintTextureEnabled;
  24272. /**
  24273. * Are clear coat tint textures enabled in the application.
  24274. */
  24275. static get ClearCoatTintTextureEnabled(): boolean;
  24276. static set ClearCoatTintTextureEnabled(value: boolean);
  24277. private static _SheenTextureEnabled;
  24278. /**
  24279. * Are sheen textures enabled in the application.
  24280. */
  24281. static get SheenTextureEnabled(): boolean;
  24282. static set SheenTextureEnabled(value: boolean);
  24283. private static _AnisotropicTextureEnabled;
  24284. /**
  24285. * Are anisotropic textures enabled in the application.
  24286. */
  24287. static get AnisotropicTextureEnabled(): boolean;
  24288. static set AnisotropicTextureEnabled(value: boolean);
  24289. private static _ThicknessTextureEnabled;
  24290. /**
  24291. * Are thickness textures enabled in the application.
  24292. */
  24293. static get ThicknessTextureEnabled(): boolean;
  24294. static set ThicknessTextureEnabled(value: boolean);
  24295. }
  24296. }
  24297. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  24298. /** @hidden */
  24299. export var defaultFragmentDeclaration: {
  24300. name: string;
  24301. shader: string;
  24302. };
  24303. }
  24304. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  24305. /** @hidden */
  24306. export var defaultUboDeclaration: {
  24307. name: string;
  24308. shader: string;
  24309. };
  24310. }
  24311. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  24312. /** @hidden */
  24313. export var prePassDeclaration: {
  24314. name: string;
  24315. shader: string;
  24316. };
  24317. }
  24318. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  24319. /** @hidden */
  24320. export var lightFragmentDeclaration: {
  24321. name: string;
  24322. shader: string;
  24323. };
  24324. }
  24325. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  24326. /** @hidden */
  24327. export var lightUboDeclaration: {
  24328. name: string;
  24329. shader: string;
  24330. };
  24331. }
  24332. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  24333. /** @hidden */
  24334. export var lightsFragmentFunctions: {
  24335. name: string;
  24336. shader: string;
  24337. };
  24338. }
  24339. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  24340. /** @hidden */
  24341. export var shadowsFragmentFunctions: {
  24342. name: string;
  24343. shader: string;
  24344. };
  24345. }
  24346. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  24347. /** @hidden */
  24348. export var fresnelFunction: {
  24349. name: string;
  24350. shader: string;
  24351. };
  24352. }
  24353. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  24354. /** @hidden */
  24355. export var bumpFragmentMainFunctions: {
  24356. name: string;
  24357. shader: string;
  24358. };
  24359. }
  24360. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  24361. /** @hidden */
  24362. export var bumpFragmentFunctions: {
  24363. name: string;
  24364. shader: string;
  24365. };
  24366. }
  24367. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  24368. /** @hidden */
  24369. export var logDepthDeclaration: {
  24370. name: string;
  24371. shader: string;
  24372. };
  24373. }
  24374. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  24375. /** @hidden */
  24376. export var bumpFragment: {
  24377. name: string;
  24378. shader: string;
  24379. };
  24380. }
  24381. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  24382. /** @hidden */
  24383. export var depthPrePass: {
  24384. name: string;
  24385. shader: string;
  24386. };
  24387. }
  24388. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  24389. /** @hidden */
  24390. export var lightFragment: {
  24391. name: string;
  24392. shader: string;
  24393. };
  24394. }
  24395. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  24396. /** @hidden */
  24397. export var logDepthFragment: {
  24398. name: string;
  24399. shader: string;
  24400. };
  24401. }
  24402. declare module "babylonjs/Shaders/default.fragment" {
  24403. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  24404. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24405. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  24406. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24407. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24408. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24409. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  24410. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  24411. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  24412. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  24413. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24414. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24415. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  24416. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  24417. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  24418. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24419. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24420. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  24421. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  24422. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  24423. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  24424. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  24425. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24426. /** @hidden */
  24427. export var defaultPixelShader: {
  24428. name: string;
  24429. shader: string;
  24430. };
  24431. }
  24432. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  24433. /** @hidden */
  24434. export var defaultVertexDeclaration: {
  24435. name: string;
  24436. shader: string;
  24437. };
  24438. }
  24439. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  24440. /** @hidden */
  24441. export var prePassVertexDeclaration: {
  24442. name: string;
  24443. shader: string;
  24444. };
  24445. }
  24446. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  24447. /** @hidden */
  24448. export var bumpVertexDeclaration: {
  24449. name: string;
  24450. shader: string;
  24451. };
  24452. }
  24453. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  24454. /** @hidden */
  24455. export var prePassVertex: {
  24456. name: string;
  24457. shader: string;
  24458. };
  24459. }
  24460. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  24461. /** @hidden */
  24462. export var bumpVertex: {
  24463. name: string;
  24464. shader: string;
  24465. };
  24466. }
  24467. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  24468. /** @hidden */
  24469. export var fogVertex: {
  24470. name: string;
  24471. shader: string;
  24472. };
  24473. }
  24474. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  24475. /** @hidden */
  24476. export var shadowsVertex: {
  24477. name: string;
  24478. shader: string;
  24479. };
  24480. }
  24481. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  24482. /** @hidden */
  24483. export var pointCloudVertex: {
  24484. name: string;
  24485. shader: string;
  24486. };
  24487. }
  24488. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  24489. /** @hidden */
  24490. export var logDepthVertex: {
  24491. name: string;
  24492. shader: string;
  24493. };
  24494. }
  24495. declare module "babylonjs/Shaders/default.vertex" {
  24496. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  24497. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24498. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24499. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  24500. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  24501. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  24502. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  24503. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  24504. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24505. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24506. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24507. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  24508. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  24509. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24510. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  24511. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  24512. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  24513. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  24514. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  24515. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  24516. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  24517. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  24518. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  24519. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  24520. /** @hidden */
  24521. export var defaultVertexShader: {
  24522. name: string;
  24523. shader: string;
  24524. };
  24525. }
  24526. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  24527. import { Nullable } from "babylonjs/types";
  24528. import { Scene } from "babylonjs/scene";
  24529. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24530. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24531. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24532. /**
  24533. * @hidden
  24534. */
  24535. export interface IMaterialDetailMapDefines {
  24536. DETAIL: boolean;
  24537. DETAILDIRECTUV: number;
  24538. DETAIL_NORMALBLENDMETHOD: number;
  24539. /** @hidden */
  24540. _areTexturesDirty: boolean;
  24541. }
  24542. /**
  24543. * Define the code related to the detail map parameters of a material
  24544. *
  24545. * Inspired from:
  24546. * 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
  24547. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  24548. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  24549. */
  24550. export class DetailMapConfiguration {
  24551. private _texture;
  24552. /**
  24553. * The detail texture of the material.
  24554. */
  24555. texture: Nullable<BaseTexture>;
  24556. /**
  24557. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  24558. * Bigger values mean stronger blending
  24559. */
  24560. diffuseBlendLevel: number;
  24561. /**
  24562. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  24563. * Bigger values mean stronger blending. Only used with PBR materials
  24564. */
  24565. roughnessBlendLevel: number;
  24566. /**
  24567. * Defines how strong the bump effect from the detail map is
  24568. * Bigger values mean stronger effect
  24569. */
  24570. bumpLevel: number;
  24571. private _normalBlendMethod;
  24572. /**
  24573. * The method used to blend the bump and detail normals together
  24574. */
  24575. normalBlendMethod: number;
  24576. private _isEnabled;
  24577. /**
  24578. * Enable or disable the detail map on this material
  24579. */
  24580. isEnabled: boolean;
  24581. /** @hidden */
  24582. private _internalMarkAllSubMeshesAsTexturesDirty;
  24583. /** @hidden */
  24584. _markAllSubMeshesAsTexturesDirty(): void;
  24585. /**
  24586. * Instantiate a new detail map
  24587. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24588. */
  24589. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24590. /**
  24591. * Gets whether the submesh is ready to be used or not.
  24592. * @param defines the list of "defines" to update.
  24593. * @param scene defines the scene the material belongs to.
  24594. * @returns - boolean indicating that the submesh is ready or not.
  24595. */
  24596. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24597. /**
  24598. * Update the defines for detail map usage
  24599. * @param defines the list of "defines" to update.
  24600. * @param scene defines the scene the material belongs to.
  24601. */
  24602. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24603. /**
  24604. * Binds the material data.
  24605. * @param uniformBuffer defines the Uniform buffer to fill in.
  24606. * @param scene defines the scene the material belongs to.
  24607. * @param isFrozen defines whether the material is frozen or not.
  24608. */
  24609. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24610. /**
  24611. * Checks to see if a texture is used in the material.
  24612. * @param texture - Base texture to use.
  24613. * @returns - Boolean specifying if a texture is used in the material.
  24614. */
  24615. hasTexture(texture: BaseTexture): boolean;
  24616. /**
  24617. * Returns an array of the actively used textures.
  24618. * @param activeTextures Array of BaseTextures
  24619. */
  24620. getActiveTextures(activeTextures: BaseTexture[]): void;
  24621. /**
  24622. * Returns the animatable textures.
  24623. * @param animatables Array of animatable textures.
  24624. */
  24625. getAnimatables(animatables: IAnimatable[]): void;
  24626. /**
  24627. * Disposes the resources of the material.
  24628. * @param forceDisposeTextures - Forces the disposal of all textures.
  24629. */
  24630. dispose(forceDisposeTextures?: boolean): void;
  24631. /**
  24632. * Get the current class name useful for serialization or dynamic coding.
  24633. * @returns "DetailMap"
  24634. */
  24635. getClassName(): string;
  24636. /**
  24637. * Add the required uniforms to the current list.
  24638. * @param uniforms defines the current uniform list.
  24639. */
  24640. static AddUniforms(uniforms: string[]): void;
  24641. /**
  24642. * Add the required samplers to the current list.
  24643. * @param samplers defines the current sampler list.
  24644. */
  24645. static AddSamplers(samplers: string[]): void;
  24646. /**
  24647. * Add the required uniforms to the current buffer.
  24648. * @param uniformBuffer defines the current uniform buffer.
  24649. */
  24650. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24651. /**
  24652. * Makes a duplicate of the current instance into another one.
  24653. * @param detailMap define the instance where to copy the info
  24654. */
  24655. copyTo(detailMap: DetailMapConfiguration): void;
  24656. /**
  24657. * Serializes this detail map instance
  24658. * @returns - An object with the serialized instance.
  24659. */
  24660. serialize(): any;
  24661. /**
  24662. * Parses a detail map setting from a serialized object.
  24663. * @param source - Serialized object.
  24664. * @param scene Defines the scene we are parsing for
  24665. * @param rootUrl Defines the rootUrl to load from
  24666. */
  24667. parse(source: any, scene: Scene, rootUrl: string): void;
  24668. }
  24669. }
  24670. declare module "babylonjs/Materials/standardMaterial" {
  24671. import { SmartArray } from "babylonjs/Misc/smartArray";
  24672. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24673. import { Nullable } from "babylonjs/types";
  24674. import { Scene } from "babylonjs/scene";
  24675. import { Matrix } from "babylonjs/Maths/math.vector";
  24676. import { Color3 } from "babylonjs/Maths/math.color";
  24677. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24679. import { Mesh } from "babylonjs/Meshes/mesh";
  24680. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  24681. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  24682. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24683. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  24684. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24685. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  24686. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24687. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24688. import "babylonjs/Shaders/default.fragment";
  24689. import "babylonjs/Shaders/default.vertex";
  24690. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  24691. /** @hidden */
  24692. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24693. MAINUV1: boolean;
  24694. MAINUV2: boolean;
  24695. DIFFUSE: boolean;
  24696. DIFFUSEDIRECTUV: number;
  24697. DETAIL: boolean;
  24698. DETAILDIRECTUV: number;
  24699. DETAIL_NORMALBLENDMETHOD: number;
  24700. AMBIENT: boolean;
  24701. AMBIENTDIRECTUV: number;
  24702. OPACITY: boolean;
  24703. OPACITYDIRECTUV: number;
  24704. OPACITYRGB: boolean;
  24705. REFLECTION: boolean;
  24706. EMISSIVE: boolean;
  24707. EMISSIVEDIRECTUV: number;
  24708. SPECULAR: boolean;
  24709. SPECULARDIRECTUV: number;
  24710. BUMP: boolean;
  24711. BUMPDIRECTUV: number;
  24712. PARALLAX: boolean;
  24713. PARALLAXOCCLUSION: boolean;
  24714. SPECULAROVERALPHA: boolean;
  24715. CLIPPLANE: boolean;
  24716. CLIPPLANE2: boolean;
  24717. CLIPPLANE3: boolean;
  24718. CLIPPLANE4: boolean;
  24719. CLIPPLANE5: boolean;
  24720. CLIPPLANE6: boolean;
  24721. ALPHATEST: boolean;
  24722. DEPTHPREPASS: boolean;
  24723. ALPHAFROMDIFFUSE: boolean;
  24724. POINTSIZE: boolean;
  24725. FOG: boolean;
  24726. SPECULARTERM: boolean;
  24727. DIFFUSEFRESNEL: boolean;
  24728. OPACITYFRESNEL: boolean;
  24729. REFLECTIONFRESNEL: boolean;
  24730. REFRACTIONFRESNEL: boolean;
  24731. EMISSIVEFRESNEL: boolean;
  24732. FRESNEL: boolean;
  24733. NORMAL: boolean;
  24734. UV1: boolean;
  24735. UV2: boolean;
  24736. VERTEXCOLOR: boolean;
  24737. VERTEXALPHA: boolean;
  24738. NUM_BONE_INFLUENCERS: number;
  24739. BonesPerMesh: number;
  24740. BONETEXTURE: boolean;
  24741. BONES_VELOCITY_ENABLED: boolean;
  24742. INSTANCES: boolean;
  24743. THIN_INSTANCES: boolean;
  24744. GLOSSINESS: boolean;
  24745. ROUGHNESS: boolean;
  24746. EMISSIVEASILLUMINATION: boolean;
  24747. LINKEMISSIVEWITHDIFFUSE: boolean;
  24748. REFLECTIONFRESNELFROMSPECULAR: boolean;
  24749. LIGHTMAP: boolean;
  24750. LIGHTMAPDIRECTUV: number;
  24751. OBJECTSPACE_NORMALMAP: boolean;
  24752. USELIGHTMAPASSHADOWMAP: boolean;
  24753. REFLECTIONMAP_3D: boolean;
  24754. REFLECTIONMAP_SPHERICAL: boolean;
  24755. REFLECTIONMAP_PLANAR: boolean;
  24756. REFLECTIONMAP_CUBIC: boolean;
  24757. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  24758. REFLECTIONMAP_PROJECTION: boolean;
  24759. REFLECTIONMAP_SKYBOX: boolean;
  24760. REFLECTIONMAP_EXPLICIT: boolean;
  24761. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  24762. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  24763. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  24764. INVERTCUBICMAP: boolean;
  24765. LOGARITHMICDEPTH: boolean;
  24766. REFRACTION: boolean;
  24767. REFRACTIONMAP_3D: boolean;
  24768. REFLECTIONOVERALPHA: boolean;
  24769. TWOSIDEDLIGHTING: boolean;
  24770. SHADOWFLOAT: boolean;
  24771. MORPHTARGETS: boolean;
  24772. MORPHTARGETS_NORMAL: boolean;
  24773. MORPHTARGETS_TANGENT: boolean;
  24774. MORPHTARGETS_UV: boolean;
  24775. NUM_MORPH_INFLUENCERS: number;
  24776. NONUNIFORMSCALING: boolean;
  24777. PREMULTIPLYALPHA: boolean;
  24778. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  24779. ALPHABLEND: boolean;
  24780. PREPASS: boolean;
  24781. PREPASS_IRRADIANCE: boolean;
  24782. PREPASS_IRRADIANCE_INDEX: number;
  24783. PREPASS_ALBEDO: boolean;
  24784. PREPASS_ALBEDO_INDEX: number;
  24785. PREPASS_DEPTHNORMAL: boolean;
  24786. PREPASS_DEPTHNORMAL_INDEX: number;
  24787. PREPASS_POSITION: boolean;
  24788. PREPASS_POSITION_INDEX: number;
  24789. PREPASS_VELOCITY: boolean;
  24790. PREPASS_VELOCITY_INDEX: number;
  24791. PREPASS_REFLECTIVITY: boolean;
  24792. PREPASS_REFLECTIVITY_INDEX: number;
  24793. SCENE_MRT_COUNT: number;
  24794. RGBDLIGHTMAP: boolean;
  24795. RGBDREFLECTION: boolean;
  24796. RGBDREFRACTION: boolean;
  24797. IMAGEPROCESSING: boolean;
  24798. VIGNETTE: boolean;
  24799. VIGNETTEBLENDMODEMULTIPLY: boolean;
  24800. VIGNETTEBLENDMODEOPAQUE: boolean;
  24801. TONEMAPPING: boolean;
  24802. TONEMAPPING_ACES: boolean;
  24803. CONTRAST: boolean;
  24804. COLORCURVES: boolean;
  24805. COLORGRADING: boolean;
  24806. COLORGRADING3D: boolean;
  24807. SAMPLER3DGREENDEPTH: boolean;
  24808. SAMPLER3DBGRMAP: boolean;
  24809. IMAGEPROCESSINGPOSTPROCESS: boolean;
  24810. MULTIVIEW: boolean;
  24811. /**
  24812. * If the reflection texture on this material is in linear color space
  24813. * @hidden
  24814. */
  24815. IS_REFLECTION_LINEAR: boolean;
  24816. /**
  24817. * If the refraction texture on this material is in linear color space
  24818. * @hidden
  24819. */
  24820. IS_REFRACTION_LINEAR: boolean;
  24821. EXPOSURE: boolean;
  24822. constructor();
  24823. setReflectionMode(modeToEnable: string): void;
  24824. }
  24825. /**
  24826. * This is the default material used in Babylon. It is the best trade off between quality
  24827. * and performances.
  24828. * @see https://doc.babylonjs.com/babylon101/materials
  24829. */
  24830. export class StandardMaterial extends PushMaterial {
  24831. private _diffuseTexture;
  24832. /**
  24833. * The basic texture of the material as viewed under a light.
  24834. */
  24835. diffuseTexture: Nullable<BaseTexture>;
  24836. private _ambientTexture;
  24837. /**
  24838. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  24839. */
  24840. ambientTexture: Nullable<BaseTexture>;
  24841. private _opacityTexture;
  24842. /**
  24843. * Define the transparency of the material from a texture.
  24844. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  24845. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  24846. */
  24847. opacityTexture: Nullable<BaseTexture>;
  24848. private _reflectionTexture;
  24849. /**
  24850. * Define the texture used to display the reflection.
  24851. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24852. */
  24853. reflectionTexture: Nullable<BaseTexture>;
  24854. private _emissiveTexture;
  24855. /**
  24856. * Define texture of the material as if self lit.
  24857. * This will be mixed in the final result even in the absence of light.
  24858. */
  24859. emissiveTexture: Nullable<BaseTexture>;
  24860. private _specularTexture;
  24861. /**
  24862. * Define how the color and intensity of the highlight given by the light in the material.
  24863. */
  24864. specularTexture: Nullable<BaseTexture>;
  24865. private _bumpTexture;
  24866. /**
  24867. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  24868. * 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.
  24869. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  24870. */
  24871. bumpTexture: Nullable<BaseTexture>;
  24872. private _lightmapTexture;
  24873. /**
  24874. * Complex lighting can be computationally expensive to compute at runtime.
  24875. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  24876. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  24877. */
  24878. lightmapTexture: Nullable<BaseTexture>;
  24879. private _refractionTexture;
  24880. /**
  24881. * Define the texture used to display the refraction.
  24882. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24883. */
  24884. refractionTexture: Nullable<BaseTexture>;
  24885. /**
  24886. * The color of the material lit by the environmental background lighting.
  24887. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24888. */
  24889. ambientColor: Color3;
  24890. /**
  24891. * The basic color of the material as viewed under a light.
  24892. */
  24893. diffuseColor: Color3;
  24894. /**
  24895. * Define how the color and intensity of the highlight given by the light in the material.
  24896. */
  24897. specularColor: Color3;
  24898. /**
  24899. * Define the color of the material as if self lit.
  24900. * This will be mixed in the final result even in the absence of light.
  24901. */
  24902. emissiveColor: Color3;
  24903. /**
  24904. * Defines how sharp are the highlights in the material.
  24905. * The bigger the value the sharper giving a more glossy feeling to the result.
  24906. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24907. */
  24908. specularPower: number;
  24909. private _useAlphaFromDiffuseTexture;
  24910. /**
  24911. * Does the transparency come from the diffuse texture alpha channel.
  24912. */
  24913. useAlphaFromDiffuseTexture: boolean;
  24914. private _useEmissiveAsIllumination;
  24915. /**
  24916. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24917. */
  24918. useEmissiveAsIllumination: boolean;
  24919. private _linkEmissiveWithDiffuse;
  24920. /**
  24921. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24922. * the emissive level when the final color is close to one.
  24923. */
  24924. linkEmissiveWithDiffuse: boolean;
  24925. private _useSpecularOverAlpha;
  24926. /**
  24927. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24928. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24929. */
  24930. useSpecularOverAlpha: boolean;
  24931. private _useReflectionOverAlpha;
  24932. /**
  24933. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24934. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24935. */
  24936. useReflectionOverAlpha: boolean;
  24937. private _disableLighting;
  24938. /**
  24939. * Does lights from the scene impacts this material.
  24940. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24941. */
  24942. disableLighting: boolean;
  24943. private _useObjectSpaceNormalMap;
  24944. /**
  24945. * Allows using an object space normal map (instead of tangent space).
  24946. */
  24947. useObjectSpaceNormalMap: boolean;
  24948. private _useParallax;
  24949. /**
  24950. * Is parallax enabled or not.
  24951. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24952. */
  24953. useParallax: boolean;
  24954. private _useParallaxOcclusion;
  24955. /**
  24956. * Is parallax occlusion enabled or not.
  24957. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24958. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24959. */
  24960. useParallaxOcclusion: boolean;
  24961. /**
  24962. * 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.
  24963. */
  24964. parallaxScaleBias: number;
  24965. private _roughness;
  24966. /**
  24967. * Helps to define how blurry the reflections should appears in the material.
  24968. */
  24969. roughness: number;
  24970. /**
  24971. * In case of refraction, define the value of the index of refraction.
  24972. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24973. */
  24974. indexOfRefraction: number;
  24975. /**
  24976. * Invert the refraction texture alongside the y axis.
  24977. * It can be useful with procedural textures or probe for instance.
  24978. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24979. */
  24980. invertRefractionY: boolean;
  24981. /**
  24982. * Defines the alpha limits in alpha test mode.
  24983. */
  24984. alphaCutOff: number;
  24985. private _useLightmapAsShadowmap;
  24986. /**
  24987. * In case of light mapping, define whether the map contains light or shadow informations.
  24988. */
  24989. useLightmapAsShadowmap: boolean;
  24990. private _diffuseFresnelParameters;
  24991. /**
  24992. * Define the diffuse fresnel parameters of the material.
  24993. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24994. */
  24995. diffuseFresnelParameters: FresnelParameters;
  24996. private _opacityFresnelParameters;
  24997. /**
  24998. * Define the opacity fresnel parameters of the material.
  24999. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25000. */
  25001. opacityFresnelParameters: FresnelParameters;
  25002. private _reflectionFresnelParameters;
  25003. /**
  25004. * Define the reflection fresnel parameters of the material.
  25005. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25006. */
  25007. reflectionFresnelParameters: FresnelParameters;
  25008. private _refractionFresnelParameters;
  25009. /**
  25010. * Define the refraction fresnel parameters of the material.
  25011. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25012. */
  25013. refractionFresnelParameters: FresnelParameters;
  25014. private _emissiveFresnelParameters;
  25015. /**
  25016. * Define the emissive fresnel parameters of the material.
  25017. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25018. */
  25019. emissiveFresnelParameters: FresnelParameters;
  25020. private _useReflectionFresnelFromSpecular;
  25021. /**
  25022. * If true automatically deducts the fresnels values from the material specularity.
  25023. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25024. */
  25025. useReflectionFresnelFromSpecular: boolean;
  25026. private _useGlossinessFromSpecularMapAlpha;
  25027. /**
  25028. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  25029. */
  25030. useGlossinessFromSpecularMapAlpha: boolean;
  25031. private _maxSimultaneousLights;
  25032. /**
  25033. * Defines the maximum number of lights that can be used in the material
  25034. */
  25035. maxSimultaneousLights: number;
  25036. private _invertNormalMapX;
  25037. /**
  25038. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25039. */
  25040. invertNormalMapX: boolean;
  25041. private _invertNormalMapY;
  25042. /**
  25043. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25044. */
  25045. invertNormalMapY: boolean;
  25046. private _twoSidedLighting;
  25047. /**
  25048. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25049. */
  25050. twoSidedLighting: boolean;
  25051. /**
  25052. * Default configuration related to image processing available in the standard Material.
  25053. */
  25054. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25055. /**
  25056. * Gets the image processing configuration used either in this material.
  25057. */
  25058. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25059. /**
  25060. * Sets the Default image processing configuration used either in the this material.
  25061. *
  25062. * If sets to null, the scene one is in use.
  25063. */
  25064. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25065. /**
  25066. * Keep track of the image processing observer to allow dispose and replace.
  25067. */
  25068. private _imageProcessingObserver;
  25069. /**
  25070. * Attaches a new image processing configuration to the Standard Material.
  25071. * @param configuration
  25072. */
  25073. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25074. /**
  25075. * Defines additionnal PrePass parameters for the material.
  25076. */
  25077. readonly prePassConfiguration: PrePassConfiguration;
  25078. /**
  25079. * Gets wether the color curves effect is enabled.
  25080. */
  25081. get cameraColorCurvesEnabled(): boolean;
  25082. /**
  25083. * Sets wether the color curves effect is enabled.
  25084. */
  25085. set cameraColorCurvesEnabled(value: boolean);
  25086. /**
  25087. * Gets wether the color grading effect is enabled.
  25088. */
  25089. get cameraColorGradingEnabled(): boolean;
  25090. /**
  25091. * Gets wether the color grading effect is enabled.
  25092. */
  25093. set cameraColorGradingEnabled(value: boolean);
  25094. /**
  25095. * Gets wether tonemapping is enabled or not.
  25096. */
  25097. get cameraToneMappingEnabled(): boolean;
  25098. /**
  25099. * Sets wether tonemapping is enabled or not
  25100. */
  25101. set cameraToneMappingEnabled(value: boolean);
  25102. /**
  25103. * The camera exposure used on this material.
  25104. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25105. * This corresponds to a photographic exposure.
  25106. */
  25107. get cameraExposure(): number;
  25108. /**
  25109. * The camera exposure used on this material.
  25110. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25111. * This corresponds to a photographic exposure.
  25112. */
  25113. set cameraExposure(value: number);
  25114. /**
  25115. * Gets The camera contrast used on this material.
  25116. */
  25117. get cameraContrast(): number;
  25118. /**
  25119. * Sets The camera contrast used on this material.
  25120. */
  25121. set cameraContrast(value: number);
  25122. /**
  25123. * Gets the Color Grading 2D Lookup Texture.
  25124. */
  25125. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  25126. /**
  25127. * Sets the Color Grading 2D Lookup Texture.
  25128. */
  25129. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  25130. /**
  25131. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25132. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25133. * 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;
  25134. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25135. */
  25136. get cameraColorCurves(): Nullable<ColorCurves>;
  25137. /**
  25138. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25139. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25140. * 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;
  25141. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25142. */
  25143. set cameraColorCurves(value: Nullable<ColorCurves>);
  25144. /**
  25145. * Can this material render to several textures at once
  25146. */
  25147. get canRenderToMRT(): boolean;
  25148. /**
  25149. * Defines the detail map parameters for the material.
  25150. */
  25151. readonly detailMap: DetailMapConfiguration;
  25152. protected _renderTargets: SmartArray<RenderTargetTexture>;
  25153. protected _worldViewProjectionMatrix: Matrix;
  25154. protected _globalAmbientColor: Color3;
  25155. protected _useLogarithmicDepth: boolean;
  25156. protected _rebuildInParallel: boolean;
  25157. /**
  25158. * Instantiates a new standard material.
  25159. * This is the default material used in Babylon. It is the best trade off between quality
  25160. * and performances.
  25161. * @see https://doc.babylonjs.com/babylon101/materials
  25162. * @param name Define the name of the material in the scene
  25163. * @param scene Define the scene the material belong to
  25164. */
  25165. constructor(name: string, scene: Scene);
  25166. /**
  25167. * Gets a boolean indicating that current material needs to register RTT
  25168. */
  25169. get hasRenderTargetTextures(): boolean;
  25170. /**
  25171. * Gets the current class name of the material e.g. "StandardMaterial"
  25172. * Mainly use in serialization.
  25173. * @returns the class name
  25174. */
  25175. getClassName(): string;
  25176. /**
  25177. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  25178. * You can try switching to logarithmic depth.
  25179. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  25180. */
  25181. get useLogarithmicDepth(): boolean;
  25182. set useLogarithmicDepth(value: boolean);
  25183. /**
  25184. * Specifies if the material will require alpha blending
  25185. * @returns a boolean specifying if alpha blending is needed
  25186. */
  25187. needAlphaBlending(): boolean;
  25188. /**
  25189. * Specifies if this material should be rendered in alpha test mode
  25190. * @returns a boolean specifying if an alpha test is needed.
  25191. */
  25192. needAlphaTesting(): boolean;
  25193. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  25194. /**
  25195. * Get the texture used for alpha test purpose.
  25196. * @returns the diffuse texture in case of the standard material.
  25197. */
  25198. getAlphaTestTexture(): Nullable<BaseTexture>;
  25199. /**
  25200. * Get if the submesh is ready to be used and all its information available.
  25201. * Child classes can use it to update shaders
  25202. * @param mesh defines the mesh to check
  25203. * @param subMesh defines which submesh to check
  25204. * @param useInstances specifies that instances should be used
  25205. * @returns a boolean indicating that the submesh is ready or not
  25206. */
  25207. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25208. /**
  25209. * Builds the material UBO layouts.
  25210. * Used internally during the effect preparation.
  25211. */
  25212. buildUniformLayout(): void;
  25213. /**
  25214. * Unbinds the material from the mesh
  25215. */
  25216. unbind(): void;
  25217. /**
  25218. * Binds the submesh to this material by preparing the effect and shader to draw
  25219. * @param world defines the world transformation matrix
  25220. * @param mesh defines the mesh containing the submesh
  25221. * @param subMesh defines the submesh to bind the material to
  25222. */
  25223. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25224. /**
  25225. * Get the list of animatables in the material.
  25226. * @returns the list of animatables object used in the material
  25227. */
  25228. getAnimatables(): IAnimatable[];
  25229. /**
  25230. * Gets the active textures from the material
  25231. * @returns an array of textures
  25232. */
  25233. getActiveTextures(): BaseTexture[];
  25234. /**
  25235. * Specifies if the material uses a texture
  25236. * @param texture defines the texture to check against the material
  25237. * @returns a boolean specifying if the material uses the texture
  25238. */
  25239. hasTexture(texture: BaseTexture): boolean;
  25240. /**
  25241. * Disposes the material
  25242. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25243. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25244. */
  25245. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25246. /**
  25247. * Makes a duplicate of the material, and gives it a new name
  25248. * @param name defines the new name for the duplicated material
  25249. * @returns the cloned material
  25250. */
  25251. clone(name: string): StandardMaterial;
  25252. /**
  25253. * Serializes this material in a JSON representation
  25254. * @returns the serialized material object
  25255. */
  25256. serialize(): any;
  25257. /**
  25258. * Creates a standard material from parsed material data
  25259. * @param source defines the JSON representation of the material
  25260. * @param scene defines the hosting scene
  25261. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25262. * @returns a new standard material
  25263. */
  25264. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  25265. /**
  25266. * Are diffuse textures enabled in the application.
  25267. */
  25268. static get DiffuseTextureEnabled(): boolean;
  25269. static set DiffuseTextureEnabled(value: boolean);
  25270. /**
  25271. * Are detail textures enabled in the application.
  25272. */
  25273. static get DetailTextureEnabled(): boolean;
  25274. static set DetailTextureEnabled(value: boolean);
  25275. /**
  25276. * Are ambient textures enabled in the application.
  25277. */
  25278. static get AmbientTextureEnabled(): boolean;
  25279. static set AmbientTextureEnabled(value: boolean);
  25280. /**
  25281. * Are opacity textures enabled in the application.
  25282. */
  25283. static get OpacityTextureEnabled(): boolean;
  25284. static set OpacityTextureEnabled(value: boolean);
  25285. /**
  25286. * Are reflection textures enabled in the application.
  25287. */
  25288. static get ReflectionTextureEnabled(): boolean;
  25289. static set ReflectionTextureEnabled(value: boolean);
  25290. /**
  25291. * Are emissive textures enabled in the application.
  25292. */
  25293. static get EmissiveTextureEnabled(): boolean;
  25294. static set EmissiveTextureEnabled(value: boolean);
  25295. /**
  25296. * Are specular textures enabled in the application.
  25297. */
  25298. static get SpecularTextureEnabled(): boolean;
  25299. static set SpecularTextureEnabled(value: boolean);
  25300. /**
  25301. * Are bump textures enabled in the application.
  25302. */
  25303. static get BumpTextureEnabled(): boolean;
  25304. static set BumpTextureEnabled(value: boolean);
  25305. /**
  25306. * Are lightmap textures enabled in the application.
  25307. */
  25308. static get LightmapTextureEnabled(): boolean;
  25309. static set LightmapTextureEnabled(value: boolean);
  25310. /**
  25311. * Are refraction textures enabled in the application.
  25312. */
  25313. static get RefractionTextureEnabled(): boolean;
  25314. static set RefractionTextureEnabled(value: boolean);
  25315. /**
  25316. * Are color grading textures enabled in the application.
  25317. */
  25318. static get ColorGradingTextureEnabled(): boolean;
  25319. static set ColorGradingTextureEnabled(value: boolean);
  25320. /**
  25321. * Are fresnels enabled in the application.
  25322. */
  25323. static get FresnelEnabled(): boolean;
  25324. static set FresnelEnabled(value: boolean);
  25325. }
  25326. }
  25327. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  25328. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25329. /** @hidden */
  25330. export var rgbdDecodePixelShader: {
  25331. name: string;
  25332. shader: string;
  25333. };
  25334. }
  25335. declare module "babylonjs/Misc/rgbdTextureTools" {
  25336. import "babylonjs/Shaders/rgbdDecode.fragment";
  25337. import "babylonjs/Engines/Extensions/engine.renderTarget";
  25338. import { Texture } from "babylonjs/Materials/Textures/texture";
  25339. /**
  25340. * Class used to host RGBD texture specific utilities
  25341. */
  25342. export class RGBDTextureTools {
  25343. /**
  25344. * Expand the RGBD Texture from RGBD to Half Float if possible.
  25345. * @param texture the texture to expand.
  25346. */
  25347. static ExpandRGBDTexture(texture: Texture): void;
  25348. }
  25349. }
  25350. declare module "babylonjs/Misc/brdfTextureTools" {
  25351. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25352. import { Scene } from "babylonjs/scene";
  25353. /**
  25354. * Class used to host texture specific utilities
  25355. */
  25356. export class BRDFTextureTools {
  25357. /**
  25358. * Prevents texture cache collision
  25359. */
  25360. private static _instanceNumber;
  25361. /**
  25362. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  25363. * @param scene defines the hosting scene
  25364. * @returns the environment BRDF texture
  25365. */
  25366. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  25367. private static _environmentBRDFBase64Texture;
  25368. }
  25369. }
  25370. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  25371. import { Nullable } from "babylonjs/types";
  25372. import { Color3 } from "babylonjs/Maths/math.color";
  25373. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25374. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25375. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25376. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25377. import { Engine } from "babylonjs/Engines/engine";
  25378. import { Scene } from "babylonjs/scene";
  25379. /**
  25380. * @hidden
  25381. */
  25382. export interface IMaterialClearCoatDefines {
  25383. CLEARCOAT: boolean;
  25384. CLEARCOAT_DEFAULTIOR: boolean;
  25385. CLEARCOAT_TEXTURE: boolean;
  25386. CLEARCOAT_TEXTUREDIRECTUV: number;
  25387. CLEARCOAT_BUMP: boolean;
  25388. CLEARCOAT_BUMPDIRECTUV: number;
  25389. CLEARCOAT_REMAP_F0: boolean;
  25390. CLEARCOAT_TINT: boolean;
  25391. CLEARCOAT_TINT_TEXTURE: boolean;
  25392. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  25393. /** @hidden */
  25394. _areTexturesDirty: boolean;
  25395. }
  25396. /**
  25397. * Define the code related to the clear coat parameters of the pbr material.
  25398. */
  25399. export class PBRClearCoatConfiguration {
  25400. /**
  25401. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25402. * The default fits with a polyurethane material.
  25403. */
  25404. private static readonly _DefaultIndexOfRefraction;
  25405. private _isEnabled;
  25406. /**
  25407. * Defines if the clear coat is enabled in the material.
  25408. */
  25409. isEnabled: boolean;
  25410. /**
  25411. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  25412. */
  25413. intensity: number;
  25414. /**
  25415. * Defines the clear coat layer roughness.
  25416. */
  25417. roughness: number;
  25418. private _indexOfRefraction;
  25419. /**
  25420. * Defines the index of refraction of the clear coat.
  25421. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25422. * The default fits with a polyurethane material.
  25423. * Changing the default value is more performance intensive.
  25424. */
  25425. indexOfRefraction: number;
  25426. private _texture;
  25427. /**
  25428. * Stores the clear coat values in a texture.
  25429. */
  25430. texture: Nullable<BaseTexture>;
  25431. private _remapF0OnInterfaceChange;
  25432. /**
  25433. * Defines if the F0 value should be remapped to account for the interface change in the material.
  25434. */
  25435. remapF0OnInterfaceChange: boolean;
  25436. private _bumpTexture;
  25437. /**
  25438. * Define the clear coat specific bump texture.
  25439. */
  25440. bumpTexture: Nullable<BaseTexture>;
  25441. private _isTintEnabled;
  25442. /**
  25443. * Defines if the clear coat tint is enabled in the material.
  25444. */
  25445. isTintEnabled: boolean;
  25446. /**
  25447. * Defines the clear coat tint of the material.
  25448. * This is only use if tint is enabled
  25449. */
  25450. tintColor: Color3;
  25451. /**
  25452. * Defines the distance at which the tint color should be found in the
  25453. * clear coat media.
  25454. * This is only use if tint is enabled
  25455. */
  25456. tintColorAtDistance: number;
  25457. /**
  25458. * Defines the clear coat layer thickness.
  25459. * This is only use if tint is enabled
  25460. */
  25461. tintThickness: number;
  25462. private _tintTexture;
  25463. /**
  25464. * Stores the clear tint values in a texture.
  25465. * rgb is tint
  25466. * a is a thickness factor
  25467. */
  25468. tintTexture: Nullable<BaseTexture>;
  25469. /** @hidden */
  25470. private _internalMarkAllSubMeshesAsTexturesDirty;
  25471. /** @hidden */
  25472. _markAllSubMeshesAsTexturesDirty(): void;
  25473. /**
  25474. * Instantiate a new istance of clear coat configuration.
  25475. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25476. */
  25477. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25478. /**
  25479. * Gets wehter the submesh is ready to be used or not.
  25480. * @param defines the list of "defines" to update.
  25481. * @param scene defines the scene the material belongs to.
  25482. * @param engine defines the engine the material belongs to.
  25483. * @param disableBumpMap defines wether the material disables bump or not.
  25484. * @returns - boolean indicating that the submesh is ready or not.
  25485. */
  25486. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  25487. /**
  25488. * Checks to see if a texture is used in the material.
  25489. * @param defines the list of "defines" to update.
  25490. * @param scene defines the scene to the material belongs to.
  25491. */
  25492. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  25493. /**
  25494. * Binds the material data.
  25495. * @param uniformBuffer defines the Uniform buffer to fill in.
  25496. * @param scene defines the scene the material belongs to.
  25497. * @param engine defines the engine the material belongs to.
  25498. * @param disableBumpMap defines wether the material disables bump or not.
  25499. * @param isFrozen defines wether the material is frozen or not.
  25500. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  25501. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  25502. */
  25503. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  25504. /**
  25505. * Checks to see if a texture is used in the material.
  25506. * @param texture - Base texture to use.
  25507. * @returns - Boolean specifying if a texture is used in the material.
  25508. */
  25509. hasTexture(texture: BaseTexture): boolean;
  25510. /**
  25511. * Returns an array of the actively used textures.
  25512. * @param activeTextures Array of BaseTextures
  25513. */
  25514. getActiveTextures(activeTextures: BaseTexture[]): void;
  25515. /**
  25516. * Returns the animatable textures.
  25517. * @param animatables Array of animatable textures.
  25518. */
  25519. getAnimatables(animatables: IAnimatable[]): void;
  25520. /**
  25521. * Disposes the resources of the material.
  25522. * @param forceDisposeTextures - Forces the disposal of all textures.
  25523. */
  25524. dispose(forceDisposeTextures?: boolean): void;
  25525. /**
  25526. * Get the current class name of the texture useful for serialization or dynamic coding.
  25527. * @returns "PBRClearCoatConfiguration"
  25528. */
  25529. getClassName(): string;
  25530. /**
  25531. * Add fallbacks to the effect fallbacks list.
  25532. * @param defines defines the Base texture to use.
  25533. * @param fallbacks defines the current fallback list.
  25534. * @param currentRank defines the current fallback rank.
  25535. * @returns the new fallback rank.
  25536. */
  25537. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25538. /**
  25539. * Add the required uniforms to the current list.
  25540. * @param uniforms defines the current uniform list.
  25541. */
  25542. static AddUniforms(uniforms: string[]): void;
  25543. /**
  25544. * Add the required samplers to the current list.
  25545. * @param samplers defines the current sampler list.
  25546. */
  25547. static AddSamplers(samplers: string[]): void;
  25548. /**
  25549. * Add the required uniforms to the current buffer.
  25550. * @param uniformBuffer defines the current uniform buffer.
  25551. */
  25552. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25553. /**
  25554. * Makes a duplicate of the current configuration into another one.
  25555. * @param clearCoatConfiguration define the config where to copy the info
  25556. */
  25557. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  25558. /**
  25559. * Serializes this clear coat configuration.
  25560. * @returns - An object with the serialized config.
  25561. */
  25562. serialize(): any;
  25563. /**
  25564. * Parses a anisotropy Configuration from a serialized object.
  25565. * @param source - Serialized object.
  25566. * @param scene Defines the scene we are parsing for
  25567. * @param rootUrl Defines the rootUrl to load from
  25568. */
  25569. parse(source: any, scene: Scene, rootUrl: string): void;
  25570. }
  25571. }
  25572. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  25573. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25575. import { Vector2 } from "babylonjs/Maths/math.vector";
  25576. import { Scene } from "babylonjs/scene";
  25577. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25578. import { Nullable } from "babylonjs/types";
  25579. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25580. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25581. /**
  25582. * @hidden
  25583. */
  25584. export interface IMaterialAnisotropicDefines {
  25585. ANISOTROPIC: boolean;
  25586. ANISOTROPIC_TEXTURE: boolean;
  25587. ANISOTROPIC_TEXTUREDIRECTUV: number;
  25588. MAINUV1: boolean;
  25589. _areTexturesDirty: boolean;
  25590. _needUVs: boolean;
  25591. }
  25592. /**
  25593. * Define the code related to the anisotropic parameters of the pbr material.
  25594. */
  25595. export class PBRAnisotropicConfiguration {
  25596. private _isEnabled;
  25597. /**
  25598. * Defines if the anisotropy is enabled in the material.
  25599. */
  25600. isEnabled: boolean;
  25601. /**
  25602. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  25603. */
  25604. intensity: number;
  25605. /**
  25606. * Defines if the effect is along the tangents, bitangents or in between.
  25607. * By default, the effect is "strectching" the highlights along the tangents.
  25608. */
  25609. direction: Vector2;
  25610. private _texture;
  25611. /**
  25612. * Stores the anisotropy values in a texture.
  25613. * rg is direction (like normal from -1 to 1)
  25614. * b is a intensity
  25615. */
  25616. texture: Nullable<BaseTexture>;
  25617. /** @hidden */
  25618. private _internalMarkAllSubMeshesAsTexturesDirty;
  25619. /** @hidden */
  25620. _markAllSubMeshesAsTexturesDirty(): void;
  25621. /**
  25622. * Instantiate a new istance of anisotropy configuration.
  25623. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25624. */
  25625. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25626. /**
  25627. * Specifies that the submesh is ready to be used.
  25628. * @param defines the list of "defines" to update.
  25629. * @param scene defines the scene the material belongs to.
  25630. * @returns - boolean indicating that the submesh is ready or not.
  25631. */
  25632. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25633. /**
  25634. * Checks to see if a texture is used in the material.
  25635. * @param defines the list of "defines" to update.
  25636. * @param mesh the mesh we are preparing the defines for.
  25637. * @param scene defines the scene the material belongs to.
  25638. */
  25639. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25640. /**
  25641. * Binds the material data.
  25642. * @param uniformBuffer defines the Uniform buffer to fill in.
  25643. * @param scene defines the scene the material belongs to.
  25644. * @param isFrozen defines wether the material is frozen or not.
  25645. */
  25646. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25647. /**
  25648. * Checks to see if a texture is used in the material.
  25649. * @param texture - Base texture to use.
  25650. * @returns - Boolean specifying if a texture is used in the material.
  25651. */
  25652. hasTexture(texture: BaseTexture): boolean;
  25653. /**
  25654. * Returns an array of the actively used textures.
  25655. * @param activeTextures Array of BaseTextures
  25656. */
  25657. getActiveTextures(activeTextures: BaseTexture[]): void;
  25658. /**
  25659. * Returns the animatable textures.
  25660. * @param animatables Array of animatable textures.
  25661. */
  25662. getAnimatables(animatables: IAnimatable[]): void;
  25663. /**
  25664. * Disposes the resources of the material.
  25665. * @param forceDisposeTextures - Forces the disposal of all textures.
  25666. */
  25667. dispose(forceDisposeTextures?: boolean): void;
  25668. /**
  25669. * Get the current class name of the texture useful for serialization or dynamic coding.
  25670. * @returns "PBRAnisotropicConfiguration"
  25671. */
  25672. getClassName(): string;
  25673. /**
  25674. * Add fallbacks to the effect fallbacks list.
  25675. * @param defines defines the Base texture to use.
  25676. * @param fallbacks defines the current fallback list.
  25677. * @param currentRank defines the current fallback rank.
  25678. * @returns the new fallback rank.
  25679. */
  25680. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25681. /**
  25682. * Add the required uniforms to the current list.
  25683. * @param uniforms defines the current uniform list.
  25684. */
  25685. static AddUniforms(uniforms: string[]): void;
  25686. /**
  25687. * Add the required uniforms to the current buffer.
  25688. * @param uniformBuffer defines the current uniform buffer.
  25689. */
  25690. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25691. /**
  25692. * Add the required samplers to the current list.
  25693. * @param samplers defines the current sampler list.
  25694. */
  25695. static AddSamplers(samplers: string[]): void;
  25696. /**
  25697. * Makes a duplicate of the current configuration into another one.
  25698. * @param anisotropicConfiguration define the config where to copy the info
  25699. */
  25700. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  25701. /**
  25702. * Serializes this anisotropy configuration.
  25703. * @returns - An object with the serialized config.
  25704. */
  25705. serialize(): any;
  25706. /**
  25707. * Parses a anisotropy Configuration from a serialized object.
  25708. * @param source - Serialized object.
  25709. * @param scene Defines the scene we are parsing for
  25710. * @param rootUrl Defines the rootUrl to load from
  25711. */
  25712. parse(source: any, scene: Scene, rootUrl: string): void;
  25713. }
  25714. }
  25715. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  25716. import { Scene } from "babylonjs/scene";
  25717. /**
  25718. * @hidden
  25719. */
  25720. export interface IMaterialBRDFDefines {
  25721. BRDF_V_HEIGHT_CORRELATED: boolean;
  25722. MS_BRDF_ENERGY_CONSERVATION: boolean;
  25723. SPHERICAL_HARMONICS: boolean;
  25724. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  25725. /** @hidden */
  25726. _areMiscDirty: boolean;
  25727. }
  25728. /**
  25729. * Define the code related to the BRDF parameters of the pbr material.
  25730. */
  25731. export class PBRBRDFConfiguration {
  25732. /**
  25733. * Default value used for the energy conservation.
  25734. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25735. */
  25736. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  25737. /**
  25738. * Default value used for the Smith Visibility Height Correlated mode.
  25739. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25740. */
  25741. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  25742. /**
  25743. * Default value used for the IBL diffuse part.
  25744. * This can help switching back to the polynomials mode globally which is a tiny bit
  25745. * less GPU intensive at the drawback of a lower quality.
  25746. */
  25747. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  25748. /**
  25749. * Default value used for activating energy conservation for the specular workflow.
  25750. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25751. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25752. */
  25753. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  25754. private _useEnergyConservation;
  25755. /**
  25756. * Defines if the material uses energy conservation.
  25757. */
  25758. useEnergyConservation: boolean;
  25759. private _useSmithVisibilityHeightCorrelated;
  25760. /**
  25761. * LEGACY Mode set to false
  25762. * Defines if the material uses height smith correlated visibility term.
  25763. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  25764. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  25765. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  25766. * Not relying on height correlated will also disable energy conservation.
  25767. */
  25768. useSmithVisibilityHeightCorrelated: boolean;
  25769. private _useSphericalHarmonics;
  25770. /**
  25771. * LEGACY Mode set to false
  25772. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  25773. * diffuse part of the IBL.
  25774. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  25775. * to the ground truth.
  25776. */
  25777. useSphericalHarmonics: boolean;
  25778. private _useSpecularGlossinessInputEnergyConservation;
  25779. /**
  25780. * Defines if the material uses energy conservation, when the specular workflow is active.
  25781. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25782. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25783. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  25784. */
  25785. useSpecularGlossinessInputEnergyConservation: boolean;
  25786. /** @hidden */
  25787. private _internalMarkAllSubMeshesAsMiscDirty;
  25788. /** @hidden */
  25789. _markAllSubMeshesAsMiscDirty(): void;
  25790. /**
  25791. * Instantiate a new istance of clear coat configuration.
  25792. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  25793. */
  25794. constructor(markAllSubMeshesAsMiscDirty: () => void);
  25795. /**
  25796. * Checks to see if a texture is used in the material.
  25797. * @param defines the list of "defines" to update.
  25798. */
  25799. prepareDefines(defines: IMaterialBRDFDefines): void;
  25800. /**
  25801. * Get the current class name of the texture useful for serialization or dynamic coding.
  25802. * @returns "PBRClearCoatConfiguration"
  25803. */
  25804. getClassName(): string;
  25805. /**
  25806. * Makes a duplicate of the current configuration into another one.
  25807. * @param brdfConfiguration define the config where to copy the info
  25808. */
  25809. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  25810. /**
  25811. * Serializes this BRDF configuration.
  25812. * @returns - An object with the serialized config.
  25813. */
  25814. serialize(): any;
  25815. /**
  25816. * Parses a anisotropy Configuration from a serialized object.
  25817. * @param source - Serialized object.
  25818. * @param scene Defines the scene we are parsing for
  25819. * @param rootUrl Defines the rootUrl to load from
  25820. */
  25821. parse(source: any, scene: Scene, rootUrl: string): void;
  25822. }
  25823. }
  25824. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  25825. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25826. import { Color3 } from "babylonjs/Maths/math.color";
  25827. import { Scene } from "babylonjs/scene";
  25828. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25829. import { Nullable } from "babylonjs/types";
  25830. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25831. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25832. /**
  25833. * @hidden
  25834. */
  25835. export interface IMaterialSheenDefines {
  25836. SHEEN: boolean;
  25837. SHEEN_TEXTURE: boolean;
  25838. SHEEN_TEXTUREDIRECTUV: number;
  25839. SHEEN_LINKWITHALBEDO: boolean;
  25840. SHEEN_ROUGHNESS: boolean;
  25841. SHEEN_ALBEDOSCALING: boolean;
  25842. /** @hidden */
  25843. _areTexturesDirty: boolean;
  25844. }
  25845. /**
  25846. * Define the code related to the Sheen parameters of the pbr material.
  25847. */
  25848. export class PBRSheenConfiguration {
  25849. private _isEnabled;
  25850. /**
  25851. * Defines if the material uses sheen.
  25852. */
  25853. isEnabled: boolean;
  25854. private _linkSheenWithAlbedo;
  25855. /**
  25856. * Defines if the sheen is linked to the sheen color.
  25857. */
  25858. linkSheenWithAlbedo: boolean;
  25859. /**
  25860. * Defines the sheen intensity.
  25861. */
  25862. intensity: number;
  25863. /**
  25864. * Defines the sheen color.
  25865. */
  25866. color: Color3;
  25867. private _texture;
  25868. /**
  25869. * Stores the sheen tint values in a texture.
  25870. * rgb is tint
  25871. * a is a intensity or roughness if roughness has been defined
  25872. */
  25873. texture: Nullable<BaseTexture>;
  25874. private _roughness;
  25875. /**
  25876. * Defines the sheen roughness.
  25877. * It is not taken into account if linkSheenWithAlbedo is true.
  25878. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25879. */
  25880. roughness: Nullable<number>;
  25881. private _albedoScaling;
  25882. /**
  25883. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25884. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25885. * making it easier to setup and tweak the effect
  25886. */
  25887. albedoScaling: boolean;
  25888. /** @hidden */
  25889. private _internalMarkAllSubMeshesAsTexturesDirty;
  25890. /** @hidden */
  25891. _markAllSubMeshesAsTexturesDirty(): void;
  25892. /**
  25893. * Instantiate a new istance of clear coat configuration.
  25894. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25895. */
  25896. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25897. /**
  25898. * Specifies that the submesh is ready to be used.
  25899. * @param defines the list of "defines" to update.
  25900. * @param scene defines the scene the material belongs to.
  25901. * @returns - boolean indicating that the submesh is ready or not.
  25902. */
  25903. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25904. /**
  25905. * Checks to see if a texture is used in the material.
  25906. * @param defines the list of "defines" to update.
  25907. * @param scene defines the scene the material belongs to.
  25908. */
  25909. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25910. /**
  25911. * Binds the material data.
  25912. * @param uniformBuffer defines the Uniform buffer to fill in.
  25913. * @param scene defines the scene the material belongs to.
  25914. * @param isFrozen defines wether the material is frozen or not.
  25915. */
  25916. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25917. /**
  25918. * Checks to see if a texture is used in the material.
  25919. * @param texture - Base texture to use.
  25920. * @returns - Boolean specifying if a texture is used in the material.
  25921. */
  25922. hasTexture(texture: BaseTexture): boolean;
  25923. /**
  25924. * Returns an array of the actively used textures.
  25925. * @param activeTextures Array of BaseTextures
  25926. */
  25927. getActiveTextures(activeTextures: BaseTexture[]): void;
  25928. /**
  25929. * Returns the animatable textures.
  25930. * @param animatables Array of animatable textures.
  25931. */
  25932. getAnimatables(animatables: IAnimatable[]): void;
  25933. /**
  25934. * Disposes the resources of the material.
  25935. * @param forceDisposeTextures - Forces the disposal of all textures.
  25936. */
  25937. dispose(forceDisposeTextures?: boolean): void;
  25938. /**
  25939. * Get the current class name of the texture useful for serialization or dynamic coding.
  25940. * @returns "PBRSheenConfiguration"
  25941. */
  25942. getClassName(): string;
  25943. /**
  25944. * Add fallbacks to the effect fallbacks list.
  25945. * @param defines defines the Base texture to use.
  25946. * @param fallbacks defines the current fallback list.
  25947. * @param currentRank defines the current fallback rank.
  25948. * @returns the new fallback rank.
  25949. */
  25950. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25951. /**
  25952. * Add the required uniforms to the current list.
  25953. * @param uniforms defines the current uniform list.
  25954. */
  25955. static AddUniforms(uniforms: string[]): void;
  25956. /**
  25957. * Add the required uniforms to the current buffer.
  25958. * @param uniformBuffer defines the current uniform buffer.
  25959. */
  25960. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25961. /**
  25962. * Add the required samplers to the current list.
  25963. * @param samplers defines the current sampler list.
  25964. */
  25965. static AddSamplers(samplers: string[]): void;
  25966. /**
  25967. * Makes a duplicate of the current configuration into another one.
  25968. * @param sheenConfiguration define the config where to copy the info
  25969. */
  25970. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  25971. /**
  25972. * Serializes this BRDF configuration.
  25973. * @returns - An object with the serialized config.
  25974. */
  25975. serialize(): any;
  25976. /**
  25977. * Parses a anisotropy Configuration from a serialized object.
  25978. * @param source - Serialized object.
  25979. * @param scene Defines the scene we are parsing for
  25980. * @param rootUrl Defines the rootUrl to load from
  25981. */
  25982. parse(source: any, scene: Scene, rootUrl: string): void;
  25983. }
  25984. }
  25985. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  25986. import { Nullable } from "babylonjs/types";
  25987. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25988. import { Color3 } from "babylonjs/Maths/math.color";
  25989. import { SmartArray } from "babylonjs/Misc/smartArray";
  25990. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25991. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25992. import { Effect } from "babylonjs/Materials/effect";
  25993. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25994. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25995. import { Engine } from "babylonjs/Engines/engine";
  25996. import { Scene } from "babylonjs/scene";
  25997. /**
  25998. * @hidden
  25999. */
  26000. export interface IMaterialSubSurfaceDefines {
  26001. SUBSURFACE: boolean;
  26002. SS_REFRACTION: boolean;
  26003. SS_TRANSLUCENCY: boolean;
  26004. SS_SCATTERING: boolean;
  26005. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26006. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26007. SS_REFRACTIONMAP_3D: boolean;
  26008. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26009. SS_LODINREFRACTIONALPHA: boolean;
  26010. SS_GAMMAREFRACTION: boolean;
  26011. SS_RGBDREFRACTION: boolean;
  26012. SS_LINEARSPECULARREFRACTION: boolean;
  26013. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26014. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26015. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26016. /** @hidden */
  26017. _areTexturesDirty: boolean;
  26018. }
  26019. /**
  26020. * Define the code related to the sub surface parameters of the pbr material.
  26021. */
  26022. export class PBRSubSurfaceConfiguration {
  26023. private _isRefractionEnabled;
  26024. /**
  26025. * Defines if the refraction is enabled in the material.
  26026. */
  26027. isRefractionEnabled: boolean;
  26028. private _isTranslucencyEnabled;
  26029. /**
  26030. * Defines if the translucency is enabled in the material.
  26031. */
  26032. isTranslucencyEnabled: boolean;
  26033. private _isScatteringEnabled;
  26034. /**
  26035. * Defines if the sub surface scattering is enabled in the material.
  26036. */
  26037. isScatteringEnabled: boolean;
  26038. private _scatteringDiffusionProfileIndex;
  26039. /**
  26040. * Diffusion profile for subsurface scattering.
  26041. * Useful for better scattering in the skins or foliages.
  26042. */
  26043. get scatteringDiffusionProfile(): Nullable<Color3>;
  26044. set scatteringDiffusionProfile(c: Nullable<Color3>);
  26045. /**
  26046. * Defines the refraction intensity of the material.
  26047. * The refraction when enabled replaces the Diffuse part of the material.
  26048. * The intensity helps transitionning between diffuse and refraction.
  26049. */
  26050. refractionIntensity: number;
  26051. /**
  26052. * Defines the translucency intensity of the material.
  26053. * When translucency has been enabled, this defines how much of the "translucency"
  26054. * is addded to the diffuse part of the material.
  26055. */
  26056. translucencyIntensity: number;
  26057. /**
  26058. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  26059. */
  26060. useAlbedoToTintRefraction: boolean;
  26061. private _thicknessTexture;
  26062. /**
  26063. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  26064. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  26065. * 0 would mean minimumThickness
  26066. * 1 would mean maximumThickness
  26067. * The other channels might be use as a mask to vary the different effects intensity.
  26068. */
  26069. thicknessTexture: Nullable<BaseTexture>;
  26070. private _refractionTexture;
  26071. /**
  26072. * Defines the texture to use for refraction.
  26073. */
  26074. refractionTexture: Nullable<BaseTexture>;
  26075. private _indexOfRefraction;
  26076. /**
  26077. * Index of refraction of the material base layer.
  26078. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26079. *
  26080. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26081. *
  26082. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26083. */
  26084. indexOfRefraction: number;
  26085. private _volumeIndexOfRefraction;
  26086. /**
  26087. * Index of refraction of the material's volume.
  26088. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26089. *
  26090. * This ONLY impacts refraction. If not provided or given a non-valid value,
  26091. * the volume will use the same IOR as the surface.
  26092. */
  26093. get volumeIndexOfRefraction(): number;
  26094. set volumeIndexOfRefraction(value: number);
  26095. private _invertRefractionY;
  26096. /**
  26097. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26098. */
  26099. invertRefractionY: boolean;
  26100. private _linkRefractionWithTransparency;
  26101. /**
  26102. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26103. * Materials half opaque for instance using refraction could benefit from this control.
  26104. */
  26105. linkRefractionWithTransparency: boolean;
  26106. /**
  26107. * Defines the minimum thickness stored in the thickness map.
  26108. * If no thickness map is defined, this value will be used to simulate thickness.
  26109. */
  26110. minimumThickness: number;
  26111. /**
  26112. * Defines the maximum thickness stored in the thickness map.
  26113. */
  26114. maximumThickness: number;
  26115. /**
  26116. * Defines the volume tint of the material.
  26117. * This is used for both translucency and scattering.
  26118. */
  26119. tintColor: Color3;
  26120. /**
  26121. * Defines the distance at which the tint color should be found in the media.
  26122. * This is used for refraction only.
  26123. */
  26124. tintColorAtDistance: number;
  26125. /**
  26126. * Defines how far each channel transmit through the media.
  26127. * It is defined as a color to simplify it selection.
  26128. */
  26129. diffusionDistance: Color3;
  26130. private _useMaskFromThicknessTexture;
  26131. /**
  26132. * Stores the intensity of the different subsurface effects in the thickness texture.
  26133. * * the green channel is the translucency intensity.
  26134. * * the blue channel is the scattering intensity.
  26135. * * the alpha channel is the refraction intensity.
  26136. */
  26137. useMaskFromThicknessTexture: boolean;
  26138. private _scene;
  26139. /** @hidden */
  26140. private _internalMarkAllSubMeshesAsTexturesDirty;
  26141. private _internalMarkScenePrePassDirty;
  26142. /** @hidden */
  26143. _markAllSubMeshesAsTexturesDirty(): void;
  26144. /** @hidden */
  26145. _markScenePrePassDirty(): void;
  26146. /**
  26147. * Instantiate a new istance of sub surface configuration.
  26148. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  26149. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  26150. * @param scene The scene
  26151. */
  26152. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  26153. /**
  26154. * Gets wehter the submesh is ready to be used or not.
  26155. * @param defines the list of "defines" to update.
  26156. * @param scene defines the scene the material belongs to.
  26157. * @returns - boolean indicating that the submesh is ready or not.
  26158. */
  26159. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  26160. /**
  26161. * Checks to see if a texture is used in the material.
  26162. * @param defines the list of "defines" to update.
  26163. * @param scene defines the scene to the material belongs to.
  26164. */
  26165. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  26166. /**
  26167. * Binds the material data.
  26168. * @param uniformBuffer defines the Uniform buffer to fill in.
  26169. * @param scene defines the scene the material belongs to.
  26170. * @param engine defines the engine the material belongs to.
  26171. * @param isFrozen defines whether the material is frozen or not.
  26172. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  26173. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  26174. */
  26175. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  26176. /**
  26177. * Unbinds the material from the mesh.
  26178. * @param activeEffect defines the effect that should be unbound from.
  26179. * @returns true if unbound, otherwise false
  26180. */
  26181. unbind(activeEffect: Effect): boolean;
  26182. /**
  26183. * Returns the texture used for refraction or null if none is used.
  26184. * @param scene defines the scene the material belongs to.
  26185. * @returns - Refraction texture if present. If no refraction texture and refraction
  26186. * is linked with transparency, returns environment texture. Otherwise, returns null.
  26187. */
  26188. private _getRefractionTexture;
  26189. /**
  26190. * Returns true if alpha blending should be disabled.
  26191. */
  26192. get disableAlphaBlending(): boolean;
  26193. /**
  26194. * Fills the list of render target textures.
  26195. * @param renderTargets the list of render targets to update
  26196. */
  26197. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  26198. /**
  26199. * Checks to see if a texture is used in the material.
  26200. * @param texture - Base texture to use.
  26201. * @returns - Boolean specifying if a texture is used in the material.
  26202. */
  26203. hasTexture(texture: BaseTexture): boolean;
  26204. /**
  26205. * Gets a boolean indicating that current material needs to register RTT
  26206. * @returns true if this uses a render target otherwise false.
  26207. */
  26208. hasRenderTargetTextures(): boolean;
  26209. /**
  26210. * Returns an array of the actively used textures.
  26211. * @param activeTextures Array of BaseTextures
  26212. */
  26213. getActiveTextures(activeTextures: BaseTexture[]): void;
  26214. /**
  26215. * Returns the animatable textures.
  26216. * @param animatables Array of animatable textures.
  26217. */
  26218. getAnimatables(animatables: IAnimatable[]): void;
  26219. /**
  26220. * Disposes the resources of the material.
  26221. * @param forceDisposeTextures - Forces the disposal of all textures.
  26222. */
  26223. dispose(forceDisposeTextures?: boolean): void;
  26224. /**
  26225. * Get the current class name of the texture useful for serialization or dynamic coding.
  26226. * @returns "PBRSubSurfaceConfiguration"
  26227. */
  26228. getClassName(): string;
  26229. /**
  26230. * Add fallbacks to the effect fallbacks list.
  26231. * @param defines defines the Base texture to use.
  26232. * @param fallbacks defines the current fallback list.
  26233. * @param currentRank defines the current fallback rank.
  26234. * @returns the new fallback rank.
  26235. */
  26236. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26237. /**
  26238. * Add the required uniforms to the current list.
  26239. * @param uniforms defines the current uniform list.
  26240. */
  26241. static AddUniforms(uniforms: string[]): void;
  26242. /**
  26243. * Add the required samplers to the current list.
  26244. * @param samplers defines the current sampler list.
  26245. */
  26246. static AddSamplers(samplers: string[]): void;
  26247. /**
  26248. * Add the required uniforms to the current buffer.
  26249. * @param uniformBuffer defines the current uniform buffer.
  26250. */
  26251. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26252. /**
  26253. * Makes a duplicate of the current configuration into another one.
  26254. * @param configuration define the config where to copy the info
  26255. */
  26256. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  26257. /**
  26258. * Serializes this Sub Surface configuration.
  26259. * @returns - An object with the serialized config.
  26260. */
  26261. serialize(): any;
  26262. /**
  26263. * Parses a anisotropy Configuration from a serialized object.
  26264. * @param source - Serialized object.
  26265. * @param scene Defines the scene we are parsing for
  26266. * @param rootUrl Defines the rootUrl to load from
  26267. */
  26268. parse(source: any, scene: Scene, rootUrl: string): void;
  26269. }
  26270. }
  26271. declare module "babylonjs/Maths/sphericalPolynomial" {
  26272. import { Vector3 } from "babylonjs/Maths/math.vector";
  26273. import { Color3 } from "babylonjs/Maths/math.color";
  26274. /**
  26275. * Class representing spherical harmonics coefficients to the 3rd degree
  26276. */
  26277. export class SphericalHarmonics {
  26278. /**
  26279. * Defines whether or not the harmonics have been prescaled for rendering.
  26280. */
  26281. preScaled: boolean;
  26282. /**
  26283. * The l0,0 coefficients of the spherical harmonics
  26284. */
  26285. l00: Vector3;
  26286. /**
  26287. * The l1,-1 coefficients of the spherical harmonics
  26288. */
  26289. l1_1: Vector3;
  26290. /**
  26291. * The l1,0 coefficients of the spherical harmonics
  26292. */
  26293. l10: Vector3;
  26294. /**
  26295. * The l1,1 coefficients of the spherical harmonics
  26296. */
  26297. l11: Vector3;
  26298. /**
  26299. * The l2,-2 coefficients of the spherical harmonics
  26300. */
  26301. l2_2: Vector3;
  26302. /**
  26303. * The l2,-1 coefficients of the spherical harmonics
  26304. */
  26305. l2_1: Vector3;
  26306. /**
  26307. * The l2,0 coefficients of the spherical harmonics
  26308. */
  26309. l20: Vector3;
  26310. /**
  26311. * The l2,1 coefficients of the spherical harmonics
  26312. */
  26313. l21: Vector3;
  26314. /**
  26315. * The l2,2 coefficients of the spherical harmonics
  26316. */
  26317. l22: Vector3;
  26318. /**
  26319. * Adds a light to the spherical harmonics
  26320. * @param direction the direction of the light
  26321. * @param color the color of the light
  26322. * @param deltaSolidAngle the delta solid angle of the light
  26323. */
  26324. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  26325. /**
  26326. * Scales the spherical harmonics by the given amount
  26327. * @param scale the amount to scale
  26328. */
  26329. scaleInPlace(scale: number): void;
  26330. /**
  26331. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  26332. *
  26333. * ```
  26334. * E_lm = A_l * L_lm
  26335. * ```
  26336. *
  26337. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  26338. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  26339. * the scaling factors are given in equation 9.
  26340. */
  26341. convertIncidentRadianceToIrradiance(): void;
  26342. /**
  26343. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  26344. *
  26345. * ```
  26346. * L = (1/pi) * E * rho
  26347. * ```
  26348. *
  26349. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  26350. */
  26351. convertIrradianceToLambertianRadiance(): void;
  26352. /**
  26353. * Integrates the reconstruction coefficients directly in to the SH preventing further
  26354. * required operations at run time.
  26355. *
  26356. * This is simply done by scaling back the SH with Ylm constants parameter.
  26357. * The trigonometric part being applied by the shader at run time.
  26358. */
  26359. preScaleForRendering(): void;
  26360. /**
  26361. * Constructs a spherical harmonics from an array.
  26362. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  26363. * @returns the spherical harmonics
  26364. */
  26365. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  26366. /**
  26367. * Gets the spherical harmonics from polynomial
  26368. * @param polynomial the spherical polynomial
  26369. * @returns the spherical harmonics
  26370. */
  26371. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  26372. }
  26373. /**
  26374. * Class representing spherical polynomial coefficients to the 3rd degree
  26375. */
  26376. export class SphericalPolynomial {
  26377. private _harmonics;
  26378. /**
  26379. * The spherical harmonics used to create the polynomials.
  26380. */
  26381. get preScaledHarmonics(): SphericalHarmonics;
  26382. /**
  26383. * The x coefficients of the spherical polynomial
  26384. */
  26385. x: Vector3;
  26386. /**
  26387. * The y coefficients of the spherical polynomial
  26388. */
  26389. y: Vector3;
  26390. /**
  26391. * The z coefficients of the spherical polynomial
  26392. */
  26393. z: Vector3;
  26394. /**
  26395. * The xx coefficients of the spherical polynomial
  26396. */
  26397. xx: Vector3;
  26398. /**
  26399. * The yy coefficients of the spherical polynomial
  26400. */
  26401. yy: Vector3;
  26402. /**
  26403. * The zz coefficients of the spherical polynomial
  26404. */
  26405. zz: Vector3;
  26406. /**
  26407. * The xy coefficients of the spherical polynomial
  26408. */
  26409. xy: Vector3;
  26410. /**
  26411. * The yz coefficients of the spherical polynomial
  26412. */
  26413. yz: Vector3;
  26414. /**
  26415. * The zx coefficients of the spherical polynomial
  26416. */
  26417. zx: Vector3;
  26418. /**
  26419. * Adds an ambient color to the spherical polynomial
  26420. * @param color the color to add
  26421. */
  26422. addAmbient(color: Color3): void;
  26423. /**
  26424. * Scales the spherical polynomial by the given amount
  26425. * @param scale the amount to scale
  26426. */
  26427. scaleInPlace(scale: number): void;
  26428. /**
  26429. * Gets the spherical polynomial from harmonics
  26430. * @param harmonics the spherical harmonics
  26431. * @returns the spherical polynomial
  26432. */
  26433. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  26434. /**
  26435. * Constructs a spherical polynomial from an array.
  26436. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  26437. * @returns the spherical polynomial
  26438. */
  26439. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  26440. }
  26441. }
  26442. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  26443. import { Nullable } from "babylonjs/types";
  26444. /**
  26445. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26446. */
  26447. export interface CubeMapInfo {
  26448. /**
  26449. * The pixel array for the front face.
  26450. * This is stored in format, left to right, up to down format.
  26451. */
  26452. front: Nullable<ArrayBufferView>;
  26453. /**
  26454. * The pixel array for the back face.
  26455. * This is stored in format, left to right, up to down format.
  26456. */
  26457. back: Nullable<ArrayBufferView>;
  26458. /**
  26459. * The pixel array for the left face.
  26460. * This is stored in format, left to right, up to down format.
  26461. */
  26462. left: Nullable<ArrayBufferView>;
  26463. /**
  26464. * The pixel array for the right face.
  26465. * This is stored in format, left to right, up to down format.
  26466. */
  26467. right: Nullable<ArrayBufferView>;
  26468. /**
  26469. * The pixel array for the up face.
  26470. * This is stored in format, left to right, up to down format.
  26471. */
  26472. up: Nullable<ArrayBufferView>;
  26473. /**
  26474. * The pixel array for the down face.
  26475. * This is stored in format, left to right, up to down format.
  26476. */
  26477. down: Nullable<ArrayBufferView>;
  26478. /**
  26479. * The size of the cubemap stored.
  26480. *
  26481. * Each faces will be size * size pixels.
  26482. */
  26483. size: number;
  26484. /**
  26485. * The format of the texture.
  26486. *
  26487. * RGBA, RGB.
  26488. */
  26489. format: number;
  26490. /**
  26491. * The type of the texture data.
  26492. *
  26493. * UNSIGNED_INT, FLOAT.
  26494. */
  26495. type: number;
  26496. /**
  26497. * Specifies whether the texture is in gamma space.
  26498. */
  26499. gammaSpace: boolean;
  26500. }
  26501. /**
  26502. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  26503. */
  26504. export class PanoramaToCubeMapTools {
  26505. private static FACE_LEFT;
  26506. private static FACE_RIGHT;
  26507. private static FACE_FRONT;
  26508. private static FACE_BACK;
  26509. private static FACE_DOWN;
  26510. private static FACE_UP;
  26511. /**
  26512. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  26513. *
  26514. * @param float32Array The source data.
  26515. * @param inputWidth The width of the input panorama.
  26516. * @param inputHeight The height of the input panorama.
  26517. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  26518. * @return The cubemap data
  26519. */
  26520. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  26521. private static CreateCubemapTexture;
  26522. private static CalcProjectionSpherical;
  26523. }
  26524. }
  26525. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  26526. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26527. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26528. import { Nullable } from "babylonjs/types";
  26529. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  26530. /**
  26531. * Helper class dealing with the extraction of spherical polynomial dataArray
  26532. * from a cube map.
  26533. */
  26534. export class CubeMapToSphericalPolynomialTools {
  26535. private static FileFaces;
  26536. /**
  26537. * Converts a texture to the according Spherical Polynomial data.
  26538. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26539. *
  26540. * @param texture The texture to extract the information from.
  26541. * @return The Spherical Polynomial data.
  26542. */
  26543. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  26544. /**
  26545. * Converts a cubemap to the according Spherical Polynomial data.
  26546. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26547. *
  26548. * @param cubeInfo The Cube map to extract the information from.
  26549. * @return The Spherical Polynomial data.
  26550. */
  26551. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  26552. }
  26553. }
  26554. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  26555. import { Nullable } from "babylonjs/types";
  26556. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26557. module "babylonjs/Materials/Textures/baseTexture" {
  26558. interface BaseTexture {
  26559. /**
  26560. * Get the polynomial representation of the texture data.
  26561. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26562. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26563. */
  26564. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26565. }
  26566. }
  26567. }
  26568. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  26569. /** @hidden */
  26570. export var pbrFragmentDeclaration: {
  26571. name: string;
  26572. shader: string;
  26573. };
  26574. }
  26575. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  26576. /** @hidden */
  26577. export var pbrUboDeclaration: {
  26578. name: string;
  26579. shader: string;
  26580. };
  26581. }
  26582. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  26583. /** @hidden */
  26584. export var pbrFragmentExtraDeclaration: {
  26585. name: string;
  26586. shader: string;
  26587. };
  26588. }
  26589. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  26590. /** @hidden */
  26591. export var pbrFragmentSamplersDeclaration: {
  26592. name: string;
  26593. shader: string;
  26594. };
  26595. }
  26596. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  26597. /** @hidden */
  26598. export var subSurfaceScatteringFunctions: {
  26599. name: string;
  26600. shader: string;
  26601. };
  26602. }
  26603. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  26604. /** @hidden */
  26605. export var importanceSampling: {
  26606. name: string;
  26607. shader: string;
  26608. };
  26609. }
  26610. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  26611. /** @hidden */
  26612. export var pbrHelperFunctions: {
  26613. name: string;
  26614. shader: string;
  26615. };
  26616. }
  26617. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  26618. /** @hidden */
  26619. export var harmonicsFunctions: {
  26620. name: string;
  26621. shader: string;
  26622. };
  26623. }
  26624. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  26625. /** @hidden */
  26626. export var pbrDirectLightingSetupFunctions: {
  26627. name: string;
  26628. shader: string;
  26629. };
  26630. }
  26631. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  26632. /** @hidden */
  26633. export var pbrDirectLightingFalloffFunctions: {
  26634. name: string;
  26635. shader: string;
  26636. };
  26637. }
  26638. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  26639. /** @hidden */
  26640. export var pbrBRDFFunctions: {
  26641. name: string;
  26642. shader: string;
  26643. };
  26644. }
  26645. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  26646. /** @hidden */
  26647. export var hdrFilteringFunctions: {
  26648. name: string;
  26649. shader: string;
  26650. };
  26651. }
  26652. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  26653. /** @hidden */
  26654. export var pbrDirectLightingFunctions: {
  26655. name: string;
  26656. shader: string;
  26657. };
  26658. }
  26659. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  26660. /** @hidden */
  26661. export var pbrIBLFunctions: {
  26662. name: string;
  26663. shader: string;
  26664. };
  26665. }
  26666. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  26667. /** @hidden */
  26668. export var pbrBlockAlbedoOpacity: {
  26669. name: string;
  26670. shader: string;
  26671. };
  26672. }
  26673. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  26674. /** @hidden */
  26675. export var pbrBlockReflectivity: {
  26676. name: string;
  26677. shader: string;
  26678. };
  26679. }
  26680. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  26681. /** @hidden */
  26682. export var pbrBlockAmbientOcclusion: {
  26683. name: string;
  26684. shader: string;
  26685. };
  26686. }
  26687. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  26688. /** @hidden */
  26689. export var pbrBlockAlphaFresnel: {
  26690. name: string;
  26691. shader: string;
  26692. };
  26693. }
  26694. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  26695. /** @hidden */
  26696. export var pbrBlockAnisotropic: {
  26697. name: string;
  26698. shader: string;
  26699. };
  26700. }
  26701. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  26702. /** @hidden */
  26703. export var pbrBlockReflection: {
  26704. name: string;
  26705. shader: string;
  26706. };
  26707. }
  26708. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  26709. /** @hidden */
  26710. export var pbrBlockSheen: {
  26711. name: string;
  26712. shader: string;
  26713. };
  26714. }
  26715. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  26716. /** @hidden */
  26717. export var pbrBlockClearcoat: {
  26718. name: string;
  26719. shader: string;
  26720. };
  26721. }
  26722. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  26723. /** @hidden */
  26724. export var pbrBlockSubSurface: {
  26725. name: string;
  26726. shader: string;
  26727. };
  26728. }
  26729. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  26730. /** @hidden */
  26731. export var pbrBlockNormalGeometric: {
  26732. name: string;
  26733. shader: string;
  26734. };
  26735. }
  26736. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  26737. /** @hidden */
  26738. export var pbrBlockNormalFinal: {
  26739. name: string;
  26740. shader: string;
  26741. };
  26742. }
  26743. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  26744. /** @hidden */
  26745. export var pbrBlockLightmapInit: {
  26746. name: string;
  26747. shader: string;
  26748. };
  26749. }
  26750. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  26751. /** @hidden */
  26752. export var pbrBlockGeometryInfo: {
  26753. name: string;
  26754. shader: string;
  26755. };
  26756. }
  26757. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  26758. /** @hidden */
  26759. export var pbrBlockReflectance0: {
  26760. name: string;
  26761. shader: string;
  26762. };
  26763. }
  26764. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  26765. /** @hidden */
  26766. export var pbrBlockReflectance: {
  26767. name: string;
  26768. shader: string;
  26769. };
  26770. }
  26771. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  26772. /** @hidden */
  26773. export var pbrBlockDirectLighting: {
  26774. name: string;
  26775. shader: string;
  26776. };
  26777. }
  26778. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  26779. /** @hidden */
  26780. export var pbrBlockFinalLitComponents: {
  26781. name: string;
  26782. shader: string;
  26783. };
  26784. }
  26785. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  26786. /** @hidden */
  26787. export var pbrBlockFinalUnlitComponents: {
  26788. name: string;
  26789. shader: string;
  26790. };
  26791. }
  26792. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  26793. /** @hidden */
  26794. export var pbrBlockFinalColorComposition: {
  26795. name: string;
  26796. shader: string;
  26797. };
  26798. }
  26799. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  26800. /** @hidden */
  26801. export var pbrBlockImageProcessing: {
  26802. name: string;
  26803. shader: string;
  26804. };
  26805. }
  26806. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  26807. /** @hidden */
  26808. export var pbrDebug: {
  26809. name: string;
  26810. shader: string;
  26811. };
  26812. }
  26813. declare module "babylonjs/Shaders/pbr.fragment" {
  26814. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  26815. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  26816. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26817. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  26818. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26819. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26820. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  26821. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26822. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26823. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26824. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26825. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26826. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  26827. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  26828. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  26829. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26830. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26831. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26832. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  26833. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  26834. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  26835. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  26836. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  26837. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  26838. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  26839. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26840. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26841. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  26842. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  26843. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  26844. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  26845. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  26846. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  26847. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  26848. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  26849. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  26850. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26851. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  26852. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26853. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  26854. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26855. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  26856. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  26857. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  26858. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  26859. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  26860. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26861. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  26862. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  26863. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  26864. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26865. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26866. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  26867. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  26868. /** @hidden */
  26869. export var pbrPixelShader: {
  26870. name: string;
  26871. shader: string;
  26872. };
  26873. }
  26874. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  26875. /** @hidden */
  26876. export var pbrVertexDeclaration: {
  26877. name: string;
  26878. shader: string;
  26879. };
  26880. }
  26881. declare module "babylonjs/Shaders/pbr.vertex" {
  26882. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  26883. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26884. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26885. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26886. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26887. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  26888. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26889. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26890. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26891. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26892. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26893. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26894. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26895. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26896. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26897. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26898. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26899. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26900. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  26901. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26902. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26903. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26904. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26905. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26906. /** @hidden */
  26907. export var pbrVertexShader: {
  26908. name: string;
  26909. shader: string;
  26910. };
  26911. }
  26912. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  26913. import { Nullable } from "babylonjs/types";
  26914. import { Scene } from "babylonjs/scene";
  26915. import { Matrix } from "babylonjs/Maths/math.vector";
  26916. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26918. import { Mesh } from "babylonjs/Meshes/mesh";
  26919. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  26920. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  26921. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  26922. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  26923. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  26924. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  26925. import { Color3 } from "babylonjs/Maths/math.color";
  26926. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26927. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  26928. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26929. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26930. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26931. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26932. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  26933. import "babylonjs/Shaders/pbr.fragment";
  26934. import "babylonjs/Shaders/pbr.vertex";
  26935. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  26936. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  26937. /**
  26938. * Manages the defines for the PBR Material.
  26939. * @hidden
  26940. */
  26941. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  26942. PBR: boolean;
  26943. NUM_SAMPLES: string;
  26944. REALTIME_FILTERING: boolean;
  26945. MAINUV1: boolean;
  26946. MAINUV2: boolean;
  26947. UV1: boolean;
  26948. UV2: boolean;
  26949. ALBEDO: boolean;
  26950. GAMMAALBEDO: boolean;
  26951. ALBEDODIRECTUV: number;
  26952. VERTEXCOLOR: boolean;
  26953. DETAIL: boolean;
  26954. DETAILDIRECTUV: number;
  26955. DETAIL_NORMALBLENDMETHOD: number;
  26956. AMBIENT: boolean;
  26957. AMBIENTDIRECTUV: number;
  26958. AMBIENTINGRAYSCALE: boolean;
  26959. OPACITY: boolean;
  26960. VERTEXALPHA: boolean;
  26961. OPACITYDIRECTUV: number;
  26962. OPACITYRGB: boolean;
  26963. ALPHATEST: boolean;
  26964. DEPTHPREPASS: boolean;
  26965. ALPHABLEND: boolean;
  26966. ALPHAFROMALBEDO: boolean;
  26967. ALPHATESTVALUE: string;
  26968. SPECULAROVERALPHA: boolean;
  26969. RADIANCEOVERALPHA: boolean;
  26970. ALPHAFRESNEL: boolean;
  26971. LINEARALPHAFRESNEL: boolean;
  26972. PREMULTIPLYALPHA: boolean;
  26973. EMISSIVE: boolean;
  26974. EMISSIVEDIRECTUV: number;
  26975. REFLECTIVITY: boolean;
  26976. REFLECTIVITYDIRECTUV: number;
  26977. SPECULARTERM: boolean;
  26978. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  26979. MICROSURFACEAUTOMATIC: boolean;
  26980. LODBASEDMICROSFURACE: boolean;
  26981. MICROSURFACEMAP: boolean;
  26982. MICROSURFACEMAPDIRECTUV: number;
  26983. METALLICWORKFLOW: boolean;
  26984. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  26985. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  26986. METALLNESSSTOREINMETALMAPBLUE: boolean;
  26987. AOSTOREINMETALMAPRED: boolean;
  26988. METALLIC_REFLECTANCE: boolean;
  26989. METALLIC_REFLECTANCEDIRECTUV: number;
  26990. ENVIRONMENTBRDF: boolean;
  26991. ENVIRONMENTBRDF_RGBD: boolean;
  26992. NORMAL: boolean;
  26993. TANGENT: boolean;
  26994. BUMP: boolean;
  26995. BUMPDIRECTUV: number;
  26996. OBJECTSPACE_NORMALMAP: boolean;
  26997. PARALLAX: boolean;
  26998. PARALLAXOCCLUSION: boolean;
  26999. NORMALXYSCALE: boolean;
  27000. LIGHTMAP: boolean;
  27001. LIGHTMAPDIRECTUV: number;
  27002. USELIGHTMAPASSHADOWMAP: boolean;
  27003. GAMMALIGHTMAP: boolean;
  27004. RGBDLIGHTMAP: boolean;
  27005. REFLECTION: boolean;
  27006. REFLECTIONMAP_3D: boolean;
  27007. REFLECTIONMAP_SPHERICAL: boolean;
  27008. REFLECTIONMAP_PLANAR: boolean;
  27009. REFLECTIONMAP_CUBIC: boolean;
  27010. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27011. REFLECTIONMAP_PROJECTION: boolean;
  27012. REFLECTIONMAP_SKYBOX: boolean;
  27013. REFLECTIONMAP_EXPLICIT: boolean;
  27014. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27015. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27016. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27017. INVERTCUBICMAP: boolean;
  27018. USESPHERICALFROMREFLECTIONMAP: boolean;
  27019. USEIRRADIANCEMAP: boolean;
  27020. SPHERICAL_HARMONICS: boolean;
  27021. USESPHERICALINVERTEX: boolean;
  27022. REFLECTIONMAP_OPPOSITEZ: boolean;
  27023. LODINREFLECTIONALPHA: boolean;
  27024. GAMMAREFLECTION: boolean;
  27025. RGBDREFLECTION: boolean;
  27026. LINEARSPECULARREFLECTION: boolean;
  27027. RADIANCEOCCLUSION: boolean;
  27028. HORIZONOCCLUSION: boolean;
  27029. INSTANCES: boolean;
  27030. THIN_INSTANCES: boolean;
  27031. PREPASS: boolean;
  27032. PREPASS_IRRADIANCE: boolean;
  27033. PREPASS_IRRADIANCE_INDEX: number;
  27034. PREPASS_ALBEDO: boolean;
  27035. PREPASS_ALBEDO_INDEX: number;
  27036. PREPASS_DEPTHNORMAL: boolean;
  27037. PREPASS_DEPTHNORMAL_INDEX: number;
  27038. PREPASS_POSITION: boolean;
  27039. PREPASS_POSITION_INDEX: number;
  27040. PREPASS_VELOCITY: boolean;
  27041. PREPASS_VELOCITY_INDEX: number;
  27042. PREPASS_REFLECTIVITY: boolean;
  27043. PREPASS_REFLECTIVITY_INDEX: number;
  27044. SCENE_MRT_COUNT: number;
  27045. NUM_BONE_INFLUENCERS: number;
  27046. BonesPerMesh: number;
  27047. BONETEXTURE: boolean;
  27048. BONES_VELOCITY_ENABLED: boolean;
  27049. NONUNIFORMSCALING: boolean;
  27050. MORPHTARGETS: boolean;
  27051. MORPHTARGETS_NORMAL: boolean;
  27052. MORPHTARGETS_TANGENT: boolean;
  27053. MORPHTARGETS_UV: boolean;
  27054. NUM_MORPH_INFLUENCERS: number;
  27055. IMAGEPROCESSING: boolean;
  27056. VIGNETTE: boolean;
  27057. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27058. VIGNETTEBLENDMODEOPAQUE: boolean;
  27059. TONEMAPPING: boolean;
  27060. TONEMAPPING_ACES: boolean;
  27061. CONTRAST: boolean;
  27062. COLORCURVES: boolean;
  27063. COLORGRADING: boolean;
  27064. COLORGRADING3D: boolean;
  27065. SAMPLER3DGREENDEPTH: boolean;
  27066. SAMPLER3DBGRMAP: boolean;
  27067. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27068. EXPOSURE: boolean;
  27069. MULTIVIEW: boolean;
  27070. USEPHYSICALLIGHTFALLOFF: boolean;
  27071. USEGLTFLIGHTFALLOFF: boolean;
  27072. TWOSIDEDLIGHTING: boolean;
  27073. SHADOWFLOAT: boolean;
  27074. CLIPPLANE: boolean;
  27075. CLIPPLANE2: boolean;
  27076. CLIPPLANE3: boolean;
  27077. CLIPPLANE4: boolean;
  27078. CLIPPLANE5: boolean;
  27079. CLIPPLANE6: boolean;
  27080. POINTSIZE: boolean;
  27081. FOG: boolean;
  27082. LOGARITHMICDEPTH: boolean;
  27083. FORCENORMALFORWARD: boolean;
  27084. SPECULARAA: boolean;
  27085. CLEARCOAT: boolean;
  27086. CLEARCOAT_DEFAULTIOR: boolean;
  27087. CLEARCOAT_TEXTURE: boolean;
  27088. CLEARCOAT_TEXTUREDIRECTUV: number;
  27089. CLEARCOAT_BUMP: boolean;
  27090. CLEARCOAT_BUMPDIRECTUV: number;
  27091. CLEARCOAT_REMAP_F0: boolean;
  27092. CLEARCOAT_TINT: boolean;
  27093. CLEARCOAT_TINT_TEXTURE: boolean;
  27094. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  27095. ANISOTROPIC: boolean;
  27096. ANISOTROPIC_TEXTURE: boolean;
  27097. ANISOTROPIC_TEXTUREDIRECTUV: number;
  27098. BRDF_V_HEIGHT_CORRELATED: boolean;
  27099. MS_BRDF_ENERGY_CONSERVATION: boolean;
  27100. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  27101. SHEEN: boolean;
  27102. SHEEN_TEXTURE: boolean;
  27103. SHEEN_TEXTUREDIRECTUV: number;
  27104. SHEEN_LINKWITHALBEDO: boolean;
  27105. SHEEN_ROUGHNESS: boolean;
  27106. SHEEN_ALBEDOSCALING: boolean;
  27107. SUBSURFACE: boolean;
  27108. SS_REFRACTION: boolean;
  27109. SS_TRANSLUCENCY: boolean;
  27110. SS_SCATTERING: boolean;
  27111. SS_THICKNESSANDMASK_TEXTURE: boolean;
  27112. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  27113. SS_REFRACTIONMAP_3D: boolean;
  27114. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  27115. SS_LODINREFRACTIONALPHA: boolean;
  27116. SS_GAMMAREFRACTION: boolean;
  27117. SS_RGBDREFRACTION: boolean;
  27118. SS_LINEARSPECULARREFRACTION: boolean;
  27119. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  27120. SS_ALBEDOFORREFRACTIONTINT: boolean;
  27121. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  27122. UNLIT: boolean;
  27123. DEBUGMODE: number;
  27124. /**
  27125. * Initializes the PBR Material defines.
  27126. */
  27127. constructor();
  27128. /**
  27129. * Resets the PBR Material defines.
  27130. */
  27131. reset(): void;
  27132. }
  27133. /**
  27134. * The Physically based material base class of BJS.
  27135. *
  27136. * This offers the main features of a standard PBR material.
  27137. * For more information, please refer to the documentation :
  27138. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27139. */
  27140. export abstract class PBRBaseMaterial extends PushMaterial {
  27141. /**
  27142. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27143. */
  27144. static readonly PBRMATERIAL_OPAQUE: number;
  27145. /**
  27146. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27147. */
  27148. static readonly PBRMATERIAL_ALPHATEST: number;
  27149. /**
  27150. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27151. */
  27152. static readonly PBRMATERIAL_ALPHABLEND: number;
  27153. /**
  27154. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27155. * They are also discarded below the alpha cutoff threshold to improve performances.
  27156. */
  27157. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27158. /**
  27159. * Defines the default value of how much AO map is occluding the analytical lights
  27160. * (point spot...).
  27161. */
  27162. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27163. /**
  27164. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  27165. */
  27166. static readonly LIGHTFALLOFF_PHYSICAL: number;
  27167. /**
  27168. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  27169. * to enhance interoperability with other engines.
  27170. */
  27171. static readonly LIGHTFALLOFF_GLTF: number;
  27172. /**
  27173. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  27174. * to enhance interoperability with other materials.
  27175. */
  27176. static readonly LIGHTFALLOFF_STANDARD: number;
  27177. /**
  27178. * Intensity of the direct lights e.g. the four lights available in your scene.
  27179. * This impacts both the direct diffuse and specular highlights.
  27180. */
  27181. protected _directIntensity: number;
  27182. /**
  27183. * Intensity of the emissive part of the material.
  27184. * This helps controlling the emissive effect without modifying the emissive color.
  27185. */
  27186. protected _emissiveIntensity: number;
  27187. /**
  27188. * Intensity of the environment e.g. how much the environment will light the object
  27189. * either through harmonics for rough material or through the refelction for shiny ones.
  27190. */
  27191. protected _environmentIntensity: number;
  27192. /**
  27193. * This is a special control allowing the reduction of the specular highlights coming from the
  27194. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27195. */
  27196. protected _specularIntensity: number;
  27197. /**
  27198. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  27199. */
  27200. private _lightingInfos;
  27201. /**
  27202. * Debug Control allowing disabling the bump map on this material.
  27203. */
  27204. protected _disableBumpMap: boolean;
  27205. /**
  27206. * AKA Diffuse Texture in standard nomenclature.
  27207. */
  27208. protected _albedoTexture: Nullable<BaseTexture>;
  27209. /**
  27210. * AKA Occlusion Texture in other nomenclature.
  27211. */
  27212. protected _ambientTexture: Nullable<BaseTexture>;
  27213. /**
  27214. * AKA Occlusion Texture Intensity in other nomenclature.
  27215. */
  27216. protected _ambientTextureStrength: number;
  27217. /**
  27218. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27219. * 1 means it completely occludes it
  27220. * 0 mean it has no impact
  27221. */
  27222. protected _ambientTextureImpactOnAnalyticalLights: number;
  27223. /**
  27224. * Stores the alpha values in a texture.
  27225. */
  27226. protected _opacityTexture: Nullable<BaseTexture>;
  27227. /**
  27228. * Stores the reflection values in a texture.
  27229. */
  27230. protected _reflectionTexture: Nullable<BaseTexture>;
  27231. /**
  27232. * Stores the emissive values in a texture.
  27233. */
  27234. protected _emissiveTexture: Nullable<BaseTexture>;
  27235. /**
  27236. * AKA Specular texture in other nomenclature.
  27237. */
  27238. protected _reflectivityTexture: Nullable<BaseTexture>;
  27239. /**
  27240. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27241. */
  27242. protected _metallicTexture: Nullable<BaseTexture>;
  27243. /**
  27244. * Specifies the metallic scalar of the metallic/roughness workflow.
  27245. * Can also be used to scale the metalness values of the metallic texture.
  27246. */
  27247. protected _metallic: Nullable<number>;
  27248. /**
  27249. * Specifies the roughness scalar of the metallic/roughness workflow.
  27250. * Can also be used to scale the roughness values of the metallic texture.
  27251. */
  27252. protected _roughness: Nullable<number>;
  27253. /**
  27254. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27255. * By default the indexOfrefraction is used to compute F0;
  27256. *
  27257. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27258. *
  27259. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27260. * F90 = metallicReflectanceColor;
  27261. */
  27262. protected _metallicF0Factor: number;
  27263. /**
  27264. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27265. * By default the F90 is always 1;
  27266. *
  27267. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27268. *
  27269. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27270. * F90 = metallicReflectanceColor;
  27271. */
  27272. protected _metallicReflectanceColor: Color3;
  27273. /**
  27274. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27275. * This is multiply against the scalar values defined in the material.
  27276. */
  27277. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  27278. /**
  27279. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27280. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27281. */
  27282. protected _microSurfaceTexture: Nullable<BaseTexture>;
  27283. /**
  27284. * Stores surface normal data used to displace a mesh in a texture.
  27285. */
  27286. protected _bumpTexture: Nullable<BaseTexture>;
  27287. /**
  27288. * Stores the pre-calculated light information of a mesh in a texture.
  27289. */
  27290. protected _lightmapTexture: Nullable<BaseTexture>;
  27291. /**
  27292. * The color of a material in ambient lighting.
  27293. */
  27294. protected _ambientColor: Color3;
  27295. /**
  27296. * AKA Diffuse Color in other nomenclature.
  27297. */
  27298. protected _albedoColor: Color3;
  27299. /**
  27300. * AKA Specular Color in other nomenclature.
  27301. */
  27302. protected _reflectivityColor: Color3;
  27303. /**
  27304. * The color applied when light is reflected from a material.
  27305. */
  27306. protected _reflectionColor: Color3;
  27307. /**
  27308. * The color applied when light is emitted from a material.
  27309. */
  27310. protected _emissiveColor: Color3;
  27311. /**
  27312. * AKA Glossiness in other nomenclature.
  27313. */
  27314. protected _microSurface: number;
  27315. /**
  27316. * Specifies that the material will use the light map as a show map.
  27317. */
  27318. protected _useLightmapAsShadowmap: boolean;
  27319. /**
  27320. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27321. * makes the reflect vector face the model (under horizon).
  27322. */
  27323. protected _useHorizonOcclusion: boolean;
  27324. /**
  27325. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27326. * too much the area relying on ambient texture to define their ambient occlusion.
  27327. */
  27328. protected _useRadianceOcclusion: boolean;
  27329. /**
  27330. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27331. */
  27332. protected _useAlphaFromAlbedoTexture: boolean;
  27333. /**
  27334. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  27335. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27336. */
  27337. protected _useSpecularOverAlpha: boolean;
  27338. /**
  27339. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27340. */
  27341. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27342. /**
  27343. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27344. */
  27345. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  27346. /**
  27347. * Specifies if the metallic texture contains the roughness information in its green channel.
  27348. */
  27349. protected _useRoughnessFromMetallicTextureGreen: boolean;
  27350. /**
  27351. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27352. */
  27353. protected _useMetallnessFromMetallicTextureBlue: boolean;
  27354. /**
  27355. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27356. */
  27357. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  27358. /**
  27359. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27360. */
  27361. protected _useAmbientInGrayScale: boolean;
  27362. /**
  27363. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27364. * The material will try to infer what glossiness each pixel should be.
  27365. */
  27366. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  27367. /**
  27368. * Defines the falloff type used in this material.
  27369. * It by default is Physical.
  27370. */
  27371. protected _lightFalloff: number;
  27372. /**
  27373. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27374. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27375. */
  27376. protected _useRadianceOverAlpha: boolean;
  27377. /**
  27378. * Allows using an object space normal map (instead of tangent space).
  27379. */
  27380. protected _useObjectSpaceNormalMap: boolean;
  27381. /**
  27382. * Allows using the bump map in parallax mode.
  27383. */
  27384. protected _useParallax: boolean;
  27385. /**
  27386. * Allows using the bump map in parallax occlusion mode.
  27387. */
  27388. protected _useParallaxOcclusion: boolean;
  27389. /**
  27390. * Controls the scale bias of the parallax mode.
  27391. */
  27392. protected _parallaxScaleBias: number;
  27393. /**
  27394. * If sets to true, disables all the lights affecting the material.
  27395. */
  27396. protected _disableLighting: boolean;
  27397. /**
  27398. * Number of Simultaneous lights allowed on the material.
  27399. */
  27400. protected _maxSimultaneousLights: number;
  27401. /**
  27402. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  27403. */
  27404. protected _invertNormalMapX: boolean;
  27405. /**
  27406. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  27407. */
  27408. protected _invertNormalMapY: boolean;
  27409. /**
  27410. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27411. */
  27412. protected _twoSidedLighting: boolean;
  27413. /**
  27414. * Defines the alpha limits in alpha test mode.
  27415. */
  27416. protected _alphaCutOff: number;
  27417. /**
  27418. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27419. */
  27420. protected _forceAlphaTest: 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 is converted to gamma to compute the fresnel)
  27424. */
  27425. protected _useAlphaFresnel: boolean;
  27426. /**
  27427. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27428. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27429. */
  27430. protected _useLinearAlphaFresnel: boolean;
  27431. /**
  27432. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  27433. * from cos thetav and roughness:
  27434. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  27435. */
  27436. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  27437. /**
  27438. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27439. */
  27440. protected _forceIrradianceInFragment: boolean;
  27441. private _realTimeFiltering;
  27442. /**
  27443. * Enables realtime filtering on the texture.
  27444. */
  27445. get realTimeFiltering(): boolean;
  27446. set realTimeFiltering(b: boolean);
  27447. private _realTimeFilteringQuality;
  27448. /**
  27449. * Quality switch for realtime filtering
  27450. */
  27451. get realTimeFilteringQuality(): number;
  27452. set realTimeFilteringQuality(n: number);
  27453. /**
  27454. * Can this material render to several textures at once
  27455. */
  27456. get canRenderToMRT(): boolean;
  27457. /**
  27458. * Force normal to face away from face.
  27459. */
  27460. protected _forceNormalForward: boolean;
  27461. /**
  27462. * Enables specular anti aliasing in the PBR shader.
  27463. * It will both interacts on the Geometry for analytical and IBL lighting.
  27464. * It also prefilter the roughness map based on the bump values.
  27465. */
  27466. protected _enableSpecularAntiAliasing: boolean;
  27467. /**
  27468. * Default configuration related to image processing available in the PBR Material.
  27469. */
  27470. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27471. /**
  27472. * Keep track of the image processing observer to allow dispose and replace.
  27473. */
  27474. private _imageProcessingObserver;
  27475. /**
  27476. * Attaches a new image processing configuration to the PBR Material.
  27477. * @param configuration
  27478. */
  27479. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27480. /**
  27481. * Stores the available render targets.
  27482. */
  27483. private _renderTargets;
  27484. /**
  27485. * Sets the global ambient color for the material used in lighting calculations.
  27486. */
  27487. private _globalAmbientColor;
  27488. /**
  27489. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  27490. */
  27491. private _useLogarithmicDepth;
  27492. /**
  27493. * If set to true, no lighting calculations will be applied.
  27494. */
  27495. private _unlit;
  27496. private _debugMode;
  27497. /**
  27498. * @hidden
  27499. * This is reserved for the inspector.
  27500. * Defines the material debug mode.
  27501. * It helps seeing only some components of the material while troubleshooting.
  27502. */
  27503. debugMode: number;
  27504. /**
  27505. * @hidden
  27506. * This is reserved for the inspector.
  27507. * Specify from where on screen the debug mode should start.
  27508. * The value goes from -1 (full screen) to 1 (not visible)
  27509. * It helps with side by side comparison against the final render
  27510. * This defaults to -1
  27511. */
  27512. private debugLimit;
  27513. /**
  27514. * @hidden
  27515. * This is reserved for the inspector.
  27516. * As the default viewing range might not be enough (if the ambient is really small for instance)
  27517. * You can use the factor to better multiply the final value.
  27518. */
  27519. private debugFactor;
  27520. /**
  27521. * Defines the clear coat layer parameters for the material.
  27522. */
  27523. readonly clearCoat: PBRClearCoatConfiguration;
  27524. /**
  27525. * Defines the anisotropic parameters for the material.
  27526. */
  27527. readonly anisotropy: PBRAnisotropicConfiguration;
  27528. /**
  27529. * Defines the BRDF parameters for the material.
  27530. */
  27531. readonly brdf: PBRBRDFConfiguration;
  27532. /**
  27533. * Defines the Sheen parameters for the material.
  27534. */
  27535. readonly sheen: PBRSheenConfiguration;
  27536. /**
  27537. * Defines the SubSurface parameters for the material.
  27538. */
  27539. readonly subSurface: PBRSubSurfaceConfiguration;
  27540. /**
  27541. * Defines additionnal PrePass parameters for the material.
  27542. */
  27543. readonly prePassConfiguration: PrePassConfiguration;
  27544. /**
  27545. * Defines the detail map parameters for the material.
  27546. */
  27547. readonly detailMap: DetailMapConfiguration;
  27548. protected _rebuildInParallel: boolean;
  27549. /**
  27550. * Instantiates a new PBRMaterial instance.
  27551. *
  27552. * @param name The material name
  27553. * @param scene The scene the material will be use in.
  27554. */
  27555. constructor(name: string, scene: Scene);
  27556. /**
  27557. * Gets a boolean indicating that current material needs to register RTT
  27558. */
  27559. get hasRenderTargetTextures(): boolean;
  27560. /**
  27561. * Gets the name of the material class.
  27562. */
  27563. getClassName(): string;
  27564. /**
  27565. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27566. */
  27567. get useLogarithmicDepth(): boolean;
  27568. /**
  27569. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27570. */
  27571. set useLogarithmicDepth(value: boolean);
  27572. /**
  27573. * Returns true if alpha blending should be disabled.
  27574. */
  27575. protected get _disableAlphaBlending(): boolean;
  27576. /**
  27577. * Specifies whether or not this material should be rendered in alpha blend mode.
  27578. */
  27579. needAlphaBlending(): boolean;
  27580. /**
  27581. * Specifies whether or not this material should be rendered in alpha test mode.
  27582. */
  27583. needAlphaTesting(): boolean;
  27584. /**
  27585. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  27586. */
  27587. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  27588. /**
  27589. * Gets the texture used for the alpha test.
  27590. */
  27591. getAlphaTestTexture(): Nullable<BaseTexture>;
  27592. /**
  27593. * Specifies that the submesh is ready to be used.
  27594. * @param mesh - BJS mesh.
  27595. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  27596. * @param useInstances - Specifies that instances should be used.
  27597. * @returns - boolean indicating that the submesh is ready or not.
  27598. */
  27599. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27600. /**
  27601. * Specifies if the material uses metallic roughness workflow.
  27602. * @returns boolean specifiying if the material uses metallic roughness workflow.
  27603. */
  27604. isMetallicWorkflow(): boolean;
  27605. private _prepareEffect;
  27606. private _prepareDefines;
  27607. /**
  27608. * Force shader compilation
  27609. */
  27610. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  27611. /**
  27612. * Initializes the uniform buffer layout for the shader.
  27613. */
  27614. buildUniformLayout(): void;
  27615. /**
  27616. * Unbinds the material from the mesh
  27617. */
  27618. unbind(): void;
  27619. /**
  27620. * Binds the submesh data.
  27621. * @param world - The world matrix.
  27622. * @param mesh - The BJS mesh.
  27623. * @param subMesh - A submesh of the BJS mesh.
  27624. */
  27625. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27626. /**
  27627. * Returns the animatable textures.
  27628. * @returns - Array of animatable textures.
  27629. */
  27630. getAnimatables(): IAnimatable[];
  27631. /**
  27632. * Returns the texture used for reflections.
  27633. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  27634. */
  27635. private _getReflectionTexture;
  27636. /**
  27637. * Returns an array of the actively used textures.
  27638. * @returns - Array of BaseTextures
  27639. */
  27640. getActiveTextures(): BaseTexture[];
  27641. /**
  27642. * Checks to see if a texture is used in the material.
  27643. * @param texture - Base texture to use.
  27644. * @returns - Boolean specifying if a texture is used in the material.
  27645. */
  27646. hasTexture(texture: BaseTexture): boolean;
  27647. /**
  27648. * Sets the required values to the prepass renderer.
  27649. * @param prePassRenderer defines the prepass renderer to setup
  27650. */
  27651. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  27652. /**
  27653. * Disposes the resources of the material.
  27654. * @param forceDisposeEffect - Forces the disposal of effects.
  27655. * @param forceDisposeTextures - Forces the disposal of all textures.
  27656. */
  27657. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27658. }
  27659. }
  27660. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  27661. import { Nullable } from "babylonjs/types";
  27662. import { Scene } from "babylonjs/scene";
  27663. import { Color3 } from "babylonjs/Maths/math.color";
  27664. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  27665. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27666. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27667. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  27668. /**
  27669. * The Physically based material of BJS.
  27670. *
  27671. * This offers the main features of a standard PBR material.
  27672. * For more information, please refer to the documentation :
  27673. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27674. */
  27675. export class PBRMaterial extends PBRBaseMaterial {
  27676. /**
  27677. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27678. */
  27679. static readonly PBRMATERIAL_OPAQUE: number;
  27680. /**
  27681. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27682. */
  27683. static readonly PBRMATERIAL_ALPHATEST: number;
  27684. /**
  27685. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27686. */
  27687. static readonly PBRMATERIAL_ALPHABLEND: number;
  27688. /**
  27689. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27690. * They are also discarded below the alpha cutoff threshold to improve performances.
  27691. */
  27692. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27693. /**
  27694. * Defines the default value of how much AO map is occluding the analytical lights
  27695. * (point spot...).
  27696. */
  27697. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27698. /**
  27699. * Intensity of the direct lights e.g. the four lights available in your scene.
  27700. * This impacts both the direct diffuse and specular highlights.
  27701. */
  27702. directIntensity: number;
  27703. /**
  27704. * Intensity of the emissive part of the material.
  27705. * This helps controlling the emissive effect without modifying the emissive color.
  27706. */
  27707. emissiveIntensity: number;
  27708. /**
  27709. * Intensity of the environment e.g. how much the environment will light the object
  27710. * either through harmonics for rough material or through the refelction for shiny ones.
  27711. */
  27712. environmentIntensity: number;
  27713. /**
  27714. * This is a special control allowing the reduction of the specular highlights coming from the
  27715. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27716. */
  27717. specularIntensity: number;
  27718. /**
  27719. * Debug Control allowing disabling the bump map on this material.
  27720. */
  27721. disableBumpMap: boolean;
  27722. /**
  27723. * AKA Diffuse Texture in standard nomenclature.
  27724. */
  27725. albedoTexture: BaseTexture;
  27726. /**
  27727. * AKA Occlusion Texture in other nomenclature.
  27728. */
  27729. ambientTexture: BaseTexture;
  27730. /**
  27731. * AKA Occlusion Texture Intensity in other nomenclature.
  27732. */
  27733. ambientTextureStrength: number;
  27734. /**
  27735. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27736. * 1 means it completely occludes it
  27737. * 0 mean it has no impact
  27738. */
  27739. ambientTextureImpactOnAnalyticalLights: number;
  27740. /**
  27741. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  27742. */
  27743. opacityTexture: BaseTexture;
  27744. /**
  27745. * Stores the reflection values in a texture.
  27746. */
  27747. reflectionTexture: Nullable<BaseTexture>;
  27748. /**
  27749. * Stores the emissive values in a texture.
  27750. */
  27751. emissiveTexture: BaseTexture;
  27752. /**
  27753. * AKA Specular texture in other nomenclature.
  27754. */
  27755. reflectivityTexture: BaseTexture;
  27756. /**
  27757. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27758. */
  27759. metallicTexture: BaseTexture;
  27760. /**
  27761. * Specifies the metallic scalar of the metallic/roughness workflow.
  27762. * Can also be used to scale the metalness values of the metallic texture.
  27763. */
  27764. metallic: Nullable<number>;
  27765. /**
  27766. * Specifies the roughness scalar of the metallic/roughness workflow.
  27767. * Can also be used to scale the roughness values of the metallic texture.
  27768. */
  27769. roughness: Nullable<number>;
  27770. /**
  27771. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27772. * By default the indexOfrefraction is used to compute F0;
  27773. *
  27774. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27775. *
  27776. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27777. * F90 = metallicReflectanceColor;
  27778. */
  27779. metallicF0Factor: number;
  27780. /**
  27781. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27782. * By default the F90 is always 1;
  27783. *
  27784. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27785. *
  27786. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27787. * F90 = metallicReflectanceColor;
  27788. */
  27789. metallicReflectanceColor: Color3;
  27790. /**
  27791. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27792. * This is multiply against the scalar values defined in the material.
  27793. */
  27794. metallicReflectanceTexture: Nullable<BaseTexture>;
  27795. /**
  27796. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27797. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27798. */
  27799. microSurfaceTexture: BaseTexture;
  27800. /**
  27801. * Stores surface normal data used to displace a mesh in a texture.
  27802. */
  27803. bumpTexture: BaseTexture;
  27804. /**
  27805. * Stores the pre-calculated light information of a mesh in a texture.
  27806. */
  27807. lightmapTexture: BaseTexture;
  27808. /**
  27809. * Stores the refracted light information in a texture.
  27810. */
  27811. get refractionTexture(): Nullable<BaseTexture>;
  27812. set refractionTexture(value: Nullable<BaseTexture>);
  27813. /**
  27814. * The color of a material in ambient lighting.
  27815. */
  27816. ambientColor: Color3;
  27817. /**
  27818. * AKA Diffuse Color in other nomenclature.
  27819. */
  27820. albedoColor: Color3;
  27821. /**
  27822. * AKA Specular Color in other nomenclature.
  27823. */
  27824. reflectivityColor: Color3;
  27825. /**
  27826. * The color reflected from the material.
  27827. */
  27828. reflectionColor: Color3;
  27829. /**
  27830. * The color emitted from the material.
  27831. */
  27832. emissiveColor: Color3;
  27833. /**
  27834. * AKA Glossiness in other nomenclature.
  27835. */
  27836. microSurface: number;
  27837. /**
  27838. * Index of refraction of the material base layer.
  27839. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  27840. *
  27841. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  27842. *
  27843. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  27844. */
  27845. get indexOfRefraction(): number;
  27846. set indexOfRefraction(value: number);
  27847. /**
  27848. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  27849. */
  27850. get invertRefractionY(): boolean;
  27851. set invertRefractionY(value: boolean);
  27852. /**
  27853. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27854. * Materials half opaque for instance using refraction could benefit from this control.
  27855. */
  27856. get linkRefractionWithTransparency(): boolean;
  27857. set linkRefractionWithTransparency(value: boolean);
  27858. /**
  27859. * If true, the light map contains occlusion information instead of lighting info.
  27860. */
  27861. useLightmapAsShadowmap: boolean;
  27862. /**
  27863. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27864. */
  27865. useAlphaFromAlbedoTexture: boolean;
  27866. /**
  27867. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27868. */
  27869. forceAlphaTest: boolean;
  27870. /**
  27871. * Defines the alpha limits in alpha test mode.
  27872. */
  27873. alphaCutOff: number;
  27874. /**
  27875. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27876. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27877. */
  27878. useSpecularOverAlpha: boolean;
  27879. /**
  27880. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27881. */
  27882. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27883. /**
  27884. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27885. */
  27886. useRoughnessFromMetallicTextureAlpha: boolean;
  27887. /**
  27888. * Specifies if the metallic texture contains the roughness information in its green channel.
  27889. */
  27890. useRoughnessFromMetallicTextureGreen: boolean;
  27891. /**
  27892. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27893. */
  27894. useMetallnessFromMetallicTextureBlue: boolean;
  27895. /**
  27896. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27897. */
  27898. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27899. /**
  27900. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27901. */
  27902. useAmbientInGrayScale: boolean;
  27903. /**
  27904. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27905. * The material will try to infer what glossiness each pixel should be.
  27906. */
  27907. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27908. /**
  27909. * BJS is using an harcoded light falloff based on a manually sets up range.
  27910. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27911. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27912. */
  27913. get usePhysicalLightFalloff(): boolean;
  27914. /**
  27915. * BJS is using an harcoded light falloff based on a manually sets up range.
  27916. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27917. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27918. */
  27919. set usePhysicalLightFalloff(value: 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. get useGLTFLightFalloff(): boolean;
  27925. /**
  27926. * In order to support the falloff compatibility with gltf, a special mode has been added
  27927. * to reproduce the gltf light falloff.
  27928. */
  27929. set useGLTFLightFalloff(value: boolean);
  27930. /**
  27931. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27932. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27933. */
  27934. useRadianceOverAlpha: boolean;
  27935. /**
  27936. * Allows using an object space normal map (instead of tangent space).
  27937. */
  27938. useObjectSpaceNormalMap: boolean;
  27939. /**
  27940. * Allows using the bump map in parallax mode.
  27941. */
  27942. useParallax: boolean;
  27943. /**
  27944. * Allows using the bump map in parallax occlusion mode.
  27945. */
  27946. useParallaxOcclusion: boolean;
  27947. /**
  27948. * Controls the scale bias of the parallax mode.
  27949. */
  27950. parallaxScaleBias: number;
  27951. /**
  27952. * If sets to true, disables all the lights affecting the material.
  27953. */
  27954. disableLighting: boolean;
  27955. /**
  27956. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27957. */
  27958. forceIrradianceInFragment: boolean;
  27959. /**
  27960. * Number of Simultaneous lights allowed on the material.
  27961. */
  27962. maxSimultaneousLights: number;
  27963. /**
  27964. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27965. */
  27966. invertNormalMapX: boolean;
  27967. /**
  27968. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27969. */
  27970. invertNormalMapY: boolean;
  27971. /**
  27972. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27973. */
  27974. twoSidedLighting: 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 is converted to gamma to compute the fresnel)
  27978. */
  27979. useAlphaFresnel: boolean;
  27980. /**
  27981. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27982. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27983. */
  27984. useLinearAlphaFresnel: boolean;
  27985. /**
  27986. * Let user defines the brdf lookup texture used for IBL.
  27987. * A default 8bit version is embedded but you could point at :
  27988. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  27989. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  27990. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  27991. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  27992. */
  27993. environmentBRDFTexture: Nullable<BaseTexture>;
  27994. /**
  27995. * Force normal to face away from face.
  27996. */
  27997. forceNormalForward: boolean;
  27998. /**
  27999. * Enables specular anti aliasing in the PBR shader.
  28000. * It will both interacts on the Geometry for analytical and IBL lighting.
  28001. * It also prefilter the roughness map based on the bump values.
  28002. */
  28003. enableSpecularAntiAliasing: boolean;
  28004. /**
  28005. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  28006. * makes the reflect vector face the model (under horizon).
  28007. */
  28008. useHorizonOcclusion: boolean;
  28009. /**
  28010. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  28011. * too much the area relying on ambient texture to define their ambient occlusion.
  28012. */
  28013. useRadianceOcclusion: boolean;
  28014. /**
  28015. * If set to true, no lighting calculations will be applied.
  28016. */
  28017. unlit: boolean;
  28018. /**
  28019. * Gets the image processing configuration used either in this material.
  28020. */
  28021. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  28022. /**
  28023. * Sets the Default image processing configuration used either in the this material.
  28024. *
  28025. * If sets to null, the scene one is in use.
  28026. */
  28027. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  28028. /**
  28029. * Gets wether the color curves effect is enabled.
  28030. */
  28031. get cameraColorCurvesEnabled(): boolean;
  28032. /**
  28033. * Sets wether the color curves effect is enabled.
  28034. */
  28035. set cameraColorCurvesEnabled(value: boolean);
  28036. /**
  28037. * Gets wether the color grading effect is enabled.
  28038. */
  28039. get cameraColorGradingEnabled(): boolean;
  28040. /**
  28041. * Gets wether the color grading effect is enabled.
  28042. */
  28043. set cameraColorGradingEnabled(value: boolean);
  28044. /**
  28045. * Gets wether tonemapping is enabled or not.
  28046. */
  28047. get cameraToneMappingEnabled(): boolean;
  28048. /**
  28049. * Sets wether tonemapping is enabled or not
  28050. */
  28051. set cameraToneMappingEnabled(value: boolean);
  28052. /**
  28053. * The camera exposure used on this material.
  28054. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28055. * This corresponds to a photographic exposure.
  28056. */
  28057. get cameraExposure(): number;
  28058. /**
  28059. * The camera exposure used on this material.
  28060. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28061. * This corresponds to a photographic exposure.
  28062. */
  28063. set cameraExposure(value: number);
  28064. /**
  28065. * Gets The camera contrast used on this material.
  28066. */
  28067. get cameraContrast(): number;
  28068. /**
  28069. * Sets The camera contrast used on this material.
  28070. */
  28071. set cameraContrast(value: number);
  28072. /**
  28073. * Gets the Color Grading 2D Lookup Texture.
  28074. */
  28075. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28076. /**
  28077. * Sets the Color Grading 2D Lookup Texture.
  28078. */
  28079. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28080. /**
  28081. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28082. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28083. * 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;
  28084. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28085. */
  28086. get cameraColorCurves(): Nullable<ColorCurves>;
  28087. /**
  28088. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28089. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28090. * 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;
  28091. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28092. */
  28093. set cameraColorCurves(value: Nullable<ColorCurves>);
  28094. /**
  28095. * Instantiates a new PBRMaterial instance.
  28096. *
  28097. * @param name The material name
  28098. * @param scene The scene the material will be use in.
  28099. */
  28100. constructor(name: string, scene: Scene);
  28101. /**
  28102. * Returns the name of this material class.
  28103. */
  28104. getClassName(): string;
  28105. /**
  28106. * Makes a duplicate of the current material.
  28107. * @param name - name to use for the new material.
  28108. */
  28109. clone(name: string): PBRMaterial;
  28110. /**
  28111. * Serializes this PBR Material.
  28112. * @returns - An object with the serialized material.
  28113. */
  28114. serialize(): any;
  28115. /**
  28116. * Parses a PBR Material from a serialized object.
  28117. * @param source - Serialized object.
  28118. * @param scene - BJS scene instance.
  28119. * @param rootUrl - url for the scene object
  28120. * @returns - PBRMaterial
  28121. */
  28122. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  28123. }
  28124. }
  28125. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  28126. /** @hidden */
  28127. export var mrtFragmentDeclaration: {
  28128. name: string;
  28129. shader: string;
  28130. };
  28131. }
  28132. declare module "babylonjs/Shaders/geometry.fragment" {
  28133. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  28134. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  28135. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  28136. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  28137. /** @hidden */
  28138. export var geometryPixelShader: {
  28139. name: string;
  28140. shader: string;
  28141. };
  28142. }
  28143. declare module "babylonjs/Shaders/geometry.vertex" {
  28144. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28145. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28146. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28147. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28148. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28149. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28150. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28151. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  28152. /** @hidden */
  28153. export var geometryVertexShader: {
  28154. name: string;
  28155. shader: string;
  28156. };
  28157. }
  28158. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  28159. import { Matrix } from "babylonjs/Maths/math.vector";
  28160. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28161. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28162. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28163. import { Effect } from "babylonjs/Materials/effect";
  28164. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28165. import { Scene } from "babylonjs/scene";
  28166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28167. import { Nullable } from "babylonjs/types";
  28168. import "babylonjs/Shaders/geometry.fragment";
  28169. import "babylonjs/Shaders/geometry.vertex";
  28170. /** @hidden */
  28171. interface ISavedTransformationMatrix {
  28172. world: Matrix;
  28173. viewProjection: Matrix;
  28174. }
  28175. /**
  28176. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28177. */
  28178. export class GeometryBufferRenderer {
  28179. /**
  28180. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  28181. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  28182. */
  28183. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  28184. /**
  28185. * Constant used to retrieve the position texture index in the G-Buffer textures array
  28186. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  28187. */
  28188. static readonly POSITION_TEXTURE_TYPE: number;
  28189. /**
  28190. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  28191. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  28192. */
  28193. static readonly VELOCITY_TEXTURE_TYPE: number;
  28194. /**
  28195. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  28196. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  28197. */
  28198. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  28199. /**
  28200. * Dictionary used to store the previous transformation matrices of each rendered mesh
  28201. * in order to compute objects velocities when enableVelocity is set to "true"
  28202. * @hidden
  28203. */
  28204. _previousTransformationMatrices: {
  28205. [index: number]: ISavedTransformationMatrix;
  28206. };
  28207. /**
  28208. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  28209. * in order to compute objects velocities when enableVelocity is set to "true"
  28210. * @hidden
  28211. */
  28212. _previousBonesTransformationMatrices: {
  28213. [index: number]: Float32Array;
  28214. };
  28215. /**
  28216. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  28217. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  28218. */
  28219. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  28220. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  28221. renderTransparentMeshes: boolean;
  28222. private _scene;
  28223. private _resizeObserver;
  28224. private _multiRenderTarget;
  28225. private _ratio;
  28226. private _enablePosition;
  28227. private _enableVelocity;
  28228. private _enableReflectivity;
  28229. private _positionIndex;
  28230. private _velocityIndex;
  28231. private _reflectivityIndex;
  28232. private _depthNormalIndex;
  28233. private _linkedWithPrePass;
  28234. private _prePassRenderer;
  28235. private _attachments;
  28236. protected _effect: Effect;
  28237. protected _cachedDefines: string;
  28238. /**
  28239. * @hidden
  28240. * Sets up internal structures to share outputs with PrePassRenderer
  28241. * This method should only be called by the PrePassRenderer itself
  28242. */
  28243. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  28244. /**
  28245. * @hidden
  28246. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  28247. * This method should only be called by the PrePassRenderer itself
  28248. */
  28249. _unlinkPrePassRenderer(): void;
  28250. /**
  28251. * @hidden
  28252. * Resets the geometry buffer layout
  28253. */
  28254. _resetLayout(): void;
  28255. /**
  28256. * @hidden
  28257. * Replaces a texture in the geometry buffer renderer
  28258. * Useful when linking textures of the prepass renderer
  28259. */
  28260. _forceTextureType(geometryBufferType: number, index: number): void;
  28261. /**
  28262. * @hidden
  28263. * Sets texture attachments
  28264. * Useful when linking textures of the prepass renderer
  28265. */
  28266. _setAttachments(attachments: number[]): void;
  28267. /**
  28268. * @hidden
  28269. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  28270. * Useful when linking textures of the prepass renderer
  28271. */
  28272. _linkInternalTexture(internalTexture: InternalTexture): void;
  28273. /**
  28274. * Gets the render list (meshes to be rendered) used in the G buffer.
  28275. */
  28276. get renderList(): Nullable<AbstractMesh[]>;
  28277. /**
  28278. * Set the render list (meshes to be rendered) used in the G buffer.
  28279. */
  28280. set renderList(meshes: Nullable<AbstractMesh[]>);
  28281. /**
  28282. * Gets wether or not G buffer are supported by the running hardware.
  28283. * This requires draw buffer supports
  28284. */
  28285. get isSupported(): boolean;
  28286. /**
  28287. * Returns the index of the given texture type in the G-Buffer textures array
  28288. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  28289. * @returns the index of the given texture type in the G-Buffer textures array
  28290. */
  28291. getTextureIndex(textureType: number): number;
  28292. /**
  28293. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  28294. */
  28295. get enablePosition(): boolean;
  28296. /**
  28297. * Sets whether or not objects positions are enabled for the G buffer.
  28298. */
  28299. set enablePosition(enable: boolean);
  28300. /**
  28301. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  28302. */
  28303. get enableVelocity(): boolean;
  28304. /**
  28305. * Sets wether or not objects velocities are enabled for the G buffer.
  28306. */
  28307. set enableVelocity(enable: boolean);
  28308. /**
  28309. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  28310. */
  28311. get enableReflectivity(): boolean;
  28312. /**
  28313. * Sets wether or not objects roughness are enabled for the G buffer.
  28314. */
  28315. set enableReflectivity(enable: boolean);
  28316. /**
  28317. * Gets the scene associated with the buffer.
  28318. */
  28319. get scene(): Scene;
  28320. /**
  28321. * Gets the ratio used by the buffer during its creation.
  28322. * How big is the buffer related to the main canvas.
  28323. */
  28324. get ratio(): number;
  28325. /** @hidden */
  28326. static _SceneComponentInitialization: (scene: Scene) => void;
  28327. /**
  28328. * Creates a new G Buffer for the scene
  28329. * @param scene The scene the buffer belongs to
  28330. * @param ratio How big is the buffer related to the main canvas.
  28331. */
  28332. constructor(scene: Scene, ratio?: number);
  28333. /**
  28334. * Checks wether everything is ready to render a submesh to the G buffer.
  28335. * @param subMesh the submesh to check readiness for
  28336. * @param useInstances is the mesh drawn using instance or not
  28337. * @returns true if ready otherwise false
  28338. */
  28339. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28340. /**
  28341. * Gets the current underlying G Buffer.
  28342. * @returns the buffer
  28343. */
  28344. getGBuffer(): MultiRenderTarget;
  28345. /**
  28346. * Gets the number of samples used to render the buffer (anti aliasing).
  28347. */
  28348. get samples(): number;
  28349. /**
  28350. * Sets the number of samples used to render the buffer (anti aliasing).
  28351. */
  28352. set samples(value: number);
  28353. /**
  28354. * Disposes the renderer and frees up associated resources.
  28355. */
  28356. dispose(): void;
  28357. private _assignRenderTargetIndices;
  28358. protected _createRenderTargets(): void;
  28359. private _copyBonesTransformationMatrices;
  28360. }
  28361. }
  28362. declare module "babylonjs/Rendering/prePassRenderer" {
  28363. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28364. import { Scene } from "babylonjs/scene";
  28365. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  28366. import { Effect } from "babylonjs/Materials/effect";
  28367. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28369. import { Material } from "babylonjs/Materials/material";
  28370. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28371. /**
  28372. * Renders a pre pass of the scene
  28373. * This means every mesh in the scene will be rendered to a render target texture
  28374. * And then this texture will be composited to the rendering canvas with post processes
  28375. * It is necessary for effects like subsurface scattering or deferred shading
  28376. */
  28377. export class PrePassRenderer {
  28378. /** @hidden */
  28379. static _SceneComponentInitialization: (scene: Scene) => void;
  28380. private _textureFormats;
  28381. /**
  28382. * To save performance, we can excluded skinned meshes from the prepass
  28383. */
  28384. excludedSkinnedMesh: AbstractMesh[];
  28385. /**
  28386. * Force material to be excluded from the prepass
  28387. * Can be useful when `useGeometryBufferFallback` is set to `true`
  28388. * and you don't want a material to show in the effect.
  28389. */
  28390. excludedMaterials: Material[];
  28391. private _textureIndices;
  28392. private _scene;
  28393. private _engine;
  28394. private _isDirty;
  28395. /**
  28396. * Number of textures in the multi render target texture where the scene is directly rendered
  28397. */
  28398. mrtCount: number;
  28399. /**
  28400. * The render target where the scene is directly rendered
  28401. */
  28402. prePassRT: MultiRenderTarget;
  28403. private _multiRenderAttachments;
  28404. private _defaultAttachments;
  28405. private _clearAttachments;
  28406. private _postProcesses;
  28407. private readonly _clearColor;
  28408. /**
  28409. * Image processing post process for composition
  28410. */
  28411. imageProcessingPostProcess: ImageProcessingPostProcess;
  28412. /**
  28413. * Configuration for prepass effects
  28414. */
  28415. private _effectConfigurations;
  28416. private _mrtFormats;
  28417. private _mrtLayout;
  28418. private _enabled;
  28419. /**
  28420. * Indicates if the prepass is enabled
  28421. */
  28422. get enabled(): boolean;
  28423. /**
  28424. * How many samples are used for MSAA of the scene render target
  28425. */
  28426. get samples(): number;
  28427. set samples(n: number);
  28428. private _geometryBuffer;
  28429. private _useGeometryBufferFallback;
  28430. /**
  28431. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  28432. */
  28433. get useGeometryBufferFallback(): boolean;
  28434. set useGeometryBufferFallback(value: boolean);
  28435. /**
  28436. * Instanciates a prepass renderer
  28437. * @param scene The scene
  28438. */
  28439. constructor(scene: Scene);
  28440. private _initializeAttachments;
  28441. private _createCompositionEffect;
  28442. /**
  28443. * Indicates if rendering a prepass is supported
  28444. */
  28445. get isSupported(): boolean;
  28446. /**
  28447. * Sets the proper output textures to draw in the engine.
  28448. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  28449. * @param subMesh Submesh on which the effect is applied
  28450. */
  28451. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  28452. /**
  28453. * @hidden
  28454. */
  28455. _beforeCameraDraw(): void;
  28456. /**
  28457. * @hidden
  28458. */
  28459. _afterCameraDraw(): void;
  28460. private _checkRTSize;
  28461. private _bindFrameBuffer;
  28462. /**
  28463. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  28464. */
  28465. clear(): void;
  28466. private _setState;
  28467. private _updateGeometryBufferLayout;
  28468. /**
  28469. * Adds an effect configuration to the prepass.
  28470. * If an effect has already been added, it won't add it twice and will return the configuration
  28471. * already present.
  28472. * @param cfg the effect configuration
  28473. * @return the effect configuration now used by the prepass
  28474. */
  28475. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  28476. /**
  28477. * Returns the index of a texture in the multi render target texture array.
  28478. * @param type Texture type
  28479. * @return The index
  28480. */
  28481. getIndex(type: number): number;
  28482. private _enable;
  28483. private _disable;
  28484. private _resetLayout;
  28485. private _resetPostProcessChain;
  28486. private _bindPostProcessChain;
  28487. /**
  28488. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  28489. */
  28490. markAsDirty(): void;
  28491. /**
  28492. * Enables a texture on the MultiRenderTarget for prepass
  28493. */
  28494. private _enableTextures;
  28495. private _update;
  28496. private _markAllMaterialsAsPrePassDirty;
  28497. /**
  28498. * Disposes the prepass renderer.
  28499. */
  28500. dispose(): void;
  28501. }
  28502. }
  28503. declare module "babylonjs/PostProcesses/postProcess" {
  28504. import { Nullable } from "babylonjs/types";
  28505. import { SmartArray } from "babylonjs/Misc/smartArray";
  28506. import { Observable } from "babylonjs/Misc/observable";
  28507. import { Vector2 } from "babylonjs/Maths/math.vector";
  28508. import { Camera } from "babylonjs/Cameras/camera";
  28509. import { Effect } from "babylonjs/Materials/effect";
  28510. import "babylonjs/Shaders/postprocess.vertex";
  28511. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28512. import { Engine } from "babylonjs/Engines/engine";
  28513. import { Color4 } from "babylonjs/Maths/math.color";
  28514. import "babylonjs/Engines/Extensions/engine.renderTarget";
  28515. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  28516. import { Scene } from "babylonjs/scene";
  28517. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28518. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28519. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28520. /**
  28521. * Size options for a post process
  28522. */
  28523. export type PostProcessOptions = {
  28524. width: number;
  28525. height: number;
  28526. };
  28527. /**
  28528. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28529. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28530. */
  28531. export class PostProcess {
  28532. /**
  28533. * Gets or sets the unique id of the post process
  28534. */
  28535. uniqueId: number;
  28536. /** Name of the PostProcess. */
  28537. name: string;
  28538. /**
  28539. * Width of the texture to apply the post process on
  28540. */
  28541. width: number;
  28542. /**
  28543. * Height of the texture to apply the post process on
  28544. */
  28545. height: number;
  28546. /**
  28547. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  28548. */
  28549. nodeMaterialSource: Nullable<NodeMaterial>;
  28550. /**
  28551. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28552. * @hidden
  28553. */
  28554. _outputTexture: Nullable<InternalTexture>;
  28555. /**
  28556. * Sampling mode used by the shader
  28557. * See https://doc.babylonjs.com/classes/3.1/texture
  28558. */
  28559. renderTargetSamplingMode: number;
  28560. /**
  28561. * Clear color to use when screen clearing
  28562. */
  28563. clearColor: Color4;
  28564. /**
  28565. * If the buffer needs to be cleared before applying the post process. (default: true)
  28566. * Should be set to false if shader will overwrite all previous pixels.
  28567. */
  28568. autoClear: boolean;
  28569. /**
  28570. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28571. */
  28572. alphaMode: number;
  28573. /**
  28574. * Sets the setAlphaBlendConstants of the babylon engine
  28575. */
  28576. alphaConstants: Color4;
  28577. /**
  28578. * Animations to be used for the post processing
  28579. */
  28580. animations: import("babylonjs/Animations/animation").Animation[];
  28581. /**
  28582. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28583. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28584. */
  28585. enablePixelPerfectMode: boolean;
  28586. /**
  28587. * Force the postprocess to be applied without taking in account viewport
  28588. */
  28589. forceFullscreenViewport: boolean;
  28590. /**
  28591. * List of inspectable custom properties (used by the Inspector)
  28592. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28593. */
  28594. inspectableCustomProperties: IInspectable[];
  28595. /**
  28596. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28597. *
  28598. * | Value | Type | Description |
  28599. * | ----- | ----------------------------------- | ----------- |
  28600. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28601. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28602. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28603. *
  28604. */
  28605. scaleMode: number;
  28606. /**
  28607. * Force textures to be a power of two (default: false)
  28608. */
  28609. alwaysForcePOT: boolean;
  28610. private _samples;
  28611. /**
  28612. * Number of sample textures (default: 1)
  28613. */
  28614. get samples(): number;
  28615. set samples(n: number);
  28616. /**
  28617. * Modify the scale of the post process to be the same as the viewport (default: false)
  28618. */
  28619. adaptScaleToCurrentViewport: boolean;
  28620. private _camera;
  28621. protected _scene: Scene;
  28622. private _engine;
  28623. private _options;
  28624. private _reusable;
  28625. private _textureType;
  28626. private _textureFormat;
  28627. /**
  28628. * Smart array of input and output textures for the post process.
  28629. * @hidden
  28630. */
  28631. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  28632. /**
  28633. * The index in _textures that corresponds to the output texture.
  28634. * @hidden
  28635. */
  28636. _currentRenderTextureInd: number;
  28637. private _effect;
  28638. private _samplers;
  28639. private _fragmentUrl;
  28640. private _vertexUrl;
  28641. private _parameters;
  28642. private _scaleRatio;
  28643. protected _indexParameters: any;
  28644. private _shareOutputWithPostProcess;
  28645. private _texelSize;
  28646. private _forcedOutputTexture;
  28647. /**
  28648. * Prepass configuration in case this post process needs a texture from prepass
  28649. * @hidden
  28650. */
  28651. _prePassEffectConfiguration: PrePassEffectConfiguration;
  28652. /**
  28653. * Returns the fragment url or shader name used in the post process.
  28654. * @returns the fragment url or name in the shader store.
  28655. */
  28656. getEffectName(): string;
  28657. /**
  28658. * An event triggered when the postprocess is activated.
  28659. */
  28660. onActivateObservable: Observable<Camera>;
  28661. private _onActivateObserver;
  28662. /**
  28663. * A function that is added to the onActivateObservable
  28664. */
  28665. set onActivate(callback: Nullable<(camera: Camera) => void>);
  28666. /**
  28667. * An event triggered when the postprocess changes its size.
  28668. */
  28669. onSizeChangedObservable: Observable<PostProcess>;
  28670. private _onSizeChangedObserver;
  28671. /**
  28672. * A function that is added to the onSizeChangedObservable
  28673. */
  28674. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  28675. /**
  28676. * An event triggered when the postprocess applies its effect.
  28677. */
  28678. onApplyObservable: Observable<Effect>;
  28679. private _onApplyObserver;
  28680. /**
  28681. * A function that is added to the onApplyObservable
  28682. */
  28683. set onApply(callback: (effect: Effect) => void);
  28684. /**
  28685. * An event triggered before rendering the postprocess
  28686. */
  28687. onBeforeRenderObservable: Observable<Effect>;
  28688. private _onBeforeRenderObserver;
  28689. /**
  28690. * A function that is added to the onBeforeRenderObservable
  28691. */
  28692. set onBeforeRender(callback: (effect: Effect) => void);
  28693. /**
  28694. * An event triggered after rendering the postprocess
  28695. */
  28696. onAfterRenderObservable: Observable<Effect>;
  28697. private _onAfterRenderObserver;
  28698. /**
  28699. * A function that is added to the onAfterRenderObservable
  28700. */
  28701. set onAfterRender(callback: (efect: Effect) => void);
  28702. /**
  28703. * 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
  28704. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28705. */
  28706. get inputTexture(): InternalTexture;
  28707. set inputTexture(value: InternalTexture);
  28708. /**
  28709. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  28710. * the only way to unset it is to use this function to restore its internal state
  28711. */
  28712. restoreDefaultInputTexture(): void;
  28713. /**
  28714. * Gets the camera which post process is applied to.
  28715. * @returns The camera the post process is applied to.
  28716. */
  28717. getCamera(): Camera;
  28718. /**
  28719. * Gets the texel size of the postprocess.
  28720. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28721. */
  28722. get texelSize(): Vector2;
  28723. /**
  28724. * Creates a new instance PostProcess
  28725. * @param name The name of the PostProcess.
  28726. * @param fragmentUrl The url of the fragment shader to be used.
  28727. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28728. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28729. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28730. * @param camera The camera to apply the render pass to.
  28731. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28732. * @param engine The engine which the post process will be applied. (default: current engine)
  28733. * @param reusable If the post process can be reused on the same frame. (default: false)
  28734. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28735. * @param textureType Type of textures used when performing the post process. (default: 0)
  28736. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28737. * @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
  28738. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  28739. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  28740. */
  28741. 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);
  28742. /**
  28743. * Gets a string identifying the name of the class
  28744. * @returns "PostProcess" string
  28745. */
  28746. getClassName(): string;
  28747. /**
  28748. * Gets the engine which this post process belongs to.
  28749. * @returns The engine the post process was enabled with.
  28750. */
  28751. getEngine(): Engine;
  28752. /**
  28753. * The effect that is created when initializing the post process.
  28754. * @returns The created effect corresponding the the postprocess.
  28755. */
  28756. getEffect(): Effect;
  28757. /**
  28758. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28759. * @param postProcess The post process to share the output with.
  28760. * @returns This post process.
  28761. */
  28762. shareOutputWith(postProcess: PostProcess): PostProcess;
  28763. /**
  28764. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28765. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28766. */
  28767. useOwnOutput(): void;
  28768. /**
  28769. * Updates the effect with the current post process compile time values and recompiles the shader.
  28770. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28771. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28772. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28773. * @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
  28774. * @param onCompiled Called when the shader has been compiled.
  28775. * @param onError Called if there is an error when compiling a shader.
  28776. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  28777. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  28778. */
  28779. 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;
  28780. /**
  28781. * The post process is reusable if it can be used multiple times within one frame.
  28782. * @returns If the post process is reusable
  28783. */
  28784. isReusable(): boolean;
  28785. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28786. markTextureDirty(): void;
  28787. /**
  28788. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28789. * 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.
  28790. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28791. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28792. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28793. * @returns The target texture that was bound to be written to.
  28794. */
  28795. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28796. /**
  28797. * If the post process is supported.
  28798. */
  28799. get isSupported(): boolean;
  28800. /**
  28801. * The aspect ratio of the output texture.
  28802. */
  28803. get aspectRatio(): number;
  28804. /**
  28805. * Get a value indicating if the post-process is ready to be used
  28806. * @returns true if the post-process is ready (shader is compiled)
  28807. */
  28808. isReady(): boolean;
  28809. /**
  28810. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28811. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  28812. */
  28813. apply(): Nullable<Effect>;
  28814. private _disposeTextures;
  28815. /**
  28816. * Sets the required values to the prepass renderer.
  28817. * @param prePassRenderer defines the prepass renderer to setup.
  28818. * @returns true if the pre pass is needed.
  28819. */
  28820. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28821. /**
  28822. * Disposes the post process.
  28823. * @param camera The camera to dispose the post process on.
  28824. */
  28825. dispose(camera?: Camera): void;
  28826. /**
  28827. * Serializes the particle system to a JSON object
  28828. * @returns the JSON object
  28829. */
  28830. serialize(): any;
  28831. /**
  28832. * Creates a material from parsed material data
  28833. * @param parsedPostProcess defines parsed post process data
  28834. * @param scene defines the hosting scene
  28835. * @param rootUrl defines the root URL to use to load textures
  28836. * @returns a new post process
  28837. */
  28838. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  28839. }
  28840. }
  28841. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  28842. /** @hidden */
  28843. export var kernelBlurVaryingDeclaration: {
  28844. name: string;
  28845. shader: string;
  28846. };
  28847. }
  28848. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  28849. /** @hidden */
  28850. export var kernelBlurFragment: {
  28851. name: string;
  28852. shader: string;
  28853. };
  28854. }
  28855. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  28856. /** @hidden */
  28857. export var kernelBlurFragment2: {
  28858. name: string;
  28859. shader: string;
  28860. };
  28861. }
  28862. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  28863. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28864. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  28865. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  28866. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  28867. /** @hidden */
  28868. export var kernelBlurPixelShader: {
  28869. name: string;
  28870. shader: string;
  28871. };
  28872. }
  28873. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  28874. /** @hidden */
  28875. export var kernelBlurVertex: {
  28876. name: string;
  28877. shader: string;
  28878. };
  28879. }
  28880. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  28881. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28882. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  28883. /** @hidden */
  28884. export var kernelBlurVertexShader: {
  28885. name: string;
  28886. shader: string;
  28887. };
  28888. }
  28889. declare module "babylonjs/PostProcesses/blurPostProcess" {
  28890. import { Vector2 } from "babylonjs/Maths/math.vector";
  28891. import { Nullable } from "babylonjs/types";
  28892. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  28893. import { Camera } from "babylonjs/Cameras/camera";
  28894. import { Effect } from "babylonjs/Materials/effect";
  28895. import { Engine } from "babylonjs/Engines/engine";
  28896. import "babylonjs/Shaders/kernelBlur.fragment";
  28897. import "babylonjs/Shaders/kernelBlur.vertex";
  28898. import { Scene } from "babylonjs/scene";
  28899. /**
  28900. * The Blur Post Process which blurs an image based on a kernel and direction.
  28901. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  28902. */
  28903. export class BlurPostProcess extends PostProcess {
  28904. private blockCompilation;
  28905. protected _kernel: number;
  28906. protected _idealKernel: number;
  28907. protected _packedFloat: boolean;
  28908. private _staticDefines;
  28909. /** The direction in which to blur the image. */
  28910. direction: Vector2;
  28911. /**
  28912. * Sets the length in pixels of the blur sample region
  28913. */
  28914. set kernel(v: number);
  28915. /**
  28916. * Gets the length in pixels of the blur sample region
  28917. */
  28918. get kernel(): number;
  28919. /**
  28920. * Sets wether or not the blur needs to unpack/repack floats
  28921. */
  28922. set packedFloat(v: boolean);
  28923. /**
  28924. * Gets wether or not the blur is unpacking/repacking floats
  28925. */
  28926. get packedFloat(): boolean;
  28927. /**
  28928. * Gets a string identifying the name of the class
  28929. * @returns "BlurPostProcess" string
  28930. */
  28931. getClassName(): string;
  28932. /**
  28933. * Creates a new instance BlurPostProcess
  28934. * @param name The name of the effect.
  28935. * @param direction The direction in which to blur the image.
  28936. * @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.
  28937. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28938. * @param camera The camera to apply the render pass to.
  28939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28940. * @param engine The engine which the post process will be applied. (default: current engine)
  28941. * @param reusable If the post process can be reused on the same frame. (default: false)
  28942. * @param textureType Type of textures used when performing the post process. (default: 0)
  28943. * @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)
  28944. */
  28945. 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);
  28946. /**
  28947. * Updates the effect with the current post process compile time values and recompiles the shader.
  28948. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28949. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28950. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28951. * @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
  28952. * @param onCompiled Called when the shader has been compiled.
  28953. * @param onError Called if there is an error when compiling a shader.
  28954. */
  28955. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28956. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28957. /**
  28958. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  28959. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  28960. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  28961. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  28962. * The gaps between physical kernels are compensated for in the weighting of the samples
  28963. * @param idealKernel Ideal blur kernel.
  28964. * @return Nearest best kernel.
  28965. */
  28966. protected _nearestBestKernel(idealKernel: number): number;
  28967. /**
  28968. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  28969. * @param x The point on the Gaussian distribution to sample.
  28970. * @return the value of the Gaussian function at x.
  28971. */
  28972. protected _gaussianWeight(x: number): number;
  28973. /**
  28974. * Generates a string that can be used as a floating point number in GLSL.
  28975. * @param x Value to print.
  28976. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  28977. * @return GLSL float string.
  28978. */
  28979. protected _glslFloat(x: number, decimalFigures?: number): string;
  28980. /** @hidden */
  28981. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  28982. }
  28983. }
  28984. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  28985. import { Scene } from "babylonjs/scene";
  28986. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28987. import { Plane } from "babylonjs/Maths/math.plane";
  28988. /**
  28989. * Mirror texture can be used to simulate the view from a mirror in a scene.
  28990. * It will dynamically be rendered every frame to adapt to the camera point of view.
  28991. * You can then easily use it as a reflectionTexture on a flat surface.
  28992. * In case the surface is not a plane, please consider relying on reflection probes.
  28993. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28994. */
  28995. export class MirrorTexture extends RenderTargetTexture {
  28996. private scene;
  28997. /**
  28998. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  28999. * 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.
  29000. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29001. */
  29002. mirrorPlane: Plane;
  29003. /**
  29004. * Define the blur ratio used to blur the reflection if needed.
  29005. */
  29006. set blurRatio(value: number);
  29007. get blurRatio(): number;
  29008. /**
  29009. * Define the adaptive blur kernel used to blur the reflection if needed.
  29010. * This will autocompute the closest best match for the `blurKernel`
  29011. */
  29012. set adaptiveBlurKernel(value: number);
  29013. /**
  29014. * Define the blur kernel 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 blurKernel(value: number);
  29018. /**
  29019. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  29020. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29021. */
  29022. set blurKernelX(value: number);
  29023. get blurKernelX(): number;
  29024. /**
  29025. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  29026. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29027. */
  29028. set blurKernelY(value: number);
  29029. get blurKernelY(): number;
  29030. private _autoComputeBlurKernel;
  29031. protected _onRatioRescale(): void;
  29032. private _updateGammaSpace;
  29033. private _imageProcessingConfigChangeObserver;
  29034. private _transformMatrix;
  29035. private _mirrorMatrix;
  29036. private _savedViewMatrix;
  29037. private _blurX;
  29038. private _blurY;
  29039. private _adaptiveBlurKernel;
  29040. private _blurKernelX;
  29041. private _blurKernelY;
  29042. private _blurRatio;
  29043. /**
  29044. * Instantiates a Mirror Texture.
  29045. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29046. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29047. * You can then easily use it as a reflectionTexture on a flat surface.
  29048. * In case the surface is not a plane, please consider relying on reflection probes.
  29049. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29050. * @param name
  29051. * @param size
  29052. * @param scene
  29053. * @param generateMipMaps
  29054. * @param type
  29055. * @param samplingMode
  29056. * @param generateDepthBuffer
  29057. */
  29058. constructor(name: string, size: number | {
  29059. width: number;
  29060. height: number;
  29061. } | {
  29062. ratio: number;
  29063. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  29064. private _preparePostProcesses;
  29065. /**
  29066. * Clone the mirror texture.
  29067. * @returns the cloned texture
  29068. */
  29069. clone(): MirrorTexture;
  29070. /**
  29071. * Serialize the texture to a JSON representation you could use in Parse later on
  29072. * @returns the serialized JSON representation
  29073. */
  29074. serialize(): any;
  29075. /**
  29076. * Dispose the texture and release its associated resources.
  29077. */
  29078. dispose(): void;
  29079. }
  29080. }
  29081. declare module "babylonjs/Materials/Textures/texture" {
  29082. import { Observable } from "babylonjs/Misc/observable";
  29083. import { Nullable } from "babylonjs/types";
  29084. import { Matrix } from "babylonjs/Maths/math.vector";
  29085. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29086. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29087. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29088. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  29089. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  29090. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29091. import { Scene } from "babylonjs/scene";
  29092. /**
  29093. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29094. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29095. */
  29096. export class Texture extends BaseTexture {
  29097. /**
  29098. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  29099. */
  29100. static SerializeBuffers: boolean;
  29101. /** @hidden */
  29102. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  29103. /** @hidden */
  29104. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  29105. /** @hidden */
  29106. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  29107. /** nearest is mag = nearest and min = nearest and mip = linear */
  29108. static readonly NEAREST_SAMPLINGMODE: number;
  29109. /** nearest is mag = nearest and min = nearest and mip = linear */
  29110. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  29111. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29112. static readonly BILINEAR_SAMPLINGMODE: number;
  29113. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29114. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  29115. /** Trilinear is mag = linear and min = linear and mip = linear */
  29116. static readonly TRILINEAR_SAMPLINGMODE: number;
  29117. /** Trilinear is mag = linear and min = linear and mip = linear */
  29118. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  29119. /** mag = nearest and min = nearest and mip = nearest */
  29120. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  29121. /** mag = nearest and min = linear and mip = nearest */
  29122. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  29123. /** mag = nearest and min = linear and mip = linear */
  29124. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  29125. /** mag = nearest and min = linear and mip = none */
  29126. static readonly NEAREST_LINEAR: number;
  29127. /** mag = nearest and min = nearest and mip = none */
  29128. static readonly NEAREST_NEAREST: number;
  29129. /** mag = linear and min = nearest and mip = nearest */
  29130. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  29131. /** mag = linear and min = nearest and mip = linear */
  29132. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  29133. /** mag = linear and min = linear and mip = none */
  29134. static readonly LINEAR_LINEAR: number;
  29135. /** mag = linear and min = nearest and mip = none */
  29136. static readonly LINEAR_NEAREST: number;
  29137. /** Explicit coordinates mode */
  29138. static readonly EXPLICIT_MODE: number;
  29139. /** Spherical coordinates mode */
  29140. static readonly SPHERICAL_MODE: number;
  29141. /** Planar coordinates mode */
  29142. static readonly PLANAR_MODE: number;
  29143. /** Cubic coordinates mode */
  29144. static readonly CUBIC_MODE: number;
  29145. /** Projection coordinates mode */
  29146. static readonly PROJECTION_MODE: number;
  29147. /** Inverse Cubic coordinates mode */
  29148. static readonly SKYBOX_MODE: number;
  29149. /** Inverse Cubic coordinates mode */
  29150. static readonly INVCUBIC_MODE: number;
  29151. /** Equirectangular coordinates mode */
  29152. static readonly EQUIRECTANGULAR_MODE: number;
  29153. /** Equirectangular Fixed coordinates mode */
  29154. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  29155. /** Equirectangular Fixed Mirrored coordinates mode */
  29156. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29157. /** Texture is not repeating outside of 0..1 UVs */
  29158. static readonly CLAMP_ADDRESSMODE: number;
  29159. /** Texture is repeating outside of 0..1 UVs */
  29160. static readonly WRAP_ADDRESSMODE: number;
  29161. /** Texture is repeating and mirrored */
  29162. static readonly MIRROR_ADDRESSMODE: number;
  29163. /**
  29164. * 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
  29165. */
  29166. static UseSerializedUrlIfAny: boolean;
  29167. /**
  29168. * Define the url of the texture.
  29169. */
  29170. url: Nullable<string>;
  29171. /**
  29172. * Define an offset on the texture to offset the u coordinates of the UVs
  29173. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29174. */
  29175. uOffset: number;
  29176. /**
  29177. * Define an offset on the texture to offset the v coordinates of the UVs
  29178. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29179. */
  29180. vOffset: number;
  29181. /**
  29182. * Define an offset on the texture to scale the u coordinates of the UVs
  29183. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29184. */
  29185. uScale: number;
  29186. /**
  29187. * Define an offset on the texture to scale the v coordinates of the UVs
  29188. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29189. */
  29190. vScale: number;
  29191. /**
  29192. * Define an offset on the texture to rotate around the u coordinates of the UVs
  29193. * @see https://doc.babylonjs.com/how_to/more_materials
  29194. */
  29195. uAng: number;
  29196. /**
  29197. * Define an offset on the texture to rotate around the v coordinates of the UVs
  29198. * @see https://doc.babylonjs.com/how_to/more_materials
  29199. */
  29200. vAng: number;
  29201. /**
  29202. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  29203. * @see https://doc.babylonjs.com/how_to/more_materials
  29204. */
  29205. wAng: number;
  29206. /**
  29207. * Defines the center of rotation (U)
  29208. */
  29209. uRotationCenter: number;
  29210. /**
  29211. * Defines the center of rotation (V)
  29212. */
  29213. vRotationCenter: number;
  29214. /**
  29215. * Defines the center of rotation (W)
  29216. */
  29217. wRotationCenter: number;
  29218. /**
  29219. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  29220. */
  29221. homogeneousRotationInUVTransform: boolean;
  29222. /**
  29223. * Are mip maps generated for this texture or not.
  29224. */
  29225. get noMipmap(): boolean;
  29226. /**
  29227. * List of inspectable custom properties (used by the Inspector)
  29228. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29229. */
  29230. inspectableCustomProperties: Nullable<IInspectable[]>;
  29231. private _noMipmap;
  29232. /** @hidden */
  29233. _invertY: boolean;
  29234. private _rowGenerationMatrix;
  29235. private _cachedTextureMatrix;
  29236. private _projectionModeMatrix;
  29237. private _t0;
  29238. private _t1;
  29239. private _t2;
  29240. private _cachedUOffset;
  29241. private _cachedVOffset;
  29242. private _cachedUScale;
  29243. private _cachedVScale;
  29244. private _cachedUAng;
  29245. private _cachedVAng;
  29246. private _cachedWAng;
  29247. private _cachedProjectionMatrixId;
  29248. private _cachedURotationCenter;
  29249. private _cachedVRotationCenter;
  29250. private _cachedWRotationCenter;
  29251. private _cachedHomogeneousRotationInUVTransform;
  29252. private _cachedCoordinatesMode;
  29253. /** @hidden */
  29254. protected _initialSamplingMode: number;
  29255. /** @hidden */
  29256. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  29257. private _deleteBuffer;
  29258. protected _format: Nullable<number>;
  29259. private _delayedOnLoad;
  29260. private _delayedOnError;
  29261. private _mimeType?;
  29262. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  29263. get mimeType(): string | undefined;
  29264. /**
  29265. * Observable triggered once the texture has been loaded.
  29266. */
  29267. onLoadObservable: Observable<Texture>;
  29268. protected _isBlocking: boolean;
  29269. /**
  29270. * Is the texture preventing material to render while loading.
  29271. * If false, a default texture will be used instead of the loading one during the preparation step.
  29272. */
  29273. set isBlocking(value: boolean);
  29274. get isBlocking(): boolean;
  29275. /**
  29276. * Get the current sampling mode associated with the texture.
  29277. */
  29278. get samplingMode(): number;
  29279. /**
  29280. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  29281. */
  29282. get invertY(): boolean;
  29283. /**
  29284. * Instantiates a new texture.
  29285. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29286. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29287. * @param url defines the url of the picture to load as a texture
  29288. * @param sceneOrEngine defines the scene or engine the texture will belong to
  29289. * @param noMipmap defines if the texture will require mip maps or not
  29290. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  29291. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29292. * @param onLoad defines a callback triggered when the texture has been loaded
  29293. * @param onError defines a callback triggered when an error occurred during the loading session
  29294. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  29295. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  29296. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29297. * @param mimeType defines an optional mime type information
  29298. */
  29299. 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);
  29300. /**
  29301. * Update the url (and optional buffer) of this texture if url was null during construction.
  29302. * @param url the url of the texture
  29303. * @param buffer the buffer of the texture (defaults to null)
  29304. * @param onLoad callback called when the texture is loaded (defaults to null)
  29305. */
  29306. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  29307. /**
  29308. * Finish the loading sequence of a texture flagged as delayed load.
  29309. * @hidden
  29310. */
  29311. delayLoad(): void;
  29312. private _prepareRowForTextureGeneration;
  29313. /**
  29314. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  29315. * @returns the transform matrix of the texture.
  29316. */
  29317. getTextureMatrix(uBase?: number): Matrix;
  29318. /**
  29319. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  29320. * @returns The reflection texture transform
  29321. */
  29322. getReflectionTextureMatrix(): Matrix;
  29323. /**
  29324. * Clones the texture.
  29325. * @returns the cloned texture
  29326. */
  29327. clone(): Texture;
  29328. /**
  29329. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29330. * @returns The JSON representation of the texture
  29331. */
  29332. serialize(): any;
  29333. /**
  29334. * Get the current class name of the texture useful for serialization or dynamic coding.
  29335. * @returns "Texture"
  29336. */
  29337. getClassName(): string;
  29338. /**
  29339. * Dispose the texture and release its associated resources.
  29340. */
  29341. dispose(): void;
  29342. /**
  29343. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  29344. * @param parsedTexture Define the JSON representation of the texture
  29345. * @param scene Define the scene the parsed texture should be instantiated in
  29346. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  29347. * @returns The parsed texture if successful
  29348. */
  29349. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  29350. /**
  29351. * Creates a texture from its base 64 representation.
  29352. * @param data Define the base64 payload without the data: prefix
  29353. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29354. * @param scene Define the scene the texture should belong to
  29355. * @param noMipmap Forces the texture to not create mip map information if true
  29356. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29357. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29358. * @param onLoad define a callback triggered when the texture has been loaded
  29359. * @param onError define a callback triggered when an error occurred during the loading session
  29360. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29361. * @returns the created texture
  29362. */
  29363. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  29364. /**
  29365. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  29366. * @param data Define the base64 payload without the data: prefix
  29367. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29368. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  29369. * @param scene Define the scene the texture should belong to
  29370. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  29371. * @param noMipmap Forces the texture to not create mip map information if true
  29372. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29373. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29374. * @param onLoad define a callback triggered when the texture has been loaded
  29375. * @param onError define a callback triggered when an error occurred during the loading session
  29376. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29377. * @returns the created texture
  29378. */
  29379. 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;
  29380. }
  29381. }
  29382. declare module "babylonjs/PostProcesses/postProcessManager" {
  29383. import { Nullable } from "babylonjs/types";
  29384. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29385. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29386. import { Scene } from "babylonjs/scene";
  29387. /**
  29388. * PostProcessManager is used to manage one or more post processes or post process pipelines
  29389. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  29390. */
  29391. export class PostProcessManager {
  29392. private _scene;
  29393. private _indexBuffer;
  29394. private _vertexBuffers;
  29395. /**
  29396. * Creates a new instance PostProcess
  29397. * @param scene The scene that the post process is associated with.
  29398. */
  29399. constructor(scene: Scene);
  29400. private _prepareBuffers;
  29401. private _buildIndexBuffer;
  29402. /**
  29403. * Rebuilds the vertex buffers of the manager.
  29404. * @hidden
  29405. */
  29406. _rebuild(): void;
  29407. /**
  29408. * Prepares a frame to be run through a post process.
  29409. * @param sourceTexture The input texture to the post procesess. (default: null)
  29410. * @param postProcesses An array of post processes to be run. (default: null)
  29411. * @returns True if the post processes were able to be run.
  29412. * @hidden
  29413. */
  29414. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  29415. /**
  29416. * Manually render a set of post processes to a texture.
  29417. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  29418. * @param postProcesses An array of post processes to be run.
  29419. * @param targetTexture The target texture to render to.
  29420. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  29421. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  29422. * @param lodLevel defines which lod of the texture to render to
  29423. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  29424. */
  29425. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  29426. /**
  29427. * Finalize the result of the output of the postprocesses.
  29428. * @param doNotPresent If true the result will not be displayed to the screen.
  29429. * @param targetTexture The target texture to render to.
  29430. * @param faceIndex The index of the face to bind the target texture to.
  29431. * @param postProcesses The array of post processes to render.
  29432. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  29433. * @hidden
  29434. */
  29435. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  29436. /**
  29437. * Disposes of the post process manager.
  29438. */
  29439. dispose(): void;
  29440. }
  29441. }
  29442. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  29443. import { Observable } from "babylonjs/Misc/observable";
  29444. import { SmartArray } from "babylonjs/Misc/smartArray";
  29445. import { Nullable, Immutable } from "babylonjs/types";
  29446. import { Camera } from "babylonjs/Cameras/camera";
  29447. import { Scene } from "babylonjs/scene";
  29448. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29449. import { Color4 } from "babylonjs/Maths/math.color";
  29450. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  29451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29452. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29453. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29454. import { Texture } from "babylonjs/Materials/Textures/texture";
  29455. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29456. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  29457. import "babylonjs/Engines/Extensions/engine.renderTarget";
  29458. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  29459. import { Engine } from "babylonjs/Engines/engine";
  29460. /**
  29461. * This Helps creating a texture that will be created from a camera in your scene.
  29462. * It is basically a dynamic texture that could be used to create special effects for instance.
  29463. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  29464. */
  29465. export class RenderTargetTexture extends Texture {
  29466. /**
  29467. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  29468. */
  29469. static readonly REFRESHRATE_RENDER_ONCE: number;
  29470. /**
  29471. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  29472. */
  29473. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  29474. /**
  29475. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  29476. * the central point of your effect and can save a lot of performances.
  29477. */
  29478. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  29479. /**
  29480. * Use this predicate to dynamically define the list of mesh you want to render.
  29481. * If set, the renderList property will be overwritten.
  29482. */
  29483. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  29484. private _renderList;
  29485. /**
  29486. * Use this list to define the list of mesh you want to render.
  29487. */
  29488. get renderList(): Nullable<Array<AbstractMesh>>;
  29489. set renderList(value: Nullable<Array<AbstractMesh>>);
  29490. /**
  29491. * Use this function to overload the renderList array at rendering time.
  29492. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  29493. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  29494. * the cube (if the RTT is a cube, else layerOrFace=0).
  29495. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  29496. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  29497. * hold dummy elements!
  29498. */
  29499. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  29500. private _hookArray;
  29501. /**
  29502. * Define if particles should be rendered in your texture.
  29503. */
  29504. renderParticles: boolean;
  29505. /**
  29506. * Define if sprites should be rendered in your texture.
  29507. */
  29508. renderSprites: boolean;
  29509. /**
  29510. * Define the camera used to render the texture.
  29511. */
  29512. activeCamera: Nullable<Camera>;
  29513. /**
  29514. * Override the mesh isReady function with your own one.
  29515. */
  29516. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  29517. /**
  29518. * Override the render function of the texture with your own one.
  29519. */
  29520. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  29521. /**
  29522. * Define if camera post processes should be use while rendering the texture.
  29523. */
  29524. useCameraPostProcesses: boolean;
  29525. /**
  29526. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  29527. */
  29528. ignoreCameraViewport: boolean;
  29529. private _postProcessManager;
  29530. private _postProcesses;
  29531. private _resizeObserver;
  29532. /**
  29533. * An event triggered when the texture is unbind.
  29534. */
  29535. onBeforeBindObservable: Observable<RenderTargetTexture>;
  29536. /**
  29537. * An event triggered when the texture is unbind.
  29538. */
  29539. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  29540. private _onAfterUnbindObserver;
  29541. /**
  29542. * Set a after unbind callback in the texture.
  29543. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  29544. */
  29545. set onAfterUnbind(callback: () => void);
  29546. /**
  29547. * An event triggered before rendering the texture
  29548. */
  29549. onBeforeRenderObservable: Observable<number>;
  29550. private _onBeforeRenderObserver;
  29551. /**
  29552. * Set a before render callback in the texture.
  29553. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  29554. */
  29555. set onBeforeRender(callback: (faceIndex: number) => void);
  29556. /**
  29557. * An event triggered after rendering the texture
  29558. */
  29559. onAfterRenderObservable: Observable<number>;
  29560. private _onAfterRenderObserver;
  29561. /**
  29562. * Set a after render callback in the texture.
  29563. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  29564. */
  29565. set onAfterRender(callback: (faceIndex: number) => void);
  29566. /**
  29567. * An event triggered after the texture clear
  29568. */
  29569. onClearObservable: Observable<Engine>;
  29570. private _onClearObserver;
  29571. /**
  29572. * Set a clear callback in the texture.
  29573. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  29574. */
  29575. set onClear(callback: (Engine: Engine) => void);
  29576. /**
  29577. * An event triggered when the texture is resized.
  29578. */
  29579. onResizeObservable: Observable<RenderTargetTexture>;
  29580. /**
  29581. * Define the clear color of the Render Target if it should be different from the scene.
  29582. */
  29583. clearColor: Color4;
  29584. protected _size: number | {
  29585. width: number;
  29586. height: number;
  29587. layers?: number;
  29588. };
  29589. protected _initialSizeParameter: number | {
  29590. width: number;
  29591. height: number;
  29592. } | {
  29593. ratio: number;
  29594. };
  29595. protected _sizeRatio: Nullable<number>;
  29596. /** @hidden */
  29597. _generateMipMaps: boolean;
  29598. protected _renderingManager: RenderingManager;
  29599. /** @hidden */
  29600. _waitingRenderList?: string[];
  29601. protected _doNotChangeAspectRatio: boolean;
  29602. protected _currentRefreshId: number;
  29603. protected _refreshRate: number;
  29604. protected _textureMatrix: Matrix;
  29605. protected _samples: number;
  29606. protected _renderTargetOptions: RenderTargetCreationOptions;
  29607. /**
  29608. * Gets render target creation options that were used.
  29609. */
  29610. get renderTargetOptions(): RenderTargetCreationOptions;
  29611. protected _onRatioRescale(): void;
  29612. /**
  29613. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  29614. * It must define where the camera used to render the texture is set
  29615. */
  29616. boundingBoxPosition: Vector3;
  29617. private _boundingBoxSize;
  29618. /**
  29619. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  29620. * When defined, the cubemap will switch to local mode
  29621. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  29622. * @example https://www.babylonjs-playground.com/#RNASML
  29623. */
  29624. set boundingBoxSize(value: Vector3);
  29625. get boundingBoxSize(): Vector3;
  29626. /**
  29627. * In case the RTT has been created with a depth texture, get the associated
  29628. * depth texture.
  29629. * Otherwise, return null.
  29630. */
  29631. get depthStencilTexture(): Nullable<InternalTexture>;
  29632. /**
  29633. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  29634. * or used a shadow, depth texture...
  29635. * @param name The friendly name of the texture
  29636. * @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)
  29637. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  29638. * @param generateMipMaps True if mip maps need to be generated after render.
  29639. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  29640. * @param type The type of the buffer in the RTT (int, half float, float...)
  29641. * @param isCube True if a cube texture needs to be created
  29642. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  29643. * @param generateDepthBuffer True to generate a depth buffer
  29644. * @param generateStencilBuffer True to generate a stencil buffer
  29645. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  29646. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  29647. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29648. */
  29649. constructor(name: string, size: number | {
  29650. width: number;
  29651. height: number;
  29652. layers?: number;
  29653. } | {
  29654. ratio: number;
  29655. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  29656. /**
  29657. * Creates a depth stencil texture.
  29658. * This is only available in WebGL 2 or with the depth texture extension available.
  29659. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  29660. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  29661. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  29662. */
  29663. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  29664. private _processSizeParameter;
  29665. /**
  29666. * Define the number of samples to use in case of MSAA.
  29667. * It defaults to one meaning no MSAA has been enabled.
  29668. */
  29669. get samples(): number;
  29670. set samples(value: number);
  29671. /**
  29672. * Resets the refresh counter of the texture and start bak from scratch.
  29673. * Could be useful to regenerate the texture if it is setup to render only once.
  29674. */
  29675. resetRefreshCounter(): void;
  29676. /**
  29677. * Define the refresh rate of the texture or the rendering frequency.
  29678. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  29679. */
  29680. get refreshRate(): number;
  29681. set refreshRate(value: number);
  29682. /**
  29683. * Adds a post process to the render target rendering passes.
  29684. * @param postProcess define the post process to add
  29685. */
  29686. addPostProcess(postProcess: PostProcess): void;
  29687. /**
  29688. * Clear all the post processes attached to the render target
  29689. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  29690. */
  29691. clearPostProcesses(dispose?: boolean): void;
  29692. /**
  29693. * Remove one of the post process from the list of attached post processes to the texture
  29694. * @param postProcess define the post process to remove from the list
  29695. */
  29696. removePostProcess(postProcess: PostProcess): void;
  29697. /** @hidden */
  29698. _shouldRender(): boolean;
  29699. /**
  29700. * Gets the actual render size of the texture.
  29701. * @returns the width of the render size
  29702. */
  29703. getRenderSize(): number;
  29704. /**
  29705. * Gets the actual render width of the texture.
  29706. * @returns the width of the render size
  29707. */
  29708. getRenderWidth(): number;
  29709. /**
  29710. * Gets the actual render height of the texture.
  29711. * @returns the height of the render size
  29712. */
  29713. getRenderHeight(): number;
  29714. /**
  29715. * Gets the actual number of layers of the texture.
  29716. * @returns the number of layers
  29717. */
  29718. getRenderLayers(): number;
  29719. /**
  29720. * Get if the texture can be rescaled or not.
  29721. */
  29722. get canRescale(): boolean;
  29723. /**
  29724. * Resize the texture using a ratio.
  29725. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  29726. */
  29727. scale(ratio: number): void;
  29728. /**
  29729. * Get the texture reflection matrix used to rotate/transform the reflection.
  29730. * @returns the reflection matrix
  29731. */
  29732. getReflectionTextureMatrix(): Matrix;
  29733. /**
  29734. * Resize the texture to a new desired size.
  29735. * Be carrefull as it will recreate all the data in the new texture.
  29736. * @param size Define the new size. It can be:
  29737. * - a number for squared texture,
  29738. * - an object containing { width: number, height: number }
  29739. * - or an object containing a ratio { ratio: number }
  29740. */
  29741. resize(size: number | {
  29742. width: number;
  29743. height: number;
  29744. } | {
  29745. ratio: number;
  29746. }): void;
  29747. private _defaultRenderListPrepared;
  29748. /**
  29749. * Renders all the objects from the render list into the texture.
  29750. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  29751. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  29752. */
  29753. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  29754. private _bestReflectionRenderTargetDimension;
  29755. private _prepareRenderingManager;
  29756. /**
  29757. * @hidden
  29758. * @param faceIndex face index to bind to if this is a cubetexture
  29759. * @param layer defines the index of the texture to bind in the array
  29760. */
  29761. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  29762. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  29763. private renderToTarget;
  29764. /**
  29765. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29766. * This allowed control for front to back rendering or reversly depending of the special needs.
  29767. *
  29768. * @param renderingGroupId The rendering group id corresponding to its index
  29769. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29770. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29771. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29772. */
  29773. 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;
  29774. /**
  29775. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29776. *
  29777. * @param renderingGroupId The rendering group id corresponding to its index
  29778. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29779. */
  29780. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  29781. /**
  29782. * Clones the texture.
  29783. * @returns the cloned texture
  29784. */
  29785. clone(): RenderTargetTexture;
  29786. /**
  29787. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29788. * @returns The JSON representation of the texture
  29789. */
  29790. serialize(): any;
  29791. /**
  29792. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  29793. */
  29794. disposeFramebufferObjects(): void;
  29795. /**
  29796. * Dispose the texture and release its associated resources.
  29797. */
  29798. dispose(): void;
  29799. /** @hidden */
  29800. _rebuild(): void;
  29801. /**
  29802. * Clear the info related to rendering groups preventing retention point in material dispose.
  29803. */
  29804. freeRenderingGroups(): void;
  29805. /**
  29806. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  29807. * @returns the view count
  29808. */
  29809. getViewCount(): number;
  29810. }
  29811. }
  29812. declare module "babylonjs/Misc/guid" {
  29813. /**
  29814. * Class used to manipulate GUIDs
  29815. */
  29816. export class GUID {
  29817. /**
  29818. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29819. * Be aware Math.random() could cause collisions, but:
  29820. * "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"
  29821. * @returns a pseudo random id
  29822. */
  29823. static RandomId(): string;
  29824. }
  29825. }
  29826. declare module "babylonjs/Materials/shadowDepthWrapper" {
  29827. import { Nullable } from "babylonjs/types";
  29828. import { Scene } from "babylonjs/scene";
  29829. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29830. import { Material } from "babylonjs/Materials/material";
  29831. import { Effect } from "babylonjs/Materials/effect";
  29832. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  29833. /**
  29834. * Options to be used when creating a shadow depth material
  29835. */
  29836. export interface IIOptionShadowDepthMaterial {
  29837. /** Variables in the vertex shader code that need to have their names remapped.
  29838. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29839. * "var_name" should be either: worldPos or vNormalW
  29840. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29841. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29842. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29843. */
  29844. remappedVariables?: string[];
  29845. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29846. standalone?: boolean;
  29847. }
  29848. /**
  29849. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29850. */
  29851. export class ShadowDepthWrapper {
  29852. private _scene;
  29853. private _options?;
  29854. private _baseMaterial;
  29855. private _onEffectCreatedObserver;
  29856. private _subMeshToEffect;
  29857. private _subMeshToDepthEffect;
  29858. private _meshes;
  29859. /** @hidden */
  29860. _matriceNames: any;
  29861. /** Gets the standalone status of the wrapper */
  29862. get standalone(): boolean;
  29863. /** Gets the base material the wrapper is built upon */
  29864. get baseMaterial(): Material;
  29865. /**
  29866. * Instantiate a new shadow depth wrapper.
  29867. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29868. * generate the shadow depth map. For more information, please refer to the documentation:
  29869. * https://doc.babylonjs.com/babylon101/shadows
  29870. * @param baseMaterial Material to wrap
  29871. * @param scene Define the scene the material belongs to
  29872. * @param options Options used to create the wrapper
  29873. */
  29874. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29875. /**
  29876. * Gets the effect to use to generate the depth map
  29877. * @param subMesh subMesh to get the effect for
  29878. * @param shadowGenerator shadow generator to get the effect for
  29879. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29880. */
  29881. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29882. /**
  29883. * Specifies that the submesh is ready to be used for depth rendering
  29884. * @param subMesh submesh to check
  29885. * @param defines the list of defines to take into account when checking the effect
  29886. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29887. * @param useInstances specifies that instances should be used
  29888. * @returns a boolean indicating that the submesh is ready or not
  29889. */
  29890. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29891. /**
  29892. * Disposes the resources
  29893. */
  29894. dispose(): void;
  29895. private _makeEffect;
  29896. }
  29897. }
  29898. declare module "babylonjs/Materials/material" {
  29899. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29900. import { SmartArray } from "babylonjs/Misc/smartArray";
  29901. import { Observable } from "babylonjs/Misc/observable";
  29902. import { Nullable } from "babylonjs/types";
  29903. import { Scene } from "babylonjs/scene";
  29904. import { Matrix } from "babylonjs/Maths/math.vector";
  29905. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29907. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29908. import { Effect } from "babylonjs/Materials/effect";
  29909. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29910. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29911. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29912. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29913. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  29914. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  29915. import { Mesh } from "babylonjs/Meshes/mesh";
  29916. import { Animation } from "babylonjs/Animations/animation";
  29917. /**
  29918. * Options for compiling materials.
  29919. */
  29920. export interface IMaterialCompilationOptions {
  29921. /**
  29922. * Defines whether clip planes are enabled.
  29923. */
  29924. clipPlane: boolean;
  29925. /**
  29926. * Defines whether instances are enabled.
  29927. */
  29928. useInstances: boolean;
  29929. }
  29930. /**
  29931. * Options passed when calling customShaderNameResolve
  29932. */
  29933. export interface ICustomShaderNameResolveOptions {
  29934. /**
  29935. * 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
  29936. */
  29937. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29938. }
  29939. /**
  29940. * Base class for the main features of a material in Babylon.js
  29941. */
  29942. export class Material implements IAnimatable {
  29943. /**
  29944. * Returns the triangle fill mode
  29945. */
  29946. static readonly TriangleFillMode: number;
  29947. /**
  29948. * Returns the wireframe mode
  29949. */
  29950. static readonly WireFrameFillMode: number;
  29951. /**
  29952. * Returns the point fill mode
  29953. */
  29954. static readonly PointFillMode: number;
  29955. /**
  29956. * Returns the point list draw mode
  29957. */
  29958. static readonly PointListDrawMode: number;
  29959. /**
  29960. * Returns the line list draw mode
  29961. */
  29962. static readonly LineListDrawMode: number;
  29963. /**
  29964. * Returns the line loop draw mode
  29965. */
  29966. static readonly LineLoopDrawMode: number;
  29967. /**
  29968. * Returns the line strip draw mode
  29969. */
  29970. static readonly LineStripDrawMode: number;
  29971. /**
  29972. * Returns the triangle strip draw mode
  29973. */
  29974. static readonly TriangleStripDrawMode: number;
  29975. /**
  29976. * Returns the triangle fan draw mode
  29977. */
  29978. static readonly TriangleFanDrawMode: number;
  29979. /**
  29980. * Stores the clock-wise side orientation
  29981. */
  29982. static readonly ClockWiseSideOrientation: number;
  29983. /**
  29984. * Stores the counter clock-wise side orientation
  29985. */
  29986. static readonly CounterClockWiseSideOrientation: number;
  29987. /**
  29988. * The dirty texture flag value
  29989. */
  29990. static readonly TextureDirtyFlag: number;
  29991. /**
  29992. * The dirty light flag value
  29993. */
  29994. static readonly LightDirtyFlag: number;
  29995. /**
  29996. * The dirty fresnel flag value
  29997. */
  29998. static readonly FresnelDirtyFlag: number;
  29999. /**
  30000. * The dirty attribute flag value
  30001. */
  30002. static readonly AttributesDirtyFlag: number;
  30003. /**
  30004. * The dirty misc flag value
  30005. */
  30006. static readonly MiscDirtyFlag: number;
  30007. /**
  30008. * The dirty prepass flag value
  30009. */
  30010. static readonly PrePassDirtyFlag: number;
  30011. /**
  30012. * The all dirty flag value
  30013. */
  30014. static readonly AllDirtyFlag: number;
  30015. /**
  30016. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30017. */
  30018. static readonly MATERIAL_OPAQUE: number;
  30019. /**
  30020. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30021. */
  30022. static readonly MATERIAL_ALPHATEST: number;
  30023. /**
  30024. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30025. */
  30026. static readonly MATERIAL_ALPHABLEND: number;
  30027. /**
  30028. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30029. * They are also discarded below the alpha cutoff threshold to improve performances.
  30030. */
  30031. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30032. /**
  30033. * The Whiteout 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_WHITEOUT: number;
  30037. /**
  30038. * The Reoriented Normal Mapping method is used to blend normals.
  30039. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30040. */
  30041. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30042. /**
  30043. * Custom callback helping to override the default shader used in the material.
  30044. */
  30045. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30046. /**
  30047. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30048. */
  30049. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30050. /**
  30051. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30052. * This means that the material can keep using a previous shader while a new one is being compiled.
  30053. * This is mostly used when shader parallel compilation is supported (true by default)
  30054. */
  30055. allowShaderHotSwapping: boolean;
  30056. /**
  30057. * The ID of the material
  30058. */
  30059. id: string;
  30060. /**
  30061. * Gets or sets the unique id of the material
  30062. */
  30063. uniqueId: number;
  30064. /**
  30065. * The name of the material
  30066. */
  30067. name: string;
  30068. /**
  30069. * Gets or sets user defined metadata
  30070. */
  30071. metadata: any;
  30072. /**
  30073. * For internal use only. Please do not use.
  30074. */
  30075. reservedDataStore: any;
  30076. /**
  30077. * Specifies if the ready state should be checked on each call
  30078. */
  30079. checkReadyOnEveryCall: boolean;
  30080. /**
  30081. * Specifies if the ready state should be checked once
  30082. */
  30083. checkReadyOnlyOnce: boolean;
  30084. /**
  30085. * The state of the material
  30086. */
  30087. state: string;
  30088. /**
  30089. * If the material can be rendered to several textures with MRT extension
  30090. */
  30091. get canRenderToMRT(): boolean;
  30092. /**
  30093. * The alpha value of the material
  30094. */
  30095. protected _alpha: number;
  30096. /**
  30097. * List of inspectable custom properties (used by the Inspector)
  30098. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30099. */
  30100. inspectableCustomProperties: IInspectable[];
  30101. /**
  30102. * Sets the alpha value of the material
  30103. */
  30104. set alpha(value: number);
  30105. /**
  30106. * Gets the alpha value of the material
  30107. */
  30108. get alpha(): number;
  30109. /**
  30110. * Specifies if back face culling is enabled
  30111. */
  30112. protected _backFaceCulling: boolean;
  30113. /**
  30114. * Sets the back-face culling state
  30115. */
  30116. set backFaceCulling(value: boolean);
  30117. /**
  30118. * Gets the back-face culling state
  30119. */
  30120. get backFaceCulling(): boolean;
  30121. /**
  30122. * Stores the value for side orientation
  30123. */
  30124. sideOrientation: number;
  30125. /**
  30126. * Callback triggered when the material is compiled
  30127. */
  30128. onCompiled: Nullable<(effect: Effect) => void>;
  30129. /**
  30130. * Callback triggered when an error occurs
  30131. */
  30132. onError: Nullable<(effect: Effect, errors: string) => void>;
  30133. /**
  30134. * Callback triggered to get the render target textures
  30135. */
  30136. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30137. /**
  30138. * Gets a boolean indicating that current material needs to register RTT
  30139. */
  30140. get hasRenderTargetTextures(): boolean;
  30141. /**
  30142. * Specifies if the material should be serialized
  30143. */
  30144. doNotSerialize: boolean;
  30145. /**
  30146. * @hidden
  30147. */
  30148. _storeEffectOnSubMeshes: boolean;
  30149. /**
  30150. * Stores the animations for the material
  30151. */
  30152. animations: Nullable<Array<Animation>>;
  30153. /**
  30154. * An event triggered when the material is disposed
  30155. */
  30156. onDisposeObservable: Observable<Material>;
  30157. /**
  30158. * An observer which watches for dispose events
  30159. */
  30160. private _onDisposeObserver;
  30161. private _onUnBindObservable;
  30162. /**
  30163. * Called during a dispose event
  30164. */
  30165. set onDispose(callback: () => void);
  30166. private _onBindObservable;
  30167. /**
  30168. * An event triggered when the material is bound
  30169. */
  30170. get onBindObservable(): Observable<AbstractMesh>;
  30171. /**
  30172. * An observer which watches for bind events
  30173. */
  30174. private _onBindObserver;
  30175. /**
  30176. * Called during a bind event
  30177. */
  30178. set onBind(callback: (Mesh: AbstractMesh) => void);
  30179. /**
  30180. * An event triggered when the material is unbound
  30181. */
  30182. get onUnBindObservable(): Observable<Material>;
  30183. protected _onEffectCreatedObservable: Nullable<Observable<{
  30184. effect: Effect;
  30185. subMesh: Nullable<SubMesh>;
  30186. }>>;
  30187. /**
  30188. * An event triggered when the effect is (re)created
  30189. */
  30190. get onEffectCreatedObservable(): Observable<{
  30191. effect: Effect;
  30192. subMesh: Nullable<SubMesh>;
  30193. }>;
  30194. /**
  30195. * Stores the value of the alpha mode
  30196. */
  30197. private _alphaMode;
  30198. /**
  30199. * Sets the value of the alpha mode.
  30200. *
  30201. * | Value | Type | Description |
  30202. * | --- | --- | --- |
  30203. * | 0 | ALPHA_DISABLE | |
  30204. * | 1 | ALPHA_ADD | |
  30205. * | 2 | ALPHA_COMBINE | |
  30206. * | 3 | ALPHA_SUBTRACT | |
  30207. * | 4 | ALPHA_MULTIPLY | |
  30208. * | 5 | ALPHA_MAXIMIZED | |
  30209. * | 6 | ALPHA_ONEONE | |
  30210. * | 7 | ALPHA_PREMULTIPLIED | |
  30211. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30212. * | 9 | ALPHA_INTERPOLATE | |
  30213. * | 10 | ALPHA_SCREENMODE | |
  30214. *
  30215. */
  30216. set alphaMode(value: number);
  30217. /**
  30218. * Gets the value of the alpha mode
  30219. */
  30220. get alphaMode(): number;
  30221. /**
  30222. * Stores the state of the need depth pre-pass value
  30223. */
  30224. private _needDepthPrePass;
  30225. /**
  30226. * Sets the need depth pre-pass value
  30227. */
  30228. set needDepthPrePass(value: boolean);
  30229. /**
  30230. * Gets the depth pre-pass value
  30231. */
  30232. get needDepthPrePass(): boolean;
  30233. /**
  30234. * Specifies if depth writing should be disabled
  30235. */
  30236. disableDepthWrite: boolean;
  30237. /**
  30238. * Specifies if color writing should be disabled
  30239. */
  30240. disableColorWrite: boolean;
  30241. /**
  30242. * Specifies if depth writing should be forced
  30243. */
  30244. forceDepthWrite: boolean;
  30245. /**
  30246. * Specifies the depth function that should be used. 0 means the default engine function
  30247. */
  30248. depthFunction: number;
  30249. /**
  30250. * Specifies if there should be a separate pass for culling
  30251. */
  30252. separateCullingPass: boolean;
  30253. /**
  30254. * Stores the state specifing if fog should be enabled
  30255. */
  30256. private _fogEnabled;
  30257. /**
  30258. * Sets the state for enabling fog
  30259. */
  30260. set fogEnabled(value: boolean);
  30261. /**
  30262. * Gets the value of the fog enabled state
  30263. */
  30264. get fogEnabled(): boolean;
  30265. /**
  30266. * Stores the size of points
  30267. */
  30268. pointSize: number;
  30269. /**
  30270. * Stores the z offset value
  30271. */
  30272. zOffset: number;
  30273. get wireframe(): boolean;
  30274. /**
  30275. * Sets the state of wireframe mode
  30276. */
  30277. set wireframe(value: boolean);
  30278. /**
  30279. * Gets the value specifying if point clouds are enabled
  30280. */
  30281. get pointsCloud(): boolean;
  30282. /**
  30283. * Sets the state of point cloud mode
  30284. */
  30285. set pointsCloud(value: boolean);
  30286. /**
  30287. * Gets the material fill mode
  30288. */
  30289. get fillMode(): number;
  30290. /**
  30291. * Sets the material fill mode
  30292. */
  30293. set fillMode(value: number);
  30294. /**
  30295. * @hidden
  30296. * Stores the effects for the material
  30297. */
  30298. _effect: Nullable<Effect>;
  30299. /**
  30300. * Specifies if uniform buffers should be used
  30301. */
  30302. private _useUBO;
  30303. /**
  30304. * Stores a reference to the scene
  30305. */
  30306. private _scene;
  30307. /**
  30308. * Stores the fill mode state
  30309. */
  30310. private _fillMode;
  30311. /**
  30312. * Specifies if the depth write state should be cached
  30313. */
  30314. private _cachedDepthWriteState;
  30315. /**
  30316. * Specifies if the color write state should be cached
  30317. */
  30318. private _cachedColorWriteState;
  30319. /**
  30320. * Specifies if the depth function state should be cached
  30321. */
  30322. private _cachedDepthFunctionState;
  30323. /**
  30324. * Stores the uniform buffer
  30325. */
  30326. protected _uniformBuffer: UniformBuffer;
  30327. /** @hidden */
  30328. _indexInSceneMaterialArray: number;
  30329. /** @hidden */
  30330. meshMap: Nullable<{
  30331. [id: string]: AbstractMesh | undefined;
  30332. }>;
  30333. /**
  30334. * Creates a material instance
  30335. * @param name defines the name of the material
  30336. * @param scene defines the scene to reference
  30337. * @param doNotAdd specifies if the material should be added to the scene
  30338. */
  30339. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30340. /**
  30341. * Returns a string representation of the current material
  30342. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30343. * @returns a string with material information
  30344. */
  30345. toString(fullDetails?: boolean): string;
  30346. /**
  30347. * Gets the class name of the material
  30348. * @returns a string with the class name of the material
  30349. */
  30350. getClassName(): string;
  30351. /**
  30352. * Specifies if updates for the material been locked
  30353. */
  30354. get isFrozen(): boolean;
  30355. /**
  30356. * Locks updates for the material
  30357. */
  30358. freeze(): void;
  30359. /**
  30360. * Unlocks updates for the material
  30361. */
  30362. unfreeze(): void;
  30363. /**
  30364. * Specifies if the material is ready to be used
  30365. * @param mesh defines the mesh to check
  30366. * @param useInstances specifies if instances should be used
  30367. * @returns a boolean indicating if the material is ready to be used
  30368. */
  30369. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30370. /**
  30371. * Specifies that the submesh is ready to be used
  30372. * @param mesh defines the mesh to check
  30373. * @param subMesh defines which submesh to check
  30374. * @param useInstances specifies that instances should be used
  30375. * @returns a boolean indicating that the submesh is ready or not
  30376. */
  30377. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30378. /**
  30379. * Returns the material effect
  30380. * @returns the effect associated with the material
  30381. */
  30382. getEffect(): Nullable<Effect>;
  30383. /**
  30384. * Returns the current scene
  30385. * @returns a Scene
  30386. */
  30387. getScene(): Scene;
  30388. /**
  30389. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30390. */
  30391. protected _forceAlphaTest: boolean;
  30392. /**
  30393. * The transparency mode of the material.
  30394. */
  30395. protected _transparencyMode: Nullable<number>;
  30396. /**
  30397. * Gets the current transparency mode.
  30398. */
  30399. get transparencyMode(): Nullable<number>;
  30400. /**
  30401. * Sets the transparency mode of the material.
  30402. *
  30403. * | Value | Type | Description |
  30404. * | ----- | ----------------------------------- | ----------- |
  30405. * | 0 | OPAQUE | |
  30406. * | 1 | ALPHATEST | |
  30407. * | 2 | ALPHABLEND | |
  30408. * | 3 | ALPHATESTANDBLEND | |
  30409. *
  30410. */
  30411. set transparencyMode(value: Nullable<number>);
  30412. /**
  30413. * Returns true if alpha blending should be disabled.
  30414. */
  30415. protected get _disableAlphaBlending(): boolean;
  30416. /**
  30417. * Specifies whether or not this material should be rendered in alpha blend mode.
  30418. * @returns a boolean specifying if alpha blending is needed
  30419. */
  30420. needAlphaBlending(): boolean;
  30421. /**
  30422. * Specifies if the mesh will require alpha blending
  30423. * @param mesh defines the mesh to check
  30424. * @returns a boolean specifying if alpha blending is needed for the mesh
  30425. */
  30426. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30427. /**
  30428. * Specifies whether or not this material should be rendered in alpha test mode.
  30429. * @returns a boolean specifying if an alpha test is needed.
  30430. */
  30431. needAlphaTesting(): boolean;
  30432. /**
  30433. * Specifies if material alpha testing should be turned on for the mesh
  30434. * @param mesh defines the mesh to check
  30435. */
  30436. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30437. /**
  30438. * Gets the texture used for the alpha test
  30439. * @returns the texture to use for alpha testing
  30440. */
  30441. getAlphaTestTexture(): Nullable<BaseTexture>;
  30442. /**
  30443. * Marks the material to indicate that it needs to be re-calculated
  30444. */
  30445. markDirty(): void;
  30446. /** @hidden */
  30447. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30448. /**
  30449. * Binds the material to the mesh
  30450. * @param world defines the world transformation matrix
  30451. * @param mesh defines the mesh to bind the material to
  30452. */
  30453. bind(world: Matrix, mesh?: Mesh): void;
  30454. /**
  30455. * Binds the submesh to the material
  30456. * @param world defines the world transformation matrix
  30457. * @param mesh defines the mesh containing the submesh
  30458. * @param subMesh defines the submesh to bind the material to
  30459. */
  30460. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30461. /**
  30462. * Binds the world matrix to the material
  30463. * @param world defines the world transformation matrix
  30464. */
  30465. bindOnlyWorldMatrix(world: Matrix): void;
  30466. /**
  30467. * Binds the scene's uniform buffer to the effect.
  30468. * @param effect defines the effect to bind to the scene uniform buffer
  30469. * @param sceneUbo defines the uniform buffer storing scene data
  30470. */
  30471. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30472. /**
  30473. * Binds the view matrix to the effect
  30474. * @param effect defines the effect to bind the view matrix to
  30475. */
  30476. bindView(effect: Effect): void;
  30477. /**
  30478. * Binds the view projection matrix to the effect
  30479. * @param effect defines the effect to bind the view projection matrix to
  30480. */
  30481. bindViewProjection(effect: Effect): void;
  30482. /**
  30483. * Processes to execute after binding the material to a mesh
  30484. * @param mesh defines the rendered mesh
  30485. */
  30486. protected _afterBind(mesh?: Mesh): void;
  30487. /**
  30488. * Unbinds the material from the mesh
  30489. */
  30490. unbind(): void;
  30491. /**
  30492. * Gets the active textures from the material
  30493. * @returns an array of textures
  30494. */
  30495. getActiveTextures(): BaseTexture[];
  30496. /**
  30497. * Specifies if the material uses a texture
  30498. * @param texture defines the texture to check against the material
  30499. * @returns a boolean specifying if the material uses the texture
  30500. */
  30501. hasTexture(texture: BaseTexture): boolean;
  30502. /**
  30503. * Makes a duplicate of the material, and gives it a new name
  30504. * @param name defines the new name for the duplicated material
  30505. * @returns the cloned material
  30506. */
  30507. clone(name: string): Nullable<Material>;
  30508. /**
  30509. * Gets the meshes bound to the material
  30510. * @returns an array of meshes bound to the material
  30511. */
  30512. getBindedMeshes(): AbstractMesh[];
  30513. /**
  30514. * Force shader compilation
  30515. * @param mesh defines the mesh associated with this material
  30516. * @param onCompiled defines a function to execute once the material is compiled
  30517. * @param options defines the options to configure the compilation
  30518. * @param onError defines a function to execute if the material fails compiling
  30519. */
  30520. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30521. /**
  30522. * Force shader compilation
  30523. * @param mesh defines the mesh that will use this material
  30524. * @param options defines additional options for compiling the shaders
  30525. * @returns a promise that resolves when the compilation completes
  30526. */
  30527. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30528. private static readonly _AllDirtyCallBack;
  30529. private static readonly _ImageProcessingDirtyCallBack;
  30530. private static readonly _TextureDirtyCallBack;
  30531. private static readonly _FresnelDirtyCallBack;
  30532. private static readonly _MiscDirtyCallBack;
  30533. private static readonly _PrePassDirtyCallBack;
  30534. private static readonly _LightsDirtyCallBack;
  30535. private static readonly _AttributeDirtyCallBack;
  30536. private static _FresnelAndMiscDirtyCallBack;
  30537. private static _TextureAndMiscDirtyCallBack;
  30538. private static readonly _DirtyCallbackArray;
  30539. private static readonly _RunDirtyCallBacks;
  30540. /**
  30541. * Marks a define in the material to indicate that it needs to be re-computed
  30542. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30543. */
  30544. markAsDirty(flag: number): void;
  30545. /**
  30546. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30547. * @param func defines a function which checks material defines against the submeshes
  30548. */
  30549. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30550. /**
  30551. * Indicates that the scene should check if the rendering now needs a prepass
  30552. */
  30553. protected _markScenePrePassDirty(): void;
  30554. /**
  30555. * Indicates that we need to re-calculated for all submeshes
  30556. */
  30557. protected _markAllSubMeshesAsAllDirty(): void;
  30558. /**
  30559. * Indicates that image processing needs to be re-calculated for all submeshes
  30560. */
  30561. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30562. /**
  30563. * Indicates that textures need to be re-calculated for all submeshes
  30564. */
  30565. protected _markAllSubMeshesAsTexturesDirty(): void;
  30566. /**
  30567. * Indicates that fresnel needs to be re-calculated for all submeshes
  30568. */
  30569. protected _markAllSubMeshesAsFresnelDirty(): void;
  30570. /**
  30571. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30572. */
  30573. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30574. /**
  30575. * Indicates that lights need to be re-calculated for all submeshes
  30576. */
  30577. protected _markAllSubMeshesAsLightsDirty(): void;
  30578. /**
  30579. * Indicates that attributes need to be re-calculated for all submeshes
  30580. */
  30581. protected _markAllSubMeshesAsAttributesDirty(): void;
  30582. /**
  30583. * Indicates that misc needs to be re-calculated for all submeshes
  30584. */
  30585. protected _markAllSubMeshesAsMiscDirty(): void;
  30586. /**
  30587. * Indicates that prepass needs to be re-calculated for all submeshes
  30588. */
  30589. protected _markAllSubMeshesAsPrePassDirty(): void;
  30590. /**
  30591. * Indicates that textures and misc need to be re-calculated for all submeshes
  30592. */
  30593. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30594. /**
  30595. * Sets the required values to the prepass renderer.
  30596. * @param prePassRenderer defines the prepass renderer to setup.
  30597. * @returns true if the pre pass is needed.
  30598. */
  30599. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30600. /**
  30601. * Disposes the material
  30602. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30603. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30604. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30605. */
  30606. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30607. /** @hidden */
  30608. private releaseVertexArrayObject;
  30609. /**
  30610. * Serializes this material
  30611. * @returns the serialized material object
  30612. */
  30613. serialize(): any;
  30614. /**
  30615. * Creates a material from parsed material data
  30616. * @param parsedMaterial defines parsed material data
  30617. * @param scene defines the hosting scene
  30618. * @param rootUrl defines the root URL to use to load textures
  30619. * @returns a new material
  30620. */
  30621. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30622. }
  30623. }
  30624. declare module "babylonjs/Materials/multiMaterial" {
  30625. import { Nullable } from "babylonjs/types";
  30626. import { Scene } from "babylonjs/scene";
  30627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30628. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30629. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30630. import { Material } from "babylonjs/Materials/material";
  30631. /**
  30632. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30633. * separate meshes. This can be use to improve performances.
  30634. * @see https://doc.babylonjs.com/how_to/multi_materials
  30635. */
  30636. export class MultiMaterial extends Material {
  30637. private _subMaterials;
  30638. /**
  30639. * Gets or Sets the list of Materials used within the multi material.
  30640. * They need to be ordered according to the submeshes order in the associated mesh
  30641. */
  30642. get subMaterials(): Nullable<Material>[];
  30643. set subMaterials(value: Nullable<Material>[]);
  30644. /**
  30645. * Function used to align with Node.getChildren()
  30646. * @returns the list of Materials used within the multi material
  30647. */
  30648. getChildren(): Nullable<Material>[];
  30649. /**
  30650. * Instantiates a new Multi Material
  30651. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30652. * separate meshes. This can be use to improve performances.
  30653. * @see https://doc.babylonjs.com/how_to/multi_materials
  30654. * @param name Define the name in the scene
  30655. * @param scene Define the scene the material belongs to
  30656. */
  30657. constructor(name: string, scene: Scene);
  30658. private _hookArray;
  30659. /**
  30660. * Get one of the submaterial by its index in the submaterials array
  30661. * @param index The index to look the sub material at
  30662. * @returns The Material if the index has been defined
  30663. */
  30664. getSubMaterial(index: number): Nullable<Material>;
  30665. /**
  30666. * Get the list of active textures for the whole sub materials list.
  30667. * @returns All the textures that will be used during the rendering
  30668. */
  30669. getActiveTextures(): BaseTexture[];
  30670. /**
  30671. * Gets the current class name of the material e.g. "MultiMaterial"
  30672. * Mainly use in serialization.
  30673. * @returns the class name
  30674. */
  30675. getClassName(): string;
  30676. /**
  30677. * Checks if the material is ready to render the requested sub mesh
  30678. * @param mesh Define the mesh the submesh belongs to
  30679. * @param subMesh Define the sub mesh to look readyness for
  30680. * @param useInstances Define whether or not the material is used with instances
  30681. * @returns true if ready, otherwise false
  30682. */
  30683. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30684. /**
  30685. * Clones the current material and its related sub materials
  30686. * @param name Define the name of the newly cloned material
  30687. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30688. * @returns the cloned material
  30689. */
  30690. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30691. /**
  30692. * Serializes the materials into a JSON representation.
  30693. * @returns the JSON representation
  30694. */
  30695. serialize(): any;
  30696. /**
  30697. * Dispose the material and release its associated resources
  30698. * @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)
  30699. * @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)
  30700. * @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)
  30701. */
  30702. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30703. /**
  30704. * Creates a MultiMaterial from parsed MultiMaterial data.
  30705. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30706. * @param scene defines the hosting scene
  30707. * @returns a new MultiMaterial
  30708. */
  30709. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30710. }
  30711. }
  30712. declare module "babylonjs/Meshes/subMesh" {
  30713. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  30714. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30715. import { Engine } from "babylonjs/Engines/engine";
  30716. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  30717. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  30718. import { Effect } from "babylonjs/Materials/effect";
  30719. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30720. import { Plane } from "babylonjs/Maths/math.plane";
  30721. import { Collider } from "babylonjs/Collisions/collider";
  30722. import { Material } from "babylonjs/Materials/material";
  30723. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30725. import { Mesh } from "babylonjs/Meshes/mesh";
  30726. import { Ray } from "babylonjs/Culling/ray";
  30727. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  30728. /**
  30729. * Defines a subdivision inside a mesh
  30730. */
  30731. export class SubMesh implements ICullable {
  30732. /** the material index to use */
  30733. materialIndex: number;
  30734. /** vertex index start */
  30735. verticesStart: number;
  30736. /** vertices count */
  30737. verticesCount: number;
  30738. /** index start */
  30739. indexStart: number;
  30740. /** indices count */
  30741. indexCount: number;
  30742. /** @hidden */
  30743. _materialDefines: Nullable<MaterialDefines>;
  30744. /** @hidden */
  30745. _materialEffect: Nullable<Effect>;
  30746. /** @hidden */
  30747. _effectOverride: Nullable<Effect>;
  30748. /**
  30749. * Gets material defines used by the effect associated to the sub mesh
  30750. */
  30751. get materialDefines(): Nullable<MaterialDefines>;
  30752. /**
  30753. * Sets material defines used by the effect associated to the sub mesh
  30754. */
  30755. set materialDefines(defines: Nullable<MaterialDefines>);
  30756. /**
  30757. * Gets associated effect
  30758. */
  30759. get effect(): Nullable<Effect>;
  30760. /**
  30761. * Sets associated effect (effect used to render this submesh)
  30762. * @param effect defines the effect to associate with
  30763. * @param defines defines the set of defines used to compile this effect
  30764. */
  30765. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30766. /** @hidden */
  30767. _linesIndexCount: number;
  30768. private _mesh;
  30769. private _renderingMesh;
  30770. private _boundingInfo;
  30771. private _linesIndexBuffer;
  30772. /** @hidden */
  30773. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30774. /** @hidden */
  30775. _trianglePlanes: Plane[];
  30776. /** @hidden */
  30777. _lastColliderTransformMatrix: Nullable<Matrix>;
  30778. /** @hidden */
  30779. _renderId: number;
  30780. /** @hidden */
  30781. _alphaIndex: number;
  30782. /** @hidden */
  30783. _distanceToCamera: number;
  30784. /** @hidden */
  30785. _id: number;
  30786. private _currentMaterial;
  30787. /**
  30788. * Add a new submesh to a mesh
  30789. * @param materialIndex defines the material index to use
  30790. * @param verticesStart defines vertex index start
  30791. * @param verticesCount defines vertices count
  30792. * @param indexStart defines index start
  30793. * @param indexCount defines indices count
  30794. * @param mesh defines the parent mesh
  30795. * @param renderingMesh defines an optional rendering mesh
  30796. * @param createBoundingBox defines if bounding box should be created for this submesh
  30797. * @returns the new submesh
  30798. */
  30799. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30800. /**
  30801. * Creates a new submesh
  30802. * @param materialIndex defines the material index to use
  30803. * @param verticesStart defines vertex index start
  30804. * @param verticesCount defines vertices count
  30805. * @param indexStart defines index start
  30806. * @param indexCount defines indices count
  30807. * @param mesh defines the parent mesh
  30808. * @param renderingMesh defines an optional rendering mesh
  30809. * @param createBoundingBox defines if bounding box should be created for this submesh
  30810. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30811. */
  30812. constructor(
  30813. /** the material index to use */
  30814. materialIndex: number,
  30815. /** vertex index start */
  30816. verticesStart: number,
  30817. /** vertices count */
  30818. verticesCount: number,
  30819. /** index start */
  30820. indexStart: number,
  30821. /** indices count */
  30822. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30823. /**
  30824. * Returns true if this submesh covers the entire parent mesh
  30825. * @ignorenaming
  30826. */
  30827. get IsGlobal(): boolean;
  30828. /**
  30829. * Returns the submesh BoudingInfo object
  30830. * @returns current bounding info (or mesh's one if the submesh is global)
  30831. */
  30832. getBoundingInfo(): BoundingInfo;
  30833. /**
  30834. * Sets the submesh BoundingInfo
  30835. * @param boundingInfo defines the new bounding info to use
  30836. * @returns the SubMesh
  30837. */
  30838. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30839. /**
  30840. * Returns the mesh of the current submesh
  30841. * @return the parent mesh
  30842. */
  30843. getMesh(): AbstractMesh;
  30844. /**
  30845. * Returns the rendering mesh of the submesh
  30846. * @returns the rendering mesh (could be different from parent mesh)
  30847. */
  30848. getRenderingMesh(): Mesh;
  30849. /**
  30850. * Returns the replacement mesh of the submesh
  30851. * @returns the replacement mesh (could be different from parent mesh)
  30852. */
  30853. getReplacementMesh(): Nullable<AbstractMesh>;
  30854. /**
  30855. * Returns the effective mesh of the submesh
  30856. * @returns the effective mesh (could be different from parent mesh)
  30857. */
  30858. getEffectiveMesh(): AbstractMesh;
  30859. /**
  30860. * Returns the submesh material
  30861. * @returns null or the current material
  30862. */
  30863. getMaterial(): Nullable<Material>;
  30864. private _IsMultiMaterial;
  30865. /**
  30866. * Sets a new updated BoundingInfo object to the submesh
  30867. * @param data defines an optional position array to use to determine the bounding info
  30868. * @returns the SubMesh
  30869. */
  30870. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30871. /** @hidden */
  30872. _checkCollision(collider: Collider): boolean;
  30873. /**
  30874. * Updates the submesh BoundingInfo
  30875. * @param world defines the world matrix to use to update the bounding info
  30876. * @returns the submesh
  30877. */
  30878. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30879. /**
  30880. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30881. * @param frustumPlanes defines the frustum planes
  30882. * @returns true if the submesh is intersecting with the frustum
  30883. */
  30884. isInFrustum(frustumPlanes: Plane[]): boolean;
  30885. /**
  30886. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30887. * @param frustumPlanes defines the frustum planes
  30888. * @returns true if the submesh is inside the frustum
  30889. */
  30890. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30891. /**
  30892. * Renders the submesh
  30893. * @param enableAlphaMode defines if alpha needs to be used
  30894. * @returns the submesh
  30895. */
  30896. render(enableAlphaMode: boolean): SubMesh;
  30897. /**
  30898. * @hidden
  30899. */
  30900. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30901. /**
  30902. * Checks if the submesh intersects with a ray
  30903. * @param ray defines the ray to test
  30904. * @returns true is the passed ray intersects the submesh bounding box
  30905. */
  30906. canIntersects(ray: Ray): boolean;
  30907. /**
  30908. * Intersects current submesh with a ray
  30909. * @param ray defines the ray to test
  30910. * @param positions defines mesh's positions array
  30911. * @param indices defines mesh's indices array
  30912. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30913. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30914. * @returns intersection info or null if no intersection
  30915. */
  30916. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30917. /** @hidden */
  30918. private _intersectLines;
  30919. /** @hidden */
  30920. private _intersectUnIndexedLines;
  30921. /** @hidden */
  30922. private _intersectTriangles;
  30923. /** @hidden */
  30924. private _intersectUnIndexedTriangles;
  30925. /** @hidden */
  30926. _rebuild(): void;
  30927. /**
  30928. * Creates a new submesh from the passed mesh
  30929. * @param newMesh defines the new hosting mesh
  30930. * @param newRenderingMesh defines an optional rendering mesh
  30931. * @returns the new submesh
  30932. */
  30933. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30934. /**
  30935. * Release associated resources
  30936. */
  30937. dispose(): void;
  30938. /**
  30939. * Gets the class name
  30940. * @returns the string "SubMesh".
  30941. */
  30942. getClassName(): string;
  30943. /**
  30944. * Creates a new submesh from indices data
  30945. * @param materialIndex the index of the main mesh material
  30946. * @param startIndex the index where to start the copy in the mesh indices array
  30947. * @param indexCount the number of indices to copy then from the startIndex
  30948. * @param mesh the main mesh to create the submesh from
  30949. * @param renderingMesh the optional rendering mesh
  30950. * @returns a new submesh
  30951. */
  30952. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30953. }
  30954. }
  30955. declare module "babylonjs/Loading/sceneLoaderFlags" {
  30956. /**
  30957. * Class used to represent data loading progression
  30958. */
  30959. export class SceneLoaderFlags {
  30960. private static _ForceFullSceneLoadingForIncremental;
  30961. private static _ShowLoadingScreen;
  30962. private static _CleanBoneMatrixWeights;
  30963. private static _loggingLevel;
  30964. /**
  30965. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30966. */
  30967. static get ForceFullSceneLoadingForIncremental(): boolean;
  30968. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30969. /**
  30970. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30971. */
  30972. static get ShowLoadingScreen(): boolean;
  30973. static set ShowLoadingScreen(value: boolean);
  30974. /**
  30975. * Defines the current logging level (while loading the scene)
  30976. * @ignorenaming
  30977. */
  30978. static get loggingLevel(): number;
  30979. static set loggingLevel(value: number);
  30980. /**
  30981. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30982. */
  30983. static get CleanBoneMatrixWeights(): boolean;
  30984. static set CleanBoneMatrixWeights(value: boolean);
  30985. }
  30986. }
  30987. declare module "babylonjs/Meshes/geometry" {
  30988. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30989. import { Scene } from "babylonjs/scene";
  30990. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  30991. import { Engine } from "babylonjs/Engines/engine";
  30992. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  30993. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30994. import { Effect } from "babylonjs/Materials/effect";
  30995. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  30996. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30997. import { Mesh } from "babylonjs/Meshes/mesh";
  30998. /**
  30999. * Class used to store geometry data (vertex buffers + index buffer)
  31000. */
  31001. export class Geometry implements IGetSetVerticesData {
  31002. /**
  31003. * Gets or sets the ID of the geometry
  31004. */
  31005. id: string;
  31006. /**
  31007. * Gets or sets the unique ID of the geometry
  31008. */
  31009. uniqueId: number;
  31010. /**
  31011. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31012. */
  31013. delayLoadState: number;
  31014. /**
  31015. * Gets the file containing the data to load when running in delay load state
  31016. */
  31017. delayLoadingFile: Nullable<string>;
  31018. /**
  31019. * Callback called when the geometry is updated
  31020. */
  31021. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31022. private _scene;
  31023. private _engine;
  31024. private _meshes;
  31025. private _totalVertices;
  31026. /** @hidden */
  31027. _indices: IndicesArray;
  31028. /** @hidden */
  31029. _vertexBuffers: {
  31030. [key: string]: VertexBuffer;
  31031. };
  31032. private _isDisposed;
  31033. private _extend;
  31034. private _boundingBias;
  31035. /** @hidden */
  31036. _delayInfo: Array<string>;
  31037. private _indexBuffer;
  31038. private _indexBufferIsUpdatable;
  31039. /** @hidden */
  31040. _boundingInfo: Nullable<BoundingInfo>;
  31041. /** @hidden */
  31042. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31043. /** @hidden */
  31044. _softwareSkinningFrameId: number;
  31045. private _vertexArrayObjects;
  31046. private _updatable;
  31047. /** @hidden */
  31048. _positions: Nullable<Vector3[]>;
  31049. /**
  31050. * 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
  31051. */
  31052. get boundingBias(): Vector2;
  31053. /**
  31054. * 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
  31055. */
  31056. set boundingBias(value: Vector2);
  31057. /**
  31058. * Static function used to attach a new empty geometry to a mesh
  31059. * @param mesh defines the mesh to attach the geometry to
  31060. * @returns the new Geometry
  31061. */
  31062. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31063. /** Get the list of meshes using this geometry */
  31064. get meshes(): Mesh[];
  31065. /**
  31066. * 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
  31067. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31068. */
  31069. useBoundingInfoFromGeometry: boolean;
  31070. /**
  31071. * Creates a new geometry
  31072. * @param id defines the unique ID
  31073. * @param scene defines the hosting scene
  31074. * @param vertexData defines the VertexData used to get geometry data
  31075. * @param updatable defines if geometry must be updatable (false by default)
  31076. * @param mesh defines the mesh that will be associated with the geometry
  31077. */
  31078. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31079. /**
  31080. * Gets the current extend of the geometry
  31081. */
  31082. get extend(): {
  31083. minimum: Vector3;
  31084. maximum: Vector3;
  31085. };
  31086. /**
  31087. * Gets the hosting scene
  31088. * @returns the hosting Scene
  31089. */
  31090. getScene(): Scene;
  31091. /**
  31092. * Gets the hosting engine
  31093. * @returns the hosting Engine
  31094. */
  31095. getEngine(): Engine;
  31096. /**
  31097. * Defines if the geometry is ready to use
  31098. * @returns true if the geometry is ready to be used
  31099. */
  31100. isReady(): boolean;
  31101. /**
  31102. * Gets a value indicating that the geometry should not be serialized
  31103. */
  31104. get doNotSerialize(): boolean;
  31105. /** @hidden */
  31106. _rebuild(): void;
  31107. /**
  31108. * Affects all geometry data in one call
  31109. * @param vertexData defines the geometry data
  31110. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31111. */
  31112. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31113. /**
  31114. * Set specific vertex data
  31115. * @param kind defines the data kind (Position, normal, etc...)
  31116. * @param data defines the vertex data to use
  31117. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31118. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31119. */
  31120. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31121. /**
  31122. * Removes a specific vertex data
  31123. * @param kind defines the data kind (Position, normal, etc...)
  31124. */
  31125. removeVerticesData(kind: string): void;
  31126. /**
  31127. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31128. * @param buffer defines the vertex buffer to use
  31129. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31130. */
  31131. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31132. /**
  31133. * Update a specific vertex buffer
  31134. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31135. * It will do nothing if the buffer is not updatable
  31136. * @param kind defines the data kind (Position, normal, etc...)
  31137. * @param data defines the data to use
  31138. * @param offset defines the offset in the target buffer where to store the data
  31139. * @param useBytes set to true if the offset is in bytes
  31140. */
  31141. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31142. /**
  31143. * Update a specific vertex buffer
  31144. * This function will create a new buffer if the current one is not updatable
  31145. * @param kind defines the data kind (Position, normal, etc...)
  31146. * @param data defines the data to use
  31147. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31148. */
  31149. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31150. private _updateBoundingInfo;
  31151. /** @hidden */
  31152. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31153. /**
  31154. * Gets total number of vertices
  31155. * @returns the total number of vertices
  31156. */
  31157. getTotalVertices(): number;
  31158. /**
  31159. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31160. * @param kind defines the data kind (Position, normal, etc...)
  31161. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31162. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31163. * @returns a float array containing vertex data
  31164. */
  31165. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31166. /**
  31167. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31168. * @param kind defines the data kind (Position, normal, etc...)
  31169. * @returns true if the vertex buffer with the specified kind is updatable
  31170. */
  31171. isVertexBufferUpdatable(kind: string): boolean;
  31172. /**
  31173. * Gets a specific vertex buffer
  31174. * @param kind defines the data kind (Position, normal, etc...)
  31175. * @returns a VertexBuffer
  31176. */
  31177. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31178. /**
  31179. * Returns all vertex buffers
  31180. * @return an object holding all vertex buffers indexed by kind
  31181. */
  31182. getVertexBuffers(): Nullable<{
  31183. [key: string]: VertexBuffer;
  31184. }>;
  31185. /**
  31186. * Gets a boolean indicating if specific vertex buffer is present
  31187. * @param kind defines the data kind (Position, normal, etc...)
  31188. * @returns true if data is present
  31189. */
  31190. isVerticesDataPresent(kind: string): boolean;
  31191. /**
  31192. * Gets a list of all attached data kinds (Position, normal, etc...)
  31193. * @returns a list of string containing all kinds
  31194. */
  31195. getVerticesDataKinds(): string[];
  31196. /**
  31197. * Update index buffer
  31198. * @param indices defines the indices to store in the index buffer
  31199. * @param offset defines the offset in the target buffer where to store the data
  31200. * @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)
  31201. */
  31202. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31203. /**
  31204. * Creates a new index buffer
  31205. * @param indices defines the indices to store in the index buffer
  31206. * @param totalVertices defines the total number of vertices (could be null)
  31207. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31208. */
  31209. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31210. /**
  31211. * Return the total number of indices
  31212. * @returns the total number of indices
  31213. */
  31214. getTotalIndices(): number;
  31215. /**
  31216. * Gets the index buffer array
  31217. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31218. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31219. * @returns the index buffer array
  31220. */
  31221. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31222. /**
  31223. * Gets the index buffer
  31224. * @return the index buffer
  31225. */
  31226. getIndexBuffer(): Nullable<DataBuffer>;
  31227. /** @hidden */
  31228. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31229. /**
  31230. * Release the associated resources for a specific mesh
  31231. * @param mesh defines the source mesh
  31232. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31233. */
  31234. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31235. /**
  31236. * Apply current geometry to a given mesh
  31237. * @param mesh defines the mesh to apply geometry to
  31238. */
  31239. applyToMesh(mesh: Mesh): void;
  31240. private _updateExtend;
  31241. private _applyToMesh;
  31242. private notifyUpdate;
  31243. /**
  31244. * Load the geometry if it was flagged as delay loaded
  31245. * @param scene defines the hosting scene
  31246. * @param onLoaded defines a callback called when the geometry is loaded
  31247. */
  31248. load(scene: Scene, onLoaded?: () => void): void;
  31249. private _queueLoad;
  31250. /**
  31251. * Invert the geometry to move from a right handed system to a left handed one.
  31252. */
  31253. toLeftHanded(): void;
  31254. /** @hidden */
  31255. _resetPointsArrayCache(): void;
  31256. /** @hidden */
  31257. _generatePointsArray(): boolean;
  31258. /**
  31259. * Gets a value indicating if the geometry is disposed
  31260. * @returns true if the geometry was disposed
  31261. */
  31262. isDisposed(): boolean;
  31263. private _disposeVertexArrayObjects;
  31264. /**
  31265. * Free all associated resources
  31266. */
  31267. dispose(): void;
  31268. /**
  31269. * Clone the current geometry into a new geometry
  31270. * @param id defines the unique ID of the new geometry
  31271. * @returns a new geometry object
  31272. */
  31273. copy(id: string): Geometry;
  31274. /**
  31275. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31276. * @return a JSON representation of the current geometry data (without the vertices data)
  31277. */
  31278. serialize(): any;
  31279. private toNumberArray;
  31280. /**
  31281. * Serialize all vertices data into a JSON oject
  31282. * @returns a JSON representation of the current geometry data
  31283. */
  31284. serializeVerticeData(): any;
  31285. /**
  31286. * Extracts a clone of a mesh geometry
  31287. * @param mesh defines the source mesh
  31288. * @param id defines the unique ID of the new geometry object
  31289. * @returns the new geometry object
  31290. */
  31291. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31292. /**
  31293. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31294. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31295. * Be aware Math.random() could cause collisions, but:
  31296. * "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"
  31297. * @returns a string containing a new GUID
  31298. */
  31299. static RandomId(): string;
  31300. /** @hidden */
  31301. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31302. private static _CleanMatricesWeights;
  31303. /**
  31304. * Create a new geometry from persisted data (Using .babylon file format)
  31305. * @param parsedVertexData defines the persisted data
  31306. * @param scene defines the hosting scene
  31307. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31308. * @returns the new geometry object
  31309. */
  31310. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31311. }
  31312. }
  31313. declare module "babylonjs/Meshes/mesh.vertexData" {
  31314. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  31315. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  31316. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  31317. import { Geometry } from "babylonjs/Meshes/geometry";
  31318. import { Mesh } from "babylonjs/Meshes/mesh";
  31319. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  31320. /**
  31321. * Define an interface for all classes that will get and set the data on vertices
  31322. */
  31323. export interface IGetSetVerticesData {
  31324. /**
  31325. * Gets a boolean indicating if specific vertex data is present
  31326. * @param kind defines the vertex data kind to use
  31327. * @returns true is data kind is present
  31328. */
  31329. isVerticesDataPresent(kind: string): boolean;
  31330. /**
  31331. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31332. * @param kind defines the data kind (Position, normal, etc...)
  31333. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31334. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31335. * @returns a float array containing vertex data
  31336. */
  31337. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31338. /**
  31339. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  31340. * @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.
  31341. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31342. * @returns the indices array or an empty array if the mesh has no geometry
  31343. */
  31344. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31345. /**
  31346. * Set specific vertex data
  31347. * @param kind defines the data kind (Position, normal, etc...)
  31348. * @param data defines the vertex data to use
  31349. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31350. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31351. */
  31352. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  31353. /**
  31354. * Update a specific associated vertex buffer
  31355. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  31356. * - VertexBuffer.PositionKind
  31357. * - VertexBuffer.UVKind
  31358. * - VertexBuffer.UV2Kind
  31359. * - VertexBuffer.UV3Kind
  31360. * - VertexBuffer.UV4Kind
  31361. * - VertexBuffer.UV5Kind
  31362. * - VertexBuffer.UV6Kind
  31363. * - VertexBuffer.ColorKind
  31364. * - VertexBuffer.MatricesIndicesKind
  31365. * - VertexBuffer.MatricesIndicesExtraKind
  31366. * - VertexBuffer.MatricesWeightsKind
  31367. * - VertexBuffer.MatricesWeightsExtraKind
  31368. * @param data defines the data source
  31369. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  31370. * @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)
  31371. */
  31372. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  31373. /**
  31374. * Creates a new index buffer
  31375. * @param indices defines the indices to store in the index buffer
  31376. * @param totalVertices defines the total number of vertices (could be null)
  31377. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31378. */
  31379. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  31380. }
  31381. /**
  31382. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  31383. */
  31384. export class VertexData {
  31385. /**
  31386. * Mesh side orientation : usually the external or front surface
  31387. */
  31388. static readonly FRONTSIDE: number;
  31389. /**
  31390. * Mesh side orientation : usually the internal or back surface
  31391. */
  31392. static readonly BACKSIDE: number;
  31393. /**
  31394. * Mesh side orientation : both internal and external or front and back surfaces
  31395. */
  31396. static readonly DOUBLESIDE: number;
  31397. /**
  31398. * Mesh side orientation : by default, `FRONTSIDE`
  31399. */
  31400. static readonly DEFAULTSIDE: number;
  31401. /**
  31402. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  31403. */
  31404. positions: Nullable<FloatArray>;
  31405. /**
  31406. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  31407. */
  31408. normals: Nullable<FloatArray>;
  31409. /**
  31410. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  31411. */
  31412. tangents: Nullable<FloatArray>;
  31413. /**
  31414. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31415. */
  31416. uvs: Nullable<FloatArray>;
  31417. /**
  31418. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31419. */
  31420. uvs2: Nullable<FloatArray>;
  31421. /**
  31422. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31423. */
  31424. uvs3: Nullable<FloatArray>;
  31425. /**
  31426. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31427. */
  31428. uvs4: Nullable<FloatArray>;
  31429. /**
  31430. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31431. */
  31432. uvs5: Nullable<FloatArray>;
  31433. /**
  31434. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31435. */
  31436. uvs6: Nullable<FloatArray>;
  31437. /**
  31438. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  31439. */
  31440. colors: Nullable<FloatArray>;
  31441. /**
  31442. * 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).
  31443. */
  31444. matricesIndices: Nullable<FloatArray>;
  31445. /**
  31446. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  31447. */
  31448. matricesWeights: Nullable<FloatArray>;
  31449. /**
  31450. * An array extending the number of possible indices
  31451. */
  31452. matricesIndicesExtra: Nullable<FloatArray>;
  31453. /**
  31454. * An array extending the number of possible weights when the number of indices is extended
  31455. */
  31456. matricesWeightsExtra: Nullable<FloatArray>;
  31457. /**
  31458. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  31459. */
  31460. indices: Nullable<IndicesArray>;
  31461. /**
  31462. * Uses the passed data array to set the set the values for the specified kind of data
  31463. * @param data a linear array of floating numbers
  31464. * @param kind the type of data that is being set, eg positions, colors etc
  31465. */
  31466. set(data: FloatArray, kind: string): void;
  31467. /**
  31468. * Associates the vertexData to the passed Mesh.
  31469. * Sets it as updatable or not (default `false`)
  31470. * @param mesh the mesh the vertexData is applied to
  31471. * @param updatable when used and having the value true allows new data to update the vertexData
  31472. * @returns the VertexData
  31473. */
  31474. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  31475. /**
  31476. * Associates the vertexData to the passed Geometry.
  31477. * Sets it as updatable or not (default `false`)
  31478. * @param geometry the geometry the vertexData is applied to
  31479. * @param updatable when used and having the value true allows new data to update the vertexData
  31480. * @returns VertexData
  31481. */
  31482. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  31483. /**
  31484. * Updates the associated mesh
  31485. * @param mesh the mesh to be updated
  31486. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31487. * @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
  31488. * @returns VertexData
  31489. */
  31490. updateMesh(mesh: Mesh): VertexData;
  31491. /**
  31492. * Updates the associated geometry
  31493. * @param geometry the geometry to be updated
  31494. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31495. * @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
  31496. * @returns VertexData.
  31497. */
  31498. updateGeometry(geometry: Geometry): VertexData;
  31499. private _applyTo;
  31500. private _update;
  31501. /**
  31502. * Transforms each position and each normal of the vertexData according to the passed Matrix
  31503. * @param matrix the transforming matrix
  31504. * @returns the VertexData
  31505. */
  31506. transform(matrix: Matrix): VertexData;
  31507. /**
  31508. * Merges the passed VertexData into the current one
  31509. * @param other the VertexData to be merged into the current one
  31510. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  31511. * @returns the modified VertexData
  31512. */
  31513. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  31514. private _mergeElement;
  31515. private _validate;
  31516. /**
  31517. * Serializes the VertexData
  31518. * @returns a serialized object
  31519. */
  31520. serialize(): any;
  31521. /**
  31522. * Extracts the vertexData from a mesh
  31523. * @param mesh the mesh from which to extract the VertexData
  31524. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  31525. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31526. * @returns the object VertexData associated to the passed mesh
  31527. */
  31528. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31529. /**
  31530. * Extracts the vertexData from the geometry
  31531. * @param geometry the geometry from which to extract the VertexData
  31532. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  31533. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31534. * @returns the object VertexData associated to the passed mesh
  31535. */
  31536. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31537. private static _ExtractFrom;
  31538. /**
  31539. * Creates the VertexData for a Ribbon
  31540. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  31541. * * pathArray array of paths, each of which an array of successive Vector3
  31542. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  31543. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  31544. * * 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
  31545. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31546. * * 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)
  31547. * * 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)
  31548. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  31549. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  31550. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  31551. * @returns the VertexData of the ribbon
  31552. */
  31553. static CreateRibbon(options: {
  31554. pathArray: Vector3[][];
  31555. closeArray?: boolean;
  31556. closePath?: boolean;
  31557. offset?: number;
  31558. sideOrientation?: number;
  31559. frontUVs?: Vector4;
  31560. backUVs?: Vector4;
  31561. invertUV?: boolean;
  31562. uvs?: Vector2[];
  31563. colors?: Color4[];
  31564. }): VertexData;
  31565. /**
  31566. * Creates the VertexData for a box
  31567. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31568. * * size sets the width, height and depth of the box to the value of size, optional default 1
  31569. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  31570. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  31571. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  31572. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31573. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31574. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31575. * * 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)
  31576. * * 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)
  31577. * @returns the VertexData of the box
  31578. */
  31579. static CreateBox(options: {
  31580. size?: number;
  31581. width?: number;
  31582. height?: number;
  31583. depth?: number;
  31584. faceUV?: Vector4[];
  31585. faceColors?: Color4[];
  31586. sideOrientation?: number;
  31587. frontUVs?: Vector4;
  31588. backUVs?: Vector4;
  31589. }): VertexData;
  31590. /**
  31591. * Creates the VertexData for a tiled box
  31592. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31593. * * faceTiles sets the pattern, tile size and number of tiles for a face
  31594. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31595. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31596. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31597. * @returns the VertexData of the box
  31598. */
  31599. static CreateTiledBox(options: {
  31600. pattern?: number;
  31601. width?: number;
  31602. height?: number;
  31603. depth?: number;
  31604. tileSize?: number;
  31605. tileWidth?: number;
  31606. tileHeight?: number;
  31607. alignHorizontal?: number;
  31608. alignVertical?: number;
  31609. faceUV?: Vector4[];
  31610. faceColors?: Color4[];
  31611. sideOrientation?: number;
  31612. }): VertexData;
  31613. /**
  31614. * Creates the VertexData for a tiled plane
  31615. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31616. * * pattern a limited pattern arrangement depending on the number
  31617. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  31618. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  31619. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  31620. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31621. * * 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)
  31622. * * 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)
  31623. * @returns the VertexData of the tiled plane
  31624. */
  31625. static CreateTiledPlane(options: {
  31626. pattern?: number;
  31627. tileSize?: number;
  31628. tileWidth?: number;
  31629. tileHeight?: number;
  31630. size?: number;
  31631. width?: number;
  31632. height?: number;
  31633. alignHorizontal?: number;
  31634. alignVertical?: number;
  31635. sideOrientation?: number;
  31636. frontUVs?: Vector4;
  31637. backUVs?: Vector4;
  31638. }): VertexData;
  31639. /**
  31640. * Creates the VertexData for an ellipsoid, defaults to a sphere
  31641. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31642. * * segments sets the number of horizontal strips optional, default 32
  31643. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  31644. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  31645. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  31646. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  31647. * * 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
  31648. * * 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
  31649. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31650. * * 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)
  31651. * * 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)
  31652. * @returns the VertexData of the ellipsoid
  31653. */
  31654. static CreateSphere(options: {
  31655. segments?: number;
  31656. diameter?: number;
  31657. diameterX?: number;
  31658. diameterY?: number;
  31659. diameterZ?: number;
  31660. arc?: number;
  31661. slice?: number;
  31662. sideOrientation?: number;
  31663. frontUVs?: Vector4;
  31664. backUVs?: Vector4;
  31665. }): VertexData;
  31666. /**
  31667. * Creates the VertexData for a cylinder, cone or prism
  31668. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31669. * * height sets the height (y direction) of the cylinder, optional, default 2
  31670. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  31671. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  31672. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  31673. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31674. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  31675. * * 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
  31676. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31677. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31678. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  31679. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  31680. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31681. * * 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)
  31682. * * 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)
  31683. * @returns the VertexData of the cylinder, cone or prism
  31684. */
  31685. static CreateCylinder(options: {
  31686. height?: number;
  31687. diameterTop?: number;
  31688. diameterBottom?: number;
  31689. diameter?: number;
  31690. tessellation?: number;
  31691. subdivisions?: number;
  31692. arc?: number;
  31693. faceColors?: Color4[];
  31694. faceUV?: Vector4[];
  31695. hasRings?: boolean;
  31696. enclose?: boolean;
  31697. sideOrientation?: number;
  31698. frontUVs?: Vector4;
  31699. backUVs?: Vector4;
  31700. }): VertexData;
  31701. /**
  31702. * Creates the VertexData for a torus
  31703. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31704. * * diameter the diameter of the torus, optional default 1
  31705. * * thickness the diameter of the tube forming the torus, optional default 0.5
  31706. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31707. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31708. * * 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)
  31709. * * 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)
  31710. * @returns the VertexData of the torus
  31711. */
  31712. static CreateTorus(options: {
  31713. diameter?: number;
  31714. thickness?: number;
  31715. tessellation?: number;
  31716. sideOrientation?: number;
  31717. frontUVs?: Vector4;
  31718. backUVs?: Vector4;
  31719. }): VertexData;
  31720. /**
  31721. * Creates the VertexData of the LineSystem
  31722. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  31723. * - lines an array of lines, each line being an array of successive Vector3
  31724. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  31725. * @returns the VertexData of the LineSystem
  31726. */
  31727. static CreateLineSystem(options: {
  31728. lines: Vector3[][];
  31729. colors?: Nullable<Color4[][]>;
  31730. }): VertexData;
  31731. /**
  31732. * Create the VertexData for a DashedLines
  31733. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  31734. * - points an array successive Vector3
  31735. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  31736. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  31737. * - dashNb the intended total number of dashes, optional, default 200
  31738. * @returns the VertexData for the DashedLines
  31739. */
  31740. static CreateDashedLines(options: {
  31741. points: Vector3[];
  31742. dashSize?: number;
  31743. gapSize?: number;
  31744. dashNb?: number;
  31745. }): VertexData;
  31746. /**
  31747. * Creates the VertexData for a Ground
  31748. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31749. * - width the width (x direction) of the ground, optional, default 1
  31750. * - height the height (z direction) of the ground, optional, default 1
  31751. * - subdivisions the number of subdivisions per side, optional, default 1
  31752. * @returns the VertexData of the Ground
  31753. */
  31754. static CreateGround(options: {
  31755. width?: number;
  31756. height?: number;
  31757. subdivisions?: number;
  31758. subdivisionsX?: number;
  31759. subdivisionsY?: number;
  31760. }): VertexData;
  31761. /**
  31762. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  31763. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31764. * * xmin the ground minimum X coordinate, optional, default -1
  31765. * * zmin the ground minimum Z coordinate, optional, default -1
  31766. * * xmax the ground maximum X coordinate, optional, default 1
  31767. * * zmax the ground maximum Z coordinate, optional, default 1
  31768. * * 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}
  31769. * * 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}
  31770. * @returns the VertexData of the TiledGround
  31771. */
  31772. static CreateTiledGround(options: {
  31773. xmin: number;
  31774. zmin: number;
  31775. xmax: number;
  31776. zmax: number;
  31777. subdivisions?: {
  31778. w: number;
  31779. h: number;
  31780. };
  31781. precision?: {
  31782. w: number;
  31783. h: number;
  31784. };
  31785. }): VertexData;
  31786. /**
  31787. * Creates the VertexData of the Ground designed from a heightmap
  31788. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  31789. * * width the width (x direction) of the ground
  31790. * * height the height (z direction) of the ground
  31791. * * subdivisions the number of subdivisions per side
  31792. * * minHeight the minimum altitude on the ground, optional, default 0
  31793. * * maxHeight the maximum altitude on the ground, optional default 1
  31794. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  31795. * * buffer the array holding the image color data
  31796. * * bufferWidth the width of image
  31797. * * bufferHeight the height of image
  31798. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  31799. * @returns the VertexData of the Ground designed from a heightmap
  31800. */
  31801. static CreateGroundFromHeightMap(options: {
  31802. width: number;
  31803. height: number;
  31804. subdivisions: number;
  31805. minHeight: number;
  31806. maxHeight: number;
  31807. colorFilter: Color3;
  31808. buffer: Uint8Array;
  31809. bufferWidth: number;
  31810. bufferHeight: number;
  31811. alphaFilter: number;
  31812. }): VertexData;
  31813. /**
  31814. * Creates the VertexData for a Plane
  31815. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  31816. * * size sets the width and height of the plane to the value of size, optional default 1
  31817. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  31818. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  31819. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31820. * * 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)
  31821. * * 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)
  31822. * @returns the VertexData of the box
  31823. */
  31824. static CreatePlane(options: {
  31825. size?: number;
  31826. width?: number;
  31827. height?: number;
  31828. sideOrientation?: number;
  31829. frontUVs?: Vector4;
  31830. backUVs?: Vector4;
  31831. }): VertexData;
  31832. /**
  31833. * Creates the VertexData of the Disc or regular Polygon
  31834. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  31835. * * radius the radius of the disc, optional default 0.5
  31836. * * tessellation the number of polygon sides, optional, default 64
  31837. * * 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
  31838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31839. * * 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)
  31840. * * 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)
  31841. * @returns the VertexData of the box
  31842. */
  31843. static CreateDisc(options: {
  31844. radius?: number;
  31845. tessellation?: number;
  31846. arc?: number;
  31847. sideOrientation?: number;
  31848. frontUVs?: Vector4;
  31849. backUVs?: Vector4;
  31850. }): VertexData;
  31851. /**
  31852. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  31853. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  31854. * @param polygon a mesh built from polygonTriangulation.build()
  31855. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31856. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31857. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31858. * @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)
  31859. * @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)
  31860. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  31861. * @returns the VertexData of the Polygon
  31862. */
  31863. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  31864. /**
  31865. * Creates the VertexData of the IcoSphere
  31866. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  31867. * * radius the radius of the IcoSphere, optional default 1
  31868. * * radiusX allows stretching in the x direction, optional, default radius
  31869. * * radiusY allows stretching in the y direction, optional, default radius
  31870. * * radiusZ allows stretching in the z direction, optional, default radius
  31871. * * flat when true creates a flat shaded mesh, optional, default true
  31872. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31873. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31874. * * 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)
  31875. * * 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)
  31876. * @returns the VertexData of the IcoSphere
  31877. */
  31878. static CreateIcoSphere(options: {
  31879. radius?: number;
  31880. radiusX?: number;
  31881. radiusY?: number;
  31882. radiusZ?: number;
  31883. flat?: boolean;
  31884. subdivisions?: number;
  31885. sideOrientation?: number;
  31886. frontUVs?: Vector4;
  31887. backUVs?: Vector4;
  31888. }): VertexData;
  31889. /**
  31890. * Creates the VertexData for a Polyhedron
  31891. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  31892. * * type provided types are:
  31893. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  31894. * * 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)
  31895. * * size the size of the IcoSphere, optional default 1
  31896. * * sizeX allows stretching in the x direction, optional, default size
  31897. * * sizeY allows stretching in the y direction, optional, default size
  31898. * * sizeZ allows stretching in the z direction, optional, default size
  31899. * * 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
  31900. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31901. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31902. * * flat when true creates a flat shaded mesh, optional, default true
  31903. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31904. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31905. * * 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)
  31906. * * 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)
  31907. * @returns the VertexData of the Polyhedron
  31908. */
  31909. static CreatePolyhedron(options: {
  31910. type?: number;
  31911. size?: number;
  31912. sizeX?: number;
  31913. sizeY?: number;
  31914. sizeZ?: number;
  31915. custom?: any;
  31916. faceUV?: Vector4[];
  31917. faceColors?: Color4[];
  31918. flat?: boolean;
  31919. sideOrientation?: number;
  31920. frontUVs?: Vector4;
  31921. backUVs?: Vector4;
  31922. }): VertexData;
  31923. /**
  31924. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  31925. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  31926. * @returns the VertexData of the Capsule
  31927. */
  31928. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  31929. /**
  31930. * Creates the VertexData for a TorusKnot
  31931. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  31932. * * radius the radius of the torus knot, optional, default 2
  31933. * * tube the thickness of the tube, optional, default 0.5
  31934. * * radialSegments the number of sides on each tube segments, optional, default 32
  31935. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  31936. * * p the number of windings around the z axis, optional, default 2
  31937. * * q the number of windings around the x axis, optional, default 3
  31938. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31939. * * 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)
  31940. * * 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)
  31941. * @returns the VertexData of the Torus Knot
  31942. */
  31943. static CreateTorusKnot(options: {
  31944. radius?: number;
  31945. tube?: number;
  31946. radialSegments?: number;
  31947. tubularSegments?: number;
  31948. p?: number;
  31949. q?: number;
  31950. sideOrientation?: number;
  31951. frontUVs?: Vector4;
  31952. backUVs?: Vector4;
  31953. }): VertexData;
  31954. /**
  31955. * Compute normals for given positions and indices
  31956. * @param positions an array of vertex positions, [...., x, y, z, ......]
  31957. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  31958. * @param normals an array of vertex normals, [...., x, y, z, ......]
  31959. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  31960. * * facetNormals : optional array of facet normals (vector3)
  31961. * * facetPositions : optional array of facet positions (vector3)
  31962. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  31963. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  31964. * * bInfo : optional bounding info, required for facetPartitioning computation
  31965. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  31966. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  31967. * * useRightHandedSystem: optional boolean to for right handed system computation
  31968. * * depthSort : optional boolean to enable the facet depth sort computation
  31969. * * distanceTo : optional Vector3 to compute the facet depth from this location
  31970. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  31971. */
  31972. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  31973. facetNormals?: any;
  31974. facetPositions?: any;
  31975. facetPartitioning?: any;
  31976. ratio?: number;
  31977. bInfo?: any;
  31978. bbSize?: Vector3;
  31979. subDiv?: any;
  31980. useRightHandedSystem?: boolean;
  31981. depthSort?: boolean;
  31982. distanceTo?: Vector3;
  31983. depthSortedFacets?: any;
  31984. }): void;
  31985. /** @hidden */
  31986. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  31987. /**
  31988. * Applies VertexData created from the imported parameters to the geometry
  31989. * @param parsedVertexData the parsed data from an imported file
  31990. * @param geometry the geometry to apply the VertexData to
  31991. */
  31992. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  31993. }
  31994. }
  31995. declare module "babylonjs/Morph/morphTarget" {
  31996. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31997. import { Observable } from "babylonjs/Misc/observable";
  31998. import { Nullable, FloatArray } from "babylonjs/types";
  31999. import { Scene } from "babylonjs/scene";
  32000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32001. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32002. /**
  32003. * Defines a target to use with MorphTargetManager
  32004. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32005. */
  32006. export class MorphTarget implements IAnimatable {
  32007. /** defines the name of the target */
  32008. name: string;
  32009. /**
  32010. * Gets or sets the list of animations
  32011. */
  32012. animations: import("babylonjs/Animations/animation").Animation[];
  32013. private _scene;
  32014. private _positions;
  32015. private _normals;
  32016. private _tangents;
  32017. private _uvs;
  32018. private _influence;
  32019. private _uniqueId;
  32020. /**
  32021. * Observable raised when the influence changes
  32022. */
  32023. onInfluenceChanged: Observable<boolean>;
  32024. /** @hidden */
  32025. _onDataLayoutChanged: Observable<void>;
  32026. /**
  32027. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32028. */
  32029. get influence(): number;
  32030. set influence(influence: number);
  32031. /**
  32032. * Gets or sets the id of the morph Target
  32033. */
  32034. id: string;
  32035. private _animationPropertiesOverride;
  32036. /**
  32037. * Gets or sets the animation properties override
  32038. */
  32039. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32040. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32041. /**
  32042. * Creates a new MorphTarget
  32043. * @param name defines the name of the target
  32044. * @param influence defines the influence to use
  32045. * @param scene defines the scene the morphtarget belongs to
  32046. */
  32047. constructor(
  32048. /** defines the name of the target */
  32049. name: string, influence?: number, scene?: Nullable<Scene>);
  32050. /**
  32051. * Gets the unique ID of this manager
  32052. */
  32053. get uniqueId(): number;
  32054. /**
  32055. * Gets a boolean defining if the target contains position data
  32056. */
  32057. get hasPositions(): boolean;
  32058. /**
  32059. * Gets a boolean defining if the target contains normal data
  32060. */
  32061. get hasNormals(): boolean;
  32062. /**
  32063. * Gets a boolean defining if the target contains tangent data
  32064. */
  32065. get hasTangents(): boolean;
  32066. /**
  32067. * Gets a boolean defining if the target contains texture coordinates data
  32068. */
  32069. get hasUVs(): boolean;
  32070. /**
  32071. * Affects position data to this target
  32072. * @param data defines the position data to use
  32073. */
  32074. setPositions(data: Nullable<FloatArray>): void;
  32075. /**
  32076. * Gets the position data stored in this target
  32077. * @returns a FloatArray containing the position data (or null if not present)
  32078. */
  32079. getPositions(): Nullable<FloatArray>;
  32080. /**
  32081. * Affects normal data to this target
  32082. * @param data defines the normal data to use
  32083. */
  32084. setNormals(data: Nullable<FloatArray>): void;
  32085. /**
  32086. * Gets the normal data stored in this target
  32087. * @returns a FloatArray containing the normal data (or null if not present)
  32088. */
  32089. getNormals(): Nullable<FloatArray>;
  32090. /**
  32091. * Affects tangent data to this target
  32092. * @param data defines the tangent data to use
  32093. */
  32094. setTangents(data: Nullable<FloatArray>): void;
  32095. /**
  32096. * Gets the tangent data stored in this target
  32097. * @returns a FloatArray containing the tangent data (or null if not present)
  32098. */
  32099. getTangents(): Nullable<FloatArray>;
  32100. /**
  32101. * Affects texture coordinates data to this target
  32102. * @param data defines the texture coordinates data to use
  32103. */
  32104. setUVs(data: Nullable<FloatArray>): void;
  32105. /**
  32106. * Gets the texture coordinates data stored in this target
  32107. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32108. */
  32109. getUVs(): Nullable<FloatArray>;
  32110. /**
  32111. * Clone the current target
  32112. * @returns a new MorphTarget
  32113. */
  32114. clone(): MorphTarget;
  32115. /**
  32116. * Serializes the current target into a Serialization object
  32117. * @returns the serialized object
  32118. */
  32119. serialize(): any;
  32120. /**
  32121. * Returns the string "MorphTarget"
  32122. * @returns "MorphTarget"
  32123. */
  32124. getClassName(): string;
  32125. /**
  32126. * Creates a new target from serialized data
  32127. * @param serializationObject defines the serialized data to use
  32128. * @returns a new MorphTarget
  32129. */
  32130. static Parse(serializationObject: any): MorphTarget;
  32131. /**
  32132. * Creates a MorphTarget from mesh data
  32133. * @param mesh defines the source mesh
  32134. * @param name defines the name to use for the new target
  32135. * @param influence defines the influence to attach to the target
  32136. * @returns a new MorphTarget
  32137. */
  32138. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32139. }
  32140. }
  32141. declare module "babylonjs/Morph/morphTargetManager" {
  32142. import { Nullable } from "babylonjs/types";
  32143. import { Scene } from "babylonjs/scene";
  32144. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32145. /**
  32146. * This class is used to deform meshes using morphing between different targets
  32147. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32148. */
  32149. export class MorphTargetManager {
  32150. private _targets;
  32151. private _targetInfluenceChangedObservers;
  32152. private _targetDataLayoutChangedObservers;
  32153. private _activeTargets;
  32154. private _scene;
  32155. private _influences;
  32156. private _supportsNormals;
  32157. private _supportsTangents;
  32158. private _supportsUVs;
  32159. private _vertexCount;
  32160. private _uniqueId;
  32161. private _tempInfluences;
  32162. /**
  32163. * Gets or sets a boolean indicating if normals must be morphed
  32164. */
  32165. enableNormalMorphing: boolean;
  32166. /**
  32167. * Gets or sets a boolean indicating if tangents must be morphed
  32168. */
  32169. enableTangentMorphing: boolean;
  32170. /**
  32171. * Gets or sets a boolean indicating if UV must be morphed
  32172. */
  32173. enableUVMorphing: boolean;
  32174. /**
  32175. * Creates a new MorphTargetManager
  32176. * @param scene defines the current scene
  32177. */
  32178. constructor(scene?: Nullable<Scene>);
  32179. /**
  32180. * Gets the unique ID of this manager
  32181. */
  32182. get uniqueId(): number;
  32183. /**
  32184. * Gets the number of vertices handled by this manager
  32185. */
  32186. get vertexCount(): number;
  32187. /**
  32188. * Gets a boolean indicating if this manager supports morphing of normals
  32189. */
  32190. get supportsNormals(): boolean;
  32191. /**
  32192. * Gets a boolean indicating if this manager supports morphing of tangents
  32193. */
  32194. get supportsTangents(): boolean;
  32195. /**
  32196. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32197. */
  32198. get supportsUVs(): boolean;
  32199. /**
  32200. * Gets the number of targets stored in this manager
  32201. */
  32202. get numTargets(): number;
  32203. /**
  32204. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32205. */
  32206. get numInfluencers(): number;
  32207. /**
  32208. * Gets the list of influences (one per target)
  32209. */
  32210. get influences(): Float32Array;
  32211. /**
  32212. * Gets the active target at specified index. An active target is a target with an influence > 0
  32213. * @param index defines the index to check
  32214. * @returns the requested target
  32215. */
  32216. getActiveTarget(index: number): MorphTarget;
  32217. /**
  32218. * Gets the target at specified index
  32219. * @param index defines the index to check
  32220. * @returns the requested target
  32221. */
  32222. getTarget(index: number): MorphTarget;
  32223. /**
  32224. * Add a new target to this manager
  32225. * @param target defines the target to add
  32226. */
  32227. addTarget(target: MorphTarget): void;
  32228. /**
  32229. * Removes a target from the manager
  32230. * @param target defines the target to remove
  32231. */
  32232. removeTarget(target: MorphTarget): void;
  32233. /**
  32234. * Clone the current manager
  32235. * @returns a new MorphTargetManager
  32236. */
  32237. clone(): MorphTargetManager;
  32238. /**
  32239. * Serializes the current manager into a Serialization object
  32240. * @returns the serialized object
  32241. */
  32242. serialize(): any;
  32243. private _syncActiveTargets;
  32244. /**
  32245. * Syncrhonize the targets with all the meshes using this morph target manager
  32246. */
  32247. synchronize(): void;
  32248. /**
  32249. * Creates a new MorphTargetManager from serialized data
  32250. * @param serializationObject defines the serialized data
  32251. * @param scene defines the hosting scene
  32252. * @returns the new MorphTargetManager
  32253. */
  32254. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32255. }
  32256. }
  32257. declare module "babylonjs/Meshes/meshLODLevel" {
  32258. import { Mesh } from "babylonjs/Meshes/mesh";
  32259. import { Nullable } from "babylonjs/types";
  32260. /**
  32261. * Class used to represent a specific level of detail of a mesh
  32262. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32263. */
  32264. export class MeshLODLevel {
  32265. /** Defines the distance where this level should start being displayed */
  32266. distance: number;
  32267. /** Defines the mesh to use to render this level */
  32268. mesh: Nullable<Mesh>;
  32269. /**
  32270. * Creates a new LOD level
  32271. * @param distance defines the distance where this level should star being displayed
  32272. * @param mesh defines the mesh to use to render this level
  32273. */
  32274. constructor(
  32275. /** Defines the distance where this level should start being displayed */
  32276. distance: number,
  32277. /** Defines the mesh to use to render this level */
  32278. mesh: Nullable<Mesh>);
  32279. }
  32280. }
  32281. declare module "babylonjs/Misc/canvasGenerator" {
  32282. /**
  32283. * Helper class used to generate a canvas to manipulate images
  32284. */
  32285. export class CanvasGenerator {
  32286. /**
  32287. * Create a new canvas (or offscreen canvas depending on the context)
  32288. * @param width defines the expected width
  32289. * @param height defines the expected height
  32290. * @return a new canvas or offscreen canvas
  32291. */
  32292. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32293. }
  32294. }
  32295. declare module "babylonjs/Meshes/groundMesh" {
  32296. import { Scene } from "babylonjs/scene";
  32297. import { Vector3 } from "babylonjs/Maths/math.vector";
  32298. import { Mesh } from "babylonjs/Meshes/mesh";
  32299. /**
  32300. * Mesh representing the gorund
  32301. */
  32302. export class GroundMesh extends Mesh {
  32303. /** If octree should be generated */
  32304. generateOctree: boolean;
  32305. private _heightQuads;
  32306. /** @hidden */
  32307. _subdivisionsX: number;
  32308. /** @hidden */
  32309. _subdivisionsY: number;
  32310. /** @hidden */
  32311. _width: number;
  32312. /** @hidden */
  32313. _height: number;
  32314. /** @hidden */
  32315. _minX: number;
  32316. /** @hidden */
  32317. _maxX: number;
  32318. /** @hidden */
  32319. _minZ: number;
  32320. /** @hidden */
  32321. _maxZ: number;
  32322. constructor(name: string, scene: Scene);
  32323. /**
  32324. * "GroundMesh"
  32325. * @returns "GroundMesh"
  32326. */
  32327. getClassName(): string;
  32328. /**
  32329. * The minimum of x and y subdivisions
  32330. */
  32331. get subdivisions(): number;
  32332. /**
  32333. * X subdivisions
  32334. */
  32335. get subdivisionsX(): number;
  32336. /**
  32337. * Y subdivisions
  32338. */
  32339. get subdivisionsY(): number;
  32340. /**
  32341. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32342. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32343. * @param chunksCount the number of subdivisions for x and y
  32344. * @param octreeBlocksSize (Default: 32)
  32345. */
  32346. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32347. /**
  32348. * Returns a height (y) value in the Worl system :
  32349. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32350. * @param x x coordinate
  32351. * @param z z coordinate
  32352. * @returns the ground y position if (x, z) are outside the ground surface.
  32353. */
  32354. getHeightAtCoordinates(x: number, z: number): number;
  32355. /**
  32356. * Returns a normalized vector (Vector3) orthogonal to the ground
  32357. * at the ground coordinates (x, z) expressed in the World system.
  32358. * @param x x coordinate
  32359. * @param z z coordinate
  32360. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32361. */
  32362. getNormalAtCoordinates(x: number, z: number): Vector3;
  32363. /**
  32364. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32365. * at the ground coordinates (x, z) expressed in the World system.
  32366. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32367. * @param x x coordinate
  32368. * @param z z coordinate
  32369. * @param ref vector to store the result
  32370. * @returns the GroundMesh.
  32371. */
  32372. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32373. /**
  32374. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32375. * if the ground has been updated.
  32376. * This can be used in the render loop.
  32377. * @returns the GroundMesh.
  32378. */
  32379. updateCoordinateHeights(): GroundMesh;
  32380. private _getFacetAt;
  32381. private _initHeightQuads;
  32382. private _computeHeightQuads;
  32383. /**
  32384. * Serializes this ground mesh
  32385. * @param serializationObject object to write serialization to
  32386. */
  32387. serialize(serializationObject: any): void;
  32388. /**
  32389. * Parses a serialized ground mesh
  32390. * @param parsedMesh the serialized mesh
  32391. * @param scene the scene to create the ground mesh in
  32392. * @returns the created ground mesh
  32393. */
  32394. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32395. }
  32396. }
  32397. declare module "babylonjs/Physics/physicsJoint" {
  32398. import { Vector3 } from "babylonjs/Maths/math.vector";
  32399. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32400. /**
  32401. * Interface for Physics-Joint data
  32402. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32403. */
  32404. export interface PhysicsJointData {
  32405. /**
  32406. * The main pivot of the joint
  32407. */
  32408. mainPivot?: Vector3;
  32409. /**
  32410. * The connected pivot of the joint
  32411. */
  32412. connectedPivot?: Vector3;
  32413. /**
  32414. * The main axis of the joint
  32415. */
  32416. mainAxis?: Vector3;
  32417. /**
  32418. * The connected axis of the joint
  32419. */
  32420. connectedAxis?: Vector3;
  32421. /**
  32422. * The collision of the joint
  32423. */
  32424. collision?: boolean;
  32425. /**
  32426. * Native Oimo/Cannon/Energy data
  32427. */
  32428. nativeParams?: any;
  32429. }
  32430. /**
  32431. * This is a holder class for the physics joint created by the physics plugin
  32432. * It holds a set of functions to control the underlying joint
  32433. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32434. */
  32435. export class PhysicsJoint {
  32436. /**
  32437. * The type of the physics joint
  32438. */
  32439. type: number;
  32440. /**
  32441. * The data for the physics joint
  32442. */
  32443. jointData: PhysicsJointData;
  32444. private _physicsJoint;
  32445. protected _physicsPlugin: IPhysicsEnginePlugin;
  32446. /**
  32447. * Initializes the physics joint
  32448. * @param type The type of the physics joint
  32449. * @param jointData The data for the physics joint
  32450. */
  32451. constructor(
  32452. /**
  32453. * The type of the physics joint
  32454. */
  32455. type: number,
  32456. /**
  32457. * The data for the physics joint
  32458. */
  32459. jointData: PhysicsJointData);
  32460. /**
  32461. * Gets the physics joint
  32462. */
  32463. get physicsJoint(): any;
  32464. /**
  32465. * Sets the physics joint
  32466. */
  32467. set physicsJoint(newJoint: any);
  32468. /**
  32469. * Sets the physics plugin
  32470. */
  32471. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32472. /**
  32473. * Execute a function that is physics-plugin specific.
  32474. * @param {Function} func the function that will be executed.
  32475. * It accepts two parameters: the physics world and the physics joint
  32476. */
  32477. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32478. /**
  32479. * Distance-Joint type
  32480. */
  32481. static DistanceJoint: number;
  32482. /**
  32483. * Hinge-Joint type
  32484. */
  32485. static HingeJoint: number;
  32486. /**
  32487. * Ball-and-Socket joint type
  32488. */
  32489. static BallAndSocketJoint: number;
  32490. /**
  32491. * Wheel-Joint type
  32492. */
  32493. static WheelJoint: number;
  32494. /**
  32495. * Slider-Joint type
  32496. */
  32497. static SliderJoint: number;
  32498. /**
  32499. * Prismatic-Joint type
  32500. */
  32501. static PrismaticJoint: number;
  32502. /**
  32503. * Universal-Joint type
  32504. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32505. */
  32506. static UniversalJoint: number;
  32507. /**
  32508. * Hinge-Joint 2 type
  32509. */
  32510. static Hinge2Joint: number;
  32511. /**
  32512. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32513. */
  32514. static PointToPointJoint: number;
  32515. /**
  32516. * Spring-Joint type
  32517. */
  32518. static SpringJoint: number;
  32519. /**
  32520. * Lock-Joint type
  32521. */
  32522. static LockJoint: number;
  32523. }
  32524. /**
  32525. * A class representing a physics distance joint
  32526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32527. */
  32528. export class DistanceJoint extends PhysicsJoint {
  32529. /**
  32530. *
  32531. * @param jointData The data for the Distance-Joint
  32532. */
  32533. constructor(jointData: DistanceJointData);
  32534. /**
  32535. * Update the predefined distance.
  32536. * @param maxDistance The maximum preferred distance
  32537. * @param minDistance The minimum preferred distance
  32538. */
  32539. updateDistance(maxDistance: number, minDistance?: number): void;
  32540. }
  32541. /**
  32542. * Represents a Motor-Enabled Joint
  32543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32544. */
  32545. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32546. /**
  32547. * Initializes the Motor-Enabled Joint
  32548. * @param type The type of the joint
  32549. * @param jointData The physica joint data for the joint
  32550. */
  32551. constructor(type: number, jointData: PhysicsJointData);
  32552. /**
  32553. * Set the motor values.
  32554. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32555. * @param force the force to apply
  32556. * @param maxForce max force for this motor.
  32557. */
  32558. setMotor(force?: number, maxForce?: number): void;
  32559. /**
  32560. * Set the motor's limits.
  32561. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32562. * @param upperLimit The upper limit of the motor
  32563. * @param lowerLimit The lower limit of the motor
  32564. */
  32565. setLimit(upperLimit: number, lowerLimit?: number): void;
  32566. }
  32567. /**
  32568. * This class represents a single physics Hinge-Joint
  32569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32570. */
  32571. export class HingeJoint extends MotorEnabledJoint {
  32572. /**
  32573. * Initializes the Hinge-Joint
  32574. * @param jointData The joint data for the Hinge-Joint
  32575. */
  32576. constructor(jointData: PhysicsJointData);
  32577. /**
  32578. * Set the motor values.
  32579. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32580. * @param {number} force the force to apply
  32581. * @param {number} maxForce max force for this motor.
  32582. */
  32583. setMotor(force?: number, maxForce?: number): void;
  32584. /**
  32585. * Set the motor's limits.
  32586. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32587. * @param upperLimit The upper limit of the motor
  32588. * @param lowerLimit The lower limit of the motor
  32589. */
  32590. setLimit(upperLimit: number, lowerLimit?: number): void;
  32591. }
  32592. /**
  32593. * This class represents a dual hinge physics joint (same as wheel joint)
  32594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32595. */
  32596. export class Hinge2Joint extends MotorEnabledJoint {
  32597. /**
  32598. * Initializes the Hinge2-Joint
  32599. * @param jointData The joint data for the Hinge2-Joint
  32600. */
  32601. constructor(jointData: PhysicsJointData);
  32602. /**
  32603. * Set the motor values.
  32604. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32605. * @param {number} targetSpeed the speed the motor is to reach
  32606. * @param {number} maxForce max force for this motor.
  32607. * @param {motorIndex} the motor's index, 0 or 1.
  32608. */
  32609. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32610. /**
  32611. * Set the motor limits.
  32612. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32613. * @param {number} upperLimit the upper limit
  32614. * @param {number} lowerLimit lower limit
  32615. * @param {motorIndex} the motor's index, 0 or 1.
  32616. */
  32617. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32618. }
  32619. /**
  32620. * Interface for a motor enabled joint
  32621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32622. */
  32623. export interface IMotorEnabledJoint {
  32624. /**
  32625. * Physics joint
  32626. */
  32627. physicsJoint: any;
  32628. /**
  32629. * Sets the motor of the motor-enabled joint
  32630. * @param force The force of the motor
  32631. * @param maxForce The maximum force of the motor
  32632. * @param motorIndex The index of the motor
  32633. */
  32634. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32635. /**
  32636. * Sets the limit of the motor
  32637. * @param upperLimit The upper limit of the motor
  32638. * @param lowerLimit The lower limit of the motor
  32639. * @param motorIndex The index of the motor
  32640. */
  32641. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32642. }
  32643. /**
  32644. * Joint data for a Distance-Joint
  32645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32646. */
  32647. export interface DistanceJointData extends PhysicsJointData {
  32648. /**
  32649. * Max distance the 2 joint objects can be apart
  32650. */
  32651. maxDistance: number;
  32652. }
  32653. /**
  32654. * Joint data from a spring joint
  32655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32656. */
  32657. export interface SpringJointData extends PhysicsJointData {
  32658. /**
  32659. * Length of the spring
  32660. */
  32661. length: number;
  32662. /**
  32663. * Stiffness of the spring
  32664. */
  32665. stiffness: number;
  32666. /**
  32667. * Damping of the spring
  32668. */
  32669. damping: number;
  32670. /** this callback will be called when applying the force to the impostors. */
  32671. forceApplicationCallback: () => void;
  32672. }
  32673. }
  32674. declare module "babylonjs/Physics/physicsRaycastResult" {
  32675. import { Vector3 } from "babylonjs/Maths/math.vector";
  32676. /**
  32677. * Holds the data for the raycast result
  32678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32679. */
  32680. export class PhysicsRaycastResult {
  32681. private _hasHit;
  32682. private _hitDistance;
  32683. private _hitNormalWorld;
  32684. private _hitPointWorld;
  32685. private _rayFromWorld;
  32686. private _rayToWorld;
  32687. /**
  32688. * Gets if there was a hit
  32689. */
  32690. get hasHit(): boolean;
  32691. /**
  32692. * Gets the distance from the hit
  32693. */
  32694. get hitDistance(): number;
  32695. /**
  32696. * Gets the hit normal/direction in the world
  32697. */
  32698. get hitNormalWorld(): Vector3;
  32699. /**
  32700. * Gets the hit point in the world
  32701. */
  32702. get hitPointWorld(): Vector3;
  32703. /**
  32704. * Gets the ray "start point" of the ray in the world
  32705. */
  32706. get rayFromWorld(): Vector3;
  32707. /**
  32708. * Gets the ray "end point" of the ray in the world
  32709. */
  32710. get rayToWorld(): Vector3;
  32711. /**
  32712. * Sets the hit data (normal & point in world space)
  32713. * @param hitNormalWorld defines the normal in world space
  32714. * @param hitPointWorld defines the point in world space
  32715. */
  32716. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32717. /**
  32718. * Sets the distance from the start point to the hit point
  32719. * @param distance
  32720. */
  32721. setHitDistance(distance: number): void;
  32722. /**
  32723. * Calculates the distance manually
  32724. */
  32725. calculateHitDistance(): void;
  32726. /**
  32727. * Resets all the values to default
  32728. * @param from The from point on world space
  32729. * @param to The to point on world space
  32730. */
  32731. reset(from?: Vector3, to?: Vector3): void;
  32732. }
  32733. /**
  32734. * Interface for the size containing width and height
  32735. */
  32736. interface IXYZ {
  32737. /**
  32738. * X
  32739. */
  32740. x: number;
  32741. /**
  32742. * Y
  32743. */
  32744. y: number;
  32745. /**
  32746. * Z
  32747. */
  32748. z: number;
  32749. }
  32750. }
  32751. declare module "babylonjs/Physics/IPhysicsEngine" {
  32752. import { Nullable } from "babylonjs/types";
  32753. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  32754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32755. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  32756. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  32757. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  32758. /**
  32759. * Interface used to describe a physics joint
  32760. */
  32761. export interface PhysicsImpostorJoint {
  32762. /** Defines the main impostor to which the joint is linked */
  32763. mainImpostor: PhysicsImpostor;
  32764. /** Defines the impostor that is connected to the main impostor using this joint */
  32765. connectedImpostor: PhysicsImpostor;
  32766. /** Defines the joint itself */
  32767. joint: PhysicsJoint;
  32768. }
  32769. /** @hidden */
  32770. export interface IPhysicsEnginePlugin {
  32771. world: any;
  32772. name: string;
  32773. setGravity(gravity: Vector3): void;
  32774. setTimeStep(timeStep: number): void;
  32775. getTimeStep(): number;
  32776. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32777. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32778. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32779. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32780. removePhysicsBody(impostor: PhysicsImpostor): void;
  32781. generateJoint(joint: PhysicsImpostorJoint): void;
  32782. removeJoint(joint: PhysicsImpostorJoint): void;
  32783. isSupported(): boolean;
  32784. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32785. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32786. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32787. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32788. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32789. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32790. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32791. getBodyMass(impostor: PhysicsImpostor): number;
  32792. getBodyFriction(impostor: PhysicsImpostor): number;
  32793. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32794. getBodyRestitution(impostor: PhysicsImpostor): number;
  32795. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32796. getBodyPressure?(impostor: PhysicsImpostor): number;
  32797. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32798. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32799. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32800. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32801. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32802. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32803. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32804. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32805. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32806. sleepBody(impostor: PhysicsImpostor): void;
  32807. wakeUpBody(impostor: PhysicsImpostor): void;
  32808. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32809. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32810. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32811. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32812. getRadius(impostor: PhysicsImpostor): number;
  32813. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32814. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32815. dispose(): void;
  32816. }
  32817. /**
  32818. * Interface used to define a physics engine
  32819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32820. */
  32821. export interface IPhysicsEngine {
  32822. /**
  32823. * Gets the gravity vector used by the simulation
  32824. */
  32825. gravity: Vector3;
  32826. /**
  32827. * Sets the gravity vector used by the simulation
  32828. * @param gravity defines the gravity vector to use
  32829. */
  32830. setGravity(gravity: Vector3): void;
  32831. /**
  32832. * Set the time step of the physics engine.
  32833. * Default is 1/60.
  32834. * To slow it down, enter 1/600 for example.
  32835. * To speed it up, 1/30
  32836. * @param newTimeStep the new timestep to apply to this world.
  32837. */
  32838. setTimeStep(newTimeStep: number): void;
  32839. /**
  32840. * Get the time step of the physics engine.
  32841. * @returns the current time step
  32842. */
  32843. getTimeStep(): number;
  32844. /**
  32845. * Set the sub time step of the physics engine.
  32846. * Default is 0 meaning there is no sub steps
  32847. * To increase physics resolution precision, set a small value (like 1 ms)
  32848. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32849. */
  32850. setSubTimeStep(subTimeStep: number): void;
  32851. /**
  32852. * Get the sub time step of the physics engine.
  32853. * @returns the current sub time step
  32854. */
  32855. getSubTimeStep(): number;
  32856. /**
  32857. * Release all resources
  32858. */
  32859. dispose(): void;
  32860. /**
  32861. * Gets the name of the current physics plugin
  32862. * @returns the name of the plugin
  32863. */
  32864. getPhysicsPluginName(): string;
  32865. /**
  32866. * Adding a new impostor for the impostor tracking.
  32867. * This will be done by the impostor itself.
  32868. * @param impostor the impostor to add
  32869. */
  32870. addImpostor(impostor: PhysicsImpostor): void;
  32871. /**
  32872. * Remove an impostor from the engine.
  32873. * This impostor and its mesh will not longer be updated by the physics engine.
  32874. * @param impostor the impostor to remove
  32875. */
  32876. removeImpostor(impostor: PhysicsImpostor): void;
  32877. /**
  32878. * Add a joint to the physics engine
  32879. * @param mainImpostor defines the main impostor to which the joint is added.
  32880. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32881. * @param joint defines the joint that will connect both impostors.
  32882. */
  32883. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32884. /**
  32885. * Removes a joint from the simulation
  32886. * @param mainImpostor defines the impostor used with the joint
  32887. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32888. * @param joint defines the joint to remove
  32889. */
  32890. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32891. /**
  32892. * Gets the current plugin used to run the simulation
  32893. * @returns current plugin
  32894. */
  32895. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32896. /**
  32897. * Gets the list of physic impostors
  32898. * @returns an array of PhysicsImpostor
  32899. */
  32900. getImpostors(): Array<PhysicsImpostor>;
  32901. /**
  32902. * Gets the impostor for a physics enabled object
  32903. * @param object defines the object impersonated by the impostor
  32904. * @returns the PhysicsImpostor or null if not found
  32905. */
  32906. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32907. /**
  32908. * Gets the impostor for a physics body object
  32909. * @param body defines physics body used by the impostor
  32910. * @returns the PhysicsImpostor or null if not found
  32911. */
  32912. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32913. /**
  32914. * Does a raycast in the physics world
  32915. * @param from when should the ray start?
  32916. * @param to when should the ray end?
  32917. * @returns PhysicsRaycastResult
  32918. */
  32919. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32920. /**
  32921. * Called by the scene. No need to call it.
  32922. * @param delta defines the timespam between frames
  32923. */
  32924. _step(delta: number): void;
  32925. }
  32926. }
  32927. declare module "babylonjs/Physics/physicsImpostor" {
  32928. import { Nullable, IndicesArray } from "babylonjs/types";
  32929. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  32930. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32932. import { Scene } from "babylonjs/scene";
  32933. import { Bone } from "babylonjs/Bones/bone";
  32934. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32935. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  32936. import { Space } from "babylonjs/Maths/math.axis";
  32937. /**
  32938. * The interface for the physics imposter parameters
  32939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32940. */
  32941. export interface PhysicsImpostorParameters {
  32942. /**
  32943. * The mass of the physics imposter
  32944. */
  32945. mass: number;
  32946. /**
  32947. * The friction of the physics imposter
  32948. */
  32949. friction?: number;
  32950. /**
  32951. * The coefficient of restitution of the physics imposter
  32952. */
  32953. restitution?: number;
  32954. /**
  32955. * The native options of the physics imposter
  32956. */
  32957. nativeOptions?: any;
  32958. /**
  32959. * Specifies if the parent should be ignored
  32960. */
  32961. ignoreParent?: boolean;
  32962. /**
  32963. * Specifies if bi-directional transformations should be disabled
  32964. */
  32965. disableBidirectionalTransformation?: boolean;
  32966. /**
  32967. * The pressure inside the physics imposter, soft object only
  32968. */
  32969. pressure?: number;
  32970. /**
  32971. * The stiffness the physics imposter, soft object only
  32972. */
  32973. stiffness?: number;
  32974. /**
  32975. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32976. */
  32977. velocityIterations?: number;
  32978. /**
  32979. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32980. */
  32981. positionIterations?: number;
  32982. /**
  32983. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32984. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32985. * Add to fix multiple points
  32986. */
  32987. fixedPoints?: number;
  32988. /**
  32989. * The collision margin around a soft object
  32990. */
  32991. margin?: number;
  32992. /**
  32993. * The collision margin around a soft object
  32994. */
  32995. damping?: number;
  32996. /**
  32997. * The path for a rope based on an extrusion
  32998. */
  32999. path?: any;
  33000. /**
  33001. * The shape of an extrusion used for a rope based on an extrusion
  33002. */
  33003. shape?: any;
  33004. }
  33005. /**
  33006. * Interface for a physics-enabled object
  33007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33008. */
  33009. export interface IPhysicsEnabledObject {
  33010. /**
  33011. * The position of the physics-enabled object
  33012. */
  33013. position: Vector3;
  33014. /**
  33015. * The rotation of the physics-enabled object
  33016. */
  33017. rotationQuaternion: Nullable<Quaternion>;
  33018. /**
  33019. * The scale of the physics-enabled object
  33020. */
  33021. scaling: Vector3;
  33022. /**
  33023. * The rotation of the physics-enabled object
  33024. */
  33025. rotation?: Vector3;
  33026. /**
  33027. * The parent of the physics-enabled object
  33028. */
  33029. parent?: any;
  33030. /**
  33031. * The bounding info of the physics-enabled object
  33032. * @returns The bounding info of the physics-enabled object
  33033. */
  33034. getBoundingInfo(): BoundingInfo;
  33035. /**
  33036. * Computes the world matrix
  33037. * @param force Specifies if the world matrix should be computed by force
  33038. * @returns A world matrix
  33039. */
  33040. computeWorldMatrix(force: boolean): Matrix;
  33041. /**
  33042. * Gets the world matrix
  33043. * @returns A world matrix
  33044. */
  33045. getWorldMatrix?(): Matrix;
  33046. /**
  33047. * Gets the child meshes
  33048. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33049. * @returns An array of abstract meshes
  33050. */
  33051. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33052. /**
  33053. * Gets the vertex data
  33054. * @param kind The type of vertex data
  33055. * @returns A nullable array of numbers, or a float32 array
  33056. */
  33057. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33058. /**
  33059. * Gets the indices from the mesh
  33060. * @returns A nullable array of index arrays
  33061. */
  33062. getIndices?(): Nullable<IndicesArray>;
  33063. /**
  33064. * Gets the scene from the mesh
  33065. * @returns the indices array or null
  33066. */
  33067. getScene?(): Scene;
  33068. /**
  33069. * Gets the absolute position from the mesh
  33070. * @returns the absolute position
  33071. */
  33072. getAbsolutePosition(): Vector3;
  33073. /**
  33074. * Gets the absolute pivot point from the mesh
  33075. * @returns the absolute pivot point
  33076. */
  33077. getAbsolutePivotPoint(): Vector3;
  33078. /**
  33079. * Rotates the mesh
  33080. * @param axis The axis of rotation
  33081. * @param amount The amount of rotation
  33082. * @param space The space of the rotation
  33083. * @returns The rotation transform node
  33084. */
  33085. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33086. /**
  33087. * Translates the mesh
  33088. * @param axis The axis of translation
  33089. * @param distance The distance of translation
  33090. * @param space The space of the translation
  33091. * @returns The transform node
  33092. */
  33093. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33094. /**
  33095. * Sets the absolute position of the mesh
  33096. * @param absolutePosition The absolute position of the mesh
  33097. * @returns The transform node
  33098. */
  33099. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33100. /**
  33101. * Gets the class name of the mesh
  33102. * @returns The class name
  33103. */
  33104. getClassName(): string;
  33105. }
  33106. /**
  33107. * Represents a physics imposter
  33108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33109. */
  33110. export class PhysicsImpostor {
  33111. /**
  33112. * The physics-enabled object used as the physics imposter
  33113. */
  33114. object: IPhysicsEnabledObject;
  33115. /**
  33116. * The type of the physics imposter
  33117. */
  33118. type: number;
  33119. private _options;
  33120. private _scene?;
  33121. /**
  33122. * The default object size of the imposter
  33123. */
  33124. static DEFAULT_OBJECT_SIZE: Vector3;
  33125. /**
  33126. * The identity quaternion of the imposter
  33127. */
  33128. static IDENTITY_QUATERNION: Quaternion;
  33129. /** @hidden */
  33130. _pluginData: any;
  33131. private _physicsEngine;
  33132. private _physicsBody;
  33133. private _bodyUpdateRequired;
  33134. private _onBeforePhysicsStepCallbacks;
  33135. private _onAfterPhysicsStepCallbacks;
  33136. /** @hidden */
  33137. _onPhysicsCollideCallbacks: Array<{
  33138. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  33139. otherImpostors: Array<PhysicsImpostor>;
  33140. }>;
  33141. private _deltaPosition;
  33142. private _deltaRotation;
  33143. private _deltaRotationConjugated;
  33144. /** @hidden */
  33145. _isFromLine: boolean;
  33146. private _parent;
  33147. private _isDisposed;
  33148. private static _tmpVecs;
  33149. private static _tmpQuat;
  33150. /**
  33151. * Specifies if the physics imposter is disposed
  33152. */
  33153. get isDisposed(): boolean;
  33154. /**
  33155. * Gets the mass of the physics imposter
  33156. */
  33157. get mass(): number;
  33158. set mass(value: number);
  33159. /**
  33160. * Gets the coefficient of friction
  33161. */
  33162. get friction(): number;
  33163. /**
  33164. * Sets the coefficient of friction
  33165. */
  33166. set friction(value: number);
  33167. /**
  33168. * Gets the coefficient of restitution
  33169. */
  33170. get restitution(): number;
  33171. /**
  33172. * Sets the coefficient of restitution
  33173. */
  33174. set restitution(value: number);
  33175. /**
  33176. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33177. */
  33178. get pressure(): number;
  33179. /**
  33180. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33181. */
  33182. set pressure(value: number);
  33183. /**
  33184. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33185. */
  33186. get stiffness(): number;
  33187. /**
  33188. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33189. */
  33190. set stiffness(value: number);
  33191. /**
  33192. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33193. */
  33194. get velocityIterations(): number;
  33195. /**
  33196. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33197. */
  33198. set velocityIterations(value: number);
  33199. /**
  33200. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33201. */
  33202. get positionIterations(): number;
  33203. /**
  33204. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33205. */
  33206. set positionIterations(value: number);
  33207. /**
  33208. * The unique id of the physics imposter
  33209. * set by the physics engine when adding this impostor to the array
  33210. */
  33211. uniqueId: number;
  33212. /**
  33213. * @hidden
  33214. */
  33215. soft: boolean;
  33216. /**
  33217. * @hidden
  33218. */
  33219. segments: number;
  33220. private _joints;
  33221. /**
  33222. * Initializes the physics imposter
  33223. * @param object The physics-enabled object used as the physics imposter
  33224. * @param type The type of the physics imposter
  33225. * @param _options The options for the physics imposter
  33226. * @param _scene The Babylon scene
  33227. */
  33228. constructor(
  33229. /**
  33230. * The physics-enabled object used as the physics imposter
  33231. */
  33232. object: IPhysicsEnabledObject,
  33233. /**
  33234. * The type of the physics imposter
  33235. */
  33236. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33237. /**
  33238. * This function will completly initialize this impostor.
  33239. * It will create a new body - but only if this mesh has no parent.
  33240. * If it has, this impostor will not be used other than to define the impostor
  33241. * of the child mesh.
  33242. * @hidden
  33243. */
  33244. _init(): void;
  33245. private _getPhysicsParent;
  33246. /**
  33247. * Should a new body be generated.
  33248. * @returns boolean specifying if body initialization is required
  33249. */
  33250. isBodyInitRequired(): boolean;
  33251. /**
  33252. * Sets the updated scaling
  33253. * @param updated Specifies if the scaling is updated
  33254. */
  33255. setScalingUpdated(): void;
  33256. /**
  33257. * Force a regeneration of this or the parent's impostor's body.
  33258. * Use under cautious - This will remove all joints already implemented.
  33259. */
  33260. forceUpdate(): void;
  33261. /**
  33262. * Gets the body that holds this impostor. Either its own, or its parent.
  33263. */
  33264. get physicsBody(): any;
  33265. /**
  33266. * Get the parent of the physics imposter
  33267. * @returns Physics imposter or null
  33268. */
  33269. get parent(): Nullable<PhysicsImpostor>;
  33270. /**
  33271. * Sets the parent of the physics imposter
  33272. */
  33273. set parent(value: Nullable<PhysicsImpostor>);
  33274. /**
  33275. * Set the physics body. Used mainly by the physics engine/plugin
  33276. */
  33277. set physicsBody(physicsBody: any);
  33278. /**
  33279. * Resets the update flags
  33280. */
  33281. resetUpdateFlags(): void;
  33282. /**
  33283. * Gets the object extend size
  33284. * @returns the object extend size
  33285. */
  33286. getObjectExtendSize(): Vector3;
  33287. /**
  33288. * Gets the object center
  33289. * @returns The object center
  33290. */
  33291. getObjectCenter(): Vector3;
  33292. /**
  33293. * Get a specific parameter from the options parameters
  33294. * @param paramName The object parameter name
  33295. * @returns The object parameter
  33296. */
  33297. getParam(paramName: string): any;
  33298. /**
  33299. * Sets a specific parameter in the options given to the physics plugin
  33300. * @param paramName The parameter name
  33301. * @param value The value of the parameter
  33302. */
  33303. setParam(paramName: string, value: number): void;
  33304. /**
  33305. * Specifically change the body's mass option. Won't recreate the physics body object
  33306. * @param mass The mass of the physics imposter
  33307. */
  33308. setMass(mass: number): void;
  33309. /**
  33310. * Gets the linear velocity
  33311. * @returns linear velocity or null
  33312. */
  33313. getLinearVelocity(): Nullable<Vector3>;
  33314. /**
  33315. * Sets the linear velocity
  33316. * @param velocity linear velocity or null
  33317. */
  33318. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33319. /**
  33320. * Gets the angular velocity
  33321. * @returns angular velocity or null
  33322. */
  33323. getAngularVelocity(): Nullable<Vector3>;
  33324. /**
  33325. * Sets the angular velocity
  33326. * @param velocity The velocity or null
  33327. */
  33328. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33329. /**
  33330. * Execute a function with the physics plugin native code
  33331. * Provide a function the will have two variables - the world object and the physics body object
  33332. * @param func The function to execute with the physics plugin native code
  33333. */
  33334. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33335. /**
  33336. * Register 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. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33340. /**
  33341. * Unregister a function that will be executed before the physics world is stepping forward
  33342. * @param func The function to execute before the physics world is stepped forward
  33343. */
  33344. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33345. /**
  33346. * Register a function that will be executed after the physics step
  33347. * @param func The function to execute after physics step
  33348. */
  33349. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33350. /**
  33351. * Unregisters a function that will be executed after the physics step
  33352. * @param func The function to execute after physics step
  33353. */
  33354. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33355. /**
  33356. * register a function that will be executed when this impostor collides against a different body
  33357. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33358. * @param func Callback that is executed on collision
  33359. */
  33360. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33361. /**
  33362. * Unregisters the physics imposter on contact
  33363. * @param collideAgainst The physics object to collide against
  33364. * @param func Callback to execute on collision
  33365. */
  33366. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33367. private _tmpQuat;
  33368. private _tmpQuat2;
  33369. /**
  33370. * Get the parent rotation
  33371. * @returns The parent rotation
  33372. */
  33373. getParentsRotation(): Quaternion;
  33374. /**
  33375. * this function is executed by the physics engine.
  33376. */
  33377. beforeStep: () => void;
  33378. /**
  33379. * this function is executed by the physics engine
  33380. */
  33381. afterStep: () => void;
  33382. /**
  33383. * Legacy collision detection event support
  33384. */
  33385. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33386. /**
  33387. * event and body object due to cannon's event-based architecture.
  33388. */
  33389. onCollide: (e: {
  33390. body: any;
  33391. }) => void;
  33392. /**
  33393. * Apply a force
  33394. * @param force The force to apply
  33395. * @param contactPoint The contact point for the force
  33396. * @returns The physics imposter
  33397. */
  33398. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33399. /**
  33400. * Apply an impulse
  33401. * @param force The impulse force
  33402. * @param contactPoint The contact point for the impulse force
  33403. * @returns The physics imposter
  33404. */
  33405. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33406. /**
  33407. * A help function to create a joint
  33408. * @param otherImpostor A physics imposter used to create a joint
  33409. * @param jointType The type of joint
  33410. * @param jointData The data for the joint
  33411. * @returns The physics imposter
  33412. */
  33413. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33414. /**
  33415. * Add a joint to this impostor with a different impostor
  33416. * @param otherImpostor A physics imposter used to add a joint
  33417. * @param joint The joint to add
  33418. * @returns The physics imposter
  33419. */
  33420. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33421. /**
  33422. * Add an anchor to a cloth impostor
  33423. * @param otherImpostor rigid impostor to anchor to
  33424. * @param width ratio across width from 0 to 1
  33425. * @param height ratio up height from 0 to 1
  33426. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33427. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33428. * @returns impostor the soft imposter
  33429. */
  33430. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33431. /**
  33432. * Add a hook to a rope impostor
  33433. * @param otherImpostor rigid impostor to anchor to
  33434. * @param length ratio across rope from 0 to 1
  33435. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33436. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33437. * @returns impostor the rope imposter
  33438. */
  33439. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33440. /**
  33441. * Will keep this body still, in a sleep mode.
  33442. * @returns the physics imposter
  33443. */
  33444. sleep(): PhysicsImpostor;
  33445. /**
  33446. * Wake the body up.
  33447. * @returns The physics imposter
  33448. */
  33449. wakeUp(): PhysicsImpostor;
  33450. /**
  33451. * Clones the physics imposter
  33452. * @param newObject The physics imposter clones to this physics-enabled object
  33453. * @returns A nullable physics imposter
  33454. */
  33455. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33456. /**
  33457. * Disposes the physics imposter
  33458. */
  33459. dispose(): void;
  33460. /**
  33461. * Sets the delta position
  33462. * @param position The delta position amount
  33463. */
  33464. setDeltaPosition(position: Vector3): void;
  33465. /**
  33466. * Sets the delta rotation
  33467. * @param rotation The delta rotation amount
  33468. */
  33469. setDeltaRotation(rotation: Quaternion): void;
  33470. /**
  33471. * Gets the box size of the physics imposter and stores the result in the input parameter
  33472. * @param result Stores the box size
  33473. * @returns The physics imposter
  33474. */
  33475. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33476. /**
  33477. * Gets the radius of the physics imposter
  33478. * @returns Radius of the physics imposter
  33479. */
  33480. getRadius(): number;
  33481. /**
  33482. * Sync a bone with this impostor
  33483. * @param bone The bone to sync to the impostor.
  33484. * @param boneMesh The mesh that the bone is influencing.
  33485. * @param jointPivot The pivot of the joint / bone in local space.
  33486. * @param distToJoint Optional distance from the impostor to the joint.
  33487. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33488. */
  33489. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33490. /**
  33491. * Sync impostor to a bone
  33492. * @param bone The bone that the impostor will be synced to.
  33493. * @param boneMesh The mesh that the bone is influencing.
  33494. * @param jointPivot The pivot of the joint / bone in local space.
  33495. * @param distToJoint Optional distance from the impostor to the joint.
  33496. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33497. * @param boneAxis Optional vector3 axis the bone is aligned with
  33498. */
  33499. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33500. /**
  33501. * No-Imposter type
  33502. */
  33503. static NoImpostor: number;
  33504. /**
  33505. * Sphere-Imposter type
  33506. */
  33507. static SphereImpostor: number;
  33508. /**
  33509. * Box-Imposter type
  33510. */
  33511. static BoxImpostor: number;
  33512. /**
  33513. * Plane-Imposter type
  33514. */
  33515. static PlaneImpostor: number;
  33516. /**
  33517. * Mesh-imposter type
  33518. */
  33519. static MeshImpostor: number;
  33520. /**
  33521. * Capsule-Impostor type (Ammo.js plugin only)
  33522. */
  33523. static CapsuleImpostor: number;
  33524. /**
  33525. * Cylinder-Imposter type
  33526. */
  33527. static CylinderImpostor: number;
  33528. /**
  33529. * Particle-Imposter type
  33530. */
  33531. static ParticleImpostor: number;
  33532. /**
  33533. * Heightmap-Imposter type
  33534. */
  33535. static HeightmapImpostor: number;
  33536. /**
  33537. * ConvexHull-Impostor type (Ammo.js plugin only)
  33538. */
  33539. static ConvexHullImpostor: number;
  33540. /**
  33541. * Custom-Imposter type (Ammo.js plugin only)
  33542. */
  33543. static CustomImpostor: number;
  33544. /**
  33545. * Rope-Imposter type
  33546. */
  33547. static RopeImpostor: number;
  33548. /**
  33549. * Cloth-Imposter type
  33550. */
  33551. static ClothImpostor: number;
  33552. /**
  33553. * Softbody-Imposter type
  33554. */
  33555. static SoftbodyImpostor: number;
  33556. }
  33557. }
  33558. declare module "babylonjs/Meshes/mesh" {
  33559. import { Observable } from "babylonjs/Misc/observable";
  33560. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33561. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33562. import { Camera } from "babylonjs/Cameras/camera";
  33563. import { Scene } from "babylonjs/scene";
  33564. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33565. import { Color4 } from "babylonjs/Maths/math.color";
  33566. import { Engine } from "babylonjs/Engines/engine";
  33567. import { Node } from "babylonjs/node";
  33568. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33569. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33570. import { Buffer } from "babylonjs/Meshes/buffer";
  33571. import { Geometry } from "babylonjs/Meshes/geometry";
  33572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33573. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33574. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33575. import { Effect } from "babylonjs/Materials/effect";
  33576. import { Material } from "babylonjs/Materials/material";
  33577. import { Skeleton } from "babylonjs/Bones/skeleton";
  33578. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33579. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33580. import { Path3D } from "babylonjs/Maths/math.path";
  33581. import { Plane } from "babylonjs/Maths/math.plane";
  33582. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33583. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33584. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33585. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33586. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33587. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33588. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33589. /**
  33590. * @hidden
  33591. **/
  33592. export class _CreationDataStorage {
  33593. closePath?: boolean;
  33594. closeArray?: boolean;
  33595. idx: number[];
  33596. dashSize: number;
  33597. gapSize: number;
  33598. path3D: Path3D;
  33599. pathArray: Vector3[][];
  33600. arc: number;
  33601. radius: number;
  33602. cap: number;
  33603. tessellation: number;
  33604. }
  33605. /**
  33606. * @hidden
  33607. **/
  33608. class _InstanceDataStorage {
  33609. visibleInstances: any;
  33610. batchCache: _InstancesBatch;
  33611. instancesBufferSize: number;
  33612. instancesBuffer: Nullable<Buffer>;
  33613. instancesData: Float32Array;
  33614. overridenInstanceCount: number;
  33615. isFrozen: boolean;
  33616. previousBatch: Nullable<_InstancesBatch>;
  33617. hardwareInstancedRendering: boolean;
  33618. sideOrientation: number;
  33619. manualUpdate: boolean;
  33620. previousRenderId: number;
  33621. }
  33622. /**
  33623. * @hidden
  33624. **/
  33625. export class _InstancesBatch {
  33626. mustReturn: boolean;
  33627. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  33628. renderSelf: boolean[];
  33629. hardwareInstancedRendering: boolean[];
  33630. }
  33631. /**
  33632. * @hidden
  33633. **/
  33634. class _ThinInstanceDataStorage {
  33635. instancesCount: number;
  33636. matrixBuffer: Nullable<Buffer>;
  33637. matrixBufferSize: number;
  33638. matrixData: Nullable<Float32Array>;
  33639. boundingVectors: Array<Vector3>;
  33640. worldMatrices: Nullable<Matrix[]>;
  33641. }
  33642. /**
  33643. * Class used to represent renderable models
  33644. */
  33645. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33646. /**
  33647. * Mesh side orientation : usually the external or front surface
  33648. */
  33649. static readonly FRONTSIDE: number;
  33650. /**
  33651. * Mesh side orientation : usually the internal or back surface
  33652. */
  33653. static readonly BACKSIDE: number;
  33654. /**
  33655. * Mesh side orientation : both internal and external or front and back surfaces
  33656. */
  33657. static readonly DOUBLESIDE: number;
  33658. /**
  33659. * Mesh side orientation : by default, `FRONTSIDE`
  33660. */
  33661. static readonly DEFAULTSIDE: number;
  33662. /**
  33663. * Mesh cap setting : no cap
  33664. */
  33665. static readonly NO_CAP: number;
  33666. /**
  33667. * Mesh cap setting : one cap at the beginning of the mesh
  33668. */
  33669. static readonly CAP_START: number;
  33670. /**
  33671. * Mesh cap setting : one cap at the end of the mesh
  33672. */
  33673. static readonly CAP_END: number;
  33674. /**
  33675. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33676. */
  33677. static readonly CAP_ALL: number;
  33678. /**
  33679. * Mesh pattern setting : no flip or rotate
  33680. */
  33681. static readonly NO_FLIP: number;
  33682. /**
  33683. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33684. */
  33685. static readonly FLIP_TILE: number;
  33686. /**
  33687. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33688. */
  33689. static readonly ROTATE_TILE: number;
  33690. /**
  33691. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33692. */
  33693. static readonly FLIP_ROW: number;
  33694. /**
  33695. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33696. */
  33697. static readonly ROTATE_ROW: number;
  33698. /**
  33699. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33700. */
  33701. static readonly FLIP_N_ROTATE_TILE: number;
  33702. /**
  33703. * Mesh pattern setting : rotate pattern and rotate
  33704. */
  33705. static readonly FLIP_N_ROTATE_ROW: number;
  33706. /**
  33707. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33708. */
  33709. static readonly CENTER: number;
  33710. /**
  33711. * Mesh tile positioning : part tiles on left
  33712. */
  33713. static readonly LEFT: number;
  33714. /**
  33715. * Mesh tile positioning : part tiles on right
  33716. */
  33717. static readonly RIGHT: number;
  33718. /**
  33719. * Mesh tile positioning : part tiles on top
  33720. */
  33721. static readonly TOP: number;
  33722. /**
  33723. * Mesh tile positioning : part tiles on bottom
  33724. */
  33725. static readonly BOTTOM: number;
  33726. /**
  33727. * Gets the default side orientation.
  33728. * @param orientation the orientation to value to attempt to get
  33729. * @returns the default orientation
  33730. * @hidden
  33731. */
  33732. static _GetDefaultSideOrientation(orientation?: number): number;
  33733. private _internalMeshDataInfo;
  33734. get computeBonesUsingShaders(): boolean;
  33735. set computeBonesUsingShaders(value: boolean);
  33736. /**
  33737. * An event triggered before rendering the mesh
  33738. */
  33739. get onBeforeRenderObservable(): Observable<Mesh>;
  33740. /**
  33741. * An event triggered before binding the mesh
  33742. */
  33743. get onBeforeBindObservable(): Observable<Mesh>;
  33744. /**
  33745. * An event triggered after rendering the mesh
  33746. */
  33747. get onAfterRenderObservable(): Observable<Mesh>;
  33748. /**
  33749. * An event triggered before drawing the mesh
  33750. */
  33751. get onBeforeDrawObservable(): Observable<Mesh>;
  33752. private _onBeforeDrawObserver;
  33753. /**
  33754. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33755. */
  33756. set onBeforeDraw(callback: () => void);
  33757. get hasInstances(): boolean;
  33758. get hasThinInstances(): boolean;
  33759. /**
  33760. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33761. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33762. */
  33763. delayLoadState: number;
  33764. /**
  33765. * Gets the list of instances created from this mesh
  33766. * it is not supposed to be modified manually.
  33767. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33768. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33769. */
  33770. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  33771. /**
  33772. * Gets the file containing delay loading data for this mesh
  33773. */
  33774. delayLoadingFile: string;
  33775. /** @hidden */
  33776. _binaryInfo: any;
  33777. /**
  33778. * User defined function used to change how LOD level selection is done
  33779. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33780. */
  33781. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33782. /**
  33783. * Gets or sets the morph target manager
  33784. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33785. */
  33786. get morphTargetManager(): Nullable<MorphTargetManager>;
  33787. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33788. /** @hidden */
  33789. _creationDataStorage: Nullable<_CreationDataStorage>;
  33790. /** @hidden */
  33791. _geometry: Nullable<Geometry>;
  33792. /** @hidden */
  33793. _delayInfo: Array<string>;
  33794. /** @hidden */
  33795. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33796. /** @hidden */
  33797. _instanceDataStorage: _InstanceDataStorage;
  33798. /** @hidden */
  33799. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33800. private _effectiveMaterial;
  33801. /** @hidden */
  33802. _shouldGenerateFlatShading: boolean;
  33803. /** @hidden */
  33804. _originalBuilderSideOrientation: number;
  33805. /**
  33806. * Use this property to change the original side orientation defined at construction time
  33807. */
  33808. overrideMaterialSideOrientation: Nullable<number>;
  33809. /**
  33810. * Gets the source mesh (the one used to clone this one from)
  33811. */
  33812. get source(): Nullable<Mesh>;
  33813. /**
  33814. * Gets the list of clones of this mesh
  33815. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33816. * Note that useClonedMeshMap=true is the default setting
  33817. */
  33818. get cloneMeshMap(): Nullable<{
  33819. [id: string]: Mesh | undefined;
  33820. }>;
  33821. /**
  33822. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33823. */
  33824. get isUnIndexed(): boolean;
  33825. set isUnIndexed(value: boolean);
  33826. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33827. get worldMatrixInstancedBuffer(): Float32Array;
  33828. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33829. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33830. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33831. /**
  33832. * @constructor
  33833. * @param name The value used by scene.getMeshByName() to do a lookup.
  33834. * @param scene The scene to add this mesh to.
  33835. * @param parent The parent of this mesh, if it has one
  33836. * @param source An optional Mesh from which geometry is shared, cloned.
  33837. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33838. * When false, achieved by calling a clone(), also passing False.
  33839. * This will make creation of children, recursive.
  33840. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33841. */
  33842. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33843. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33844. doNotInstantiate: boolean;
  33845. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33846. /**
  33847. * Gets the class name
  33848. * @returns the string "Mesh".
  33849. */
  33850. getClassName(): string;
  33851. /** @hidden */
  33852. get _isMesh(): boolean;
  33853. /**
  33854. * Returns a description of this mesh
  33855. * @param fullDetails define if full details about this mesh must be used
  33856. * @returns a descriptive string representing this mesh
  33857. */
  33858. toString(fullDetails?: boolean): string;
  33859. /** @hidden */
  33860. _unBindEffect(): void;
  33861. /**
  33862. * Gets a boolean indicating if this mesh has LOD
  33863. */
  33864. get hasLODLevels(): boolean;
  33865. /**
  33866. * Gets the list of MeshLODLevel associated with the current mesh
  33867. * @returns an array of MeshLODLevel
  33868. */
  33869. getLODLevels(): MeshLODLevel[];
  33870. private _sortLODLevels;
  33871. /**
  33872. * Add a mesh as LOD level triggered at the given distance.
  33873. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33874. * @param distance The distance from the center of the object to show this level
  33875. * @param mesh The mesh to be added as LOD level (can be null)
  33876. * @return This mesh (for chaining)
  33877. */
  33878. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33879. /**
  33880. * Returns the LOD level mesh at the passed distance or null if not found.
  33881. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33882. * @param distance The distance from the center of the object to show this level
  33883. * @returns a Mesh or `null`
  33884. */
  33885. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33886. /**
  33887. * Remove a mesh from the LOD array
  33888. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33889. * @param mesh defines the mesh to be removed
  33890. * @return This mesh (for chaining)
  33891. */
  33892. removeLODLevel(mesh: Mesh): Mesh;
  33893. /**
  33894. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33895. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33896. * @param camera defines the camera to use to compute distance
  33897. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33898. * @return This mesh (for chaining)
  33899. */
  33900. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33901. /**
  33902. * Gets the mesh internal Geometry object
  33903. */
  33904. get geometry(): Nullable<Geometry>;
  33905. /**
  33906. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33907. * @returns the total number of vertices
  33908. */
  33909. getTotalVertices(): number;
  33910. /**
  33911. * Returns the content of an associated vertex buffer
  33912. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33913. * - VertexBuffer.PositionKind
  33914. * - VertexBuffer.UVKind
  33915. * - VertexBuffer.UV2Kind
  33916. * - VertexBuffer.UV3Kind
  33917. * - VertexBuffer.UV4Kind
  33918. * - VertexBuffer.UV5Kind
  33919. * - VertexBuffer.UV6Kind
  33920. * - VertexBuffer.ColorKind
  33921. * - VertexBuffer.MatricesIndicesKind
  33922. * - VertexBuffer.MatricesIndicesExtraKind
  33923. * - VertexBuffer.MatricesWeightsKind
  33924. * - VertexBuffer.MatricesWeightsExtraKind
  33925. * @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
  33926. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33927. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33928. */
  33929. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33930. /**
  33931. * Returns the mesh VertexBuffer object from the requested `kind`
  33932. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33933. * - VertexBuffer.PositionKind
  33934. * - VertexBuffer.NormalKind
  33935. * - VertexBuffer.UVKind
  33936. * - VertexBuffer.UV2Kind
  33937. * - VertexBuffer.UV3Kind
  33938. * - VertexBuffer.UV4Kind
  33939. * - VertexBuffer.UV5Kind
  33940. * - VertexBuffer.UV6Kind
  33941. * - VertexBuffer.ColorKind
  33942. * - VertexBuffer.MatricesIndicesKind
  33943. * - VertexBuffer.MatricesIndicesExtraKind
  33944. * - VertexBuffer.MatricesWeightsKind
  33945. * - VertexBuffer.MatricesWeightsExtraKind
  33946. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33947. */
  33948. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33949. /**
  33950. * Tests if a specific vertex buffer is associated with this mesh
  33951. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33952. * - VertexBuffer.PositionKind
  33953. * - VertexBuffer.NormalKind
  33954. * - VertexBuffer.UVKind
  33955. * - VertexBuffer.UV2Kind
  33956. * - VertexBuffer.UV3Kind
  33957. * - VertexBuffer.UV4Kind
  33958. * - VertexBuffer.UV5Kind
  33959. * - VertexBuffer.UV6Kind
  33960. * - VertexBuffer.ColorKind
  33961. * - VertexBuffer.MatricesIndicesKind
  33962. * - VertexBuffer.MatricesIndicesExtraKind
  33963. * - VertexBuffer.MatricesWeightsKind
  33964. * - VertexBuffer.MatricesWeightsExtraKind
  33965. * @returns a boolean
  33966. */
  33967. isVerticesDataPresent(kind: string): boolean;
  33968. /**
  33969. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33970. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33971. * - VertexBuffer.PositionKind
  33972. * - VertexBuffer.UVKind
  33973. * - VertexBuffer.UV2Kind
  33974. * - VertexBuffer.UV3Kind
  33975. * - VertexBuffer.UV4Kind
  33976. * - VertexBuffer.UV5Kind
  33977. * - VertexBuffer.UV6Kind
  33978. * - VertexBuffer.ColorKind
  33979. * - VertexBuffer.MatricesIndicesKind
  33980. * - VertexBuffer.MatricesIndicesExtraKind
  33981. * - VertexBuffer.MatricesWeightsKind
  33982. * - VertexBuffer.MatricesWeightsExtraKind
  33983. * @returns a boolean
  33984. */
  33985. isVertexBufferUpdatable(kind: string): boolean;
  33986. /**
  33987. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33988. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33989. * - VertexBuffer.PositionKind
  33990. * - VertexBuffer.NormalKind
  33991. * - VertexBuffer.UVKind
  33992. * - VertexBuffer.UV2Kind
  33993. * - VertexBuffer.UV3Kind
  33994. * - VertexBuffer.UV4Kind
  33995. * - VertexBuffer.UV5Kind
  33996. * - VertexBuffer.UV6Kind
  33997. * - VertexBuffer.ColorKind
  33998. * - VertexBuffer.MatricesIndicesKind
  33999. * - VertexBuffer.MatricesIndicesExtraKind
  34000. * - VertexBuffer.MatricesWeightsKind
  34001. * - VertexBuffer.MatricesWeightsExtraKind
  34002. * @returns an array of strings
  34003. */
  34004. getVerticesDataKinds(): string[];
  34005. /**
  34006. * Returns a positive integer : the total number of indices in this mesh geometry.
  34007. * @returns the numner of indices or zero if the mesh has no geometry.
  34008. */
  34009. getTotalIndices(): number;
  34010. /**
  34011. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34012. * @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.
  34013. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34014. * @returns the indices array or an empty array if the mesh has no geometry
  34015. */
  34016. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34017. get isBlocked(): boolean;
  34018. /**
  34019. * Determine if the current mesh is ready to be rendered
  34020. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34021. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34022. * @returns true if all associated assets are ready (material, textures, shaders)
  34023. */
  34024. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34025. /**
  34026. * 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.
  34027. */
  34028. get areNormalsFrozen(): boolean;
  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 prevents the mesh normals from being recomputed on next `positions` array update.
  34031. * @returns the current mesh
  34032. */
  34033. freezeNormals(): Mesh;
  34034. /**
  34035. * 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
  34036. * @returns the current mesh
  34037. */
  34038. unfreezeNormals(): Mesh;
  34039. /**
  34040. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34041. */
  34042. set overridenInstanceCount(count: number);
  34043. /** @hidden */
  34044. _preActivate(): Mesh;
  34045. /** @hidden */
  34046. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34047. /** @hidden */
  34048. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34049. protected _afterComputeWorldMatrix(): void;
  34050. /** @hidden */
  34051. _postActivate(): void;
  34052. /**
  34053. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34054. * This means the mesh underlying bounding box and sphere are recomputed.
  34055. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34056. * @returns the current mesh
  34057. */
  34058. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34059. /** @hidden */
  34060. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34061. /**
  34062. * This function will subdivide the mesh into multiple submeshes
  34063. * @param count defines the expected number of submeshes
  34064. */
  34065. subdivide(count: number): void;
  34066. /**
  34067. * Copy a FloatArray into a specific associated vertex buffer
  34068. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34069. * - VertexBuffer.PositionKind
  34070. * - VertexBuffer.UVKind
  34071. * - VertexBuffer.UV2Kind
  34072. * - VertexBuffer.UV3Kind
  34073. * - VertexBuffer.UV4Kind
  34074. * - VertexBuffer.UV5Kind
  34075. * - VertexBuffer.UV6Kind
  34076. * - VertexBuffer.ColorKind
  34077. * - VertexBuffer.MatricesIndicesKind
  34078. * - VertexBuffer.MatricesIndicesExtraKind
  34079. * - VertexBuffer.MatricesWeightsKind
  34080. * - VertexBuffer.MatricesWeightsExtraKind
  34081. * @param data defines the data source
  34082. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34083. * @param stride defines the data stride size (can be null)
  34084. * @returns the current mesh
  34085. */
  34086. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34087. /**
  34088. * Delete a vertex buffer associated with this mesh
  34089. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34090. * - VertexBuffer.PositionKind
  34091. * - VertexBuffer.UVKind
  34092. * - VertexBuffer.UV2Kind
  34093. * - VertexBuffer.UV3Kind
  34094. * - VertexBuffer.UV4Kind
  34095. * - VertexBuffer.UV5Kind
  34096. * - VertexBuffer.UV6Kind
  34097. * - VertexBuffer.ColorKind
  34098. * - VertexBuffer.MatricesIndicesKind
  34099. * - VertexBuffer.MatricesIndicesExtraKind
  34100. * - VertexBuffer.MatricesWeightsKind
  34101. * - VertexBuffer.MatricesWeightsExtraKind
  34102. */
  34103. removeVerticesData(kind: string): void;
  34104. /**
  34105. * Flags an associated vertex buffer as updatable
  34106. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34107. * - VertexBuffer.PositionKind
  34108. * - VertexBuffer.UVKind
  34109. * - VertexBuffer.UV2Kind
  34110. * - VertexBuffer.UV3Kind
  34111. * - VertexBuffer.UV4Kind
  34112. * - VertexBuffer.UV5Kind
  34113. * - VertexBuffer.UV6Kind
  34114. * - VertexBuffer.ColorKind
  34115. * - VertexBuffer.MatricesIndicesKind
  34116. * - VertexBuffer.MatricesIndicesExtraKind
  34117. * - VertexBuffer.MatricesWeightsKind
  34118. * - VertexBuffer.MatricesWeightsExtraKind
  34119. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34120. */
  34121. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34122. /**
  34123. * Sets the mesh global Vertex Buffer
  34124. * @param buffer defines the buffer to use
  34125. * @returns the current mesh
  34126. */
  34127. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34128. /**
  34129. * Update a specific associated vertex buffer
  34130. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34131. * - VertexBuffer.PositionKind
  34132. * - VertexBuffer.UVKind
  34133. * - VertexBuffer.UV2Kind
  34134. * - VertexBuffer.UV3Kind
  34135. * - VertexBuffer.UV4Kind
  34136. * - VertexBuffer.UV5Kind
  34137. * - VertexBuffer.UV6Kind
  34138. * - VertexBuffer.ColorKind
  34139. * - VertexBuffer.MatricesIndicesKind
  34140. * - VertexBuffer.MatricesIndicesExtraKind
  34141. * - VertexBuffer.MatricesWeightsKind
  34142. * - VertexBuffer.MatricesWeightsExtraKind
  34143. * @param data defines the data source
  34144. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34145. * @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)
  34146. * @returns the current mesh
  34147. */
  34148. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34149. /**
  34150. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34151. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34152. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34153. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34154. * @returns the current mesh
  34155. */
  34156. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34157. /**
  34158. * Creates a un-shared specific occurence of the geometry for the mesh.
  34159. * @returns the current mesh
  34160. */
  34161. makeGeometryUnique(): Mesh;
  34162. /**
  34163. * Set the index buffer of this mesh
  34164. * @param indices defines the source data
  34165. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34166. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34167. * @returns the current mesh
  34168. */
  34169. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34170. /**
  34171. * Update the current index buffer
  34172. * @param indices defines the source data
  34173. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34174. * @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)
  34175. * @returns the current mesh
  34176. */
  34177. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34178. /**
  34179. * Invert the geometry to move from a right handed system to a left handed one.
  34180. * @returns the current mesh
  34181. */
  34182. toLeftHanded(): Mesh;
  34183. /** @hidden */
  34184. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34185. /** @hidden */
  34186. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34187. /**
  34188. * Registers for this mesh a javascript function called just before the rendering process
  34189. * @param func defines the function to call before rendering this mesh
  34190. * @returns the current mesh
  34191. */
  34192. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34193. /**
  34194. * Disposes a previously registered javascript function called before the rendering
  34195. * @param func defines the function to remove
  34196. * @returns the current mesh
  34197. */
  34198. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34199. /**
  34200. * Registers for this mesh a javascript function called just after the rendering is complete
  34201. * @param func defines the function to call after rendering this mesh
  34202. * @returns the current mesh
  34203. */
  34204. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34205. /**
  34206. * Disposes a previously registered javascript function called after the rendering.
  34207. * @param func defines the function to remove
  34208. * @returns the current mesh
  34209. */
  34210. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34211. /** @hidden */
  34212. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34213. /** @hidden */
  34214. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34215. /** @hidden */
  34216. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34217. /** @hidden */
  34218. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34219. /** @hidden */
  34220. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34221. /** @hidden */
  34222. _rebuild(): void;
  34223. /** @hidden */
  34224. _freeze(): void;
  34225. /** @hidden */
  34226. _unFreeze(): void;
  34227. /**
  34228. * 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
  34229. * @param subMesh defines the subMesh to render
  34230. * @param enableAlphaMode defines if alpha mode can be changed
  34231. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34232. * @returns the current mesh
  34233. */
  34234. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34235. private _onBeforeDraw;
  34236. /**
  34237. * Renormalize the mesh and patch it up if there are no weights
  34238. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34239. * However in the case of zero weights then we set just a single influence to 1.
  34240. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34241. */
  34242. cleanMatrixWeights(): void;
  34243. private normalizeSkinFourWeights;
  34244. private normalizeSkinWeightsAndExtra;
  34245. /**
  34246. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34247. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34248. * the user know there was an issue with importing the mesh
  34249. * @returns a validation object with skinned, valid and report string
  34250. */
  34251. validateSkinning(): {
  34252. skinned: boolean;
  34253. valid: boolean;
  34254. report: string;
  34255. };
  34256. /** @hidden */
  34257. _checkDelayState(): Mesh;
  34258. private _queueLoad;
  34259. /**
  34260. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34261. * A mesh is in the frustum if its bounding box intersects the frustum
  34262. * @param frustumPlanes defines the frustum to test
  34263. * @returns true if the mesh is in the frustum planes
  34264. */
  34265. isInFrustum(frustumPlanes: Plane[]): boolean;
  34266. /**
  34267. * Sets the mesh material by the material or multiMaterial `id` property
  34268. * @param id is a string identifying the material or the multiMaterial
  34269. * @returns the current mesh
  34270. */
  34271. setMaterialByID(id: string): Mesh;
  34272. /**
  34273. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34274. * @returns an array of IAnimatable
  34275. */
  34276. getAnimatables(): IAnimatable[];
  34277. /**
  34278. * Modifies the mesh geometry according to the passed transformation matrix.
  34279. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34280. * The mesh normals are modified using the same transformation.
  34281. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34282. * @param transform defines the transform matrix to use
  34283. * @see https://doc.babylonjs.com/resources/baking_transformations
  34284. * @returns the current mesh
  34285. */
  34286. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34287. /**
  34288. * Modifies the mesh geometry according to its own current World Matrix.
  34289. * The mesh World Matrix is then reset.
  34290. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34291. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34292. * @see https://doc.babylonjs.com/resources/baking_transformations
  34293. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34294. * @returns the current mesh
  34295. */
  34296. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34297. /** @hidden */
  34298. get _positions(): Nullable<Vector3[]>;
  34299. /** @hidden */
  34300. _resetPointsArrayCache(): Mesh;
  34301. /** @hidden */
  34302. _generatePointsArray(): boolean;
  34303. /**
  34304. * Returns a new Mesh object generated from the current mesh properties.
  34305. * This method must not get confused with createInstance()
  34306. * @param name is a string, the name given to the new mesh
  34307. * @param newParent can be any Node object (default `null`)
  34308. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34309. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34310. * @returns a new mesh
  34311. */
  34312. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34313. /**
  34314. * Releases resources associated with this mesh.
  34315. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34316. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34317. */
  34318. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34319. /** @hidden */
  34320. _disposeInstanceSpecificData(): void;
  34321. /** @hidden */
  34322. _disposeThinInstanceSpecificData(): void;
  34323. /**
  34324. * Modifies the mesh geometry according to a displacement map.
  34325. * 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.
  34326. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34327. * @param url is a string, the URL from the image file is to be downloaded.
  34328. * @param minHeight is the lower limit of the displacement.
  34329. * @param maxHeight is the upper limit of the displacement.
  34330. * @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.
  34331. * @param uvOffset is an optional vector2 used to offset UV.
  34332. * @param uvScale is an optional vector2 used to scale UV.
  34333. * @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.
  34334. * @returns the Mesh.
  34335. */
  34336. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34337. /**
  34338. * Modifies the mesh geometry according to a displacementMap buffer.
  34339. * 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.
  34340. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34341. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34342. * @param heightMapWidth is the width of the buffer image.
  34343. * @param heightMapHeight is the height of the buffer image.
  34344. * @param minHeight is the lower limit of the displacement.
  34345. * @param maxHeight is the upper limit of the displacement.
  34346. * @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.
  34347. * @param uvOffset is an optional vector2 used to offset UV.
  34348. * @param uvScale is an optional vector2 used to scale UV.
  34349. * @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.
  34350. * @returns the Mesh.
  34351. */
  34352. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34353. /**
  34354. * Modify the mesh to get a flat shading rendering.
  34355. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34356. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34357. * @returns current mesh
  34358. */
  34359. convertToFlatShadedMesh(): Mesh;
  34360. /**
  34361. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34362. * In other words, more vertices, no more indices and a single bigger VBO.
  34363. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34364. * @returns current mesh
  34365. */
  34366. convertToUnIndexedMesh(): Mesh;
  34367. /**
  34368. * Inverses facet orientations.
  34369. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34370. * @param flipNormals will also inverts the normals
  34371. * @returns current mesh
  34372. */
  34373. flipFaces(flipNormals?: boolean): Mesh;
  34374. /**
  34375. * Increase the number of facets and hence vertices in a mesh
  34376. * Vertex normals are interpolated from existing vertex normals
  34377. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34378. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34379. */
  34380. increaseVertices(numberPerEdge: number): void;
  34381. /**
  34382. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34383. * This will undo any application of covertToFlatShadedMesh
  34384. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34385. */
  34386. forceSharedVertices(): void;
  34387. /** @hidden */
  34388. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34389. /** @hidden */
  34390. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34391. /**
  34392. * Creates a new InstancedMesh object from the mesh model.
  34393. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34394. * @param name defines the name of the new instance
  34395. * @returns a new InstancedMesh
  34396. */
  34397. createInstance(name: string): InstancedMesh;
  34398. /**
  34399. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34400. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34401. * @returns the current mesh
  34402. */
  34403. synchronizeInstances(): Mesh;
  34404. /**
  34405. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34406. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34407. * This should be used together with the simplification to avoid disappearing triangles.
  34408. * @param successCallback an optional success callback to be called after the optimization finished.
  34409. * @returns the current mesh
  34410. */
  34411. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34412. /**
  34413. * Serialize current mesh
  34414. * @param serializationObject defines the object which will receive the serialization data
  34415. */
  34416. serialize(serializationObject: any): void;
  34417. /** @hidden */
  34418. _syncGeometryWithMorphTargetManager(): void;
  34419. /** @hidden */
  34420. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34421. /**
  34422. * Returns a new Mesh object parsed from the source provided.
  34423. * @param parsedMesh is the source
  34424. * @param scene defines the hosting scene
  34425. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34426. * @returns a new Mesh
  34427. */
  34428. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34429. /**
  34430. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34431. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34432. * @param name defines the name of the mesh to create
  34433. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34434. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34435. * @param closePath creates a seam between the first and the last points of each path of the path array
  34436. * @param offset is taken in account only if the `pathArray` is containing a single path
  34437. * @param scene defines the hosting scene
  34438. * @param updatable defines if the mesh must be flagged as updatable
  34439. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34440. * @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)
  34441. * @returns a new Mesh
  34442. */
  34443. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34444. /**
  34445. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34446. * @param name defines the name of the mesh to create
  34447. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34448. * @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
  34449. * @param scene defines the hosting scene
  34450. * @param updatable defines if the mesh must be flagged as updatable
  34451. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34452. * @returns a new Mesh
  34453. */
  34454. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34455. /**
  34456. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34457. * @param name defines the name of the mesh to create
  34458. * @param size sets the size (float) of each box side (default 1)
  34459. * @param scene defines the hosting scene
  34460. * @param updatable defines if the mesh must be flagged as updatable
  34461. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34462. * @returns a new Mesh
  34463. */
  34464. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34465. /**
  34466. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34467. * @param name defines the name of the mesh to create
  34468. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34469. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34470. * @param scene defines the hosting scene
  34471. * @param updatable defines if the mesh must be flagged as updatable
  34472. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34473. * @returns a new Mesh
  34474. */
  34475. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34476. /**
  34477. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34478. * @param name defines the name of the mesh to create
  34479. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34480. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34481. * @param scene defines the hosting scene
  34482. * @returns a new Mesh
  34483. */
  34484. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34485. /**
  34486. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34487. * @param name defines the name of the mesh to create
  34488. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34489. * @param diameterTop set the top cap diameter (floats, default 1)
  34490. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34491. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34492. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34493. * @param scene defines the hosting scene
  34494. * @param updatable defines if the mesh must be flagged as updatable
  34495. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34496. * @returns a new Mesh
  34497. */
  34498. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34499. /**
  34500. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34501. * @param name defines the name of the mesh to create
  34502. * @param diameter sets the diameter size (float) of the torus (default 1)
  34503. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34504. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34505. * @param scene defines the hosting scene
  34506. * @param updatable defines if the mesh must be flagged as updatable
  34507. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34508. * @returns a new Mesh
  34509. */
  34510. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34511. /**
  34512. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34513. * @param name defines the name of the mesh to create
  34514. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34515. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34516. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34517. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34518. * @param p the number of windings on X axis (positive integers, default 2)
  34519. * @param q the number of windings on Y axis (positive integers, default 3)
  34520. * @param scene defines the hosting scene
  34521. * @param updatable defines if the mesh must be flagged as updatable
  34522. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34523. * @returns a new Mesh
  34524. */
  34525. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34526. /**
  34527. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34528. * @param name defines the name of the mesh to create
  34529. * @param points is an array successive Vector3
  34530. * @param scene defines the hosting scene
  34531. * @param updatable defines if the mesh must be flagged as updatable
  34532. * @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).
  34533. * @returns a new Mesh
  34534. */
  34535. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34536. /**
  34537. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34538. * @param name defines the name of the mesh to create
  34539. * @param points is an array successive Vector3
  34540. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34541. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34542. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34543. * @param scene defines the hosting scene
  34544. * @param updatable defines if the mesh must be flagged as updatable
  34545. * @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)
  34546. * @returns a new Mesh
  34547. */
  34548. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34549. /**
  34550. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34551. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34552. * 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.
  34553. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34554. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34555. * Remember you can only change the shape positions, not their number when updating a polygon.
  34556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34557. * @param name defines the name of the mesh to create
  34558. * @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
  34559. * @param scene defines the hosting scene
  34560. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34561. * @param updatable defines if the mesh must be flagged as updatable
  34562. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34563. * @param earcutInjection can be used to inject your own earcut reference
  34564. * @returns a new Mesh
  34565. */
  34566. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34567. /**
  34568. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34569. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34570. * @param name defines the name of the mesh to create
  34571. * @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
  34572. * @param depth defines the height of extrusion
  34573. * @param scene defines the hosting scene
  34574. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34575. * @param updatable defines if the mesh must be flagged as updatable
  34576. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34577. * @param earcutInjection can be used to inject your own earcut reference
  34578. * @returns a new Mesh
  34579. */
  34580. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34581. /**
  34582. * Creates an extruded shape mesh.
  34583. * 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
  34584. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34586. * @param name defines the name of the mesh to create
  34587. * @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
  34588. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34589. * @param scale is the value to scale the shape
  34590. * @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
  34591. * @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
  34592. * @param scene defines the hosting scene
  34593. * @param updatable defines if the mesh must be flagged as updatable
  34594. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34595. * @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)
  34596. * @returns a new Mesh
  34597. */
  34598. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34599. /**
  34600. * Creates an custom extruded shape mesh.
  34601. * The custom extrusion is a parametric shape.
  34602. * It has no predefined shape. Its final shape will depend on the input parameters.
  34603. * Please consider using the same method from the MeshBuilder class instead
  34604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34605. * @param name defines the name of the mesh to create
  34606. * @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
  34607. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34608. * @param scaleFunction is a custom Javascript function called on each path point
  34609. * @param rotationFunction is a custom Javascript function called on each path point
  34610. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34611. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34612. * @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
  34613. * @param scene defines the hosting scene
  34614. * @param updatable defines if the mesh must be flagged as updatable
  34615. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34616. * @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)
  34617. * @returns a new Mesh
  34618. */
  34619. 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;
  34620. /**
  34621. * Creates lathe mesh.
  34622. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34623. * Please consider using the same method from the MeshBuilder class instead
  34624. * @param name defines the name of the mesh to create
  34625. * @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
  34626. * @param radius is the radius value of the lathe
  34627. * @param tessellation is the side number of the lathe.
  34628. * @param scene defines the hosting scene
  34629. * @param updatable defines if the mesh must be flagged as updatable
  34630. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34631. * @returns a new Mesh
  34632. */
  34633. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34634. /**
  34635. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34636. * @param name defines the name of the mesh to create
  34637. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34638. * @param scene defines the hosting scene
  34639. * @param updatable defines if the mesh must be flagged as updatable
  34640. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34641. * @returns a new Mesh
  34642. */
  34643. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34644. /**
  34645. * Creates a ground mesh.
  34646. * Please consider using the same method from the MeshBuilder class instead
  34647. * @param name defines the name of the mesh to create
  34648. * @param width set the width of the ground
  34649. * @param height set the height of the ground
  34650. * @param subdivisions sets the number of subdivisions per side
  34651. * @param scene defines the hosting scene
  34652. * @param updatable defines if the mesh must be flagged as updatable
  34653. * @returns a new Mesh
  34654. */
  34655. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34656. /**
  34657. * Creates a tiled ground mesh.
  34658. * Please consider using the same method from the MeshBuilder class instead
  34659. * @param name defines the name of the mesh to create
  34660. * @param xmin set the ground minimum X coordinate
  34661. * @param zmin set the ground minimum Y coordinate
  34662. * @param xmax set the ground maximum X coordinate
  34663. * @param zmax set the ground maximum Z coordinate
  34664. * @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
  34665. * @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
  34666. * @param scene defines the hosting scene
  34667. * @param updatable defines if the mesh must be flagged as updatable
  34668. * @returns a new Mesh
  34669. */
  34670. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34671. w: number;
  34672. h: number;
  34673. }, precision: {
  34674. w: number;
  34675. h: number;
  34676. }, scene: Scene, updatable?: boolean): Mesh;
  34677. /**
  34678. * Creates a ground mesh from a height map.
  34679. * Please consider using the same method from the MeshBuilder class instead
  34680. * @see https://doc.babylonjs.com/babylon101/height_map
  34681. * @param name defines the name of the mesh to create
  34682. * @param url sets the URL of the height map image resource
  34683. * @param width set the ground width size
  34684. * @param height set the ground height size
  34685. * @param subdivisions sets the number of subdivision per side
  34686. * @param minHeight is the minimum altitude on the ground
  34687. * @param maxHeight is the maximum altitude on the ground
  34688. * @param scene defines the hosting scene
  34689. * @param updatable defines if the mesh must be flagged as updatable
  34690. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34691. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34692. * @returns a new Mesh
  34693. */
  34694. 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;
  34695. /**
  34696. * Creates a tube mesh.
  34697. * The tube is a parametric shape.
  34698. * It has no predefined shape. Its final shape will depend on the input parameters.
  34699. * Please consider using the same method from the MeshBuilder class instead
  34700. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34701. * @param name defines the name of the mesh to create
  34702. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34703. * @param radius sets the tube radius size
  34704. * @param tessellation is the number of sides on the tubular surface
  34705. * @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
  34706. * @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
  34707. * @param scene defines the hosting scene
  34708. * @param updatable defines if the mesh must be flagged as updatable
  34709. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34710. * @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)
  34711. * @returns a new Mesh
  34712. */
  34713. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34714. (i: number, distance: number): number;
  34715. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34716. /**
  34717. * Creates a polyhedron mesh.
  34718. * Please consider using the same method from the MeshBuilder class instead.
  34719. * * 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
  34720. * * The parameter `size` (positive float, default 1) sets the polygon size
  34721. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34722. * * 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`
  34723. * * 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
  34724. * * 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)`)
  34725. * * 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
  34726. * * 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
  34727. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34728. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34730. * @param name defines the name of the mesh to create
  34731. * @param options defines the options used to create the mesh
  34732. * @param scene defines the hosting scene
  34733. * @returns a new Mesh
  34734. */
  34735. static CreatePolyhedron(name: string, options: {
  34736. type?: number;
  34737. size?: number;
  34738. sizeX?: number;
  34739. sizeY?: number;
  34740. sizeZ?: number;
  34741. custom?: any;
  34742. faceUV?: Vector4[];
  34743. faceColors?: Color4[];
  34744. updatable?: boolean;
  34745. sideOrientation?: number;
  34746. }, scene: Scene): Mesh;
  34747. /**
  34748. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34749. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34750. * * 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`)
  34751. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34752. * * 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
  34753. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34756. * @param name defines the name of the mesh
  34757. * @param options defines the options used to create the mesh
  34758. * @param scene defines the hosting scene
  34759. * @returns a new Mesh
  34760. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34761. */
  34762. static CreateIcoSphere(name: string, options: {
  34763. radius?: number;
  34764. flat?: boolean;
  34765. subdivisions?: number;
  34766. sideOrientation?: number;
  34767. updatable?: boolean;
  34768. }, scene: Scene): Mesh;
  34769. /**
  34770. * Creates a decal mesh.
  34771. * Please consider using the same method from the MeshBuilder class instead.
  34772. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34773. * @param name defines the name of the mesh
  34774. * @param sourceMesh defines the mesh receiving the decal
  34775. * @param position sets the position of the decal in world coordinates
  34776. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34777. * @param size sets the decal scaling
  34778. * @param angle sets the angle to rotate the decal
  34779. * @returns a new Mesh
  34780. */
  34781. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34782. /** Creates a Capsule Mesh
  34783. * @param name defines the name of the mesh.
  34784. * @param options the constructors options used to shape the mesh.
  34785. * @param scene defines the scene the mesh is scoped to.
  34786. * @returns the capsule mesh
  34787. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34788. */
  34789. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34790. /**
  34791. * Prepare internal position array for software CPU skinning
  34792. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34793. */
  34794. setPositionsForCPUSkinning(): Float32Array;
  34795. /**
  34796. * Prepare internal normal array for software CPU skinning
  34797. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34798. */
  34799. setNormalsForCPUSkinning(): Float32Array;
  34800. /**
  34801. * Updates the vertex buffer by applying transformation from the bones
  34802. * @param skeleton defines the skeleton to apply to current mesh
  34803. * @returns the current mesh
  34804. */
  34805. applySkeleton(skeleton: Skeleton): Mesh;
  34806. /**
  34807. * 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
  34808. * @param meshes defines the list of meshes to scan
  34809. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34810. */
  34811. static MinMax(meshes: AbstractMesh[]): {
  34812. min: Vector3;
  34813. max: Vector3;
  34814. };
  34815. /**
  34816. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34817. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34818. * @returns a vector3
  34819. */
  34820. static Center(meshesOrMinMaxVector: {
  34821. min: Vector3;
  34822. max: Vector3;
  34823. } | AbstractMesh[]): Vector3;
  34824. /**
  34825. * Merge the array of meshes into a single mesh for performance reasons.
  34826. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34827. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34828. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34829. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34830. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34831. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34832. * @returns a new mesh
  34833. */
  34834. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34835. /** @hidden */
  34836. addInstance(instance: InstancedMesh): void;
  34837. /** @hidden */
  34838. removeInstance(instance: InstancedMesh): void;
  34839. }
  34840. }
  34841. declare module "babylonjs/Cameras/camera" {
  34842. import { SmartArray } from "babylonjs/Misc/smartArray";
  34843. import { Observable } from "babylonjs/Misc/observable";
  34844. import { Nullable } from "babylonjs/types";
  34845. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34846. import { Scene } from "babylonjs/scene";
  34847. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  34848. import { Node } from "babylonjs/node";
  34849. import { Mesh } from "babylonjs/Meshes/mesh";
  34850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34851. import { ICullable } from "babylonjs/Culling/boundingInfo";
  34852. import { Viewport } from "babylonjs/Maths/math.viewport";
  34853. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34854. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34855. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  34856. import { Ray } from "babylonjs/Culling/ray";
  34857. /**
  34858. * This is the base class of all the camera used in the application.
  34859. * @see https://doc.babylonjs.com/features/cameras
  34860. */
  34861. export class Camera extends Node {
  34862. /** @hidden */
  34863. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  34864. /**
  34865. * This is the default projection mode used by the cameras.
  34866. * It helps recreating a feeling of perspective and better appreciate depth.
  34867. * This is the best way to simulate real life cameras.
  34868. */
  34869. static readonly PERSPECTIVE_CAMERA: number;
  34870. /**
  34871. * This helps creating camera with an orthographic mode.
  34872. * 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.
  34873. */
  34874. static readonly ORTHOGRAPHIC_CAMERA: number;
  34875. /**
  34876. * This is the default FOV mode for perspective cameras.
  34877. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  34878. */
  34879. static readonly FOVMODE_VERTICAL_FIXED: number;
  34880. /**
  34881. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  34882. */
  34883. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  34884. /**
  34885. * This specifies ther is no need for a camera rig.
  34886. * Basically only one eye is rendered corresponding to the camera.
  34887. */
  34888. static readonly RIG_MODE_NONE: number;
  34889. /**
  34890. * Simulates a camera Rig with one blue eye and one red eye.
  34891. * This can be use with 3d blue and red glasses.
  34892. */
  34893. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  34894. /**
  34895. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  34896. */
  34897. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  34898. /**
  34899. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  34900. */
  34901. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  34902. /**
  34903. * Defines that both eyes of the camera will be rendered over under each other.
  34904. */
  34905. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  34906. /**
  34907. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  34908. */
  34909. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  34910. /**
  34911. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  34912. */
  34913. static readonly RIG_MODE_VR: number;
  34914. /**
  34915. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  34916. */
  34917. static readonly RIG_MODE_WEBVR: number;
  34918. /**
  34919. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  34920. */
  34921. static readonly RIG_MODE_CUSTOM: number;
  34922. /**
  34923. * Defines if by default attaching controls should prevent the default javascript event to continue.
  34924. */
  34925. static ForceAttachControlToAlwaysPreventDefault: boolean;
  34926. /**
  34927. * Define the input manager associated with the camera.
  34928. */
  34929. inputs: CameraInputsManager<Camera>;
  34930. /** @hidden */
  34931. _position: Vector3;
  34932. /**
  34933. * Define the current local position of the camera in the scene
  34934. */
  34935. get position(): Vector3;
  34936. set position(newPosition: Vector3);
  34937. protected _upVector: Vector3;
  34938. /**
  34939. * The vector the camera should consider as up.
  34940. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  34941. */
  34942. set upVector(vec: Vector3);
  34943. get upVector(): Vector3;
  34944. /**
  34945. * Define the current limit on the left side for an orthographic camera
  34946. * In scene unit
  34947. */
  34948. orthoLeft: Nullable<number>;
  34949. /**
  34950. * Define the current limit on the right side for an orthographic camera
  34951. * In scene unit
  34952. */
  34953. orthoRight: Nullable<number>;
  34954. /**
  34955. * Define the current limit on the bottom side for an orthographic camera
  34956. * In scene unit
  34957. */
  34958. orthoBottom: Nullable<number>;
  34959. /**
  34960. * Define the current limit on the top side for an orthographic camera
  34961. * In scene unit
  34962. */
  34963. orthoTop: Nullable<number>;
  34964. /**
  34965. * Field Of View is set in Radians. (default is 0.8)
  34966. */
  34967. fov: number;
  34968. /**
  34969. * Define the minimum distance the camera can see from.
  34970. * This is important to note that the depth buffer are not infinite and the closer it starts
  34971. * the more your scene might encounter depth fighting issue.
  34972. */
  34973. minZ: number;
  34974. /**
  34975. * Define the maximum distance the camera can see to.
  34976. * This is important to note that the depth buffer are not infinite and the further it end
  34977. * the more your scene might encounter depth fighting issue.
  34978. */
  34979. maxZ: number;
  34980. /**
  34981. * Define the default inertia of the camera.
  34982. * This helps giving a smooth feeling to the camera movement.
  34983. */
  34984. inertia: number;
  34985. /**
  34986. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  34987. */
  34988. mode: number;
  34989. /**
  34990. * Define whether the camera is intermediate.
  34991. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  34992. */
  34993. isIntermediate: boolean;
  34994. /**
  34995. * Define the viewport of the camera.
  34996. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  34997. */
  34998. viewport: Viewport;
  34999. /**
  35000. * Restricts the camera to viewing objects with the same layerMask.
  35001. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  35002. */
  35003. layerMask: number;
  35004. /**
  35005. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  35006. */
  35007. fovMode: number;
  35008. /**
  35009. * Rig mode of the camera.
  35010. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  35011. * This is normally controlled byt the camera themselves as internal use.
  35012. */
  35013. cameraRigMode: number;
  35014. /**
  35015. * Defines the distance between both "eyes" in case of a RIG
  35016. */
  35017. interaxialDistance: number;
  35018. /**
  35019. * Defines if stereoscopic rendering is done side by side or over under.
  35020. */
  35021. isStereoscopicSideBySide: boolean;
  35022. /**
  35023. * 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
  35024. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  35025. * else in the scene. (Eg. security camera)
  35026. *
  35027. * 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)
  35028. */
  35029. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  35030. /**
  35031. * When set, the camera will render to this render target instead of the default canvas
  35032. *
  35033. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  35034. */
  35035. outputRenderTarget: Nullable<RenderTargetTexture>;
  35036. /**
  35037. * Observable triggered when the camera view matrix has changed.
  35038. */
  35039. onViewMatrixChangedObservable: Observable<Camera>;
  35040. /**
  35041. * Observable triggered when the camera Projection matrix has changed.
  35042. */
  35043. onProjectionMatrixChangedObservable: Observable<Camera>;
  35044. /**
  35045. * Observable triggered when the inputs have been processed.
  35046. */
  35047. onAfterCheckInputsObservable: Observable<Camera>;
  35048. /**
  35049. * Observable triggered when reset has been called and applied to the camera.
  35050. */
  35051. onRestoreStateObservable: Observable<Camera>;
  35052. /**
  35053. * Is this camera a part of a rig system?
  35054. */
  35055. isRigCamera: boolean;
  35056. /**
  35057. * If isRigCamera set to true this will be set with the parent camera.
  35058. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  35059. */
  35060. rigParent?: Camera;
  35061. /** @hidden */
  35062. _cameraRigParams: any;
  35063. /** @hidden */
  35064. _rigCameras: Camera[];
  35065. /** @hidden */
  35066. _rigPostProcess: Nullable<PostProcess>;
  35067. protected _webvrViewMatrix: Matrix;
  35068. /** @hidden */
  35069. _skipRendering: boolean;
  35070. /** @hidden */
  35071. _projectionMatrix: Matrix;
  35072. /** @hidden */
  35073. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  35074. /** @hidden */
  35075. _activeMeshes: SmartArray<AbstractMesh>;
  35076. protected _globalPosition: Vector3;
  35077. /** @hidden */
  35078. _computedViewMatrix: Matrix;
  35079. private _doNotComputeProjectionMatrix;
  35080. private _transformMatrix;
  35081. private _frustumPlanes;
  35082. private _refreshFrustumPlanes;
  35083. private _storedFov;
  35084. private _stateStored;
  35085. /**
  35086. * Instantiates a new camera object.
  35087. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  35088. * @see https://doc.babylonjs.com/features/cameras
  35089. * @param name Defines the name of the camera in the scene
  35090. * @param position Defines the position of the camera
  35091. * @param scene Defines the scene the camera belongs too
  35092. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  35093. */
  35094. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35095. /**
  35096. * Store current camera state (fov, position, etc..)
  35097. * @returns the camera
  35098. */
  35099. storeState(): Camera;
  35100. /**
  35101. * Restores the camera state values if it has been stored. You must call storeState() first
  35102. */
  35103. protected _restoreStateValues(): boolean;
  35104. /**
  35105. * Restored camera state. You must call storeState() first.
  35106. * @returns true if restored and false otherwise
  35107. */
  35108. restoreState(): boolean;
  35109. /**
  35110. * Gets the class name of the camera.
  35111. * @returns the class name
  35112. */
  35113. getClassName(): string;
  35114. /** @hidden */
  35115. readonly _isCamera: boolean;
  35116. /**
  35117. * Gets a string representation of the camera useful for debug purpose.
  35118. * @param fullDetails Defines that a more verboe level of logging is required
  35119. * @returns the string representation
  35120. */
  35121. toString(fullDetails?: boolean): string;
  35122. /**
  35123. * Gets the current world space position of the camera.
  35124. */
  35125. get globalPosition(): Vector3;
  35126. /**
  35127. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  35128. * @returns the active meshe list
  35129. */
  35130. getActiveMeshes(): SmartArray<AbstractMesh>;
  35131. /**
  35132. * Check whether a mesh is part of the current active mesh list of the camera
  35133. * @param mesh Defines the mesh to check
  35134. * @returns true if active, false otherwise
  35135. */
  35136. isActiveMesh(mesh: Mesh): boolean;
  35137. /**
  35138. * Is this camera ready to be used/rendered
  35139. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  35140. * @return true if the camera is ready
  35141. */
  35142. isReady(completeCheck?: boolean): boolean;
  35143. /** @hidden */
  35144. _initCache(): void;
  35145. /** @hidden */
  35146. _updateCache(ignoreParentClass?: boolean): void;
  35147. /** @hidden */
  35148. _isSynchronized(): boolean;
  35149. /** @hidden */
  35150. _isSynchronizedViewMatrix(): boolean;
  35151. /** @hidden */
  35152. _isSynchronizedProjectionMatrix(): boolean;
  35153. /**
  35154. * Attach the input controls to a specific dom element to get the input from.
  35155. * @param element Defines the element the controls should be listened from
  35156. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35157. */
  35158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35159. /**
  35160. * Detach the current controls from the specified dom element.
  35161. * @param element Defines the element to stop listening the inputs from
  35162. */
  35163. detachControl(element: HTMLElement): void;
  35164. /**
  35165. * Update the camera state according to the different inputs gathered during the frame.
  35166. */
  35167. update(): void;
  35168. /** @hidden */
  35169. _checkInputs(): void;
  35170. /** @hidden */
  35171. get rigCameras(): Camera[];
  35172. /**
  35173. * Gets the post process used by the rig cameras
  35174. */
  35175. get rigPostProcess(): Nullable<PostProcess>;
  35176. /**
  35177. * Internal, gets the first post proces.
  35178. * @returns the first post process to be run on this camera.
  35179. */
  35180. _getFirstPostProcess(): Nullable<PostProcess>;
  35181. private _cascadePostProcessesToRigCams;
  35182. /**
  35183. * Attach a post process to the camera.
  35184. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35185. * @param postProcess The post process to attach to the camera
  35186. * @param insertAt The position of the post process in case several of them are in use in the scene
  35187. * @returns the position the post process has been inserted at
  35188. */
  35189. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  35190. /**
  35191. * Detach a post process to the camera.
  35192. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35193. * @param postProcess The post process to detach from the camera
  35194. */
  35195. detachPostProcess(postProcess: PostProcess): void;
  35196. /**
  35197. * Gets the current world matrix of the camera
  35198. */
  35199. getWorldMatrix(): Matrix;
  35200. /** @hidden */
  35201. _getViewMatrix(): Matrix;
  35202. /**
  35203. * Gets the current view matrix of the camera.
  35204. * @param force forces the camera to recompute the matrix without looking at the cached state
  35205. * @returns the view matrix
  35206. */
  35207. getViewMatrix(force?: boolean): Matrix;
  35208. /**
  35209. * Freeze the projection matrix.
  35210. * It will prevent the cache check of the camera projection compute and can speed up perf
  35211. * if no parameter of the camera are meant to change
  35212. * @param projection Defines manually a projection if necessary
  35213. */
  35214. freezeProjectionMatrix(projection?: Matrix): void;
  35215. /**
  35216. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  35217. */
  35218. unfreezeProjectionMatrix(): void;
  35219. /**
  35220. * Gets the current projection matrix of the camera.
  35221. * @param force forces the camera to recompute the matrix without looking at the cached state
  35222. * @returns the projection matrix
  35223. */
  35224. getProjectionMatrix(force?: boolean): Matrix;
  35225. /**
  35226. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  35227. * @returns a Matrix
  35228. */
  35229. getTransformationMatrix(): Matrix;
  35230. private _updateFrustumPlanes;
  35231. /**
  35232. * Checks if a cullable object (mesh...) is in the camera frustum
  35233. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  35234. * @param target The object to check
  35235. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  35236. * @returns true if the object is in frustum otherwise false
  35237. */
  35238. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  35239. /**
  35240. * Checks if a cullable object (mesh...) is in the camera frustum
  35241. * Unlike isInFrustum this cheks the full bounding box
  35242. * @param target The object to check
  35243. * @returns true if the object is in frustum otherwise false
  35244. */
  35245. isCompletelyInFrustum(target: ICullable): boolean;
  35246. /**
  35247. * Gets a ray in the forward direction from the camera.
  35248. * @param length Defines the length of the ray to create
  35249. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35250. * @param origin Defines the start point of the ray which defaults to the camera position
  35251. * @returns the forward ray
  35252. */
  35253. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35254. /**
  35255. * Gets a ray in the forward direction from the camera.
  35256. * @param refRay the ray to (re)use when setting the values
  35257. * @param length Defines the length of the ray to create
  35258. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35259. * @param origin Defines the start point of the ray which defaults to the camera position
  35260. * @returns the forward ray
  35261. */
  35262. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35263. /**
  35264. * Releases resources associated with this node.
  35265. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35266. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35267. */
  35268. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35269. /** @hidden */
  35270. _isLeftCamera: boolean;
  35271. /**
  35272. * Gets the left camera of a rig setup in case of Rigged Camera
  35273. */
  35274. get isLeftCamera(): boolean;
  35275. /** @hidden */
  35276. _isRightCamera: boolean;
  35277. /**
  35278. * Gets the right camera of a rig setup in case of Rigged Camera
  35279. */
  35280. get isRightCamera(): boolean;
  35281. /**
  35282. * Gets the left camera of a rig setup in case of Rigged Camera
  35283. */
  35284. get leftCamera(): Nullable<FreeCamera>;
  35285. /**
  35286. * Gets the right camera of a rig setup in case of Rigged Camera
  35287. */
  35288. get rightCamera(): Nullable<FreeCamera>;
  35289. /**
  35290. * Gets the left camera target of a rig setup in case of Rigged Camera
  35291. * @returns the target position
  35292. */
  35293. getLeftTarget(): Nullable<Vector3>;
  35294. /**
  35295. * Gets the right camera target of a rig setup in case of Rigged Camera
  35296. * @returns the target position
  35297. */
  35298. getRightTarget(): Nullable<Vector3>;
  35299. /**
  35300. * @hidden
  35301. */
  35302. setCameraRigMode(mode: number, rigParams: any): void;
  35303. /** @hidden */
  35304. static _setStereoscopicRigMode(camera: Camera): void;
  35305. /** @hidden */
  35306. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  35307. /** @hidden */
  35308. static _setVRRigMode(camera: Camera, rigParams: any): void;
  35309. /** @hidden */
  35310. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  35311. /** @hidden */
  35312. _getVRProjectionMatrix(): Matrix;
  35313. protected _updateCameraRotationMatrix(): void;
  35314. protected _updateWebVRCameraRotationMatrix(): void;
  35315. /**
  35316. * This function MUST be overwritten by the different WebVR cameras available.
  35317. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35318. * @hidden
  35319. */
  35320. _getWebVRProjectionMatrix(): Matrix;
  35321. /**
  35322. * This function MUST be overwritten by the different WebVR cameras available.
  35323. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35324. * @hidden
  35325. */
  35326. _getWebVRViewMatrix(): Matrix;
  35327. /** @hidden */
  35328. setCameraRigParameter(name: string, value: any): void;
  35329. /**
  35330. * needs to be overridden by children so sub has required properties to be copied
  35331. * @hidden
  35332. */
  35333. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  35334. /**
  35335. * May need to be overridden by children
  35336. * @hidden
  35337. */
  35338. _updateRigCameras(): void;
  35339. /** @hidden */
  35340. _setupInputs(): void;
  35341. /**
  35342. * Serialiaze the camera setup to a json represention
  35343. * @returns the JSON representation
  35344. */
  35345. serialize(): any;
  35346. /**
  35347. * Clones the current camera.
  35348. * @param name The cloned camera name
  35349. * @returns the cloned camera
  35350. */
  35351. clone(name: string): Camera;
  35352. /**
  35353. * Gets the direction of the camera relative to a given local axis.
  35354. * @param localAxis Defines the reference axis to provide a relative direction.
  35355. * @return the direction
  35356. */
  35357. getDirection(localAxis: Vector3): Vector3;
  35358. /**
  35359. * Returns the current camera absolute rotation
  35360. */
  35361. get absoluteRotation(): Quaternion;
  35362. /**
  35363. * Gets the direction of the camera relative to a given local axis into a passed vector.
  35364. * @param localAxis Defines the reference axis to provide a relative direction.
  35365. * @param result Defines the vector to store the result in
  35366. */
  35367. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  35368. /**
  35369. * Gets a camera constructor for a given camera type
  35370. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  35371. * @param name The name of the camera the result will be able to instantiate
  35372. * @param scene The scene the result will construct the camera in
  35373. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  35374. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  35375. * @returns a factory method to construc the camera
  35376. */
  35377. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  35378. /**
  35379. * Compute the world matrix of the camera.
  35380. * @returns the camera world matrix
  35381. */
  35382. computeWorldMatrix(): Matrix;
  35383. /**
  35384. * Parse a JSON and creates the camera from the parsed information
  35385. * @param parsedCamera The JSON to parse
  35386. * @param scene The scene to instantiate the camera in
  35387. * @returns the newly constructed camera
  35388. */
  35389. static Parse(parsedCamera: any, scene: Scene): Camera;
  35390. }
  35391. }
  35392. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35393. import { Nullable } from "babylonjs/types";
  35394. import { Scene } from "babylonjs/scene";
  35395. import { Vector4 } from "babylonjs/Maths/math.vector";
  35396. import { Mesh } from "babylonjs/Meshes/mesh";
  35397. /**
  35398. * Class containing static functions to help procedurally build meshes
  35399. */
  35400. export class DiscBuilder {
  35401. /**
  35402. * Creates a plane polygonal mesh. By default, this is a disc
  35403. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35404. * * 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
  35405. * * 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
  35406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35409. * @param name defines the name of the mesh
  35410. * @param options defines the options used to create the mesh
  35411. * @param scene defines the hosting scene
  35412. * @returns the plane polygonal mesh
  35413. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35414. */
  35415. static CreateDisc(name: string, options: {
  35416. radius?: number;
  35417. tessellation?: number;
  35418. arc?: number;
  35419. updatable?: boolean;
  35420. sideOrientation?: number;
  35421. frontUVs?: Vector4;
  35422. backUVs?: Vector4;
  35423. }, scene?: Nullable<Scene>): Mesh;
  35424. }
  35425. }
  35426. declare module "babylonjs/Particles/solidParticleSystem" {
  35427. import { Nullable } from "babylonjs/types";
  35428. import { Mesh } from "babylonjs/Meshes/mesh";
  35429. import { Scene, IDisposable } from "babylonjs/scene";
  35430. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35431. import { Material } from "babylonjs/Materials/material";
  35432. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35433. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35434. /**
  35435. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35436. *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.
  35437. * The SPS is also a particle system. It provides some methods to manage the particles.
  35438. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35439. *
  35440. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35441. */
  35442. export class SolidParticleSystem implements IDisposable {
  35443. /**
  35444. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35445. * Example : var p = SPS.particles[i];
  35446. */
  35447. particles: SolidParticle[];
  35448. /**
  35449. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35450. */
  35451. nbParticles: number;
  35452. /**
  35453. * If the particles must ever face the camera (default false). Useful for planar particles.
  35454. */
  35455. billboard: boolean;
  35456. /**
  35457. * Recompute normals when adding a shape
  35458. */
  35459. recomputeNormals: boolean;
  35460. /**
  35461. * This a counter ofr your own usage. It's not set by any SPS functions.
  35462. */
  35463. counter: number;
  35464. /**
  35465. * The SPS name. This name is also given to the underlying mesh.
  35466. */
  35467. name: string;
  35468. /**
  35469. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35470. */
  35471. mesh: Mesh;
  35472. /**
  35473. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35474. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35475. */
  35476. vars: any;
  35477. /**
  35478. * This array is populated when the SPS is set as 'pickable'.
  35479. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35480. * Each element of this array is an object `{idx: int, faceId: int}`.
  35481. * `idx` is the picked particle index in the `SPS.particles` array
  35482. * `faceId` is the picked face index counted within this particle.
  35483. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35484. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35485. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35486. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35487. */
  35488. pickedParticles: {
  35489. idx: number;
  35490. faceId: number;
  35491. }[];
  35492. /**
  35493. * This array is populated when the SPS is set as 'pickable'
  35494. * Each key of this array is a submesh index.
  35495. * Each element of this array is a second array defined like this :
  35496. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35497. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35498. * `idx` is the picked particle index in the `SPS.particles` array
  35499. * `faceId` is the picked face index counted within this particle.
  35500. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35501. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35502. */
  35503. pickedBySubMesh: {
  35504. idx: number;
  35505. faceId: number;
  35506. }[][];
  35507. /**
  35508. * This array is populated when `enableDepthSort` is set to true.
  35509. * Each element of this array is an instance of the class DepthSortedParticle.
  35510. */
  35511. depthSortedParticles: DepthSortedParticle[];
  35512. /**
  35513. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35514. * @hidden
  35515. */
  35516. _bSphereOnly: boolean;
  35517. /**
  35518. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35519. * @hidden
  35520. */
  35521. _bSphereRadiusFactor: number;
  35522. private _scene;
  35523. private _positions;
  35524. private _indices;
  35525. private _normals;
  35526. private _colors;
  35527. private _uvs;
  35528. private _indices32;
  35529. private _positions32;
  35530. private _normals32;
  35531. private _fixedNormal32;
  35532. private _colors32;
  35533. private _uvs32;
  35534. private _index;
  35535. private _updatable;
  35536. private _pickable;
  35537. private _isVisibilityBoxLocked;
  35538. private _alwaysVisible;
  35539. private _depthSort;
  35540. private _expandable;
  35541. private _shapeCounter;
  35542. private _copy;
  35543. private _color;
  35544. private _computeParticleColor;
  35545. private _computeParticleTexture;
  35546. private _computeParticleRotation;
  35547. private _computeParticleVertex;
  35548. private _computeBoundingBox;
  35549. private _depthSortParticles;
  35550. private _camera;
  35551. private _mustUnrotateFixedNormals;
  35552. private _particlesIntersect;
  35553. private _needs32Bits;
  35554. private _isNotBuilt;
  35555. private _lastParticleId;
  35556. private _idxOfId;
  35557. private _multimaterialEnabled;
  35558. private _useModelMaterial;
  35559. private _indicesByMaterial;
  35560. private _materialIndexes;
  35561. private _depthSortFunction;
  35562. private _materialSortFunction;
  35563. private _materials;
  35564. private _multimaterial;
  35565. private _materialIndexesById;
  35566. private _defaultMaterial;
  35567. private _autoUpdateSubMeshes;
  35568. private _tmpVertex;
  35569. /**
  35570. * Creates a SPS (Solid Particle System) object.
  35571. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35572. * @param scene (Scene) is the scene in which the SPS is added.
  35573. * @param options defines the options of the sps e.g.
  35574. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35575. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35576. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35577. * * 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.
  35578. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35579. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35580. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35581. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35582. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35583. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35584. */
  35585. constructor(name: string, scene: Scene, options?: {
  35586. updatable?: boolean;
  35587. isPickable?: boolean;
  35588. enableDepthSort?: boolean;
  35589. particleIntersection?: boolean;
  35590. boundingSphereOnly?: boolean;
  35591. bSphereRadiusFactor?: number;
  35592. expandable?: boolean;
  35593. useModelMaterial?: boolean;
  35594. enableMultiMaterial?: boolean;
  35595. });
  35596. /**
  35597. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35598. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35599. * @returns the created mesh
  35600. */
  35601. buildMesh(): Mesh;
  35602. /**
  35603. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35604. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35605. * Thus the particles generated from `digest()` have their property `position` set yet.
  35606. * @param mesh ( Mesh ) is the mesh to be digested
  35607. * @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
  35608. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35609. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35610. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35611. * @returns the current SPS
  35612. */
  35613. digest(mesh: Mesh, options?: {
  35614. facetNb?: number;
  35615. number?: number;
  35616. delta?: number;
  35617. storage?: [];
  35618. }): SolidParticleSystem;
  35619. /**
  35620. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35621. * @hidden
  35622. */
  35623. private _unrotateFixedNormals;
  35624. /**
  35625. * Resets the temporary working copy particle
  35626. * @hidden
  35627. */
  35628. private _resetCopy;
  35629. /**
  35630. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35631. * @param p the current index in the positions array to be updated
  35632. * @param ind the current index in the indices array
  35633. * @param shape a Vector3 array, the shape geometry
  35634. * @param positions the positions array to be updated
  35635. * @param meshInd the shape indices array
  35636. * @param indices the indices array to be updated
  35637. * @param meshUV the shape uv array
  35638. * @param uvs the uv array to be updated
  35639. * @param meshCol the shape color array
  35640. * @param colors the color array to be updated
  35641. * @param meshNor the shape normals array
  35642. * @param normals the normals array to be updated
  35643. * @param idx the particle index
  35644. * @param idxInShape the particle index in its shape
  35645. * @param options the addShape() method passed options
  35646. * @model the particle model
  35647. * @hidden
  35648. */
  35649. private _meshBuilder;
  35650. /**
  35651. * Returns a shape Vector3 array from positions float array
  35652. * @param positions float array
  35653. * @returns a vector3 array
  35654. * @hidden
  35655. */
  35656. private _posToShape;
  35657. /**
  35658. * Returns a shapeUV array from a float uvs (array deep copy)
  35659. * @param uvs as a float array
  35660. * @returns a shapeUV array
  35661. * @hidden
  35662. */
  35663. private _uvsToShapeUV;
  35664. /**
  35665. * Adds a new particle object in the particles array
  35666. * @param idx particle index in particles array
  35667. * @param id particle id
  35668. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35669. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35670. * @param model particle ModelShape object
  35671. * @param shapeId model shape identifier
  35672. * @param idxInShape index of the particle in the current model
  35673. * @param bInfo model bounding info object
  35674. * @param storage target storage array, if any
  35675. * @hidden
  35676. */
  35677. private _addParticle;
  35678. /**
  35679. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35680. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35681. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35682. * @param nb (positive integer) the number of particles to be created from this model
  35683. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35684. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35685. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35686. * @returns the number of shapes in the system
  35687. */
  35688. addShape(mesh: Mesh, nb: number, options?: {
  35689. positionFunction?: any;
  35690. vertexFunction?: any;
  35691. storage?: [];
  35692. }): number;
  35693. /**
  35694. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35695. * @hidden
  35696. */
  35697. private _rebuildParticle;
  35698. /**
  35699. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35700. * @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.
  35701. * @returns the SPS.
  35702. */
  35703. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35704. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35705. * Returns an array with the removed particles.
  35706. * 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.
  35707. * The SPS can't be empty so at least one particle needs to remain in place.
  35708. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35709. * @param start index of the first particle to remove
  35710. * @param end index of the last particle to remove (included)
  35711. * @returns an array populated with the removed particles
  35712. */
  35713. removeParticles(start: number, end: number): SolidParticle[];
  35714. /**
  35715. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35716. * @param solidParticleArray an array populated with Solid Particles objects
  35717. * @returns the SPS
  35718. */
  35719. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35720. /**
  35721. * Creates a new particle and modifies the SPS mesh geometry :
  35722. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35723. * - calls _addParticle() to populate the particle array
  35724. * factorized code from addShape() and insertParticlesFromArray()
  35725. * @param idx particle index in the particles array
  35726. * @param i particle index in its shape
  35727. * @param modelShape particle ModelShape object
  35728. * @param shape shape vertex array
  35729. * @param meshInd shape indices array
  35730. * @param meshUV shape uv array
  35731. * @param meshCol shape color array
  35732. * @param meshNor shape normals array
  35733. * @param bbInfo shape bounding info
  35734. * @param storage target particle storage
  35735. * @options addShape() passed options
  35736. * @hidden
  35737. */
  35738. private _insertNewParticle;
  35739. /**
  35740. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35741. * This method calls `updateParticle()` for each particle of the SPS.
  35742. * For an animated SPS, it is usually called within the render loop.
  35743. * 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.
  35744. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35745. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35746. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35747. * @returns the SPS.
  35748. */
  35749. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35750. /**
  35751. * Disposes the SPS.
  35752. */
  35753. dispose(): void;
  35754. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35755. * idx is the particle index in the SPS
  35756. * faceId is the picked face index counted within this particle.
  35757. * Returns null if the pickInfo can't identify a picked particle.
  35758. * @param pickingInfo (PickingInfo object)
  35759. * @returns {idx: number, faceId: number} or null
  35760. */
  35761. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35762. idx: number;
  35763. faceId: number;
  35764. }>;
  35765. /**
  35766. * Returns a SolidParticle object from its identifier : particle.id
  35767. * @param id (integer) the particle Id
  35768. * @returns the searched particle or null if not found in the SPS.
  35769. */
  35770. getParticleById(id: number): Nullable<SolidParticle>;
  35771. /**
  35772. * Returns a new array populated with the particles having the passed shapeId.
  35773. * @param shapeId (integer) the shape identifier
  35774. * @returns a new solid particle array
  35775. */
  35776. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35777. /**
  35778. * Populates the passed array "ref" with the particles having the passed shapeId.
  35779. * @param shapeId the shape identifier
  35780. * @returns the SPS
  35781. * @param ref
  35782. */
  35783. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35784. /**
  35785. * Computes the required SubMeshes according the materials assigned to the particles.
  35786. * @returns the solid particle system.
  35787. * Does nothing if called before the SPS mesh is built.
  35788. */
  35789. computeSubMeshes(): SolidParticleSystem;
  35790. /**
  35791. * Sorts the solid particles by material when MultiMaterial is enabled.
  35792. * Updates the indices32 array.
  35793. * Updates the indicesByMaterial array.
  35794. * Updates the mesh indices array.
  35795. * @returns the SPS
  35796. * @hidden
  35797. */
  35798. private _sortParticlesByMaterial;
  35799. /**
  35800. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35801. * @hidden
  35802. */
  35803. private _setMaterialIndexesById;
  35804. /**
  35805. * Returns an array with unique values of Materials from the passed array
  35806. * @param array the material array to be checked and filtered
  35807. * @hidden
  35808. */
  35809. private _filterUniqueMaterialId;
  35810. /**
  35811. * Sets a new Standard Material as _defaultMaterial if not already set.
  35812. * @hidden
  35813. */
  35814. private _setDefaultMaterial;
  35815. /**
  35816. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35817. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35818. * @returns the SPS.
  35819. */
  35820. refreshVisibleSize(): SolidParticleSystem;
  35821. /**
  35822. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35823. * @param size the size (float) of the visibility box
  35824. * note : this doesn't lock the SPS mesh bounding box.
  35825. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35826. */
  35827. setVisibilityBox(size: number): void;
  35828. /**
  35829. * Gets whether the SPS as always visible or not
  35830. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35831. */
  35832. get isAlwaysVisible(): boolean;
  35833. /**
  35834. * Sets the SPS as always visible or not
  35835. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35836. */
  35837. set isAlwaysVisible(val: boolean);
  35838. /**
  35839. * Sets 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. set isVisibilityBoxLocked(val: boolean);
  35843. /**
  35844. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35845. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35846. */
  35847. get isVisibilityBoxLocked(): boolean;
  35848. /**
  35849. * Tells to `setParticles()` to compute the particle rotations or not.
  35850. * Default value : true. The SPS is faster when it's set to false.
  35851. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35852. */
  35853. set computeParticleRotation(val: boolean);
  35854. /**
  35855. * Tells to `setParticles()` to compute the particle colors or not.
  35856. * Default value : true. The SPS is faster when it's set to false.
  35857. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35858. */
  35859. set computeParticleColor(val: boolean);
  35860. set computeParticleTexture(val: boolean);
  35861. /**
  35862. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35863. * Default value : false. The SPS is faster when it's set to false.
  35864. * Note : the particle custom vertex positions aren't stored values.
  35865. */
  35866. set computeParticleVertex(val: boolean);
  35867. /**
  35868. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35869. */
  35870. set computeBoundingBox(val: boolean);
  35871. /**
  35872. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35873. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35874. * Default : `true`
  35875. */
  35876. set depthSortParticles(val: boolean);
  35877. /**
  35878. * Gets if `setParticles()` computes the particle rotations or not.
  35879. * Default value : true. The SPS is faster when it's set to false.
  35880. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35881. */
  35882. get computeParticleRotation(): boolean;
  35883. /**
  35884. * Gets if `setParticles()` computes the particle colors or not.
  35885. * Default value : true. The SPS is faster when it's set to false.
  35886. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35887. */
  35888. get computeParticleColor(): boolean;
  35889. /**
  35890. * Gets if `setParticles()` computes the particle textures or not.
  35891. * Default value : true. The SPS is faster when it's set to false.
  35892. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35893. */
  35894. get computeParticleTexture(): boolean;
  35895. /**
  35896. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35897. * Default value : false. The SPS is faster when it's set to false.
  35898. * Note : the particle custom vertex positions aren't stored values.
  35899. */
  35900. get computeParticleVertex(): boolean;
  35901. /**
  35902. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35903. */
  35904. get computeBoundingBox(): boolean;
  35905. /**
  35906. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35907. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35908. * Default : `true`
  35909. */
  35910. get depthSortParticles(): boolean;
  35911. /**
  35912. * Gets if the SPS is created as expandable at construction time.
  35913. * Default : `false`
  35914. */
  35915. get expandable(): boolean;
  35916. /**
  35917. * Gets if the SPS supports the Multi Materials
  35918. */
  35919. get multimaterialEnabled(): boolean;
  35920. /**
  35921. * Gets if the SPS uses the model materials for its own multimaterial.
  35922. */
  35923. get useModelMaterial(): boolean;
  35924. /**
  35925. * The SPS used material array.
  35926. */
  35927. get materials(): Material[];
  35928. /**
  35929. * Sets the SPS MultiMaterial from the passed materials.
  35930. * Note : the passed array is internally copied and not used then by reference.
  35931. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35932. */
  35933. setMultiMaterial(materials: Material[]): void;
  35934. /**
  35935. * The SPS computed multimaterial object
  35936. */
  35937. get multimaterial(): MultiMaterial;
  35938. set multimaterial(mm: MultiMaterial);
  35939. /**
  35940. * If the subMeshes must be updated on the next call to setParticles()
  35941. */
  35942. get autoUpdateSubMeshes(): boolean;
  35943. set autoUpdateSubMeshes(val: boolean);
  35944. /**
  35945. * This function does nothing. It may be overwritten to set all the particle first values.
  35946. * The SPS doesn't call this function, you may have to call it by your own.
  35947. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35948. */
  35949. initParticles(): void;
  35950. /**
  35951. * This function does nothing. It may be overwritten to recycle a particle.
  35952. * The SPS doesn't call this function, you may have to call it by your own.
  35953. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35954. * @param particle The particle to recycle
  35955. * @returns the recycled particle
  35956. */
  35957. recycleParticle(particle: SolidParticle): SolidParticle;
  35958. /**
  35959. * Updates a particle : this function should be overwritten by the user.
  35960. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35961. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35962. * @example : just set a particle position or velocity and recycle conditions
  35963. * @param particle The particle to update
  35964. * @returns the updated particle
  35965. */
  35966. updateParticle(particle: SolidParticle): SolidParticle;
  35967. /**
  35968. * Updates a vertex of a particle : it can be overwritten by the user.
  35969. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35970. * @param particle the current particle
  35971. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35972. * @param pt the index of the current vertex in the particle shape
  35973. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35974. * @example : just set a vertex particle position or color
  35975. * @returns the sps
  35976. */
  35977. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35978. /**
  35979. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35980. * This does nothing and may be overwritten by the user.
  35981. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35982. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35983. * @param update the boolean update value actually passed to setParticles()
  35984. */
  35985. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35986. /**
  35987. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35988. * This will be passed three parameters.
  35989. * This does nothing and may be overwritten by the user.
  35990. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35991. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35992. * @param update the boolean update value actually passed to setParticles()
  35993. */
  35994. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35995. }
  35996. }
  35997. declare module "babylonjs/Particles/solidParticle" {
  35998. import { Nullable } from "babylonjs/types";
  35999. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36000. import { Color4 } from "babylonjs/Maths/math.color";
  36001. import { Mesh } from "babylonjs/Meshes/mesh";
  36002. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36003. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36004. import { Plane } from "babylonjs/Maths/math.plane";
  36005. import { Material } from "babylonjs/Materials/material";
  36006. /**
  36007. * Represents one particle of a solid particle system.
  36008. */
  36009. export class SolidParticle {
  36010. /**
  36011. * particle global index
  36012. */
  36013. idx: number;
  36014. /**
  36015. * particle identifier
  36016. */
  36017. id: number;
  36018. /**
  36019. * The color of the particle
  36020. */
  36021. color: Nullable<Color4>;
  36022. /**
  36023. * The world space position of the particle.
  36024. */
  36025. position: Vector3;
  36026. /**
  36027. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36028. */
  36029. rotation: Vector3;
  36030. /**
  36031. * The world space rotation quaternion of the particle.
  36032. */
  36033. rotationQuaternion: Nullable<Quaternion>;
  36034. /**
  36035. * The scaling of the particle.
  36036. */
  36037. scaling: Vector3;
  36038. /**
  36039. * The uvs of the particle.
  36040. */
  36041. uvs: Vector4;
  36042. /**
  36043. * The current speed of the particle.
  36044. */
  36045. velocity: Vector3;
  36046. /**
  36047. * The pivot point in the particle local space.
  36048. */
  36049. pivot: Vector3;
  36050. /**
  36051. * Must the particle be translated from its pivot point in its local space ?
  36052. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36053. * Default : false
  36054. */
  36055. translateFromPivot: boolean;
  36056. /**
  36057. * Is the particle active or not ?
  36058. */
  36059. alive: boolean;
  36060. /**
  36061. * Is the particle visible or not ?
  36062. */
  36063. isVisible: boolean;
  36064. /**
  36065. * Index of this particle in the global "positions" array (Internal use)
  36066. * @hidden
  36067. */
  36068. _pos: number;
  36069. /**
  36070. * @hidden Index of this particle in the global "indices" array (Internal use)
  36071. */
  36072. _ind: number;
  36073. /**
  36074. * @hidden ModelShape of this particle (Internal use)
  36075. */
  36076. _model: ModelShape;
  36077. /**
  36078. * ModelShape id of this particle
  36079. */
  36080. shapeId: number;
  36081. /**
  36082. * Index of the particle in its shape id
  36083. */
  36084. idxInShape: number;
  36085. /**
  36086. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36087. */
  36088. _modelBoundingInfo: BoundingInfo;
  36089. /**
  36090. * @hidden Particle BoundingInfo object (Internal use)
  36091. */
  36092. _boundingInfo: BoundingInfo;
  36093. /**
  36094. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36095. */
  36096. _sps: SolidParticleSystem;
  36097. /**
  36098. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36099. */
  36100. _stillInvisible: boolean;
  36101. /**
  36102. * @hidden Last computed particle rotation matrix
  36103. */
  36104. _rotationMatrix: number[];
  36105. /**
  36106. * Parent particle Id, if any.
  36107. * Default null.
  36108. */
  36109. parentId: Nullable<number>;
  36110. /**
  36111. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36112. */
  36113. materialIndex: Nullable<number>;
  36114. /**
  36115. * Custom object or properties.
  36116. */
  36117. props: Nullable<any>;
  36118. /**
  36119. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36120. * The possible values are :
  36121. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36122. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36123. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36124. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36125. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36126. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36127. * */
  36128. cullingStrategy: number;
  36129. /**
  36130. * @hidden Internal global position in the SPS.
  36131. */
  36132. _globalPosition: Vector3;
  36133. /**
  36134. * Creates a Solid Particle object.
  36135. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36136. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36137. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36138. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36139. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36140. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36141. * @param shapeId (integer) is the model shape identifier in the SPS.
  36142. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36143. * @param sps defines the sps it is associated to
  36144. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36145. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36146. */
  36147. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36148. /**
  36149. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36150. * @param target the particle target
  36151. * @returns the current particle
  36152. */
  36153. copyToRef(target: SolidParticle): SolidParticle;
  36154. /**
  36155. * Legacy support, changed scale to scaling
  36156. */
  36157. get scale(): Vector3;
  36158. /**
  36159. * Legacy support, changed scale to scaling
  36160. */
  36161. set scale(scale: Vector3);
  36162. /**
  36163. * Legacy support, changed quaternion to rotationQuaternion
  36164. */
  36165. get quaternion(): Nullable<Quaternion>;
  36166. /**
  36167. * Legacy support, changed quaternion to rotationQuaternion
  36168. */
  36169. set quaternion(q: Nullable<Quaternion>);
  36170. /**
  36171. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36172. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36173. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36174. * @returns true if it intersects
  36175. */
  36176. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36177. /**
  36178. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36179. * A particle is in the frustum if its bounding box intersects the frustum
  36180. * @param frustumPlanes defines the frustum to test
  36181. * @returns true if the particle is in the frustum planes
  36182. */
  36183. isInFrustum(frustumPlanes: Plane[]): boolean;
  36184. /**
  36185. * get the rotation matrix of the particle
  36186. * @hidden
  36187. */
  36188. getRotationMatrix(m: Matrix): void;
  36189. }
  36190. /**
  36191. * Represents the shape of the model used by one particle of a solid particle system.
  36192. * SPS internal tool, don't use it manually.
  36193. */
  36194. export class ModelShape {
  36195. /**
  36196. * The shape id
  36197. * @hidden
  36198. */
  36199. shapeID: number;
  36200. /**
  36201. * flat array of model positions (internal use)
  36202. * @hidden
  36203. */
  36204. _shape: Vector3[];
  36205. /**
  36206. * flat array of model UVs (internal use)
  36207. * @hidden
  36208. */
  36209. _shapeUV: number[];
  36210. /**
  36211. * color array of the model
  36212. * @hidden
  36213. */
  36214. _shapeColors: number[];
  36215. /**
  36216. * indices array of the model
  36217. * @hidden
  36218. */
  36219. _indices: number[];
  36220. /**
  36221. * normals array of the model
  36222. * @hidden
  36223. */
  36224. _normals: number[];
  36225. /**
  36226. * length of the shape in the model indices array (internal use)
  36227. * @hidden
  36228. */
  36229. _indicesLength: number;
  36230. /**
  36231. * Custom position function (internal use)
  36232. * @hidden
  36233. */
  36234. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36235. /**
  36236. * Custom vertex function (internal use)
  36237. * @hidden
  36238. */
  36239. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36240. /**
  36241. * Model material (internal use)
  36242. * @hidden
  36243. */
  36244. _material: Nullable<Material>;
  36245. /**
  36246. * 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.
  36247. * SPS internal tool, don't use it manually.
  36248. * @hidden
  36249. */
  36250. 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>);
  36251. }
  36252. /**
  36253. * Represents a Depth Sorted Particle in the solid particle system.
  36254. * @hidden
  36255. */
  36256. export class DepthSortedParticle {
  36257. /**
  36258. * Particle index
  36259. */
  36260. idx: number;
  36261. /**
  36262. * Index of the particle in the "indices" array
  36263. */
  36264. ind: number;
  36265. /**
  36266. * Length of the particle shape in the "indices" array
  36267. */
  36268. indicesLength: number;
  36269. /**
  36270. * Squared distance from the particle to the camera
  36271. */
  36272. sqDistance: number;
  36273. /**
  36274. * Material index when used with MultiMaterials
  36275. */
  36276. materialIndex: number;
  36277. /**
  36278. * Creates a new sorted particle
  36279. * @param materialIndex
  36280. */
  36281. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36282. }
  36283. /**
  36284. * Represents a solid particle vertex
  36285. */
  36286. export class SolidParticleVertex {
  36287. /**
  36288. * Vertex position
  36289. */
  36290. position: Vector3;
  36291. /**
  36292. * Vertex color
  36293. */
  36294. color: Color4;
  36295. /**
  36296. * Vertex UV
  36297. */
  36298. uv: Vector2;
  36299. /**
  36300. * Creates a new solid particle vertex
  36301. */
  36302. constructor();
  36303. /** Vertex x coordinate */
  36304. get x(): number;
  36305. set x(val: number);
  36306. /** Vertex y coordinate */
  36307. get y(): number;
  36308. set y(val: number);
  36309. /** Vertex z coordinate */
  36310. get z(): number;
  36311. set z(val: number);
  36312. }
  36313. }
  36314. declare module "babylonjs/Collisions/meshCollisionData" {
  36315. import { Collider } from "babylonjs/Collisions/collider";
  36316. import { Vector3 } from "babylonjs/Maths/math.vector";
  36317. import { Nullable } from "babylonjs/types";
  36318. import { Observer } from "babylonjs/Misc/observable";
  36319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36320. /**
  36321. * @hidden
  36322. */
  36323. export class _MeshCollisionData {
  36324. _checkCollisions: boolean;
  36325. _collisionMask: number;
  36326. _collisionGroup: number;
  36327. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36328. _collider: Nullable<Collider>;
  36329. _oldPositionForCollisions: Vector3;
  36330. _diffPositionForCollisions: Vector3;
  36331. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36332. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36333. _collisionResponse: boolean;
  36334. }
  36335. }
  36336. declare module "babylonjs/Meshes/abstractMesh" {
  36337. import { Observable } from "babylonjs/Misc/observable";
  36338. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36339. import { Camera } from "babylonjs/Cameras/camera";
  36340. import { Scene, IDisposable } from "babylonjs/scene";
  36341. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36342. import { Node } from "babylonjs/node";
  36343. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36344. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36345. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36346. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36347. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36348. import { Material } from "babylonjs/Materials/material";
  36349. import { Light } from "babylonjs/Lights/light";
  36350. import { Skeleton } from "babylonjs/Bones/skeleton";
  36351. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36352. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36353. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36354. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36355. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36356. import { Plane } from "babylonjs/Maths/math.plane";
  36357. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36358. import { Ray } from "babylonjs/Culling/ray";
  36359. import { Collider } from "babylonjs/Collisions/collider";
  36360. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36361. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36362. /** @hidden */
  36363. class _FacetDataStorage {
  36364. facetPositions: Vector3[];
  36365. facetNormals: Vector3[];
  36366. facetPartitioning: number[][];
  36367. facetNb: number;
  36368. partitioningSubdivisions: number;
  36369. partitioningBBoxRatio: number;
  36370. facetDataEnabled: boolean;
  36371. facetParameters: any;
  36372. bbSize: Vector3;
  36373. subDiv: {
  36374. max: number;
  36375. X: number;
  36376. Y: number;
  36377. Z: number;
  36378. };
  36379. facetDepthSort: boolean;
  36380. facetDepthSortEnabled: boolean;
  36381. depthSortedIndices: IndicesArray;
  36382. depthSortedFacets: {
  36383. ind: number;
  36384. sqDistance: number;
  36385. }[];
  36386. facetDepthSortFunction: (f1: {
  36387. ind: number;
  36388. sqDistance: number;
  36389. }, f2: {
  36390. ind: number;
  36391. sqDistance: number;
  36392. }) => number;
  36393. facetDepthSortFrom: Vector3;
  36394. facetDepthSortOrigin: Vector3;
  36395. invertedMatrix: Matrix;
  36396. }
  36397. /**
  36398. * @hidden
  36399. **/
  36400. class _InternalAbstractMeshDataInfo {
  36401. _hasVertexAlpha: boolean;
  36402. _useVertexColors: boolean;
  36403. _numBoneInfluencers: number;
  36404. _applyFog: boolean;
  36405. _receiveShadows: boolean;
  36406. _facetData: _FacetDataStorage;
  36407. _visibility: number;
  36408. _skeleton: Nullable<Skeleton>;
  36409. _layerMask: number;
  36410. _computeBonesUsingShaders: boolean;
  36411. _isActive: boolean;
  36412. _onlyForInstances: boolean;
  36413. _isActiveIntermediate: boolean;
  36414. _onlyForInstancesIntermediate: boolean;
  36415. _actAsRegularMesh: boolean;
  36416. }
  36417. /**
  36418. * Class used to store all common mesh properties
  36419. */
  36420. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36421. /** No occlusion */
  36422. static OCCLUSION_TYPE_NONE: number;
  36423. /** Occlusion set to optimisitic */
  36424. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36425. /** Occlusion set to strict */
  36426. static OCCLUSION_TYPE_STRICT: number;
  36427. /** Use an accurante occlusion algorithm */
  36428. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36429. /** Use a conservative occlusion algorithm */
  36430. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36431. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36432. * Test order :
  36433. * Is the bounding sphere outside the frustum ?
  36434. * If not, are the bounding box vertices outside the frustum ?
  36435. * It not, then the cullable object is in the frustum.
  36436. */
  36437. static readonly CULLINGSTRATEGY_STANDARD: number;
  36438. /** Culling strategy : Bounding Sphere Only.
  36439. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36440. * It's also less accurate than the standard because some not visible objects can still be selected.
  36441. * Test : is the bounding sphere outside the frustum ?
  36442. * If not, then the cullable object is in the frustum.
  36443. */
  36444. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36445. /** Culling strategy : Optimistic Inclusion.
  36446. * This in an inclusion test first, then the standard exclusion test.
  36447. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36448. * 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.
  36449. * Anyway, it's as accurate as the standard strategy.
  36450. * Test :
  36451. * Is the cullable object bounding sphere center in the frustum ?
  36452. * If not, apply the default culling strategy.
  36453. */
  36454. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36455. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36456. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36457. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36458. * 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.
  36459. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36460. * Test :
  36461. * Is the cullable object bounding sphere center in the frustum ?
  36462. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36463. */
  36464. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36465. /**
  36466. * No billboard
  36467. */
  36468. static get BILLBOARDMODE_NONE(): number;
  36469. /** Billboard on X axis */
  36470. static get BILLBOARDMODE_X(): number;
  36471. /** Billboard on Y axis */
  36472. static get BILLBOARDMODE_Y(): number;
  36473. /** Billboard on Z axis */
  36474. static get BILLBOARDMODE_Z(): number;
  36475. /** Billboard on all axes */
  36476. static get BILLBOARDMODE_ALL(): number;
  36477. /** Billboard on using position instead of orientation */
  36478. static get BILLBOARDMODE_USE_POSITION(): number;
  36479. /** @hidden */
  36480. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36481. /**
  36482. * The culling strategy to use to check whether the mesh must be rendered or not.
  36483. * This value can be changed at any time and will be used on the next render mesh selection.
  36484. * The possible values are :
  36485. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36486. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36487. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36488. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36489. * Please read each static variable documentation to get details about the culling process.
  36490. * */
  36491. cullingStrategy: number;
  36492. /**
  36493. * Gets the number of facets in the mesh
  36494. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36495. */
  36496. get facetNb(): number;
  36497. /**
  36498. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36499. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36500. */
  36501. get partitioningSubdivisions(): number;
  36502. set partitioningSubdivisions(nb: number);
  36503. /**
  36504. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36505. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36506. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36507. */
  36508. get partitioningBBoxRatio(): number;
  36509. set partitioningBBoxRatio(ratio: number);
  36510. /**
  36511. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36512. * Works only for updatable meshes.
  36513. * Doesn't work with multi-materials
  36514. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36515. */
  36516. get mustDepthSortFacets(): boolean;
  36517. set mustDepthSortFacets(sort: boolean);
  36518. /**
  36519. * The location (Vector3) where the facet depth sort must be computed from.
  36520. * By default, the active camera position.
  36521. * Used only when facet depth sort is enabled
  36522. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36523. */
  36524. get facetDepthSortFrom(): Vector3;
  36525. set facetDepthSortFrom(location: Vector3);
  36526. /**
  36527. * gets a boolean indicating if facetData is enabled
  36528. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36529. */
  36530. get isFacetDataEnabled(): boolean;
  36531. /** @hidden */
  36532. _updateNonUniformScalingState(value: boolean): boolean;
  36533. /**
  36534. * An event triggered when this mesh collides with another one
  36535. */
  36536. onCollideObservable: Observable<AbstractMesh>;
  36537. /** Set a function to call when this mesh collides with another one */
  36538. set onCollide(callback: () => void);
  36539. /**
  36540. * An event triggered when the collision's position changes
  36541. */
  36542. onCollisionPositionChangeObservable: Observable<Vector3>;
  36543. /** Set a function to call when the collision's position changes */
  36544. set onCollisionPositionChange(callback: () => void);
  36545. /**
  36546. * An event triggered when material is changed
  36547. */
  36548. onMaterialChangedObservable: Observable<AbstractMesh>;
  36549. /**
  36550. * Gets or sets the orientation for POV movement & rotation
  36551. */
  36552. definedFacingForward: boolean;
  36553. /** @hidden */
  36554. _occlusionQuery: Nullable<WebGLQuery>;
  36555. /** @hidden */
  36556. _renderingGroup: Nullable<RenderingGroup>;
  36557. /**
  36558. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36559. */
  36560. get visibility(): number;
  36561. /**
  36562. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36563. */
  36564. set visibility(value: number);
  36565. /** Gets or sets the alpha index used to sort transparent meshes
  36566. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36567. */
  36568. alphaIndex: number;
  36569. /**
  36570. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36571. */
  36572. isVisible: boolean;
  36573. /**
  36574. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36575. */
  36576. isPickable: boolean;
  36577. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36578. showSubMeshesBoundingBox: boolean;
  36579. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36580. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36581. */
  36582. isBlocker: boolean;
  36583. /**
  36584. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36585. */
  36586. enablePointerMoveEvents: boolean;
  36587. private _renderingGroupId;
  36588. /**
  36589. * Specifies the rendering group id for this mesh (0 by default)
  36590. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36591. */
  36592. get renderingGroupId(): number;
  36593. set renderingGroupId(value: number);
  36594. private _material;
  36595. /** Gets or sets current material */
  36596. get material(): Nullable<Material>;
  36597. set material(value: Nullable<Material>);
  36598. /**
  36599. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36600. * @see https://doc.babylonjs.com/babylon101/shadows
  36601. */
  36602. get receiveShadows(): boolean;
  36603. set receiveShadows(value: boolean);
  36604. /** Defines color to use when rendering outline */
  36605. outlineColor: Color3;
  36606. /** Define width to use when rendering outline */
  36607. outlineWidth: number;
  36608. /** Defines color to use when rendering overlay */
  36609. overlayColor: Color3;
  36610. /** Defines alpha to use when rendering overlay */
  36611. overlayAlpha: number;
  36612. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36613. get hasVertexAlpha(): boolean;
  36614. set hasVertexAlpha(value: boolean);
  36615. /** 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) */
  36616. get useVertexColors(): boolean;
  36617. set useVertexColors(value: boolean);
  36618. /**
  36619. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36620. */
  36621. get computeBonesUsingShaders(): boolean;
  36622. set computeBonesUsingShaders(value: boolean);
  36623. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36624. get numBoneInfluencers(): number;
  36625. set numBoneInfluencers(value: number);
  36626. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36627. get applyFog(): boolean;
  36628. set applyFog(value: boolean);
  36629. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36630. useOctreeForRenderingSelection: boolean;
  36631. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36632. useOctreeForPicking: boolean;
  36633. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36634. useOctreeForCollisions: boolean;
  36635. /**
  36636. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36637. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36638. */
  36639. get layerMask(): number;
  36640. set layerMask(value: number);
  36641. /**
  36642. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36643. */
  36644. alwaysSelectAsActiveMesh: boolean;
  36645. /**
  36646. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36647. */
  36648. doNotSyncBoundingInfo: boolean;
  36649. /**
  36650. * Gets or sets the current action manager
  36651. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36652. */
  36653. actionManager: Nullable<AbstractActionManager>;
  36654. private _meshCollisionData;
  36655. /**
  36656. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36657. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36658. */
  36659. ellipsoid: Vector3;
  36660. /**
  36661. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36662. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36663. */
  36664. ellipsoidOffset: Vector3;
  36665. /**
  36666. * Gets or sets a collision mask used to mask collisions (default is -1).
  36667. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36668. */
  36669. get collisionMask(): number;
  36670. set collisionMask(mask: number);
  36671. /**
  36672. * Gets or sets a collision response flag (default is true).
  36673. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36674. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36675. * to respond to the collision.
  36676. */
  36677. get collisionResponse(): boolean;
  36678. set collisionResponse(response: boolean);
  36679. /**
  36680. * Gets or sets the current collision group mask (-1 by default).
  36681. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36682. */
  36683. get collisionGroup(): number;
  36684. set collisionGroup(mask: number);
  36685. /**
  36686. * Gets or sets current surrounding meshes (null by default).
  36687. *
  36688. * By default collision detection is tested against every mesh in the scene.
  36689. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36690. * meshes will be tested for the collision.
  36691. *
  36692. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36693. */
  36694. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36695. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36696. /**
  36697. * Defines edge width used when edgesRenderer is enabled
  36698. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36699. */
  36700. edgesWidth: number;
  36701. /**
  36702. * Defines edge color used when edgesRenderer is enabled
  36703. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36704. */
  36705. edgesColor: Color4;
  36706. /** @hidden */
  36707. _edgesRenderer: Nullable<IEdgesRenderer>;
  36708. /** @hidden */
  36709. _masterMesh: Nullable<AbstractMesh>;
  36710. /** @hidden */
  36711. _boundingInfo: Nullable<BoundingInfo>;
  36712. /** @hidden */
  36713. _renderId: number;
  36714. /**
  36715. * Gets or sets the list of subMeshes
  36716. * @see https://doc.babylonjs.com/how_to/multi_materials
  36717. */
  36718. subMeshes: SubMesh[];
  36719. /** @hidden */
  36720. _intersectionsInProgress: AbstractMesh[];
  36721. /** @hidden */
  36722. _unIndexed: boolean;
  36723. /** @hidden */
  36724. _lightSources: Light[];
  36725. /** Gets the list of lights affecting that mesh */
  36726. get lightSources(): Light[];
  36727. /** @hidden */
  36728. get _positions(): Nullable<Vector3[]>;
  36729. /** @hidden */
  36730. _waitingData: {
  36731. lods: Nullable<any>;
  36732. actions: Nullable<any>;
  36733. freezeWorldMatrix: Nullable<boolean>;
  36734. };
  36735. /** @hidden */
  36736. _bonesTransformMatrices: Nullable<Float32Array>;
  36737. /** @hidden */
  36738. _transformMatrixTexture: Nullable<RawTexture>;
  36739. /**
  36740. * Gets or sets a skeleton to apply skining transformations
  36741. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36742. */
  36743. set skeleton(value: Nullable<Skeleton>);
  36744. get skeleton(): Nullable<Skeleton>;
  36745. /**
  36746. * An event triggered when the mesh is rebuilt.
  36747. */
  36748. onRebuildObservable: Observable<AbstractMesh>;
  36749. /**
  36750. * Creates a new AbstractMesh
  36751. * @param name defines the name of the mesh
  36752. * @param scene defines the hosting scene
  36753. */
  36754. constructor(name: string, scene?: Nullable<Scene>);
  36755. /**
  36756. * Returns the string "AbstractMesh"
  36757. * @returns "AbstractMesh"
  36758. */
  36759. getClassName(): string;
  36760. /**
  36761. * Gets a string representation of the current mesh
  36762. * @param fullDetails defines a boolean indicating if full details must be included
  36763. * @returns a string representation of the current mesh
  36764. */
  36765. toString(fullDetails?: boolean): string;
  36766. /**
  36767. * @hidden
  36768. */
  36769. protected _getEffectiveParent(): Nullable<Node>;
  36770. /** @hidden */
  36771. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36772. /** @hidden */
  36773. _rebuild(): void;
  36774. /** @hidden */
  36775. _resyncLightSources(): void;
  36776. /** @hidden */
  36777. _resyncLightSource(light: Light): void;
  36778. /** @hidden */
  36779. _unBindEffect(): void;
  36780. /** @hidden */
  36781. _removeLightSource(light: Light, dispose: boolean): void;
  36782. private _markSubMeshesAsDirty;
  36783. /** @hidden */
  36784. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36785. /** @hidden */
  36786. _markSubMeshesAsAttributesDirty(): void;
  36787. /** @hidden */
  36788. _markSubMeshesAsMiscDirty(): void;
  36789. /**
  36790. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36791. */
  36792. get scaling(): Vector3;
  36793. set scaling(newScaling: Vector3);
  36794. /**
  36795. * Returns true if the mesh is blocked. Implemented by child classes
  36796. */
  36797. get isBlocked(): boolean;
  36798. /**
  36799. * Returns the mesh itself by default. Implemented by child classes
  36800. * @param camera defines the camera to use to pick the right LOD level
  36801. * @returns the currentAbstractMesh
  36802. */
  36803. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36804. /**
  36805. * Returns 0 by default. Implemented by child classes
  36806. * @returns an integer
  36807. */
  36808. getTotalVertices(): number;
  36809. /**
  36810. * Returns a positive integer : the total number of indices in this mesh geometry.
  36811. * @returns the numner of indices or zero if the mesh has no geometry.
  36812. */
  36813. getTotalIndices(): number;
  36814. /**
  36815. * Returns null by default. Implemented by child classes
  36816. * @returns null
  36817. */
  36818. getIndices(): Nullable<IndicesArray>;
  36819. /**
  36820. * Returns the array of the requested vertex data kind. Implemented by child classes
  36821. * @param kind defines the vertex data kind to use
  36822. * @returns null
  36823. */
  36824. getVerticesData(kind: string): Nullable<FloatArray>;
  36825. /**
  36826. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36827. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36828. * Note that a new underlying VertexBuffer object is created each call.
  36829. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36830. * @param kind defines vertex data kind:
  36831. * * VertexBuffer.PositionKind
  36832. * * VertexBuffer.UVKind
  36833. * * VertexBuffer.UV2Kind
  36834. * * VertexBuffer.UV3Kind
  36835. * * VertexBuffer.UV4Kind
  36836. * * VertexBuffer.UV5Kind
  36837. * * VertexBuffer.UV6Kind
  36838. * * VertexBuffer.ColorKind
  36839. * * VertexBuffer.MatricesIndicesKind
  36840. * * VertexBuffer.MatricesIndicesExtraKind
  36841. * * VertexBuffer.MatricesWeightsKind
  36842. * * VertexBuffer.MatricesWeightsExtraKind
  36843. * @param data defines the data source
  36844. * @param updatable defines if the data must be flagged as updatable (or static)
  36845. * @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
  36846. * @returns the current mesh
  36847. */
  36848. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36849. /**
  36850. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36851. * If the mesh has no geometry, it is simply returned as it is.
  36852. * @param kind defines vertex data kind:
  36853. * * VertexBuffer.PositionKind
  36854. * * VertexBuffer.UVKind
  36855. * * VertexBuffer.UV2Kind
  36856. * * VertexBuffer.UV3Kind
  36857. * * VertexBuffer.UV4Kind
  36858. * * VertexBuffer.UV5Kind
  36859. * * VertexBuffer.UV6Kind
  36860. * * VertexBuffer.ColorKind
  36861. * * VertexBuffer.MatricesIndicesKind
  36862. * * VertexBuffer.MatricesIndicesExtraKind
  36863. * * VertexBuffer.MatricesWeightsKind
  36864. * * VertexBuffer.MatricesWeightsExtraKind
  36865. * @param data defines the data source
  36866. * @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
  36867. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36868. * @returns the current mesh
  36869. */
  36870. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36871. /**
  36872. * Sets the mesh indices,
  36873. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36874. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36875. * @param totalVertices Defines the total number of vertices
  36876. * @returns the current mesh
  36877. */
  36878. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36879. /**
  36880. * Gets a boolean indicating if specific vertex data is present
  36881. * @param kind defines the vertex data kind to use
  36882. * @returns true is data kind is present
  36883. */
  36884. isVerticesDataPresent(kind: string): boolean;
  36885. /**
  36886. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36887. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36888. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36889. * @returns a BoundingInfo
  36890. */
  36891. getBoundingInfo(): BoundingInfo;
  36892. /**
  36893. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36894. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36895. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36896. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36897. * @returns the current mesh
  36898. */
  36899. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36900. /**
  36901. * Overwrite the current bounding info
  36902. * @param boundingInfo defines the new bounding info
  36903. * @returns the current mesh
  36904. */
  36905. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36906. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36907. get useBones(): boolean;
  36908. /** @hidden */
  36909. _preActivate(): void;
  36910. /** @hidden */
  36911. _preActivateForIntermediateRendering(renderId: number): void;
  36912. /** @hidden */
  36913. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36914. /** @hidden */
  36915. _postActivate(): void;
  36916. /** @hidden */
  36917. _freeze(): void;
  36918. /** @hidden */
  36919. _unFreeze(): void;
  36920. /**
  36921. * Gets the current world matrix
  36922. * @returns a Matrix
  36923. */
  36924. getWorldMatrix(): Matrix;
  36925. /** @hidden */
  36926. _getWorldMatrixDeterminant(): number;
  36927. /**
  36928. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36929. */
  36930. get isAnInstance(): boolean;
  36931. /**
  36932. * Gets a boolean indicating if this mesh has instances
  36933. */
  36934. get hasInstances(): boolean;
  36935. /**
  36936. * Gets a boolean indicating if this mesh has thin instances
  36937. */
  36938. get hasThinInstances(): boolean;
  36939. /**
  36940. * Perform relative position change from the point of view of behind the front of the mesh.
  36941. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36942. * Supports definition of mesh facing forward or backward
  36943. * @param amountRight defines the distance on the right axis
  36944. * @param amountUp defines the distance on the up axis
  36945. * @param amountForward defines the distance on the forward axis
  36946. * @returns the current mesh
  36947. */
  36948. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36949. /**
  36950. * Calculate relative position change from the point of view of behind the front of the mesh.
  36951. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36952. * Supports definition of mesh facing forward or backward
  36953. * @param amountRight defines the distance on the right axis
  36954. * @param amountUp defines the distance on the up axis
  36955. * @param amountForward defines the distance on the forward axis
  36956. * @returns the new displacement vector
  36957. */
  36958. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36959. /**
  36960. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36961. * Supports definition of mesh facing forward or backward
  36962. * @param flipBack defines the flip
  36963. * @param twirlClockwise defines the twirl
  36964. * @param tiltRight defines the tilt
  36965. * @returns the current mesh
  36966. */
  36967. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36968. /**
  36969. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36970. * Supports definition of mesh facing forward or backward.
  36971. * @param flipBack defines the flip
  36972. * @param twirlClockwise defines the twirl
  36973. * @param tiltRight defines the tilt
  36974. * @returns the new rotation vector
  36975. */
  36976. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36977. /**
  36978. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36979. * This means the mesh underlying bounding box and sphere are recomputed.
  36980. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36981. * @returns the current mesh
  36982. */
  36983. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36984. /** @hidden */
  36985. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36986. /** @hidden */
  36987. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36988. /** @hidden */
  36989. _updateBoundingInfo(): AbstractMesh;
  36990. /** @hidden */
  36991. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36992. /** @hidden */
  36993. protected _afterComputeWorldMatrix(): void;
  36994. /** @hidden */
  36995. get _effectiveMesh(): AbstractMesh;
  36996. /**
  36997. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36998. * A mesh is in the frustum if its bounding box intersects the frustum
  36999. * @param frustumPlanes defines the frustum to test
  37000. * @returns true if the mesh is in the frustum planes
  37001. */
  37002. isInFrustum(frustumPlanes: Plane[]): boolean;
  37003. /**
  37004. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37005. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37006. * @param frustumPlanes defines the frustum to test
  37007. * @returns true if the mesh is completely in the frustum planes
  37008. */
  37009. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37010. /**
  37011. * True if the mesh intersects another mesh or a SolidParticle object
  37012. * @param mesh defines a target mesh or SolidParticle to test
  37013. * @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)
  37014. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37015. * @returns true if there is an intersection
  37016. */
  37017. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37018. /**
  37019. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37020. * @param point defines the point to test
  37021. * @returns true if there is an intersection
  37022. */
  37023. intersectsPoint(point: Vector3): boolean;
  37024. /**
  37025. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37026. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37027. */
  37028. get checkCollisions(): boolean;
  37029. set checkCollisions(collisionEnabled: boolean);
  37030. /**
  37031. * Gets Collider object used to compute collisions (not physics)
  37032. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37033. */
  37034. get collider(): Nullable<Collider>;
  37035. /**
  37036. * Move the mesh using collision engine
  37037. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37038. * @param displacement defines the requested displacement vector
  37039. * @returns the current mesh
  37040. */
  37041. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37042. private _onCollisionPositionChange;
  37043. /** @hidden */
  37044. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37045. /** @hidden */
  37046. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37047. /** @hidden */
  37048. _checkCollision(collider: Collider): AbstractMesh;
  37049. /** @hidden */
  37050. _generatePointsArray(): boolean;
  37051. /**
  37052. * Checks if the passed Ray intersects with the mesh
  37053. * @param ray defines the ray to use
  37054. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37055. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37056. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37057. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37058. * @returns the picking info
  37059. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37060. */
  37061. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  37062. /**
  37063. * Clones the current mesh
  37064. * @param name defines the mesh name
  37065. * @param newParent defines the new mesh parent
  37066. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37067. * @returns the new mesh
  37068. */
  37069. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37070. /**
  37071. * Disposes all the submeshes of the current meshnp
  37072. * @returns the current mesh
  37073. */
  37074. releaseSubMeshes(): AbstractMesh;
  37075. /**
  37076. * Releases resources associated with this abstract mesh.
  37077. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37078. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37079. */
  37080. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37081. /**
  37082. * Adds the passed mesh as a child to the current mesh
  37083. * @param mesh defines the child mesh
  37084. * @returns the current mesh
  37085. */
  37086. addChild(mesh: AbstractMesh): AbstractMesh;
  37087. /**
  37088. * Removes the passed mesh from the current mesh children list
  37089. * @param mesh defines the child mesh
  37090. * @returns the current mesh
  37091. */
  37092. removeChild(mesh: AbstractMesh): AbstractMesh;
  37093. /** @hidden */
  37094. private _initFacetData;
  37095. /**
  37096. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37097. * This method can be called within the render loop.
  37098. * 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
  37099. * @returns the current mesh
  37100. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37101. */
  37102. updateFacetData(): AbstractMesh;
  37103. /**
  37104. * Returns the facetLocalNormals array.
  37105. * The normals are expressed in the mesh local spac
  37106. * @returns an array of Vector3
  37107. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37108. */
  37109. getFacetLocalNormals(): Vector3[];
  37110. /**
  37111. * Returns the facetLocalPositions array.
  37112. * The facet positions are expressed in the mesh local space
  37113. * @returns an array of Vector3
  37114. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37115. */
  37116. getFacetLocalPositions(): Vector3[];
  37117. /**
  37118. * Returns the facetLocalPartioning array
  37119. * @returns an array of array of numbers
  37120. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37121. */
  37122. getFacetLocalPartitioning(): number[][];
  37123. /**
  37124. * Returns the i-th facet position in the world system.
  37125. * This method allocates a new Vector3 per call
  37126. * @param i defines the facet index
  37127. * @returns a new Vector3
  37128. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37129. */
  37130. getFacetPosition(i: number): Vector3;
  37131. /**
  37132. * Sets the reference Vector3 with the i-th facet position in the world system
  37133. * @param i defines the facet index
  37134. * @param ref defines the target vector
  37135. * @returns the current mesh
  37136. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37137. */
  37138. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37139. /**
  37140. * Returns the i-th facet normal in the world system.
  37141. * This method allocates a new Vector3 per call
  37142. * @param i defines the facet index
  37143. * @returns a new Vector3
  37144. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37145. */
  37146. getFacetNormal(i: number): Vector3;
  37147. /**
  37148. * Sets the reference Vector3 with the i-th facet normal in the world system
  37149. * @param i defines the facet index
  37150. * @param ref defines the target vector
  37151. * @returns the current mesh
  37152. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37153. */
  37154. getFacetNormalToRef(i: number, ref: Vector3): this;
  37155. /**
  37156. * 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)
  37157. * @param x defines x coordinate
  37158. * @param y defines y coordinate
  37159. * @param z defines z coordinate
  37160. * @returns the array of facet indexes
  37161. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37162. */
  37163. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37164. /**
  37165. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37166. * @param projected sets as the (x,y,z) world projection on the facet
  37167. * @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
  37168. * @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
  37169. * @param x defines x coordinate
  37170. * @param y defines y coordinate
  37171. * @param z defines z coordinate
  37172. * @returns the face index if found (or null instead)
  37173. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37174. */
  37175. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37176. /**
  37177. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37178. * @param projected sets as the (x,y,z) local projection on the facet
  37179. * @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
  37180. * @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
  37181. * @param x defines x coordinate
  37182. * @param y defines y coordinate
  37183. * @param z defines z coordinate
  37184. * @returns the face index if found (or null instead)
  37185. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37186. */
  37187. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37188. /**
  37189. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37190. * @returns the parameters
  37191. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37192. */
  37193. getFacetDataParameters(): any;
  37194. /**
  37195. * Disables the feature FacetData and frees the related memory
  37196. * @returns the current mesh
  37197. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37198. */
  37199. disableFacetData(): AbstractMesh;
  37200. /**
  37201. * Updates the AbstractMesh indices array
  37202. * @param indices defines the data source
  37203. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37204. * @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)
  37205. * @returns the current mesh
  37206. */
  37207. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37208. /**
  37209. * Creates new normals data for the mesh
  37210. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37211. * @returns the current mesh
  37212. */
  37213. createNormals(updatable: boolean): AbstractMesh;
  37214. /**
  37215. * Align the mesh with a normal
  37216. * @param normal defines the normal to use
  37217. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37218. * @returns the current mesh
  37219. */
  37220. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37221. /** @hidden */
  37222. _checkOcclusionQuery(): boolean;
  37223. /**
  37224. * Disables the mesh edge rendering mode
  37225. * @returns the currentAbstractMesh
  37226. */
  37227. disableEdgesRendering(): AbstractMesh;
  37228. /**
  37229. * Enables the edge rendering mode on the mesh.
  37230. * This mode makes the mesh edges visible
  37231. * @param epsilon defines the maximal distance between two angles to detect a face
  37232. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37233. * @returns the currentAbstractMesh
  37234. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37235. */
  37236. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  37237. /**
  37238. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37239. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37240. */
  37241. getConnectedParticleSystems(): IParticleSystem[];
  37242. }
  37243. }
  37244. declare module "babylonjs/Actions/actionEvent" {
  37245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37246. import { Nullable } from "babylonjs/types";
  37247. import { Sprite } from "babylonjs/Sprites/sprite";
  37248. import { Scene } from "babylonjs/scene";
  37249. import { Vector2 } from "babylonjs/Maths/math.vector";
  37250. /**
  37251. * Interface used to define ActionEvent
  37252. */
  37253. export interface IActionEvent {
  37254. /** The mesh or sprite that triggered the action */
  37255. source: any;
  37256. /** The X mouse cursor position at the time of the event */
  37257. pointerX: number;
  37258. /** The Y mouse cursor position at the time of the event */
  37259. pointerY: number;
  37260. /** The mesh that is currently pointed at (can be null) */
  37261. meshUnderPointer: Nullable<AbstractMesh>;
  37262. /** the original (browser) event that triggered the ActionEvent */
  37263. sourceEvent?: any;
  37264. /** additional data for the event */
  37265. additionalData?: any;
  37266. }
  37267. /**
  37268. * ActionEvent is the event being sent when an action is triggered.
  37269. */
  37270. export class ActionEvent implements IActionEvent {
  37271. /** The mesh or sprite that triggered the action */
  37272. source: any;
  37273. /** The X mouse cursor position at the time of the event */
  37274. pointerX: number;
  37275. /** The Y mouse cursor position at the time of the event */
  37276. pointerY: number;
  37277. /** The mesh that is currently pointed at (can be null) */
  37278. meshUnderPointer: Nullable<AbstractMesh>;
  37279. /** the original (browser) event that triggered the ActionEvent */
  37280. sourceEvent?: any;
  37281. /** additional data for the event */
  37282. additionalData?: any;
  37283. /**
  37284. * Creates a new ActionEvent
  37285. * @param source The mesh or sprite that triggered the action
  37286. * @param pointerX The X mouse cursor position at the time of the event
  37287. * @param pointerY The Y mouse cursor position at the time of the event
  37288. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37289. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37290. * @param additionalData additional data for the event
  37291. */
  37292. constructor(
  37293. /** The mesh or sprite that triggered the action */
  37294. source: any,
  37295. /** The X mouse cursor position at the time of the event */
  37296. pointerX: number,
  37297. /** The Y mouse cursor position at the time of the event */
  37298. pointerY: number,
  37299. /** The mesh that is currently pointed at (can be null) */
  37300. meshUnderPointer: Nullable<AbstractMesh>,
  37301. /** the original (browser) event that triggered the ActionEvent */
  37302. sourceEvent?: any,
  37303. /** additional data for the event */
  37304. additionalData?: any);
  37305. /**
  37306. * Helper function to auto-create an ActionEvent from a source mesh.
  37307. * @param source The source mesh that triggered the event
  37308. * @param evt The original (browser) event
  37309. * @param additionalData additional data for the event
  37310. * @returns the new ActionEvent
  37311. */
  37312. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37313. /**
  37314. * Helper function to auto-create an ActionEvent from a source sprite
  37315. * @param source The source sprite that triggered the event
  37316. * @param scene Scene associated with the sprite
  37317. * @param evt The original (browser) event
  37318. * @param additionalData additional data for the event
  37319. * @returns the new ActionEvent
  37320. */
  37321. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37322. /**
  37323. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37324. * @param scene the scene where the event occurred
  37325. * @param evt The original (browser) event
  37326. * @returns the new ActionEvent
  37327. */
  37328. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37329. /**
  37330. * Helper function to auto-create an ActionEvent from a primitive
  37331. * @param prim defines the target primitive
  37332. * @param pointerPos defines the pointer position
  37333. * @param evt The original (browser) event
  37334. * @param additionalData additional data for the event
  37335. * @returns the new ActionEvent
  37336. */
  37337. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37338. }
  37339. }
  37340. declare module "babylonjs/Actions/abstractActionManager" {
  37341. import { IDisposable } from "babylonjs/scene";
  37342. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37343. import { IAction } from "babylonjs/Actions/action";
  37344. import { Nullable } from "babylonjs/types";
  37345. /**
  37346. * Abstract class used to decouple action Manager from scene and meshes.
  37347. * Do not instantiate.
  37348. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37349. */
  37350. export abstract class AbstractActionManager implements IDisposable {
  37351. /** Gets the list of active triggers */
  37352. static Triggers: {
  37353. [key: string]: number;
  37354. };
  37355. /** Gets the cursor to use when hovering items */
  37356. hoverCursor: string;
  37357. /** Gets the list of actions */
  37358. actions: IAction[];
  37359. /**
  37360. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37361. */
  37362. isRecursive: boolean;
  37363. /**
  37364. * Releases all associated resources
  37365. */
  37366. abstract dispose(): void;
  37367. /**
  37368. * Does this action manager has pointer triggers
  37369. */
  37370. abstract get hasPointerTriggers(): boolean;
  37371. /**
  37372. * Does this action manager has pick triggers
  37373. */
  37374. abstract get hasPickTriggers(): boolean;
  37375. /**
  37376. * Process a specific trigger
  37377. * @param trigger defines the trigger to process
  37378. * @param evt defines the event details to be processed
  37379. */
  37380. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37381. /**
  37382. * Does this action manager handles actions of any of the given triggers
  37383. * @param triggers defines the triggers to be tested
  37384. * @return a boolean indicating whether one (or more) of the triggers is handled
  37385. */
  37386. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37387. /**
  37388. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37389. * speed.
  37390. * @param triggerA defines the trigger to be tested
  37391. * @param triggerB defines the trigger to be tested
  37392. * @return a boolean indicating whether one (or more) of the triggers is handled
  37393. */
  37394. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37395. /**
  37396. * Does this action manager handles actions of a given trigger
  37397. * @param trigger defines the trigger to be tested
  37398. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37399. * @return whether the trigger is handled
  37400. */
  37401. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37402. /**
  37403. * Serialize this manager to a JSON object
  37404. * @param name defines the property name to store this manager
  37405. * @returns a JSON representation of this manager
  37406. */
  37407. abstract serialize(name: string): any;
  37408. /**
  37409. * Registers an action to this action manager
  37410. * @param action defines the action to be registered
  37411. * @return the action amended (prepared) after registration
  37412. */
  37413. abstract registerAction(action: IAction): Nullable<IAction>;
  37414. /**
  37415. * Unregisters an action to this action manager
  37416. * @param action defines the action to be unregistered
  37417. * @return a boolean indicating whether the action has been unregistered
  37418. */
  37419. abstract unregisterAction(action: IAction): Boolean;
  37420. /**
  37421. * Does exist one action manager with at least one trigger
  37422. **/
  37423. static get HasTriggers(): boolean;
  37424. /**
  37425. * Does exist one action manager with at least one pick trigger
  37426. **/
  37427. static get HasPickTriggers(): boolean;
  37428. /**
  37429. * Does exist one action manager that handles actions of a given trigger
  37430. * @param trigger defines the trigger to be tested
  37431. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37432. **/
  37433. static HasSpecificTrigger(trigger: number): boolean;
  37434. }
  37435. }
  37436. declare module "babylonjs/node" {
  37437. import { Scene } from "babylonjs/scene";
  37438. import { Nullable } from "babylonjs/types";
  37439. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37440. import { Engine } from "babylonjs/Engines/engine";
  37441. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37442. import { Observable } from "babylonjs/Misc/observable";
  37443. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37444. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37445. import { Animatable } from "babylonjs/Animations/animatable";
  37446. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37447. import { Animation } from "babylonjs/Animations/animation";
  37448. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37450. /**
  37451. * Defines how a node can be built from a string name.
  37452. */
  37453. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37454. /**
  37455. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37456. */
  37457. export class Node implements IBehaviorAware<Node> {
  37458. /** @hidden */
  37459. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37460. private static _NodeConstructors;
  37461. /**
  37462. * Add a new node constructor
  37463. * @param type defines the type name of the node to construct
  37464. * @param constructorFunc defines the constructor function
  37465. */
  37466. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37467. /**
  37468. * Returns a node constructor based on type name
  37469. * @param type defines the type name
  37470. * @param name defines the new node name
  37471. * @param scene defines the hosting scene
  37472. * @param options defines optional options to transmit to constructors
  37473. * @returns the new constructor or null
  37474. */
  37475. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37476. /**
  37477. * Gets or sets the name of the node
  37478. */
  37479. name: string;
  37480. /**
  37481. * Gets or sets the id of the node
  37482. */
  37483. id: string;
  37484. /**
  37485. * Gets or sets the unique id of the node
  37486. */
  37487. uniqueId: number;
  37488. /**
  37489. * Gets or sets a string used to store user defined state for the node
  37490. */
  37491. state: string;
  37492. /**
  37493. * Gets or sets an object used to store user defined information for the node
  37494. */
  37495. metadata: any;
  37496. /**
  37497. * For internal use only. Please do not use.
  37498. */
  37499. reservedDataStore: any;
  37500. /**
  37501. * List of inspectable custom properties (used by the Inspector)
  37502. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37503. */
  37504. inspectableCustomProperties: IInspectable[];
  37505. private _doNotSerialize;
  37506. /**
  37507. * Gets or sets a boolean used to define if the node must be serialized
  37508. */
  37509. get doNotSerialize(): boolean;
  37510. set doNotSerialize(value: boolean);
  37511. /** @hidden */
  37512. _isDisposed: boolean;
  37513. /**
  37514. * Gets a list of Animations associated with the node
  37515. */
  37516. animations: import("babylonjs/Animations/animation").Animation[];
  37517. protected _ranges: {
  37518. [name: string]: Nullable<AnimationRange>;
  37519. };
  37520. /**
  37521. * Callback raised when the node is ready to be used
  37522. */
  37523. onReady: Nullable<(node: Node) => void>;
  37524. private _isEnabled;
  37525. private _isParentEnabled;
  37526. private _isReady;
  37527. /** @hidden */
  37528. _currentRenderId: number;
  37529. private _parentUpdateId;
  37530. /** @hidden */
  37531. _childUpdateId: number;
  37532. /** @hidden */
  37533. _waitingParentId: Nullable<string>;
  37534. /** @hidden */
  37535. _scene: Scene;
  37536. /** @hidden */
  37537. _cache: any;
  37538. private _parentNode;
  37539. private _children;
  37540. /** @hidden */
  37541. _worldMatrix: Matrix;
  37542. /** @hidden */
  37543. _worldMatrixDeterminant: number;
  37544. /** @hidden */
  37545. _worldMatrixDeterminantIsDirty: boolean;
  37546. /** @hidden */
  37547. private _sceneRootNodesIndex;
  37548. /**
  37549. * Gets a boolean indicating if the node has been disposed
  37550. * @returns true if the node was disposed
  37551. */
  37552. isDisposed(): boolean;
  37553. /**
  37554. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37555. * @see https://doc.babylonjs.com/how_to/parenting
  37556. */
  37557. set parent(parent: Nullable<Node>);
  37558. get parent(): Nullable<Node>;
  37559. /** @hidden */
  37560. _addToSceneRootNodes(): void;
  37561. /** @hidden */
  37562. _removeFromSceneRootNodes(): void;
  37563. private _animationPropertiesOverride;
  37564. /**
  37565. * Gets or sets the animation properties override
  37566. */
  37567. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37568. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37569. /**
  37570. * Gets a string identifying the name of the class
  37571. * @returns "Node" string
  37572. */
  37573. getClassName(): string;
  37574. /** @hidden */
  37575. readonly _isNode: boolean;
  37576. /**
  37577. * An event triggered when the mesh is disposed
  37578. */
  37579. onDisposeObservable: Observable<Node>;
  37580. private _onDisposeObserver;
  37581. /**
  37582. * Sets a callback that will be raised when the node will be disposed
  37583. */
  37584. set onDispose(callback: () => void);
  37585. /**
  37586. * Creates a new Node
  37587. * @param name the name and id to be given to this node
  37588. * @param scene the scene this node will be added to
  37589. */
  37590. constructor(name: string, scene?: Nullable<Scene>);
  37591. /**
  37592. * Gets the scene of the node
  37593. * @returns a scene
  37594. */
  37595. getScene(): Scene;
  37596. /**
  37597. * Gets the engine of the node
  37598. * @returns a Engine
  37599. */
  37600. getEngine(): Engine;
  37601. private _behaviors;
  37602. /**
  37603. * Attach a behavior to the node
  37604. * @see https://doc.babylonjs.com/features/behaviour
  37605. * @param behavior defines the behavior to attach
  37606. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37607. * @returns the current Node
  37608. */
  37609. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37610. /**
  37611. * Remove an attached behavior
  37612. * @see https://doc.babylonjs.com/features/behaviour
  37613. * @param behavior defines the behavior to attach
  37614. * @returns the current Node
  37615. */
  37616. removeBehavior(behavior: Behavior<Node>): Node;
  37617. /**
  37618. * Gets the list of attached behaviors
  37619. * @see https://doc.babylonjs.com/features/behaviour
  37620. */
  37621. get behaviors(): Behavior<Node>[];
  37622. /**
  37623. * Gets an attached behavior by name
  37624. * @param name defines the name of the behavior to look for
  37625. * @see https://doc.babylonjs.com/features/behaviour
  37626. * @returns null if behavior was not found else the requested behavior
  37627. */
  37628. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37629. /**
  37630. * Returns the latest update of the World matrix
  37631. * @returns a Matrix
  37632. */
  37633. getWorldMatrix(): Matrix;
  37634. /** @hidden */
  37635. _getWorldMatrixDeterminant(): number;
  37636. /**
  37637. * Returns directly the latest state of the mesh World matrix.
  37638. * A Matrix is returned.
  37639. */
  37640. get worldMatrixFromCache(): Matrix;
  37641. /** @hidden */
  37642. _initCache(): void;
  37643. /** @hidden */
  37644. updateCache(force?: boolean): void;
  37645. /** @hidden */
  37646. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37647. /** @hidden */
  37648. _updateCache(ignoreParentClass?: boolean): void;
  37649. /** @hidden */
  37650. _isSynchronized(): boolean;
  37651. /** @hidden */
  37652. _markSyncedWithParent(): void;
  37653. /** @hidden */
  37654. isSynchronizedWithParent(): boolean;
  37655. /** @hidden */
  37656. isSynchronized(): boolean;
  37657. /**
  37658. * Is this node ready to be used/rendered
  37659. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37660. * @return true if the node is ready
  37661. */
  37662. isReady(completeCheck?: boolean): boolean;
  37663. /**
  37664. * Is this node enabled?
  37665. * 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
  37666. * @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
  37667. * @return whether this node (and its parent) is enabled
  37668. */
  37669. isEnabled(checkAncestors?: boolean): boolean;
  37670. /** @hidden */
  37671. protected _syncParentEnabledState(): void;
  37672. /**
  37673. * Set the enabled state of this node
  37674. * @param value defines the new enabled state
  37675. */
  37676. setEnabled(value: boolean): void;
  37677. /**
  37678. * Is this node a descendant of the given node?
  37679. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37680. * @param ancestor defines the parent node to inspect
  37681. * @returns a boolean indicating if this node is a descendant of the given node
  37682. */
  37683. isDescendantOf(ancestor: Node): boolean;
  37684. /** @hidden */
  37685. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37686. /**
  37687. * Will return all nodes that have this node as ascendant
  37688. * @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
  37689. * @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
  37690. * @return all children nodes of all types
  37691. */
  37692. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37693. /**
  37694. * Get all child-meshes of this node
  37695. * @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)
  37696. * @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
  37697. * @returns an array of AbstractMesh
  37698. */
  37699. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37700. /**
  37701. * Get all direct children of this node
  37702. * @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
  37703. * @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)
  37704. * @returns an array of Node
  37705. */
  37706. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37707. /** @hidden */
  37708. _setReady(state: boolean): void;
  37709. /**
  37710. * Get an animation by name
  37711. * @param name defines the name of the animation to look for
  37712. * @returns null if not found else the requested animation
  37713. */
  37714. getAnimationByName(name: string): Nullable<Animation>;
  37715. /**
  37716. * Creates an animation range for this node
  37717. * @param name defines the name of the range
  37718. * @param from defines the starting key
  37719. * @param to defines the end key
  37720. */
  37721. createAnimationRange(name: string, from: number, to: number): void;
  37722. /**
  37723. * Delete a specific animation range
  37724. * @param name defines the name of the range to delete
  37725. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37726. */
  37727. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37728. /**
  37729. * Get an animation range by name
  37730. * @param name defines the name of the animation range to look for
  37731. * @returns null if not found else the requested animation range
  37732. */
  37733. getAnimationRange(name: string): Nullable<AnimationRange>;
  37734. /**
  37735. * Gets the list of all animation ranges defined on this node
  37736. * @returns an array
  37737. */
  37738. getAnimationRanges(): Nullable<AnimationRange>[];
  37739. /**
  37740. * Will start the animation sequence
  37741. * @param name defines the range frames for animation sequence
  37742. * @param loop defines if the animation should loop (false by default)
  37743. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37744. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37745. * @returns the object created for this animation. If range does not exist, it will return null
  37746. */
  37747. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37748. /**
  37749. * Serialize animation ranges into a JSON compatible object
  37750. * @returns serialization object
  37751. */
  37752. serializeAnimationRanges(): any;
  37753. /**
  37754. * Computes the world matrix of the node
  37755. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37756. * @returns the world matrix
  37757. */
  37758. computeWorldMatrix(force?: boolean): Matrix;
  37759. /**
  37760. * Releases resources associated with this node.
  37761. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37762. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37763. */
  37764. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37765. /**
  37766. * Parse animation range data from a serialization object and store them into a given node
  37767. * @param node defines where to store the animation ranges
  37768. * @param parsedNode defines the serialization object to read data from
  37769. * @param scene defines the hosting scene
  37770. */
  37771. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37772. /**
  37773. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37774. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37775. * @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
  37776. * @returns the new bounding vectors
  37777. */
  37778. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37779. min: Vector3;
  37780. max: Vector3;
  37781. };
  37782. }
  37783. }
  37784. declare module "babylonjs/Animations/animation" {
  37785. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  37786. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  37787. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37788. import { Nullable } from "babylonjs/types";
  37789. import { Scene } from "babylonjs/scene";
  37790. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  37791. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37792. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  37793. import { Node } from "babylonjs/node";
  37794. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  37795. import { Size } from "babylonjs/Maths/math.size";
  37796. import { Animatable } from "babylonjs/Animations/animatable";
  37797. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  37798. /**
  37799. * @hidden
  37800. */
  37801. export class _IAnimationState {
  37802. key: number;
  37803. repeatCount: number;
  37804. workValue?: any;
  37805. loopMode?: number;
  37806. offsetValue?: any;
  37807. highLimitValue?: any;
  37808. }
  37809. /**
  37810. * Class used to store any kind of animation
  37811. */
  37812. export class Animation {
  37813. /**Name of the animation */
  37814. name: string;
  37815. /**Property to animate */
  37816. targetProperty: string;
  37817. /**The frames per second of the animation */
  37818. framePerSecond: number;
  37819. /**The data type of the animation */
  37820. dataType: number;
  37821. /**The loop mode of the animation */
  37822. loopMode?: number | undefined;
  37823. /**Specifies if blending should be enabled */
  37824. enableBlending?: boolean | undefined;
  37825. /**
  37826. * Use matrix interpolation instead of using direct key value when animating matrices
  37827. */
  37828. static AllowMatricesInterpolation: boolean;
  37829. /**
  37830. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37831. */
  37832. static AllowMatrixDecomposeForInterpolation: boolean;
  37833. /** Define the Url to load snippets */
  37834. static SnippetUrl: string;
  37835. /** Snippet ID if the animation was created from the snippet server */
  37836. snippetId: string;
  37837. /**
  37838. * Stores the key frames of the animation
  37839. */
  37840. private _keys;
  37841. /**
  37842. * Stores the easing function of the animation
  37843. */
  37844. private _easingFunction;
  37845. /**
  37846. * @hidden Internal use only
  37847. */
  37848. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  37849. /**
  37850. * The set of event that will be linked to this animation
  37851. */
  37852. private _events;
  37853. /**
  37854. * Stores an array of target property paths
  37855. */
  37856. targetPropertyPath: string[];
  37857. /**
  37858. * Stores the blending speed of the animation
  37859. */
  37860. blendingSpeed: number;
  37861. /**
  37862. * Stores the animation ranges for the animation
  37863. */
  37864. private _ranges;
  37865. /**
  37866. * @hidden Internal use
  37867. */
  37868. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37869. /**
  37870. * Sets up an animation
  37871. * @param property The property to animate
  37872. * @param animationType The animation type to apply
  37873. * @param framePerSecond The frames per second of the animation
  37874. * @param easingFunction The easing function used in the animation
  37875. * @returns The created animation
  37876. */
  37877. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37878. /**
  37879. * Create and start an animation on a node
  37880. * @param name defines the name of the global animation that will be run on all nodes
  37881. * @param node defines the root node where the animation will take place
  37882. * @param targetProperty defines property to animate
  37883. * @param framePerSecond defines the number of frame per second yo use
  37884. * @param totalFrame defines the number of frames in total
  37885. * @param from defines the initial value
  37886. * @param to defines the final value
  37887. * @param loopMode defines which loop mode you want to use (off by default)
  37888. * @param easingFunction defines the easing function to use (linear by default)
  37889. * @param onAnimationEnd defines the callback to call when animation end
  37890. * @returns the animatable created for this animation
  37891. */
  37892. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37893. /**
  37894. * Create and start an animation on a node and its descendants
  37895. * @param name defines the name of the global animation that will be run on all nodes
  37896. * @param node defines the root node where the animation will take place
  37897. * @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
  37898. * @param targetProperty defines property to animate
  37899. * @param framePerSecond defines the number of frame per second to use
  37900. * @param totalFrame defines the number of frames in total
  37901. * @param from defines the initial value
  37902. * @param to defines the final value
  37903. * @param loopMode defines which loop mode you want to use (off by default)
  37904. * @param easingFunction defines the easing function to use (linear by default)
  37905. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37906. * @returns the list of animatables created for all nodes
  37907. * @example https://www.babylonjs-playground.com/#MH0VLI
  37908. */
  37909. 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[]>;
  37910. /**
  37911. * Creates a new animation, merges it with the existing animations and starts it
  37912. * @param name Name of the animation
  37913. * @param node Node which contains the scene that begins the animations
  37914. * @param targetProperty Specifies which property to animate
  37915. * @param framePerSecond The frames per second of the animation
  37916. * @param totalFrame The total number of frames
  37917. * @param from The frame at the beginning of the animation
  37918. * @param to The frame at the end of the animation
  37919. * @param loopMode Specifies the loop mode of the animation
  37920. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37921. * @param onAnimationEnd Callback to run once the animation is complete
  37922. * @returns Nullable animation
  37923. */
  37924. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37925. /**
  37926. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37927. * @param sourceAnimation defines the Animation containing keyframes to convert
  37928. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37929. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37930. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37931. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37932. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37933. */
  37934. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37935. /**
  37936. * Transition property of an host to the target Value
  37937. * @param property The property to transition
  37938. * @param targetValue The target Value of the property
  37939. * @param host The object where the property to animate belongs
  37940. * @param scene Scene used to run the animation
  37941. * @param frameRate Framerate (in frame/s) to use
  37942. * @param transition The transition type we want to use
  37943. * @param duration The duration of the animation, in milliseconds
  37944. * @param onAnimationEnd Callback trigger at the end of the animation
  37945. * @returns Nullable animation
  37946. */
  37947. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37948. /**
  37949. * Return the array of runtime animations currently using this animation
  37950. */
  37951. get runtimeAnimations(): RuntimeAnimation[];
  37952. /**
  37953. * Specifies if any of the runtime animations are currently running
  37954. */
  37955. get hasRunningRuntimeAnimations(): boolean;
  37956. /**
  37957. * Initializes the animation
  37958. * @param name Name of the animation
  37959. * @param targetProperty Property to animate
  37960. * @param framePerSecond The frames per second of the animation
  37961. * @param dataType The data type of the animation
  37962. * @param loopMode The loop mode of the animation
  37963. * @param enableBlending Specifies if blending should be enabled
  37964. */
  37965. constructor(
  37966. /**Name of the animation */
  37967. name: string,
  37968. /**Property to animate */
  37969. targetProperty: string,
  37970. /**The frames per second of the animation */
  37971. framePerSecond: number,
  37972. /**The data type of the animation */
  37973. dataType: number,
  37974. /**The loop mode of the animation */
  37975. loopMode?: number | undefined,
  37976. /**Specifies if blending should be enabled */
  37977. enableBlending?: boolean | undefined);
  37978. /**
  37979. * Converts the animation to a string
  37980. * @param fullDetails support for multiple levels of logging within scene loading
  37981. * @returns String form of the animation
  37982. */
  37983. toString(fullDetails?: boolean): string;
  37984. /**
  37985. * Add an event to this animation
  37986. * @param event Event to add
  37987. */
  37988. addEvent(event: AnimationEvent): void;
  37989. /**
  37990. * Remove all events found at the given frame
  37991. * @param frame The frame to remove events from
  37992. */
  37993. removeEvents(frame: number): void;
  37994. /**
  37995. * Retrieves all the events from the animation
  37996. * @returns Events from the animation
  37997. */
  37998. getEvents(): AnimationEvent[];
  37999. /**
  38000. * Creates an animation range
  38001. * @param name Name of the animation range
  38002. * @param from Starting frame of the animation range
  38003. * @param to Ending frame of the animation
  38004. */
  38005. createRange(name: string, from: number, to: number): void;
  38006. /**
  38007. * Deletes an animation range by name
  38008. * @param name Name of the animation range to delete
  38009. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38010. */
  38011. deleteRange(name: string, deleteFrames?: boolean): void;
  38012. /**
  38013. * Gets the animation range by name, or null if not defined
  38014. * @param name Name of the animation range
  38015. * @returns Nullable animation range
  38016. */
  38017. getRange(name: string): Nullable<AnimationRange>;
  38018. /**
  38019. * Gets the key frames from the animation
  38020. * @returns The key frames of the animation
  38021. */
  38022. getKeys(): Array<IAnimationKey>;
  38023. /**
  38024. * Gets the highest frame rate of the animation
  38025. * @returns Highest frame rate of the animation
  38026. */
  38027. getHighestFrame(): number;
  38028. /**
  38029. * Gets the easing function of the animation
  38030. * @returns Easing function of the animation
  38031. */
  38032. getEasingFunction(): IEasingFunction;
  38033. /**
  38034. * Sets the easing function of the animation
  38035. * @param easingFunction A custom mathematical formula for animation
  38036. */
  38037. setEasingFunction(easingFunction: EasingFunction): void;
  38038. /**
  38039. * Interpolates a scalar linearly
  38040. * @param startValue Start value of the animation curve
  38041. * @param endValue End value of the animation curve
  38042. * @param gradient Scalar amount to interpolate
  38043. * @returns Interpolated scalar value
  38044. */
  38045. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38046. /**
  38047. * Interpolates a scalar cubically
  38048. * @param startValue Start value of the animation curve
  38049. * @param outTangent End tangent of the animation
  38050. * @param endValue End value of the animation curve
  38051. * @param inTangent Start tangent of the animation curve
  38052. * @param gradient Scalar amount to interpolate
  38053. * @returns Interpolated scalar value
  38054. */
  38055. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38056. /**
  38057. * Interpolates a quaternion using a spherical linear interpolation
  38058. * @param startValue Start value of the animation curve
  38059. * @param endValue End value of the animation curve
  38060. * @param gradient Scalar amount to interpolate
  38061. * @returns Interpolated quaternion value
  38062. */
  38063. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38064. /**
  38065. * Interpolates a quaternion cubically
  38066. * @param startValue Start value of the animation curve
  38067. * @param outTangent End tangent of the animation curve
  38068. * @param endValue End value of the animation curve
  38069. * @param inTangent Start tangent of the animation curve
  38070. * @param gradient Scalar amount to interpolate
  38071. * @returns Interpolated quaternion value
  38072. */
  38073. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38074. /**
  38075. * Interpolates a Vector3 linearl
  38076. * @param startValue Start value of the animation curve
  38077. * @param endValue End value of the animation curve
  38078. * @param gradient Scalar amount to interpolate
  38079. * @returns Interpolated scalar value
  38080. */
  38081. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38082. /**
  38083. * Interpolates a Vector3 cubically
  38084. * @param startValue Start value of the animation curve
  38085. * @param outTangent End tangent of the animation
  38086. * @param endValue End value of the animation curve
  38087. * @param inTangent Start tangent of the animation curve
  38088. * @param gradient Scalar amount to interpolate
  38089. * @returns InterpolatedVector3 value
  38090. */
  38091. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38092. /**
  38093. * Interpolates a Vector2 linearly
  38094. * @param startValue Start value of the animation curve
  38095. * @param endValue End value of the animation curve
  38096. * @param gradient Scalar amount to interpolate
  38097. * @returns Interpolated Vector2 value
  38098. */
  38099. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38100. /**
  38101. * Interpolates a Vector2 cubically
  38102. * @param startValue Start value of the animation curve
  38103. * @param outTangent End tangent of the animation
  38104. * @param endValue End value of the animation curve
  38105. * @param inTangent Start tangent of the animation curve
  38106. * @param gradient Scalar amount to interpolate
  38107. * @returns Interpolated Vector2 value
  38108. */
  38109. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38110. /**
  38111. * Interpolates a size linearly
  38112. * @param startValue Start value of the animation curve
  38113. * @param endValue End value of the animation curve
  38114. * @param gradient Scalar amount to interpolate
  38115. * @returns Interpolated Size value
  38116. */
  38117. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38118. /**
  38119. * Interpolates a Color3 linearly
  38120. * @param startValue Start value of the animation curve
  38121. * @param endValue End value of the animation curve
  38122. * @param gradient Scalar amount to interpolate
  38123. * @returns Interpolated Color3 value
  38124. */
  38125. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38126. /**
  38127. * Interpolates a Color4 linearly
  38128. * @param startValue Start value of the animation curve
  38129. * @param endValue End value of the animation curve
  38130. * @param gradient Scalar amount to interpolate
  38131. * @returns Interpolated Color3 value
  38132. */
  38133. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38134. /**
  38135. * @hidden Internal use only
  38136. */
  38137. _getKeyValue(value: any): any;
  38138. /**
  38139. * @hidden Internal use only
  38140. */
  38141. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38142. /**
  38143. * Defines the function to use to interpolate matrices
  38144. * @param startValue defines the start matrix
  38145. * @param endValue defines the end matrix
  38146. * @param gradient defines the gradient between both matrices
  38147. * @param result defines an optional target matrix where to store the interpolation
  38148. * @returns the interpolated matrix
  38149. */
  38150. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38151. /**
  38152. * Makes a copy of the animation
  38153. * @returns Cloned animation
  38154. */
  38155. clone(): Animation;
  38156. /**
  38157. * Sets the key frames of the animation
  38158. * @param values The animation key frames to set
  38159. */
  38160. setKeys(values: Array<IAnimationKey>): void;
  38161. /**
  38162. * Serializes the animation to an object
  38163. * @returns Serialized object
  38164. */
  38165. serialize(): any;
  38166. /**
  38167. * Float animation type
  38168. */
  38169. static readonly ANIMATIONTYPE_FLOAT: number;
  38170. /**
  38171. * Vector3 animation type
  38172. */
  38173. static readonly ANIMATIONTYPE_VECTOR3: number;
  38174. /**
  38175. * Quaternion animation type
  38176. */
  38177. static readonly ANIMATIONTYPE_QUATERNION: number;
  38178. /**
  38179. * Matrix animation type
  38180. */
  38181. static readonly ANIMATIONTYPE_MATRIX: number;
  38182. /**
  38183. * Color3 animation type
  38184. */
  38185. static readonly ANIMATIONTYPE_COLOR3: number;
  38186. /**
  38187. * Color3 animation type
  38188. */
  38189. static readonly ANIMATIONTYPE_COLOR4: number;
  38190. /**
  38191. * Vector2 animation type
  38192. */
  38193. static readonly ANIMATIONTYPE_VECTOR2: number;
  38194. /**
  38195. * Size animation type
  38196. */
  38197. static readonly ANIMATIONTYPE_SIZE: number;
  38198. /**
  38199. * Relative Loop Mode
  38200. */
  38201. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38202. /**
  38203. * Cycle Loop Mode
  38204. */
  38205. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38206. /**
  38207. * Constant Loop Mode
  38208. */
  38209. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38210. /** @hidden */
  38211. static _UniversalLerp(left: any, right: any, amount: number): any;
  38212. /**
  38213. * Parses an animation object and creates an animation
  38214. * @param parsedAnimation Parsed animation object
  38215. * @returns Animation object
  38216. */
  38217. static Parse(parsedAnimation: any): Animation;
  38218. /**
  38219. * Appends the serialized animations from the source animations
  38220. * @param source Source containing the animations
  38221. * @param destination Target to store the animations
  38222. */
  38223. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38224. /**
  38225. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38226. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38227. * @param url defines the url to load from
  38228. * @returns a promise that will resolve to the new animation or an array of animations
  38229. */
  38230. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38231. /**
  38232. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38233. * @param snippetId defines the snippet to load
  38234. * @returns a promise that will resolve to the new animation or a new array of animations
  38235. */
  38236. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38237. }
  38238. }
  38239. declare module "babylonjs/Animations/animatable.interface" {
  38240. import { Nullable } from "babylonjs/types";
  38241. import { Animation } from "babylonjs/Animations/animation";
  38242. /**
  38243. * Interface containing an array of animations
  38244. */
  38245. export interface IAnimatable {
  38246. /**
  38247. * Array of animations
  38248. */
  38249. animations: Nullable<Array<Animation>>;
  38250. }
  38251. }
  38252. declare module "babylonjs/Misc/decorators" {
  38253. import { Nullable } from "babylonjs/types";
  38254. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38255. import { Scene } from "babylonjs/scene";
  38256. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38257. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38258. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38259. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38260. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38261. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38262. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38263. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38264. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38265. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38266. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38267. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38268. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38269. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38270. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38271. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38272. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38273. /**
  38274. * Decorator used to define property that can be serialized as reference to a camera
  38275. * @param sourceName defines the name of the property to decorate
  38276. */
  38277. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38278. /**
  38279. * Class used to help serialization objects
  38280. */
  38281. export class SerializationHelper {
  38282. /** @hidden */
  38283. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38284. /** @hidden */
  38285. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38286. /** @hidden */
  38287. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38288. /** @hidden */
  38289. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38290. /**
  38291. * Appends the serialized animations from the source animations
  38292. * @param source Source containing the animations
  38293. * @param destination Target to store the animations
  38294. */
  38295. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38296. /**
  38297. * Static function used to serialized a specific entity
  38298. * @param entity defines the entity to serialize
  38299. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38300. * @returns a JSON compatible object representing the serialization of the entity
  38301. */
  38302. static Serialize<T>(entity: T, serializationObject?: any): any;
  38303. /**
  38304. * Creates a new entity from a serialization data object
  38305. * @param creationFunction defines a function used to instanciated the new entity
  38306. * @param source defines the source serialization data
  38307. * @param scene defines the hosting scene
  38308. * @param rootUrl defines the root url for resources
  38309. * @returns a new entity
  38310. */
  38311. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38312. /**
  38313. * Clones an object
  38314. * @param creationFunction defines the function used to instanciate the new object
  38315. * @param source defines the source object
  38316. * @returns the cloned object
  38317. */
  38318. static Clone<T>(creationFunction: () => T, source: T): T;
  38319. /**
  38320. * Instanciates a new object based on a source one (some data will be shared between both object)
  38321. * @param creationFunction defines the function used to instanciate the new object
  38322. * @param source defines the source object
  38323. * @returns the new object
  38324. */
  38325. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38326. }
  38327. }
  38328. declare module "babylonjs/Materials/Textures/baseTexture" {
  38329. import { Observable } from "babylonjs/Misc/observable";
  38330. import { Nullable } from "babylonjs/types";
  38331. import { Scene } from "babylonjs/scene";
  38332. import { Matrix } from "babylonjs/Maths/math.vector";
  38333. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38334. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38335. import { ISize } from "babylonjs/Maths/math.size";
  38336. import "babylonjs/Misc/fileTools";
  38337. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38338. /**
  38339. * Base class of all the textures in babylon.
  38340. * It groups all the common properties the materials, post process, lights... might need
  38341. * in order to make a correct use of the texture.
  38342. */
  38343. export class BaseTexture implements IAnimatable {
  38344. /**
  38345. * Default anisotropic filtering level for the application.
  38346. * It is set to 4 as a good tradeoff between perf and quality.
  38347. */
  38348. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  38349. /**
  38350. * Gets or sets the unique id of the texture
  38351. */
  38352. uniqueId: number;
  38353. /**
  38354. * Define the name of the texture.
  38355. */
  38356. name: string;
  38357. /**
  38358. * Gets or sets an object used to store user defined information.
  38359. */
  38360. metadata: any;
  38361. /**
  38362. * For internal use only. Please do not use.
  38363. */
  38364. reservedDataStore: any;
  38365. private _hasAlpha;
  38366. /**
  38367. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  38368. */
  38369. set hasAlpha(value: boolean);
  38370. get hasAlpha(): boolean;
  38371. /**
  38372. * Defines if the alpha value should be determined via the rgb values.
  38373. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  38374. */
  38375. getAlphaFromRGB: boolean;
  38376. /**
  38377. * Intensity or strength of the texture.
  38378. * It is commonly used by materials to fine tune the intensity of the texture
  38379. */
  38380. level: number;
  38381. /**
  38382. * Define the UV chanel to use starting from 0 and defaulting to 0.
  38383. * This is part of the texture as textures usually maps to one uv set.
  38384. */
  38385. coordinatesIndex: number;
  38386. protected _coordinatesMode: number;
  38387. /**
  38388. * How a texture is mapped.
  38389. *
  38390. * | Value | Type | Description |
  38391. * | ----- | ----------------------------------- | ----------- |
  38392. * | 0 | EXPLICIT_MODE | |
  38393. * | 1 | SPHERICAL_MODE | |
  38394. * | 2 | PLANAR_MODE | |
  38395. * | 3 | CUBIC_MODE | |
  38396. * | 4 | PROJECTION_MODE | |
  38397. * | 5 | SKYBOX_MODE | |
  38398. * | 6 | INVCUBIC_MODE | |
  38399. * | 7 | EQUIRECTANGULAR_MODE | |
  38400. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  38401. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  38402. */
  38403. set coordinatesMode(value: number);
  38404. get coordinatesMode(): number;
  38405. private _wrapU;
  38406. /**
  38407. * | Value | Type | Description |
  38408. * | ----- | ------------------ | ----------- |
  38409. * | 0 | CLAMP_ADDRESSMODE | |
  38410. * | 1 | WRAP_ADDRESSMODE | |
  38411. * | 2 | MIRROR_ADDRESSMODE | |
  38412. */
  38413. get wrapU(): number;
  38414. set wrapU(value: number);
  38415. private _wrapV;
  38416. /**
  38417. * | Value | Type | Description |
  38418. * | ----- | ------------------ | ----------- |
  38419. * | 0 | CLAMP_ADDRESSMODE | |
  38420. * | 1 | WRAP_ADDRESSMODE | |
  38421. * | 2 | MIRROR_ADDRESSMODE | |
  38422. */
  38423. get wrapV(): number;
  38424. set wrapV(value: number);
  38425. /**
  38426. * | Value | Type | Description |
  38427. * | ----- | ------------------ | ----------- |
  38428. * | 0 | CLAMP_ADDRESSMODE | |
  38429. * | 1 | WRAP_ADDRESSMODE | |
  38430. * | 2 | MIRROR_ADDRESSMODE | |
  38431. */
  38432. wrapR: number;
  38433. /**
  38434. * With compliant hardware and browser (supporting anisotropic filtering)
  38435. * this defines the level of anisotropic filtering in the texture.
  38436. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  38437. */
  38438. anisotropicFilteringLevel: number;
  38439. /**
  38440. * Define if the texture is a cube texture or if false a 2d texture.
  38441. */
  38442. get isCube(): boolean;
  38443. set isCube(value: boolean);
  38444. /**
  38445. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  38446. */
  38447. get is3D(): boolean;
  38448. set is3D(value: boolean);
  38449. /**
  38450. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  38451. */
  38452. get is2DArray(): boolean;
  38453. set is2DArray(value: boolean);
  38454. private _gammaSpace;
  38455. /**
  38456. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  38457. * HDR texture are usually stored in linear space.
  38458. * This only impacts the PBR and Background materials
  38459. */
  38460. get gammaSpace(): boolean;
  38461. set gammaSpace(gamma: boolean);
  38462. /**
  38463. * Gets or sets whether or not the texture contains RGBD data.
  38464. */
  38465. get isRGBD(): boolean;
  38466. set isRGBD(value: boolean);
  38467. /**
  38468. * Is Z inverted in the texture (useful in a cube texture).
  38469. */
  38470. invertZ: boolean;
  38471. /**
  38472. * Are mip maps generated for this texture or not.
  38473. */
  38474. get noMipmap(): boolean;
  38475. /**
  38476. * @hidden
  38477. */
  38478. lodLevelInAlpha: boolean;
  38479. /**
  38480. * With prefiltered texture, defined the offset used during the prefiltering steps.
  38481. */
  38482. get lodGenerationOffset(): number;
  38483. set lodGenerationOffset(value: number);
  38484. /**
  38485. * With prefiltered texture, defined the scale used during the prefiltering steps.
  38486. */
  38487. get lodGenerationScale(): number;
  38488. set lodGenerationScale(value: number);
  38489. /**
  38490. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  38491. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  38492. * average roughness values.
  38493. */
  38494. get linearSpecularLOD(): boolean;
  38495. set linearSpecularLOD(value: boolean);
  38496. /**
  38497. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  38498. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  38499. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  38500. */
  38501. get irradianceTexture(): Nullable<BaseTexture>;
  38502. set irradianceTexture(value: Nullable<BaseTexture>);
  38503. /**
  38504. * Define if the texture is a render target.
  38505. */
  38506. isRenderTarget: boolean;
  38507. /**
  38508. * Define the unique id of the texture in the scene.
  38509. */
  38510. get uid(): string;
  38511. /** @hidden */
  38512. _prefiltered: boolean;
  38513. /**
  38514. * Return a string representation of the texture.
  38515. * @returns the texture as a string
  38516. */
  38517. toString(): string;
  38518. /**
  38519. * Get the class name of the texture.
  38520. * @returns "BaseTexture"
  38521. */
  38522. getClassName(): string;
  38523. /**
  38524. * Define the list of animation attached to the texture.
  38525. */
  38526. animations: import("babylonjs/Animations/animation").Animation[];
  38527. /**
  38528. * An event triggered when the texture is disposed.
  38529. */
  38530. onDisposeObservable: Observable<BaseTexture>;
  38531. private _onDisposeObserver;
  38532. /**
  38533. * Callback triggered when the texture has been disposed.
  38534. * Kept for back compatibility, you can use the onDisposeObservable instead.
  38535. */
  38536. set onDispose(callback: () => void);
  38537. /**
  38538. * Define the current state of the loading sequence when in delayed load mode.
  38539. */
  38540. delayLoadState: number;
  38541. protected _scene: Nullable<Scene>;
  38542. protected _engine: Nullable<ThinEngine>;
  38543. /** @hidden */
  38544. _texture: Nullable<InternalTexture>;
  38545. private _uid;
  38546. /**
  38547. * Define if the texture is preventinga material to render or not.
  38548. * If not and the texture is not ready, the engine will use a default black texture instead.
  38549. */
  38550. get isBlocking(): boolean;
  38551. /**
  38552. * Instantiates a new BaseTexture.
  38553. * Base class of all the textures in babylon.
  38554. * It groups all the common properties the materials, post process, lights... might need
  38555. * in order to make a correct use of the texture.
  38556. * @param sceneOrEngine Define the scene or engine the texture blongs to
  38557. */
  38558. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  38559. /**
  38560. * Get the scene the texture belongs to.
  38561. * @returns the scene or null if undefined
  38562. */
  38563. getScene(): Nullable<Scene>;
  38564. /** @hidden */
  38565. protected _getEngine(): Nullable<ThinEngine>;
  38566. /**
  38567. * Get the texture transform matrix used to offset tile the texture for istance.
  38568. * @returns the transformation matrix
  38569. */
  38570. getTextureMatrix(): Matrix;
  38571. /**
  38572. * Get the texture reflection matrix used to rotate/transform the reflection.
  38573. * @returns the reflection matrix
  38574. */
  38575. getReflectionTextureMatrix(): Matrix;
  38576. /**
  38577. * Get the underlying lower level texture from Babylon.
  38578. * @returns the insternal texture
  38579. */
  38580. getInternalTexture(): Nullable<InternalTexture>;
  38581. /**
  38582. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  38583. * @returns true if ready or not blocking
  38584. */
  38585. isReadyOrNotBlocking(): boolean;
  38586. /**
  38587. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  38588. * @returns true if fully ready
  38589. */
  38590. isReady(): boolean;
  38591. private _cachedSize;
  38592. /**
  38593. * Get the size of the texture.
  38594. * @returns the texture size.
  38595. */
  38596. getSize(): ISize;
  38597. /**
  38598. * Get the base size of the texture.
  38599. * It can be different from the size if the texture has been resized for POT for instance
  38600. * @returns the base size
  38601. */
  38602. getBaseSize(): ISize;
  38603. /**
  38604. * Update the sampling mode of the texture.
  38605. * Default is Trilinear mode.
  38606. *
  38607. * | Value | Type | Description |
  38608. * | ----- | ------------------ | ----------- |
  38609. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  38610. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  38611. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  38612. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  38613. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  38614. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  38615. * | 7 | NEAREST_LINEAR | |
  38616. * | 8 | NEAREST_NEAREST | |
  38617. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  38618. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  38619. * | 11 | LINEAR_LINEAR | |
  38620. * | 12 | LINEAR_NEAREST | |
  38621. *
  38622. * > _mag_: magnification filter (close to the viewer)
  38623. * > _min_: minification filter (far from the viewer)
  38624. * > _mip_: filter used between mip map levels
  38625. *@param samplingMode Define the new sampling mode of the texture
  38626. */
  38627. updateSamplingMode(samplingMode: number): void;
  38628. /**
  38629. * Scales the texture if is `canRescale()`
  38630. * @param ratio the resize factor we want to use to rescale
  38631. */
  38632. scale(ratio: number): void;
  38633. /**
  38634. * Get if the texture can rescale.
  38635. */
  38636. get canRescale(): boolean;
  38637. /** @hidden */
  38638. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  38639. /** @hidden */
  38640. _rebuild(): void;
  38641. /**
  38642. * Triggers the load sequence in delayed load mode.
  38643. */
  38644. delayLoad(): void;
  38645. /**
  38646. * Clones the texture.
  38647. * @returns the cloned texture
  38648. */
  38649. clone(): Nullable<BaseTexture>;
  38650. /**
  38651. * Get the texture underlying type (INT, FLOAT...)
  38652. */
  38653. get textureType(): number;
  38654. /**
  38655. * Get the texture underlying format (RGB, RGBA...)
  38656. */
  38657. get textureFormat(): number;
  38658. /**
  38659. * Indicates that textures need to be re-calculated for all materials
  38660. */
  38661. protected _markAllSubMeshesAsTexturesDirty(): void;
  38662. /**
  38663. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  38664. * This will returns an RGBA array buffer containing either in values (0-255) or
  38665. * float values (0-1) depending of the underlying buffer type.
  38666. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  38667. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  38668. * @param buffer defines a user defined buffer to fill with data (can be null)
  38669. * @returns The Array buffer containing the pixels data.
  38670. */
  38671. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  38672. /**
  38673. * Release and destroy the underlying lower level texture aka internalTexture.
  38674. */
  38675. releaseInternalTexture(): void;
  38676. /** @hidden */
  38677. get _lodTextureHigh(): Nullable<BaseTexture>;
  38678. /** @hidden */
  38679. get _lodTextureMid(): Nullable<BaseTexture>;
  38680. /** @hidden */
  38681. get _lodTextureLow(): Nullable<BaseTexture>;
  38682. /**
  38683. * Dispose the texture and release its associated resources.
  38684. */
  38685. dispose(): void;
  38686. /**
  38687. * Serialize the texture into a JSON representation that can be parsed later on.
  38688. * @returns the JSON representation of the texture
  38689. */
  38690. serialize(): any;
  38691. /**
  38692. * Helper function to be called back once a list of texture contains only ready textures.
  38693. * @param textures Define the list of textures to wait for
  38694. * @param callback Define the callback triggered once the entire list will be ready
  38695. */
  38696. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  38697. private static _isScene;
  38698. }
  38699. }
  38700. declare module "babylonjs/Materials/effect" {
  38701. import { Observable } from "babylonjs/Misc/observable";
  38702. import { Nullable } from "babylonjs/types";
  38703. import { IDisposable } from "babylonjs/scene";
  38704. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38705. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38706. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  38707. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38708. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  38709. import { Engine } from "babylonjs/Engines/engine";
  38710. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38711. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38712. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38713. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38714. /**
  38715. * Options to be used when creating an effect.
  38716. */
  38717. export interface IEffectCreationOptions {
  38718. /**
  38719. * Atrributes that will be used in the shader.
  38720. */
  38721. attributes: string[];
  38722. /**
  38723. * Uniform varible names that will be set in the shader.
  38724. */
  38725. uniformsNames: string[];
  38726. /**
  38727. * Uniform buffer variable names that will be set in the shader.
  38728. */
  38729. uniformBuffersNames: string[];
  38730. /**
  38731. * Sampler texture variable names that will be set in the shader.
  38732. */
  38733. samplers: string[];
  38734. /**
  38735. * Define statements that will be set in the shader.
  38736. */
  38737. defines: any;
  38738. /**
  38739. * Possible fallbacks for this effect to improve performance when needed.
  38740. */
  38741. fallbacks: Nullable<IEffectFallbacks>;
  38742. /**
  38743. * Callback that will be called when the shader is compiled.
  38744. */
  38745. onCompiled: Nullable<(effect: Effect) => void>;
  38746. /**
  38747. * Callback that will be called if an error occurs during shader compilation.
  38748. */
  38749. onError: Nullable<(effect: Effect, errors: string) => void>;
  38750. /**
  38751. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38752. */
  38753. indexParameters?: any;
  38754. /**
  38755. * Max number of lights that can be used in the shader.
  38756. */
  38757. maxSimultaneousLights?: number;
  38758. /**
  38759. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38760. */
  38761. transformFeedbackVaryings?: Nullable<string[]>;
  38762. /**
  38763. * 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
  38764. */
  38765. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38766. /**
  38767. * Is this effect rendering to several color attachments ?
  38768. */
  38769. multiTarget?: boolean;
  38770. }
  38771. /**
  38772. * Effect containing vertex and fragment shader that can be executed on an object.
  38773. */
  38774. export class Effect implements IDisposable {
  38775. /**
  38776. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38777. */
  38778. static ShadersRepository: string;
  38779. /**
  38780. * Enable logging of the shader code when a compilation error occurs
  38781. */
  38782. static LogShaderCodeOnCompilationError: boolean;
  38783. /**
  38784. * Name of the effect.
  38785. */
  38786. name: any;
  38787. /**
  38788. * String container all the define statements that should be set on the shader.
  38789. */
  38790. defines: string;
  38791. /**
  38792. * Callback that will be called when the shader is compiled.
  38793. */
  38794. onCompiled: Nullable<(effect: Effect) => void>;
  38795. /**
  38796. * Callback that will be called if an error occurs during shader compilation.
  38797. */
  38798. onError: Nullable<(effect: Effect, errors: string) => void>;
  38799. /**
  38800. * Callback that will be called when effect is bound.
  38801. */
  38802. onBind: Nullable<(effect: Effect) => void>;
  38803. /**
  38804. * Unique ID of the effect.
  38805. */
  38806. uniqueId: number;
  38807. /**
  38808. * Observable that will be called when the shader is compiled.
  38809. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38810. */
  38811. onCompileObservable: Observable<Effect>;
  38812. /**
  38813. * Observable that will be called if an error occurs during shader compilation.
  38814. */
  38815. onErrorObservable: Observable<Effect>;
  38816. /** @hidden */
  38817. _onBindObservable: Nullable<Observable<Effect>>;
  38818. /**
  38819. * @hidden
  38820. * Specifies if the effect was previously ready
  38821. */
  38822. _wasPreviouslyReady: boolean;
  38823. /**
  38824. * Observable that will be called when effect is bound.
  38825. */
  38826. get onBindObservable(): Observable<Effect>;
  38827. /** @hidden */
  38828. _bonesComputationForcedToCPU: boolean;
  38829. /** @hidden */
  38830. _multiTarget: boolean;
  38831. private static _uniqueIdSeed;
  38832. private _engine;
  38833. private _uniformBuffersNames;
  38834. private _uniformBuffersNamesList;
  38835. private _uniformsNames;
  38836. private _samplerList;
  38837. private _samplers;
  38838. private _isReady;
  38839. private _compilationError;
  38840. private _allFallbacksProcessed;
  38841. private _attributesNames;
  38842. private _attributes;
  38843. private _attributeLocationByName;
  38844. private _uniforms;
  38845. /**
  38846. * Key for the effect.
  38847. * @hidden
  38848. */
  38849. _key: string;
  38850. private _indexParameters;
  38851. private _fallbacks;
  38852. private _vertexSourceCode;
  38853. private _fragmentSourceCode;
  38854. private _vertexSourceCodeOverride;
  38855. private _fragmentSourceCodeOverride;
  38856. private _transformFeedbackVaryings;
  38857. /**
  38858. * Compiled shader to webGL program.
  38859. * @hidden
  38860. */
  38861. _pipelineContext: Nullable<IPipelineContext>;
  38862. private _valueCache;
  38863. private static _baseCache;
  38864. /**
  38865. * Instantiates an effect.
  38866. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38867. * @param baseName Name of the effect.
  38868. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38869. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38870. * @param samplers List of sampler variables that will be passed to the shader.
  38871. * @param engine Engine to be used to render the effect
  38872. * @param defines Define statements to be added to the shader.
  38873. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38874. * @param onCompiled Callback that will be called when the shader is compiled.
  38875. * @param onError Callback that will be called if an error occurs during shader compilation.
  38876. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38877. */
  38878. 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);
  38879. private _useFinalCode;
  38880. /**
  38881. * Unique key for this effect
  38882. */
  38883. get key(): string;
  38884. /**
  38885. * If the effect has been compiled and prepared.
  38886. * @returns if the effect is compiled and prepared.
  38887. */
  38888. isReady(): boolean;
  38889. private _isReadyInternal;
  38890. /**
  38891. * The engine the effect was initialized with.
  38892. * @returns the engine.
  38893. */
  38894. getEngine(): Engine;
  38895. /**
  38896. * The pipeline context for this effect
  38897. * @returns the associated pipeline context
  38898. */
  38899. getPipelineContext(): Nullable<IPipelineContext>;
  38900. /**
  38901. * The set of names of attribute variables for the shader.
  38902. * @returns An array of attribute names.
  38903. */
  38904. getAttributesNames(): string[];
  38905. /**
  38906. * Returns the attribute at the given index.
  38907. * @param index The index of the attribute.
  38908. * @returns The location of the attribute.
  38909. */
  38910. getAttributeLocation(index: number): number;
  38911. /**
  38912. * Returns the attribute based on the name of the variable.
  38913. * @param name of the attribute to look up.
  38914. * @returns the attribute location.
  38915. */
  38916. getAttributeLocationByName(name: string): number;
  38917. /**
  38918. * The number of attributes.
  38919. * @returns the numnber of attributes.
  38920. */
  38921. getAttributesCount(): number;
  38922. /**
  38923. * Gets the index of a uniform variable.
  38924. * @param uniformName of the uniform to look up.
  38925. * @returns the index.
  38926. */
  38927. getUniformIndex(uniformName: string): number;
  38928. /**
  38929. * Returns the attribute based on the name of the variable.
  38930. * @param uniformName of the uniform to look up.
  38931. * @returns the location of the uniform.
  38932. */
  38933. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38934. /**
  38935. * Returns an array of sampler variable names
  38936. * @returns The array of sampler variable names.
  38937. */
  38938. getSamplers(): string[];
  38939. /**
  38940. * Returns an array of uniform variable names
  38941. * @returns The array of uniform variable names.
  38942. */
  38943. getUniformNames(): string[];
  38944. /**
  38945. * Returns an array of uniform buffer variable names
  38946. * @returns The array of uniform buffer variable names.
  38947. */
  38948. getUniformBuffersNames(): string[];
  38949. /**
  38950. * Returns the index parameters used to create the effect
  38951. * @returns The index parameters object
  38952. */
  38953. getIndexParameters(): any;
  38954. /**
  38955. * The error from the last compilation.
  38956. * @returns the error string.
  38957. */
  38958. getCompilationError(): string;
  38959. /**
  38960. * Gets a boolean indicating that all fallbacks were used during compilation
  38961. * @returns true if all fallbacks were used
  38962. */
  38963. allFallbacksProcessed(): boolean;
  38964. /**
  38965. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38966. * @param func The callback to be used.
  38967. */
  38968. executeWhenCompiled(func: (effect: Effect) => void): void;
  38969. private _checkIsReady;
  38970. private _loadShader;
  38971. /**
  38972. * Gets the vertex shader source code of this effect
  38973. */
  38974. get vertexSourceCode(): string;
  38975. /**
  38976. * Gets the fragment shader source code of this effect
  38977. */
  38978. get fragmentSourceCode(): string;
  38979. /**
  38980. * Recompiles the webGL program
  38981. * @param vertexSourceCode The source code for the vertex shader.
  38982. * @param fragmentSourceCode The source code for the fragment shader.
  38983. * @param onCompiled Callback called when completed.
  38984. * @param onError Callback called on error.
  38985. * @hidden
  38986. */
  38987. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  38988. /**
  38989. * Prepares the effect
  38990. * @hidden
  38991. */
  38992. _prepareEffect(): void;
  38993. private _getShaderCodeAndErrorLine;
  38994. private _processCompilationErrors;
  38995. /**
  38996. * Checks if the effect is supported. (Must be called after compilation)
  38997. */
  38998. get isSupported(): boolean;
  38999. /**
  39000. * Binds a texture to the engine to be used as output of the shader.
  39001. * @param channel Name of the output variable.
  39002. * @param texture Texture to bind.
  39003. * @hidden
  39004. */
  39005. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39006. /**
  39007. * Sets a texture on the engine to be used in the shader.
  39008. * @param channel Name of the sampler variable.
  39009. * @param texture Texture to set.
  39010. */
  39011. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  39012. /**
  39013. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39014. * @param channel Name of the sampler variable.
  39015. * @param texture Texture to set.
  39016. */
  39017. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39018. /**
  39019. * Sets an array of textures on the engine to be used in the shader.
  39020. * @param channel Name of the variable.
  39021. * @param textures Textures to set.
  39022. */
  39023. setTextureArray(channel: string, textures: BaseTexture[]): void;
  39024. /**
  39025. * 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)
  39026. * @param channel Name of the sampler variable.
  39027. * @param postProcess Post process to get the input texture from.
  39028. */
  39029. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39030. /**
  39031. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39032. * 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)
  39033. * @param channel Name of the sampler variable.
  39034. * @param postProcess Post process to get the output texture from.
  39035. */
  39036. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39037. /** @hidden */
  39038. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39039. /** @hidden */
  39040. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39041. /** @hidden */
  39042. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39043. /** @hidden */
  39044. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39045. /**
  39046. * Binds a buffer to a uniform.
  39047. * @param buffer Buffer to bind.
  39048. * @param name Name of the uniform variable to bind to.
  39049. */
  39050. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39051. /**
  39052. * Binds block to a uniform.
  39053. * @param blockName Name of the block to bind.
  39054. * @param index Index to bind.
  39055. */
  39056. bindUniformBlock(blockName: string, index: number): void;
  39057. /**
  39058. * Sets an interger value on a uniform variable.
  39059. * @param uniformName Name of the variable.
  39060. * @param value Value to be set.
  39061. * @returns this effect.
  39062. */
  39063. setInt(uniformName: string, value: number): Effect;
  39064. /**
  39065. * Sets an int array on a uniform variable.
  39066. * @param uniformName Name of the variable.
  39067. * @param array array to be set.
  39068. * @returns this effect.
  39069. */
  39070. setIntArray(uniformName: string, array: Int32Array): Effect;
  39071. /**
  39072. * 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)
  39073. * @param uniformName Name of the variable.
  39074. * @param array array to be set.
  39075. * @returns this effect.
  39076. */
  39077. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39078. /**
  39079. * 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)
  39080. * @param uniformName Name of the variable.
  39081. * @param array array to be set.
  39082. * @returns this effect.
  39083. */
  39084. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39085. /**
  39086. * 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)
  39087. * @param uniformName Name of the variable.
  39088. * @param array array to be set.
  39089. * @returns this effect.
  39090. */
  39091. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39092. /**
  39093. * Sets an float array on a uniform variable.
  39094. * @param uniformName Name of the variable.
  39095. * @param array array to be set.
  39096. * @returns this effect.
  39097. */
  39098. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39099. /**
  39100. * 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)
  39101. * @param uniformName Name of the variable.
  39102. * @param array array to be set.
  39103. * @returns this effect.
  39104. */
  39105. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39106. /**
  39107. * 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)
  39108. * @param uniformName Name of the variable.
  39109. * @param array array to be set.
  39110. * @returns this effect.
  39111. */
  39112. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39113. /**
  39114. * 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)
  39115. * @param uniformName Name of the variable.
  39116. * @param array array to be set.
  39117. * @returns this effect.
  39118. */
  39119. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39120. /**
  39121. * Sets an array on a uniform variable.
  39122. * @param uniformName Name of the variable.
  39123. * @param array array to be set.
  39124. * @returns this effect.
  39125. */
  39126. setArray(uniformName: string, array: number[]): Effect;
  39127. /**
  39128. * 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)
  39129. * @param uniformName Name of the variable.
  39130. * @param array array to be set.
  39131. * @returns this effect.
  39132. */
  39133. setArray2(uniformName: string, array: number[]): Effect;
  39134. /**
  39135. * 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)
  39136. * @param uniformName Name of the variable.
  39137. * @param array array to be set.
  39138. * @returns this effect.
  39139. */
  39140. setArray3(uniformName: string, array: number[]): Effect;
  39141. /**
  39142. * 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)
  39143. * @param uniformName Name of the variable.
  39144. * @param array array to be set.
  39145. * @returns this effect.
  39146. */
  39147. setArray4(uniformName: string, array: number[]): Effect;
  39148. /**
  39149. * Sets matrices on a uniform variable.
  39150. * @param uniformName Name of the variable.
  39151. * @param matrices matrices to be set.
  39152. * @returns this effect.
  39153. */
  39154. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39155. /**
  39156. * Sets matrix on a uniform variable.
  39157. * @param uniformName Name of the variable.
  39158. * @param matrix matrix to be set.
  39159. * @returns this effect.
  39160. */
  39161. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39162. /**
  39163. * 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)
  39164. * @param uniformName Name of the variable.
  39165. * @param matrix matrix to be set.
  39166. * @returns this effect.
  39167. */
  39168. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39169. /**
  39170. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39171. * @param uniformName Name of the variable.
  39172. * @param matrix matrix to be set.
  39173. * @returns this effect.
  39174. */
  39175. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39176. /**
  39177. * Sets a float on a uniform variable.
  39178. * @param uniformName Name of the variable.
  39179. * @param value value to be set.
  39180. * @returns this effect.
  39181. */
  39182. setFloat(uniformName: string, value: number): Effect;
  39183. /**
  39184. * Sets a boolean on a uniform variable.
  39185. * @param uniformName Name of the variable.
  39186. * @param bool value to be set.
  39187. * @returns this effect.
  39188. */
  39189. setBool(uniformName: string, bool: boolean): Effect;
  39190. /**
  39191. * Sets a Vector2 on a uniform variable.
  39192. * @param uniformName Name of the variable.
  39193. * @param vector2 vector2 to be set.
  39194. * @returns this effect.
  39195. */
  39196. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39197. /**
  39198. * Sets a float2 on a uniform variable.
  39199. * @param uniformName Name of the variable.
  39200. * @param x First float in float2.
  39201. * @param y Second float in float2.
  39202. * @returns this effect.
  39203. */
  39204. setFloat2(uniformName: string, x: number, y: number): Effect;
  39205. /**
  39206. * Sets a Vector3 on a uniform variable.
  39207. * @param uniformName Name of the variable.
  39208. * @param vector3 Value to be set.
  39209. * @returns this effect.
  39210. */
  39211. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39212. /**
  39213. * Sets a float3 on a uniform variable.
  39214. * @param uniformName Name of the variable.
  39215. * @param x First float in float3.
  39216. * @param y Second float in float3.
  39217. * @param z Third float in float3.
  39218. * @returns this effect.
  39219. */
  39220. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39221. /**
  39222. * Sets a Vector4 on a uniform variable.
  39223. * @param uniformName Name of the variable.
  39224. * @param vector4 Value to be set.
  39225. * @returns this effect.
  39226. */
  39227. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39228. /**
  39229. * Sets a float4 on a uniform variable.
  39230. * @param uniformName Name of the variable.
  39231. * @param x First float in float4.
  39232. * @param y Second float in float4.
  39233. * @param z Third float in float4.
  39234. * @param w Fourth float in float4.
  39235. * @returns this effect.
  39236. */
  39237. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39238. /**
  39239. * Sets a Color3 on a uniform variable.
  39240. * @param uniformName Name of the variable.
  39241. * @param color3 Value to be set.
  39242. * @returns this effect.
  39243. */
  39244. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39245. /**
  39246. * Sets a Color4 on a uniform variable.
  39247. * @param uniformName Name of the variable.
  39248. * @param color3 Value to be set.
  39249. * @param alpha Alpha value to be set.
  39250. * @returns this effect.
  39251. */
  39252. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39253. /**
  39254. * Sets a Color4 on a uniform variable
  39255. * @param uniformName defines the name of the variable
  39256. * @param color4 defines the value to be set
  39257. * @returns this effect.
  39258. */
  39259. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39260. /** Release all associated resources */
  39261. dispose(): void;
  39262. /**
  39263. * This function will add a new shader to the shader store
  39264. * @param name the name of the shader
  39265. * @param pixelShader optional pixel shader content
  39266. * @param vertexShader optional vertex shader content
  39267. */
  39268. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39269. /**
  39270. * Store of each shader (The can be looked up using effect.key)
  39271. */
  39272. static ShadersStore: {
  39273. [key: string]: string;
  39274. };
  39275. /**
  39276. * Store of each included file for a shader (The can be looked up using effect.key)
  39277. */
  39278. static IncludesShadersStore: {
  39279. [key: string]: string;
  39280. };
  39281. /**
  39282. * Resets the cache of effects.
  39283. */
  39284. static ResetCache(): void;
  39285. }
  39286. }
  39287. declare module "babylonjs/Engines/engineCapabilities" {
  39288. /**
  39289. * Interface used to describe the capabilities of the engine relatively to the current browser
  39290. */
  39291. export interface EngineCapabilities {
  39292. /** Maximum textures units per fragment shader */
  39293. maxTexturesImageUnits: number;
  39294. /** Maximum texture units per vertex shader */
  39295. maxVertexTextureImageUnits: number;
  39296. /** Maximum textures units in the entire pipeline */
  39297. maxCombinedTexturesImageUnits: number;
  39298. /** Maximum texture size */
  39299. maxTextureSize: number;
  39300. /** Maximum texture samples */
  39301. maxSamples?: number;
  39302. /** Maximum cube texture size */
  39303. maxCubemapTextureSize: number;
  39304. /** Maximum render texture size */
  39305. maxRenderTextureSize: number;
  39306. /** Maximum number of vertex attributes */
  39307. maxVertexAttribs: number;
  39308. /** Maximum number of varyings */
  39309. maxVaryingVectors: number;
  39310. /** Maximum number of uniforms per vertex shader */
  39311. maxVertexUniformVectors: number;
  39312. /** Maximum number of uniforms per fragment shader */
  39313. maxFragmentUniformVectors: number;
  39314. /** Defines if standard derivates (dx/dy) are supported */
  39315. standardDerivatives: boolean;
  39316. /** Defines if s3tc texture compression is supported */
  39317. s3tc?: WEBGL_compressed_texture_s3tc;
  39318. /** Defines if pvrtc texture compression is supported */
  39319. pvrtc: any;
  39320. /** Defines if etc1 texture compression is supported */
  39321. etc1: any;
  39322. /** Defines if etc2 texture compression is supported */
  39323. etc2: any;
  39324. /** Defines if astc texture compression is supported */
  39325. astc: any;
  39326. /** Defines if bptc texture compression is supported */
  39327. bptc: any;
  39328. /** Defines if float textures are supported */
  39329. textureFloat: boolean;
  39330. /** Defines if vertex array objects are supported */
  39331. vertexArrayObject: boolean;
  39332. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39333. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39334. /** Gets the maximum level of anisotropy supported */
  39335. maxAnisotropy: number;
  39336. /** Defines if instancing is supported */
  39337. instancedArrays: boolean;
  39338. /** Defines if 32 bits indices are supported */
  39339. uintIndices: boolean;
  39340. /** Defines if high precision shaders are supported */
  39341. highPrecisionShaderSupported: boolean;
  39342. /** Defines if depth reading in the fragment shader is supported */
  39343. fragmentDepthSupported: boolean;
  39344. /** Defines if float texture linear filtering is supported*/
  39345. textureFloatLinearFiltering: boolean;
  39346. /** Defines if rendering to float textures is supported */
  39347. textureFloatRender: boolean;
  39348. /** Defines if half float textures are supported*/
  39349. textureHalfFloat: boolean;
  39350. /** Defines if half float texture linear filtering is supported*/
  39351. textureHalfFloatLinearFiltering: boolean;
  39352. /** Defines if rendering to half float textures is supported */
  39353. textureHalfFloatRender: boolean;
  39354. /** Defines if textureLOD shader command is supported */
  39355. textureLOD: boolean;
  39356. /** Defines if draw buffers extension is supported */
  39357. drawBuffersExtension: boolean;
  39358. /** Defines if depth textures are supported */
  39359. depthTextureExtension: boolean;
  39360. /** Defines if float color buffer are supported */
  39361. colorBufferFloat: boolean;
  39362. /** Gets disjoint timer query extension (null if not supported) */
  39363. timerQuery?: EXT_disjoint_timer_query;
  39364. /** Defines if timestamp can be used with timer query */
  39365. canUseTimestampForTimerQuery: boolean;
  39366. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39367. multiview?: any;
  39368. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39369. oculusMultiview?: any;
  39370. /** Function used to let the system compiles shaders in background */
  39371. parallelShaderCompile?: {
  39372. COMPLETION_STATUS_KHR: number;
  39373. };
  39374. /** Max number of texture samples for MSAA */
  39375. maxMSAASamples: number;
  39376. /** Defines if the blend min max extension is supported */
  39377. blendMinMax: boolean;
  39378. }
  39379. }
  39380. declare module "babylonjs/States/depthCullingState" {
  39381. import { Nullable } from "babylonjs/types";
  39382. /**
  39383. * @hidden
  39384. **/
  39385. export class DepthCullingState {
  39386. private _isDepthTestDirty;
  39387. private _isDepthMaskDirty;
  39388. private _isDepthFuncDirty;
  39389. private _isCullFaceDirty;
  39390. private _isCullDirty;
  39391. private _isZOffsetDirty;
  39392. private _isFrontFaceDirty;
  39393. private _depthTest;
  39394. private _depthMask;
  39395. private _depthFunc;
  39396. private _cull;
  39397. private _cullFace;
  39398. private _zOffset;
  39399. private _frontFace;
  39400. /**
  39401. * Initializes the state.
  39402. */
  39403. constructor();
  39404. get isDirty(): boolean;
  39405. get zOffset(): number;
  39406. set zOffset(value: number);
  39407. get cullFace(): Nullable<number>;
  39408. set cullFace(value: Nullable<number>);
  39409. get cull(): Nullable<boolean>;
  39410. set cull(value: Nullable<boolean>);
  39411. get depthFunc(): Nullable<number>;
  39412. set depthFunc(value: Nullable<number>);
  39413. get depthMask(): boolean;
  39414. set depthMask(value: boolean);
  39415. get depthTest(): boolean;
  39416. set depthTest(value: boolean);
  39417. get frontFace(): Nullable<number>;
  39418. set frontFace(value: Nullable<number>);
  39419. reset(): void;
  39420. apply(gl: WebGLRenderingContext): void;
  39421. }
  39422. }
  39423. declare module "babylonjs/States/stencilState" {
  39424. /**
  39425. * @hidden
  39426. **/
  39427. export class StencilState {
  39428. /** 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 */
  39429. static readonly ALWAYS: number;
  39430. /** Passed to stencilOperation to specify that stencil value must be kept */
  39431. static readonly KEEP: number;
  39432. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39433. static readonly REPLACE: number;
  39434. private _isStencilTestDirty;
  39435. private _isStencilMaskDirty;
  39436. private _isStencilFuncDirty;
  39437. private _isStencilOpDirty;
  39438. private _stencilTest;
  39439. private _stencilMask;
  39440. private _stencilFunc;
  39441. private _stencilFuncRef;
  39442. private _stencilFuncMask;
  39443. private _stencilOpStencilFail;
  39444. private _stencilOpDepthFail;
  39445. private _stencilOpStencilDepthPass;
  39446. get isDirty(): boolean;
  39447. get stencilFunc(): number;
  39448. set stencilFunc(value: number);
  39449. get stencilFuncRef(): number;
  39450. set stencilFuncRef(value: number);
  39451. get stencilFuncMask(): number;
  39452. set stencilFuncMask(value: number);
  39453. get stencilOpStencilFail(): number;
  39454. set stencilOpStencilFail(value: number);
  39455. get stencilOpDepthFail(): number;
  39456. set stencilOpDepthFail(value: number);
  39457. get stencilOpStencilDepthPass(): number;
  39458. set stencilOpStencilDepthPass(value: number);
  39459. get stencilMask(): number;
  39460. set stencilMask(value: number);
  39461. get stencilTest(): boolean;
  39462. set stencilTest(value: boolean);
  39463. constructor();
  39464. reset(): void;
  39465. apply(gl: WebGLRenderingContext): void;
  39466. }
  39467. }
  39468. declare module "babylonjs/States/alphaCullingState" {
  39469. /**
  39470. * @hidden
  39471. **/
  39472. export class AlphaState {
  39473. private _isAlphaBlendDirty;
  39474. private _isBlendFunctionParametersDirty;
  39475. private _isBlendEquationParametersDirty;
  39476. private _isBlendConstantsDirty;
  39477. private _alphaBlend;
  39478. private _blendFunctionParameters;
  39479. private _blendEquationParameters;
  39480. private _blendConstants;
  39481. /**
  39482. * Initializes the state.
  39483. */
  39484. constructor();
  39485. get isDirty(): boolean;
  39486. get alphaBlend(): boolean;
  39487. set alphaBlend(value: boolean);
  39488. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39489. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39490. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39491. reset(): void;
  39492. apply(gl: WebGLRenderingContext): void;
  39493. }
  39494. }
  39495. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  39496. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39497. /** @hidden */
  39498. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39499. attributeProcessor(attribute: string): string;
  39500. varyingProcessor(varying: string, isFragment: boolean): string;
  39501. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  39502. }
  39503. }
  39504. declare module "babylonjs/Engines/instancingAttributeInfo" {
  39505. /**
  39506. * Interface for attribute information associated with buffer instanciation
  39507. */
  39508. export interface InstancingAttributeInfo {
  39509. /**
  39510. * Name of the GLSL attribute
  39511. * if attribute index is not specified, this is used to retrieve the index from the effect
  39512. */
  39513. attributeName: string;
  39514. /**
  39515. * Index/offset of the attribute in the vertex shader
  39516. * if not specified, this will be computes from the name.
  39517. */
  39518. index?: number;
  39519. /**
  39520. * size of the attribute, 1, 2, 3 or 4
  39521. */
  39522. attributeSize: number;
  39523. /**
  39524. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39525. */
  39526. offset: number;
  39527. /**
  39528. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39529. * default to 1
  39530. */
  39531. divisor?: number;
  39532. /**
  39533. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39534. * default is FLOAT
  39535. */
  39536. attributeType?: number;
  39537. /**
  39538. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39539. */
  39540. normalized?: boolean;
  39541. }
  39542. }
  39543. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  39544. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39545. import { Nullable } from "babylonjs/types";
  39546. module "babylonjs/Engines/thinEngine" {
  39547. interface ThinEngine {
  39548. /**
  39549. * Update a video texture
  39550. * @param texture defines the texture to update
  39551. * @param video defines the video element to use
  39552. * @param invertY defines if data must be stored with Y axis inverted
  39553. */
  39554. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39555. }
  39556. }
  39557. }
  39558. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  39559. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39560. import { Nullable } from "babylonjs/types";
  39561. module "babylonjs/Engines/thinEngine" {
  39562. interface ThinEngine {
  39563. /**
  39564. * Creates a dynamic texture
  39565. * @param width defines the width of the texture
  39566. * @param height defines the height of the texture
  39567. * @param generateMipMaps defines if the engine should generate the mip levels
  39568. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39569. * @returns the dynamic texture inside an InternalTexture
  39570. */
  39571. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39572. /**
  39573. * Update the content of a dynamic texture
  39574. * @param texture defines the texture to update
  39575. * @param canvas defines the canvas containing the source
  39576. * @param invertY defines if data must be stored with Y axis inverted
  39577. * @param premulAlpha defines if alpha is stored as premultiplied
  39578. * @param format defines the format of the data
  39579. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39580. */
  39581. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39582. }
  39583. }
  39584. }
  39585. declare module "babylonjs/Materials/Textures/videoTexture" {
  39586. import { Observable } from "babylonjs/Misc/observable";
  39587. import { Nullable } from "babylonjs/types";
  39588. import { Scene } from "babylonjs/scene";
  39589. import { Texture } from "babylonjs/Materials/Textures/texture";
  39590. import "babylonjs/Engines/Extensions/engine.videoTexture";
  39591. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  39592. /**
  39593. * Settings for finer control over video usage
  39594. */
  39595. export interface VideoTextureSettings {
  39596. /**
  39597. * Applies `autoplay` to video, if specified
  39598. */
  39599. autoPlay?: boolean;
  39600. /**
  39601. * Applies `muted` to video, if specified
  39602. */
  39603. muted?: boolean;
  39604. /**
  39605. * Applies `loop` to video, if specified
  39606. */
  39607. loop?: boolean;
  39608. /**
  39609. * Automatically updates internal texture from video at every frame in the render loop
  39610. */
  39611. autoUpdateTexture: boolean;
  39612. /**
  39613. * Image src displayed during the video loading or until the user interacts with the video.
  39614. */
  39615. poster?: string;
  39616. }
  39617. /**
  39618. * If you want to display a video in your scene, this is the special texture for that.
  39619. * This special texture works similar to other textures, with the exception of a few parameters.
  39620. * @see https://doc.babylonjs.com/how_to/video_texture
  39621. */
  39622. export class VideoTexture extends Texture {
  39623. /**
  39624. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39625. */
  39626. readonly autoUpdateTexture: boolean;
  39627. /**
  39628. * The video instance used by the texture internally
  39629. */
  39630. readonly video: HTMLVideoElement;
  39631. private _onUserActionRequestedObservable;
  39632. /**
  39633. * Event triggerd when a dom action is required by the user to play the video.
  39634. * This happens due to recent changes in browser policies preventing video to auto start.
  39635. */
  39636. get onUserActionRequestedObservable(): Observable<Texture>;
  39637. private _generateMipMaps;
  39638. private _stillImageCaptured;
  39639. private _displayingPosterTexture;
  39640. private _settings;
  39641. private _createInternalTextureOnEvent;
  39642. private _frameId;
  39643. private _currentSrc;
  39644. /**
  39645. * Creates a video texture.
  39646. * If you want to display a video in your scene, this is the special texture for that.
  39647. * This special texture works similar to other textures, with the exception of a few parameters.
  39648. * @see https://doc.babylonjs.com/how_to/video_texture
  39649. * @param name optional name, will detect from video source, if not defined
  39650. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39651. * @param scene is obviously the current scene.
  39652. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39653. * @param invertY is false by default but can be used to invert video on Y axis
  39654. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39655. * @param settings allows finer control over video usage
  39656. */
  39657. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39658. private _getName;
  39659. private _getVideo;
  39660. private _createInternalTexture;
  39661. private reset;
  39662. /**
  39663. * @hidden Internal method to initiate `update`.
  39664. */
  39665. _rebuild(): void;
  39666. /**
  39667. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39668. */
  39669. update(): void;
  39670. /**
  39671. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39672. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39673. */
  39674. updateTexture(isVisible: boolean): void;
  39675. protected _updateInternalTexture: () => void;
  39676. /**
  39677. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39678. * @param url New url.
  39679. */
  39680. updateURL(url: string): void;
  39681. /**
  39682. * Clones the texture.
  39683. * @returns the cloned texture
  39684. */
  39685. clone(): VideoTexture;
  39686. /**
  39687. * Dispose the texture and release its associated resources.
  39688. */
  39689. dispose(): void;
  39690. /**
  39691. * Creates a video texture straight from a stream.
  39692. * @param scene Define the scene the texture should be created in
  39693. * @param stream Define the stream the texture should be created from
  39694. * @returns The created video texture as a promise
  39695. */
  39696. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39697. /**
  39698. * Creates a video texture straight from your WebCam video feed.
  39699. * @param scene Define the scene the texture should be created in
  39700. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39701. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39702. * @returns The created video texture as a promise
  39703. */
  39704. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39705. minWidth: number;
  39706. maxWidth: number;
  39707. minHeight: number;
  39708. maxHeight: number;
  39709. deviceId: string;
  39710. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39711. /**
  39712. * Creates a video texture straight from your WebCam video feed.
  39713. * @param scene Define the scene the texture should be created in
  39714. * @param onReady Define a callback to triggered once the texture will be ready
  39715. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39716. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39717. */
  39718. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39719. minWidth: number;
  39720. maxWidth: number;
  39721. minHeight: number;
  39722. maxHeight: number;
  39723. deviceId: string;
  39724. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39725. }
  39726. }
  39727. declare module "babylonjs/Engines/thinEngine" {
  39728. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  39729. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  39730. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39731. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39732. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  39733. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  39734. import { Observable } from "babylonjs/Misc/observable";
  39735. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  39736. import { StencilState } from "babylonjs/States/stencilState";
  39737. import { AlphaState } from "babylonjs/States/alphaCullingState";
  39738. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39739. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  39740. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39741. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39742. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39743. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  39744. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  39745. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  39746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39747. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39748. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39749. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  39750. import { WebRequest } from "babylonjs/Misc/webRequest";
  39751. import { LoadFileError } from "babylonjs/Misc/fileTools";
  39752. /**
  39753. * Defines the interface used by objects working like Scene
  39754. * @hidden
  39755. */
  39756. export interface ISceneLike {
  39757. _addPendingData(data: any): void;
  39758. _removePendingData(data: any): void;
  39759. offlineProvider: IOfflineProvider;
  39760. }
  39761. /**
  39762. * Information about the current host
  39763. */
  39764. export interface HostInformation {
  39765. /**
  39766. * Defines if the current host is a mobile
  39767. */
  39768. isMobile: boolean;
  39769. }
  39770. /** Interface defining initialization parameters for Engine class */
  39771. export interface EngineOptions extends WebGLContextAttributes {
  39772. /**
  39773. * Defines if the engine should no exceed a specified device ratio
  39774. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39775. */
  39776. limitDeviceRatio?: number;
  39777. /**
  39778. * Defines if webvr should be enabled automatically
  39779. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39780. */
  39781. autoEnableWebVR?: boolean;
  39782. /**
  39783. * Defines if webgl2 should be turned off even if supported
  39784. * @see https://doc.babylonjs.com/features/webgl2
  39785. */
  39786. disableWebGL2Support?: boolean;
  39787. /**
  39788. * Defines if webaudio should be initialized as well
  39789. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39790. */
  39791. audioEngine?: boolean;
  39792. /**
  39793. * Defines if animations should run using a deterministic lock step
  39794. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39795. */
  39796. deterministicLockstep?: boolean;
  39797. /** Defines the maximum steps to use with deterministic lock step mode */
  39798. lockstepMaxSteps?: number;
  39799. /** Defines the seconds between each deterministic lock step */
  39800. timeStep?: number;
  39801. /**
  39802. * Defines that engine should ignore context lost events
  39803. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39804. */
  39805. doNotHandleContextLost?: boolean;
  39806. /**
  39807. * Defines that engine should ignore modifying touch action attribute and style
  39808. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39809. */
  39810. doNotHandleTouchAction?: boolean;
  39811. /**
  39812. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39813. */
  39814. useHighPrecisionFloats?: boolean;
  39815. /**
  39816. * Make the canvas XR Compatible for XR sessions
  39817. */
  39818. xrCompatible?: boolean;
  39819. /**
  39820. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39821. */
  39822. useHighPrecisionMatrix?: boolean;
  39823. /**
  39824. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39825. */
  39826. failIfMajorPerformanceCaveat?: boolean;
  39827. }
  39828. /**
  39829. * The base engine class (root of all engines)
  39830. */
  39831. export class ThinEngine {
  39832. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39833. static ExceptionList: ({
  39834. key: string;
  39835. capture: string;
  39836. captureConstraint: number;
  39837. targets: string[];
  39838. } | {
  39839. key: string;
  39840. capture: null;
  39841. captureConstraint: null;
  39842. targets: string[];
  39843. })[];
  39844. /** @hidden */
  39845. static _TextureLoaders: IInternalTextureLoader[];
  39846. /**
  39847. * Returns the current npm package of the sdk
  39848. */
  39849. static get NpmPackage(): string;
  39850. /**
  39851. * Returns the current version of the framework
  39852. */
  39853. static get Version(): string;
  39854. /**
  39855. * Returns a string describing the current engine
  39856. */
  39857. get description(): string;
  39858. /**
  39859. * Gets or sets the epsilon value used by collision engine
  39860. */
  39861. static CollisionsEpsilon: number;
  39862. /**
  39863. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39864. */
  39865. static get ShadersRepository(): string;
  39866. static set ShadersRepository(value: string);
  39867. /** @hidden */
  39868. _shaderProcessor: IShaderProcessor;
  39869. /**
  39870. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39871. */
  39872. forcePOTTextures: boolean;
  39873. /**
  39874. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39875. */
  39876. isFullscreen: boolean;
  39877. /**
  39878. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39879. */
  39880. cullBackFaces: boolean;
  39881. /**
  39882. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39883. */
  39884. renderEvenInBackground: boolean;
  39885. /**
  39886. * Gets or sets a boolean indicating that cache can be kept between frames
  39887. */
  39888. preventCacheWipeBetweenFrames: boolean;
  39889. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39890. validateShaderPrograms: boolean;
  39891. /**
  39892. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39893. * This can provide greater z depth for distant objects.
  39894. */
  39895. useReverseDepthBuffer: boolean;
  39896. /**
  39897. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39898. */
  39899. disableUniformBuffers: boolean;
  39900. /** @hidden */
  39901. _uniformBuffers: UniformBuffer[];
  39902. /**
  39903. * Gets a boolean indicating that the engine supports uniform buffers
  39904. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39905. */
  39906. get supportsUniformBuffers(): boolean;
  39907. /** @hidden */
  39908. _gl: WebGLRenderingContext;
  39909. /** @hidden */
  39910. _webGLVersion: number;
  39911. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39912. protected _windowIsBackground: boolean;
  39913. protected _creationOptions: EngineOptions;
  39914. protected _highPrecisionShadersAllowed: boolean;
  39915. /** @hidden */
  39916. get _shouldUseHighPrecisionShader(): boolean;
  39917. /**
  39918. * Gets a boolean indicating that only power of 2 textures are supported
  39919. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39920. */
  39921. get needPOTTextures(): boolean;
  39922. /** @hidden */
  39923. _badOS: boolean;
  39924. /** @hidden */
  39925. _badDesktopOS: boolean;
  39926. private _hardwareScalingLevel;
  39927. /** @hidden */
  39928. _caps: EngineCapabilities;
  39929. private _isStencilEnable;
  39930. private _glVersion;
  39931. private _glRenderer;
  39932. private _glVendor;
  39933. /** @hidden */
  39934. _videoTextureSupported: boolean;
  39935. protected _renderingQueueLaunched: boolean;
  39936. protected _activeRenderLoops: (() => void)[];
  39937. /**
  39938. * Observable signaled when a context lost event is raised
  39939. */
  39940. onContextLostObservable: Observable<ThinEngine>;
  39941. /**
  39942. * Observable signaled when a context restored event is raised
  39943. */
  39944. onContextRestoredObservable: Observable<ThinEngine>;
  39945. private _onContextLost;
  39946. private _onContextRestored;
  39947. protected _contextWasLost: boolean;
  39948. /** @hidden */
  39949. _doNotHandleContextLost: boolean;
  39950. /**
  39951. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  39952. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  39953. */
  39954. get doNotHandleContextLost(): boolean;
  39955. set doNotHandleContextLost(value: boolean);
  39956. /**
  39957. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  39958. */
  39959. disableVertexArrayObjects: boolean;
  39960. /** @hidden */
  39961. protected _colorWrite: boolean;
  39962. /** @hidden */
  39963. protected _colorWriteChanged: boolean;
  39964. /** @hidden */
  39965. protected _depthCullingState: DepthCullingState;
  39966. /** @hidden */
  39967. protected _stencilState: StencilState;
  39968. /** @hidden */
  39969. _alphaState: AlphaState;
  39970. /** @hidden */
  39971. _alphaMode: number;
  39972. /** @hidden */
  39973. _alphaEquation: number;
  39974. /** @hidden */
  39975. _internalTexturesCache: InternalTexture[];
  39976. /** @hidden */
  39977. protected _activeChannel: number;
  39978. private _currentTextureChannel;
  39979. /** @hidden */
  39980. protected _boundTexturesCache: {
  39981. [key: string]: Nullable<InternalTexture>;
  39982. };
  39983. /** @hidden */
  39984. protected _currentEffect: Nullable<Effect>;
  39985. /** @hidden */
  39986. protected _currentProgram: Nullable<WebGLProgram>;
  39987. private _compiledEffects;
  39988. private _vertexAttribArraysEnabled;
  39989. /** @hidden */
  39990. protected _cachedViewport: Nullable<IViewportLike>;
  39991. private _cachedVertexArrayObject;
  39992. /** @hidden */
  39993. protected _cachedVertexBuffers: any;
  39994. /** @hidden */
  39995. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  39996. /** @hidden */
  39997. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  39998. /** @hidden */
  39999. _currentRenderTarget: Nullable<InternalTexture>;
  40000. private _uintIndicesCurrentlySet;
  40001. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40002. /** @hidden */
  40003. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40004. /** @hidden */
  40005. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40006. private _currentBufferPointers;
  40007. private _currentInstanceLocations;
  40008. private _currentInstanceBuffers;
  40009. private _textureUnits;
  40010. /** @hidden */
  40011. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40012. /** @hidden */
  40013. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40014. /** @hidden */
  40015. _boundRenderFunction: any;
  40016. private _vaoRecordInProgress;
  40017. private _mustWipeVertexAttributes;
  40018. private _emptyTexture;
  40019. private _emptyCubeTexture;
  40020. private _emptyTexture3D;
  40021. private _emptyTexture2DArray;
  40022. /** @hidden */
  40023. _frameHandler: number;
  40024. private _nextFreeTextureSlots;
  40025. private _maxSimultaneousTextures;
  40026. private _activeRequests;
  40027. /** @hidden */
  40028. _transformTextureUrl: Nullable<(url: string) => string>;
  40029. /**
  40030. * Gets information about the current host
  40031. */
  40032. hostInformation: HostInformation;
  40033. protected get _supportsHardwareTextureRescaling(): boolean;
  40034. private _framebufferDimensionsObject;
  40035. /**
  40036. * sets the object from which width and height will be taken from when getting render width and height
  40037. * Will fallback to the gl object
  40038. * @param dimensions the framebuffer width and height that will be used.
  40039. */
  40040. set framebufferDimensionsObject(dimensions: Nullable<{
  40041. framebufferWidth: number;
  40042. framebufferHeight: number;
  40043. }>);
  40044. /**
  40045. * Gets the current viewport
  40046. */
  40047. get currentViewport(): Nullable<IViewportLike>;
  40048. /**
  40049. * Gets the default empty texture
  40050. */
  40051. get emptyTexture(): InternalTexture;
  40052. /**
  40053. * Gets the default empty 3D texture
  40054. */
  40055. get emptyTexture3D(): InternalTexture;
  40056. /**
  40057. * Gets the default empty 2D array texture
  40058. */
  40059. get emptyTexture2DArray(): InternalTexture;
  40060. /**
  40061. * Gets the default empty cube texture
  40062. */
  40063. get emptyCubeTexture(): InternalTexture;
  40064. /**
  40065. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40066. */
  40067. readonly premultipliedAlpha: boolean;
  40068. /**
  40069. * Observable event triggered before each texture is initialized
  40070. */
  40071. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40072. /**
  40073. * Creates a new engine
  40074. * @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
  40075. * @param antialias defines enable antialiasing (default: false)
  40076. * @param options defines further options to be sent to the getContext() function
  40077. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40078. */
  40079. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40080. private _rebuildInternalTextures;
  40081. private _rebuildEffects;
  40082. /**
  40083. * Gets a boolean indicating if all created effects are ready
  40084. * @returns true if all effects are ready
  40085. */
  40086. areAllEffectsReady(): boolean;
  40087. protected _rebuildBuffers(): void;
  40088. protected _initGLContext(): void;
  40089. /**
  40090. * Gets version of the current webGL context
  40091. */
  40092. get webGLVersion(): number;
  40093. /**
  40094. * Gets a string identifying the name of the class
  40095. * @returns "Engine" string
  40096. */
  40097. getClassName(): string;
  40098. /**
  40099. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40100. */
  40101. get isStencilEnable(): boolean;
  40102. /** @hidden */
  40103. _prepareWorkingCanvas(): void;
  40104. /**
  40105. * Reset the texture cache to empty state
  40106. */
  40107. resetTextureCache(): void;
  40108. /**
  40109. * Gets an object containing information about the current webGL context
  40110. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40111. */
  40112. getGlInfo(): {
  40113. vendor: string;
  40114. renderer: string;
  40115. version: string;
  40116. };
  40117. /**
  40118. * Defines the hardware scaling level.
  40119. * By default the hardware scaling level is computed from the window device ratio.
  40120. * 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.
  40121. * @param level defines the level to use
  40122. */
  40123. setHardwareScalingLevel(level: number): void;
  40124. /**
  40125. * Gets the current hardware scaling level.
  40126. * By default the hardware scaling level is computed from the window device ratio.
  40127. * 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.
  40128. * @returns a number indicating the current hardware scaling level
  40129. */
  40130. getHardwareScalingLevel(): number;
  40131. /**
  40132. * Gets the list of loaded textures
  40133. * @returns an array containing all loaded textures
  40134. */
  40135. getLoadedTexturesCache(): InternalTexture[];
  40136. /**
  40137. * Gets the object containing all engine capabilities
  40138. * @returns the EngineCapabilities object
  40139. */
  40140. getCaps(): EngineCapabilities;
  40141. /**
  40142. * stop executing a render loop function and remove it from the execution array
  40143. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40144. */
  40145. stopRenderLoop(renderFunction?: () => void): void;
  40146. /** @hidden */
  40147. _renderLoop(): void;
  40148. /**
  40149. * Gets the HTML canvas attached with the current webGL context
  40150. * @returns a HTML canvas
  40151. */
  40152. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40153. /**
  40154. * Gets host window
  40155. * @returns the host window object
  40156. */
  40157. getHostWindow(): Nullable<Window>;
  40158. /**
  40159. * Gets the current render width
  40160. * @param useScreen defines if screen size must be used (or the current render target if any)
  40161. * @returns a number defining the current render width
  40162. */
  40163. getRenderWidth(useScreen?: boolean): number;
  40164. /**
  40165. * Gets the current render height
  40166. * @param useScreen defines if screen size must be used (or the current render target if any)
  40167. * @returns a number defining the current render height
  40168. */
  40169. getRenderHeight(useScreen?: boolean): number;
  40170. /**
  40171. * Can be used to override the current requestAnimationFrame requester.
  40172. * @hidden
  40173. */
  40174. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40175. /**
  40176. * Register and execute a render loop. The engine can have more than one render function
  40177. * @param renderFunction defines the function to continuously execute
  40178. */
  40179. runRenderLoop(renderFunction: () => void): void;
  40180. /**
  40181. * Clear the current render buffer or the current render target (if any is set up)
  40182. * @param color defines the color to use
  40183. * @param backBuffer defines if the back buffer must be cleared
  40184. * @param depth defines if the depth buffer must be cleared
  40185. * @param stencil defines if the stencil buffer must be cleared
  40186. */
  40187. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40188. private _viewportCached;
  40189. /** @hidden */
  40190. _viewport(x: number, y: number, width: number, height: number): void;
  40191. /**
  40192. * Set the WebGL's viewport
  40193. * @param viewport defines the viewport element to be used
  40194. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40195. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40196. */
  40197. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40198. /**
  40199. * Begin a new frame
  40200. */
  40201. beginFrame(): void;
  40202. /**
  40203. * Enf the current frame
  40204. */
  40205. endFrame(): void;
  40206. /**
  40207. * Resize the view according to the canvas' size
  40208. */
  40209. resize(): void;
  40210. /**
  40211. * Force a specific size of the canvas
  40212. * @param width defines the new canvas' width
  40213. * @param height defines the new canvas' height
  40214. * @returns true if the size was changed
  40215. */
  40216. setSize(width: number, height: number): boolean;
  40217. /**
  40218. * Binds the frame buffer to the specified texture.
  40219. * @param texture The texture to render to or null for the default canvas
  40220. * @param faceIndex The face of the texture to render to in case of cube texture
  40221. * @param requiredWidth The width of the target to render to
  40222. * @param requiredHeight The height of the target to render to
  40223. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40224. * @param lodLevel defines the lod level to bind to the frame buffer
  40225. * @param layer defines the 2d array index to bind to frame buffer to
  40226. */
  40227. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40228. /** @hidden */
  40229. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40230. /**
  40231. * Unbind the current render target texture from the webGL context
  40232. * @param texture defines the render target texture to unbind
  40233. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40234. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40235. */
  40236. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40237. /**
  40238. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40239. */
  40240. flushFramebuffer(): void;
  40241. /**
  40242. * Unbind the current render target and bind the default framebuffer
  40243. */
  40244. restoreDefaultFramebuffer(): void;
  40245. /** @hidden */
  40246. protected _resetVertexBufferBinding(): void;
  40247. /**
  40248. * Creates a vertex buffer
  40249. * @param data the data for the vertex buffer
  40250. * @returns the new WebGL static buffer
  40251. */
  40252. createVertexBuffer(data: DataArray): DataBuffer;
  40253. private _createVertexBuffer;
  40254. /**
  40255. * Creates a dynamic vertex buffer
  40256. * @param data the data for the dynamic vertex buffer
  40257. * @returns the new WebGL dynamic buffer
  40258. */
  40259. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40260. protected _resetIndexBufferBinding(): void;
  40261. /**
  40262. * Creates a new index buffer
  40263. * @param indices defines the content of the index buffer
  40264. * @param updatable defines if the index buffer must be updatable
  40265. * @returns a new webGL buffer
  40266. */
  40267. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40268. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40269. /**
  40270. * Bind a webGL buffer to the webGL context
  40271. * @param buffer defines the buffer to bind
  40272. */
  40273. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40274. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40275. private bindBuffer;
  40276. /**
  40277. * update the bound buffer with the given data
  40278. * @param data defines the data to update
  40279. */
  40280. updateArrayBuffer(data: Float32Array): void;
  40281. private _vertexAttribPointer;
  40282. /** @hidden */
  40283. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40284. private _bindVertexBuffersAttributes;
  40285. /**
  40286. * Records a vertex array object
  40287. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40288. * @param vertexBuffers defines the list of vertex buffers to store
  40289. * @param indexBuffer defines the index buffer to store
  40290. * @param effect defines the effect to store
  40291. * @returns the new vertex array object
  40292. */
  40293. recordVertexArrayObject(vertexBuffers: {
  40294. [key: string]: VertexBuffer;
  40295. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40296. /**
  40297. * Bind a specific vertex array object
  40298. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40299. * @param vertexArrayObject defines the vertex array object to bind
  40300. * @param indexBuffer defines the index buffer to bind
  40301. */
  40302. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40303. /**
  40304. * Bind webGl buffers directly to the webGL context
  40305. * @param vertexBuffer defines the vertex buffer to bind
  40306. * @param indexBuffer defines the index buffer to bind
  40307. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40308. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40309. * @param effect defines the effect associated with the vertex buffer
  40310. */
  40311. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40312. private _unbindVertexArrayObject;
  40313. /**
  40314. * Bind a list of vertex buffers to the webGL context
  40315. * @param vertexBuffers defines the list of vertex buffers to bind
  40316. * @param indexBuffer defines the index buffer to bind
  40317. * @param effect defines the effect associated with the vertex buffers
  40318. */
  40319. bindBuffers(vertexBuffers: {
  40320. [key: string]: Nullable<VertexBuffer>;
  40321. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40322. /**
  40323. * Unbind all instance attributes
  40324. */
  40325. unbindInstanceAttributes(): void;
  40326. /**
  40327. * Release and free the memory of a vertex array object
  40328. * @param vao defines the vertex array object to delete
  40329. */
  40330. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40331. /** @hidden */
  40332. _releaseBuffer(buffer: DataBuffer): boolean;
  40333. protected _deleteBuffer(buffer: DataBuffer): void;
  40334. /**
  40335. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40336. * @param instancesBuffer defines the webGL buffer to update and bind
  40337. * @param data defines the data to store in the buffer
  40338. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40339. */
  40340. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40341. /**
  40342. * Bind the content of a webGL buffer used with instantiation
  40343. * @param instancesBuffer defines the webGL buffer to bind
  40344. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40345. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40346. */
  40347. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40348. /**
  40349. * Disable the instance attribute corresponding to the name in parameter
  40350. * @param name defines the name of the attribute to disable
  40351. */
  40352. disableInstanceAttributeByName(name: string): void;
  40353. /**
  40354. * Disable the instance attribute corresponding to the location in parameter
  40355. * @param attributeLocation defines the attribute location of the attribute to disable
  40356. */
  40357. disableInstanceAttribute(attributeLocation: number): void;
  40358. /**
  40359. * Disable the attribute corresponding to the location in parameter
  40360. * @param attributeLocation defines the attribute location of the attribute to disable
  40361. */
  40362. disableAttributeByIndex(attributeLocation: number): void;
  40363. /**
  40364. * Send a draw order
  40365. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40366. * @param indexStart defines the starting index
  40367. * @param indexCount defines the number of index to draw
  40368. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40369. */
  40370. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40371. /**
  40372. * Draw a list of points
  40373. * @param verticesStart defines the index of first vertex to draw
  40374. * @param verticesCount defines the count of vertices to draw
  40375. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40376. */
  40377. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40378. /**
  40379. * Draw a list of unindexed primitives
  40380. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40381. * @param verticesStart defines the index of first vertex to draw
  40382. * @param verticesCount defines the count of vertices to draw
  40383. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40384. */
  40385. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40386. /**
  40387. * Draw a list of indexed primitives
  40388. * @param fillMode defines the primitive to use
  40389. * @param indexStart defines the starting index
  40390. * @param indexCount defines the number of index to draw
  40391. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40392. */
  40393. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40394. /**
  40395. * Draw a list of unindexed primitives
  40396. * @param fillMode defines the primitive to use
  40397. * @param verticesStart defines the index of first vertex to draw
  40398. * @param verticesCount defines the count of vertices to draw
  40399. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40400. */
  40401. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40402. private _drawMode;
  40403. /** @hidden */
  40404. protected _reportDrawCall(): void;
  40405. /** @hidden */
  40406. _releaseEffect(effect: Effect): void;
  40407. /** @hidden */
  40408. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40409. /**
  40410. * Create a new effect (used to store vertex/fragment shaders)
  40411. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40412. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40413. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40414. * @param samplers defines an array of string used to represent textures
  40415. * @param defines defines the string containing the defines to use to compile the shaders
  40416. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40417. * @param onCompiled defines a function to call when the effect creation is successful
  40418. * @param onError defines a function to call when the effect creation has failed
  40419. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40420. * @returns the new Effect
  40421. */
  40422. 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;
  40423. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40424. private _compileShader;
  40425. private _compileRawShader;
  40426. /** @hidden */
  40427. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40428. /**
  40429. * Directly creates a webGL program
  40430. * @param pipelineContext defines the pipeline context to attach to
  40431. * @param vertexCode defines the vertex shader code to use
  40432. * @param fragmentCode defines the fragment shader code to use
  40433. * @param context defines the webGL context to use (if not set, the current one will be used)
  40434. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40435. * @returns the new webGL program
  40436. */
  40437. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40438. /**
  40439. * Creates a webGL program
  40440. * @param pipelineContext defines the pipeline context to attach to
  40441. * @param vertexCode defines the vertex shader code to use
  40442. * @param fragmentCode defines the fragment shader code to use
  40443. * @param defines defines the string containing the defines to use to compile the shaders
  40444. * @param context defines the webGL context to use (if not set, the current one will be used)
  40445. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40446. * @returns the new webGL program
  40447. */
  40448. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40449. /**
  40450. * Creates a new pipeline context
  40451. * @returns the new pipeline
  40452. */
  40453. createPipelineContext(): IPipelineContext;
  40454. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40455. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40456. /** @hidden */
  40457. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  40458. /** @hidden */
  40459. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40460. /** @hidden */
  40461. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40462. /**
  40463. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40464. * @param pipelineContext defines the pipeline context to use
  40465. * @param uniformsNames defines the list of uniform names
  40466. * @returns an array of webGL uniform locations
  40467. */
  40468. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40469. /**
  40470. * Gets the lsit of active attributes for a given webGL program
  40471. * @param pipelineContext defines the pipeline context to use
  40472. * @param attributesNames defines the list of attribute names to get
  40473. * @returns an array of indices indicating the offset of each attribute
  40474. */
  40475. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40476. /**
  40477. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40478. * @param effect defines the effect to activate
  40479. */
  40480. enableEffect(effect: Nullable<Effect>): void;
  40481. /**
  40482. * Set the value of an uniform to a number (int)
  40483. * @param uniform defines the webGL uniform location where to store the value
  40484. * @param value defines the int number to store
  40485. * @returns true if the value was set
  40486. */
  40487. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40488. /**
  40489. * Set the value of an uniform to an array of int32
  40490. * @param uniform defines the webGL uniform location where to store the value
  40491. * @param array defines the array of int32 to store
  40492. * @returns true if the value was set
  40493. */
  40494. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40495. /**
  40496. * Set the value of an uniform to an array of int32 (stored as vec2)
  40497. * @param uniform defines the webGL uniform location where to store the value
  40498. * @param array defines the array of int32 to store
  40499. * @returns true if the value was set
  40500. */
  40501. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40502. /**
  40503. * Set the value of an uniform to an array of int32 (stored as vec3)
  40504. * @param uniform defines the webGL uniform location where to store the value
  40505. * @param array defines the array of int32 to store
  40506. * @returns true if the value was set
  40507. */
  40508. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40509. /**
  40510. * Set the value of an uniform to an array of int32 (stored as vec4)
  40511. * @param uniform defines the webGL uniform location where to store the value
  40512. * @param array defines the array of int32 to store
  40513. * @returns true if the value was set
  40514. */
  40515. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40516. /**
  40517. * Set the value of an uniform to an array of number
  40518. * @param uniform defines the webGL uniform location where to store the value
  40519. * @param array defines the array of number to store
  40520. * @returns true if the value was set
  40521. */
  40522. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40523. /**
  40524. * Set the value of an uniform to an array of number (stored as vec2)
  40525. * @param uniform defines the webGL uniform location where to store the value
  40526. * @param array defines the array of number to store
  40527. * @returns true if the value was set
  40528. */
  40529. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40530. /**
  40531. * Set the value of an uniform to an array of number (stored as vec3)
  40532. * @param uniform defines the webGL uniform location where to store the value
  40533. * @param array defines the array of number to store
  40534. * @returns true if the value was set
  40535. */
  40536. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40537. /**
  40538. * Set the value of an uniform to an array of number (stored as vec4)
  40539. * @param uniform defines the webGL uniform location where to store the value
  40540. * @param array defines the array of number to store
  40541. * @returns true if the value was set
  40542. */
  40543. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40544. /**
  40545. * Set the value of an uniform to an array of float32 (stored as matrices)
  40546. * @param uniform defines the webGL uniform location where to store the value
  40547. * @param matrices defines the array of float32 to store
  40548. * @returns true if the value was set
  40549. */
  40550. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40551. /**
  40552. * Set the value of an uniform to a matrix (3x3)
  40553. * @param uniform defines the webGL uniform location where to store the value
  40554. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40555. * @returns true if the value was set
  40556. */
  40557. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40558. /**
  40559. * Set the value of an uniform to a matrix (2x2)
  40560. * @param uniform defines the webGL uniform location where to store the value
  40561. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40562. * @returns true if the value was set
  40563. */
  40564. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40565. /**
  40566. * Set the value of an uniform to a number (float)
  40567. * @param uniform defines the webGL uniform location where to store the value
  40568. * @param value defines the float number to store
  40569. * @returns true if the value was transfered
  40570. */
  40571. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40572. /**
  40573. * Set the value of an uniform to a vec2
  40574. * @param uniform defines the webGL uniform location where to store the value
  40575. * @param x defines the 1st component of the value
  40576. * @param y defines the 2nd component of the value
  40577. * @returns true if the value was set
  40578. */
  40579. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40580. /**
  40581. * Set the value of an uniform to a vec3
  40582. * @param uniform defines the webGL uniform location where to store the value
  40583. * @param x defines the 1st component of the value
  40584. * @param y defines the 2nd component of the value
  40585. * @param z defines the 3rd component of the value
  40586. * @returns true if the value was set
  40587. */
  40588. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40589. /**
  40590. * Set the value of an uniform to a vec4
  40591. * @param uniform defines the webGL uniform location where to store the value
  40592. * @param x defines the 1st component of the value
  40593. * @param y defines the 2nd component of the value
  40594. * @param z defines the 3rd component of the value
  40595. * @param w defines the 4th component of the value
  40596. * @returns true if the value was set
  40597. */
  40598. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40599. /**
  40600. * Apply all cached states (depth, culling, stencil and alpha)
  40601. */
  40602. applyStates(): void;
  40603. /**
  40604. * Enable or disable color writing
  40605. * @param enable defines the state to set
  40606. */
  40607. setColorWrite(enable: boolean): void;
  40608. /**
  40609. * Gets a boolean indicating if color writing is enabled
  40610. * @returns the current color writing state
  40611. */
  40612. getColorWrite(): boolean;
  40613. /**
  40614. * Gets the depth culling state manager
  40615. */
  40616. get depthCullingState(): DepthCullingState;
  40617. /**
  40618. * Gets the alpha state manager
  40619. */
  40620. get alphaState(): AlphaState;
  40621. /**
  40622. * Gets the stencil state manager
  40623. */
  40624. get stencilState(): StencilState;
  40625. /**
  40626. * Clears the list of texture accessible through engine.
  40627. * This can help preventing texture load conflict due to name collision.
  40628. */
  40629. clearInternalTexturesCache(): void;
  40630. /**
  40631. * Force the entire cache to be cleared
  40632. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40633. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40634. */
  40635. wipeCaches(bruteForce?: boolean): void;
  40636. /** @hidden */
  40637. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40638. min: number;
  40639. mag: number;
  40640. };
  40641. /** @hidden */
  40642. _createTexture(): WebGLTexture;
  40643. /**
  40644. * Usually called from Texture.ts.
  40645. * Passed information to create a WebGLTexture
  40646. * @param url defines a value which contains one of the following:
  40647. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40648. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40649. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40650. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40651. * @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)
  40652. * @param scene needed for loading to the correct scene
  40653. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40654. * @param onLoad optional callback to be called upon successful completion
  40655. * @param onError optional callback to be called upon failure
  40656. * @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
  40657. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40658. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40659. * @param forcedExtension defines the extension to use to pick the right loader
  40660. * @param mimeType defines an optional mime type
  40661. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40662. */
  40663. 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;
  40664. /**
  40665. * Loads an image as an HTMLImageElement.
  40666. * @param input url string, ArrayBuffer, or Blob to load
  40667. * @param onLoad callback called when the image successfully loads
  40668. * @param onError callback called when the image fails to load
  40669. * @param offlineProvider offline provider for caching
  40670. * @param mimeType optional mime type
  40671. * @returns the HTMLImageElement of the loaded image
  40672. * @hidden
  40673. */
  40674. 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>;
  40675. /**
  40676. * @hidden
  40677. */
  40678. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40679. private _unpackFlipYCached;
  40680. /**
  40681. * In case you are sharing the context with other applications, it might
  40682. * be interested to not cache the unpack flip y state to ensure a consistent
  40683. * value would be set.
  40684. */
  40685. enableUnpackFlipYCached: boolean;
  40686. /** @hidden */
  40687. _unpackFlipY(value: boolean): void;
  40688. /** @hidden */
  40689. _getUnpackAlignement(): number;
  40690. private _getTextureTarget;
  40691. /**
  40692. * Update the sampling mode of a given texture
  40693. * @param samplingMode defines the required sampling mode
  40694. * @param texture defines the texture to update
  40695. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40696. */
  40697. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40698. /**
  40699. * Update the sampling mode of a given texture
  40700. * @param texture defines the texture to update
  40701. * @param wrapU defines the texture wrap mode of the u coordinates
  40702. * @param wrapV defines the texture wrap mode of the v coordinates
  40703. * @param wrapR defines the texture wrap mode of the r coordinates
  40704. */
  40705. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40706. /** @hidden */
  40707. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40708. width: number;
  40709. height: number;
  40710. layers?: number;
  40711. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  40712. /** @hidden */
  40713. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40714. /** @hidden */
  40715. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  40716. /**
  40717. * Update a portion of an internal texture
  40718. * @param texture defines the texture to update
  40719. * @param imageData defines the data to store into the texture
  40720. * @param xOffset defines the x coordinates of the update rectangle
  40721. * @param yOffset defines the y coordinates of the update rectangle
  40722. * @param width defines the width of the update rectangle
  40723. * @param height defines the height of the update rectangle
  40724. * @param faceIndex defines the face index if texture is a cube (0 by default)
  40725. * @param lod defines the lod level to update (0 by default)
  40726. */
  40727. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  40728. /** @hidden */
  40729. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40730. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  40731. private _prepareWebGLTexture;
  40732. /** @hidden */
  40733. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  40734. private _getDepthStencilBuffer;
  40735. /** @hidden */
  40736. _releaseFramebufferObjects(texture: InternalTexture): void;
  40737. /** @hidden */
  40738. _releaseTexture(texture: InternalTexture): void;
  40739. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  40740. protected _setProgram(program: WebGLProgram): void;
  40741. protected _boundUniforms: {
  40742. [key: number]: WebGLUniformLocation;
  40743. };
  40744. /**
  40745. * Binds an effect to the webGL context
  40746. * @param effect defines the effect to bind
  40747. */
  40748. bindSamplers(effect: Effect): void;
  40749. private _activateCurrentTexture;
  40750. /** @hidden */
  40751. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  40752. /** @hidden */
  40753. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  40754. /**
  40755. * Unbind all textures from the webGL context
  40756. */
  40757. unbindAllTextures(): void;
  40758. /**
  40759. * Sets a texture to the according uniform.
  40760. * @param channel The texture channel
  40761. * @param uniform The uniform to set
  40762. * @param texture The texture to apply
  40763. */
  40764. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  40765. private _bindSamplerUniformToChannel;
  40766. private _getTextureWrapMode;
  40767. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  40768. /**
  40769. * Sets an array of texture to the webGL context
  40770. * @param channel defines the channel where the texture array must be set
  40771. * @param uniform defines the associated uniform location
  40772. * @param textures defines the array of textures to bind
  40773. */
  40774. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  40775. /** @hidden */
  40776. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40777. private _setTextureParameterFloat;
  40778. private _setTextureParameterInteger;
  40779. /**
  40780. * Unbind all vertex attributes from the webGL context
  40781. */
  40782. unbindAllAttributes(): void;
  40783. /**
  40784. * 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
  40785. */
  40786. releaseEffects(): void;
  40787. /**
  40788. * Dispose and release all associated resources
  40789. */
  40790. dispose(): void;
  40791. /**
  40792. * Attach a new callback raised when context lost event is fired
  40793. * @param callback defines the callback to call
  40794. */
  40795. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40796. /**
  40797. * Attach a new callback raised when context restored event is fired
  40798. * @param callback defines the callback to call
  40799. */
  40800. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40801. /**
  40802. * Get the current error code of the webGL context
  40803. * @returns the error code
  40804. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40805. */
  40806. getError(): number;
  40807. private _canRenderToFloatFramebuffer;
  40808. private _canRenderToHalfFloatFramebuffer;
  40809. private _canRenderToFramebuffer;
  40810. /** @hidden */
  40811. _getWebGLTextureType(type: number): number;
  40812. /** @hidden */
  40813. _getInternalFormat(format: number): number;
  40814. /** @hidden */
  40815. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40816. /** @hidden */
  40817. _getRGBAMultiSampleBufferFormat(type: number): number;
  40818. /** @hidden */
  40819. _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;
  40820. /**
  40821. * Loads a file from a url
  40822. * @param url url to load
  40823. * @param onSuccess callback called when the file successfully loads
  40824. * @param onProgress callback called while file is loading (if the server supports this mode)
  40825. * @param offlineProvider defines the offline provider for caching
  40826. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40827. * @param onError callback called when the file fails to load
  40828. * @returns a file request object
  40829. * @hidden
  40830. */
  40831. 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;
  40832. /**
  40833. * Reads pixels from the current frame buffer. Please note that this function can be slow
  40834. * @param x defines the x coordinate of the rectangle where pixels must be read
  40835. * @param y defines the y coordinate of the rectangle where pixels must be read
  40836. * @param width defines the width of the rectangle where pixels must be read
  40837. * @param height defines the height of the rectangle where pixels must be read
  40838. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  40839. * @returns a Uint8Array containing RGBA colors
  40840. */
  40841. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40842. private static _IsSupported;
  40843. private static _HasMajorPerformanceCaveat;
  40844. /**
  40845. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40846. */
  40847. static get IsSupported(): boolean;
  40848. /**
  40849. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40850. * @returns true if the engine can be created
  40851. * @ignorenaming
  40852. */
  40853. static isSupported(): boolean;
  40854. /**
  40855. * 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)
  40856. */
  40857. static get HasMajorPerformanceCaveat(): boolean;
  40858. /**
  40859. * Find the next highest power of two.
  40860. * @param x Number to start search from.
  40861. * @return Next highest power of two.
  40862. */
  40863. static CeilingPOT(x: number): number;
  40864. /**
  40865. * Find the next lowest power of two.
  40866. * @param x Number to start search from.
  40867. * @return Next lowest power of two.
  40868. */
  40869. static FloorPOT(x: number): number;
  40870. /**
  40871. * Find the nearest power of two.
  40872. * @param x Number to start search from.
  40873. * @return Next nearest power of two.
  40874. */
  40875. static NearestPOT(x: number): number;
  40876. /**
  40877. * Get the closest exponent of two
  40878. * @param value defines the value to approximate
  40879. * @param max defines the maximum value to return
  40880. * @param mode defines how to define the closest value
  40881. * @returns closest exponent of two of the given value
  40882. */
  40883. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40884. /**
  40885. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40886. * @param func - the function to be called
  40887. * @param requester - the object that will request the next frame. Falls back to window.
  40888. * @returns frame number
  40889. */
  40890. static QueueNewFrame(func: () => void, requester?: any): number;
  40891. /**
  40892. * Gets host document
  40893. * @returns the host document object
  40894. */
  40895. getHostDocument(): Nullable<Document>;
  40896. }
  40897. }
  40898. declare module "babylonjs/Materials/Textures/internalTexture" {
  40899. import { Observable } from "babylonjs/Misc/observable";
  40900. import { Nullable, int } from "babylonjs/types";
  40901. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40902. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40903. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  40904. /**
  40905. * Defines the source of the internal texture
  40906. */
  40907. export enum InternalTextureSource {
  40908. /**
  40909. * The source of the texture data is unknown
  40910. */
  40911. Unknown = 0,
  40912. /**
  40913. * Texture data comes from an URL
  40914. */
  40915. Url = 1,
  40916. /**
  40917. * Texture data is only used for temporary storage
  40918. */
  40919. Temp = 2,
  40920. /**
  40921. * Texture data comes from raw data (ArrayBuffer)
  40922. */
  40923. Raw = 3,
  40924. /**
  40925. * Texture content is dynamic (video or dynamic texture)
  40926. */
  40927. Dynamic = 4,
  40928. /**
  40929. * Texture content is generated by rendering to it
  40930. */
  40931. RenderTarget = 5,
  40932. /**
  40933. * Texture content is part of a multi render target process
  40934. */
  40935. MultiRenderTarget = 6,
  40936. /**
  40937. * Texture data comes from a cube data file
  40938. */
  40939. Cube = 7,
  40940. /**
  40941. * Texture data comes from a raw cube data
  40942. */
  40943. CubeRaw = 8,
  40944. /**
  40945. * Texture data come from a prefiltered cube data file
  40946. */
  40947. CubePrefiltered = 9,
  40948. /**
  40949. * Texture content is raw 3D data
  40950. */
  40951. Raw3D = 10,
  40952. /**
  40953. * Texture content is raw 2D array data
  40954. */
  40955. Raw2DArray = 11,
  40956. /**
  40957. * Texture content is a depth texture
  40958. */
  40959. Depth = 12,
  40960. /**
  40961. * Texture data comes from a raw cube data encoded with RGBD
  40962. */
  40963. CubeRawRGBD = 13
  40964. }
  40965. /**
  40966. * Class used to store data associated with WebGL texture data for the engine
  40967. * This class should not be used directly
  40968. */
  40969. export class InternalTexture {
  40970. /** @hidden */
  40971. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  40972. /**
  40973. * Defines if the texture is ready
  40974. */
  40975. isReady: boolean;
  40976. /**
  40977. * Defines if the texture is a cube texture
  40978. */
  40979. isCube: boolean;
  40980. /**
  40981. * Defines if the texture contains 3D data
  40982. */
  40983. is3D: boolean;
  40984. /**
  40985. * Defines if the texture contains 2D array data
  40986. */
  40987. is2DArray: boolean;
  40988. /**
  40989. * Defines if the texture contains multiview data
  40990. */
  40991. isMultiview: boolean;
  40992. /**
  40993. * Gets the URL used to load this texture
  40994. */
  40995. url: string;
  40996. /**
  40997. * Gets the sampling mode of the texture
  40998. */
  40999. samplingMode: number;
  41000. /**
  41001. * Gets a boolean indicating if the texture needs mipmaps generation
  41002. */
  41003. generateMipMaps: boolean;
  41004. /**
  41005. * Gets the number of samples used by the texture (WebGL2+ only)
  41006. */
  41007. samples: number;
  41008. /**
  41009. * Gets the type of the texture (int, float...)
  41010. */
  41011. type: number;
  41012. /**
  41013. * Gets the format of the texture (RGB, RGBA...)
  41014. */
  41015. format: number;
  41016. /**
  41017. * Observable called when the texture is loaded
  41018. */
  41019. onLoadedObservable: Observable<InternalTexture>;
  41020. /**
  41021. * Gets the width of the texture
  41022. */
  41023. width: number;
  41024. /**
  41025. * Gets the height of the texture
  41026. */
  41027. height: number;
  41028. /**
  41029. * Gets the depth of the texture
  41030. */
  41031. depth: number;
  41032. /**
  41033. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41034. */
  41035. baseWidth: number;
  41036. /**
  41037. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41038. */
  41039. baseHeight: number;
  41040. /**
  41041. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41042. */
  41043. baseDepth: number;
  41044. /**
  41045. * Gets a boolean indicating if the texture is inverted on Y axis
  41046. */
  41047. invertY: boolean;
  41048. /** @hidden */
  41049. _invertVScale: boolean;
  41050. /** @hidden */
  41051. _associatedChannel: number;
  41052. /** @hidden */
  41053. _source: InternalTextureSource;
  41054. /** @hidden */
  41055. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41056. /** @hidden */
  41057. _bufferView: Nullable<ArrayBufferView>;
  41058. /** @hidden */
  41059. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41060. /** @hidden */
  41061. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41062. /** @hidden */
  41063. _size: number;
  41064. /** @hidden */
  41065. _extension: string;
  41066. /** @hidden */
  41067. _files: Nullable<string[]>;
  41068. /** @hidden */
  41069. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41070. /** @hidden */
  41071. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41072. /** @hidden */
  41073. _framebuffer: Nullable<WebGLFramebuffer>;
  41074. /** @hidden */
  41075. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41076. /** @hidden */
  41077. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41078. /** @hidden */
  41079. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41080. /** @hidden */
  41081. _attachments: Nullable<number[]>;
  41082. /** @hidden */
  41083. _textureArray: Nullable<InternalTexture[]>;
  41084. /** @hidden */
  41085. _cachedCoordinatesMode: Nullable<number>;
  41086. /** @hidden */
  41087. _cachedWrapU: Nullable<number>;
  41088. /** @hidden */
  41089. _cachedWrapV: Nullable<number>;
  41090. /** @hidden */
  41091. _cachedWrapR: Nullable<number>;
  41092. /** @hidden */
  41093. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41094. /** @hidden */
  41095. _isDisabled: boolean;
  41096. /** @hidden */
  41097. _compression: Nullable<string>;
  41098. /** @hidden */
  41099. _generateStencilBuffer: boolean;
  41100. /** @hidden */
  41101. _generateDepthBuffer: boolean;
  41102. /** @hidden */
  41103. _comparisonFunction: number;
  41104. /** @hidden */
  41105. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41106. /** @hidden */
  41107. _lodGenerationScale: number;
  41108. /** @hidden */
  41109. _lodGenerationOffset: number;
  41110. /** @hidden */
  41111. _depthStencilTexture: Nullable<InternalTexture>;
  41112. /** @hidden */
  41113. _colorTextureArray: Nullable<WebGLTexture>;
  41114. /** @hidden */
  41115. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41116. /** @hidden */
  41117. _lodTextureHigh: Nullable<BaseTexture>;
  41118. /** @hidden */
  41119. _lodTextureMid: Nullable<BaseTexture>;
  41120. /** @hidden */
  41121. _lodTextureLow: Nullable<BaseTexture>;
  41122. /** @hidden */
  41123. _isRGBD: boolean;
  41124. /** @hidden */
  41125. _linearSpecularLOD: boolean;
  41126. /** @hidden */
  41127. _irradianceTexture: Nullable<BaseTexture>;
  41128. /** @hidden */
  41129. _webGLTexture: Nullable<WebGLTexture>;
  41130. /** @hidden */
  41131. _references: number;
  41132. /** @hidden */
  41133. _gammaSpace: Nullable<boolean>;
  41134. private _engine;
  41135. /**
  41136. * Gets the Engine the texture belongs to.
  41137. * @returns The babylon engine
  41138. */
  41139. getEngine(): ThinEngine;
  41140. /**
  41141. * Gets the data source type of the texture
  41142. */
  41143. get source(): InternalTextureSource;
  41144. /**
  41145. * Creates a new InternalTexture
  41146. * @param engine defines the engine to use
  41147. * @param source defines the type of data that will be used
  41148. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41149. */
  41150. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41151. /**
  41152. * Increments the number of references (ie. the number of Texture that point to it)
  41153. */
  41154. incrementReferences(): void;
  41155. /**
  41156. * Change the size of the texture (not the size of the content)
  41157. * @param width defines the new width
  41158. * @param height defines the new height
  41159. * @param depth defines the new depth (1 by default)
  41160. */
  41161. updateSize(width: int, height: int, depth?: int): void;
  41162. /** @hidden */
  41163. _rebuild(): void;
  41164. /** @hidden */
  41165. _swapAndDie(target: InternalTexture): void;
  41166. /**
  41167. * Dispose the current allocated resources
  41168. */
  41169. dispose(): void;
  41170. }
  41171. }
  41172. declare module "babylonjs/Audio/analyser" {
  41173. import { Scene } from "babylonjs/scene";
  41174. /**
  41175. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41176. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41177. */
  41178. export class Analyser {
  41179. /**
  41180. * Gets or sets the smoothing
  41181. * @ignorenaming
  41182. */
  41183. SMOOTHING: number;
  41184. /**
  41185. * Gets or sets the FFT table size
  41186. * @ignorenaming
  41187. */
  41188. FFT_SIZE: number;
  41189. /**
  41190. * Gets or sets the bar graph amplitude
  41191. * @ignorenaming
  41192. */
  41193. BARGRAPHAMPLITUDE: number;
  41194. /**
  41195. * Gets or sets the position of the debug canvas
  41196. * @ignorenaming
  41197. */
  41198. DEBUGCANVASPOS: {
  41199. x: number;
  41200. y: number;
  41201. };
  41202. /**
  41203. * Gets or sets the debug canvas size
  41204. * @ignorenaming
  41205. */
  41206. DEBUGCANVASSIZE: {
  41207. width: number;
  41208. height: number;
  41209. };
  41210. private _byteFreqs;
  41211. private _byteTime;
  41212. private _floatFreqs;
  41213. private _webAudioAnalyser;
  41214. private _debugCanvas;
  41215. private _debugCanvasContext;
  41216. private _scene;
  41217. private _registerFunc;
  41218. private _audioEngine;
  41219. /**
  41220. * Creates a new analyser
  41221. * @param scene defines hosting scene
  41222. */
  41223. constructor(scene: Scene);
  41224. /**
  41225. * Get the number of data values you will have to play with for the visualization
  41226. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41227. * @returns a number
  41228. */
  41229. getFrequencyBinCount(): number;
  41230. /**
  41231. * Gets the current frequency data as a byte array
  41232. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41233. * @returns a Uint8Array
  41234. */
  41235. getByteFrequencyData(): Uint8Array;
  41236. /**
  41237. * Gets the current waveform as a byte array
  41238. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41239. * @returns a Uint8Array
  41240. */
  41241. getByteTimeDomainData(): Uint8Array;
  41242. /**
  41243. * Gets the current frequency data as a float array
  41244. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41245. * @returns a Float32Array
  41246. */
  41247. getFloatFrequencyData(): Float32Array;
  41248. /**
  41249. * Renders the debug canvas
  41250. */
  41251. drawDebugCanvas(): void;
  41252. /**
  41253. * Stops rendering the debug canvas and removes it
  41254. */
  41255. stopDebugCanvas(): void;
  41256. /**
  41257. * Connects two audio nodes
  41258. * @param inputAudioNode defines first node to connect
  41259. * @param outputAudioNode defines second node to connect
  41260. */
  41261. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41262. /**
  41263. * Releases all associated resources
  41264. */
  41265. dispose(): void;
  41266. }
  41267. }
  41268. declare module "babylonjs/Audio/audioEngine" {
  41269. import { IDisposable } from "babylonjs/scene";
  41270. import { Analyser } from "babylonjs/Audio/analyser";
  41271. import { Nullable } from "babylonjs/types";
  41272. import { Observable } from "babylonjs/Misc/observable";
  41273. /**
  41274. * This represents an audio engine and it is responsible
  41275. * to play, synchronize and analyse sounds throughout the application.
  41276. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41277. */
  41278. export interface IAudioEngine extends IDisposable {
  41279. /**
  41280. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41281. */
  41282. readonly canUseWebAudio: boolean;
  41283. /**
  41284. * Gets the current AudioContext if available.
  41285. */
  41286. readonly audioContext: Nullable<AudioContext>;
  41287. /**
  41288. * The master gain node defines the global audio volume of your audio engine.
  41289. */
  41290. readonly masterGain: GainNode;
  41291. /**
  41292. * Gets whether or not mp3 are supported by your browser.
  41293. */
  41294. readonly isMP3supported: boolean;
  41295. /**
  41296. * Gets whether or not ogg are supported by your browser.
  41297. */
  41298. readonly isOGGsupported: boolean;
  41299. /**
  41300. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41301. * @ignoreNaming
  41302. */
  41303. WarnedWebAudioUnsupported: boolean;
  41304. /**
  41305. * Defines if the audio engine relies on a custom unlocked button.
  41306. * In this case, the embedded button will not be displayed.
  41307. */
  41308. useCustomUnlockedButton: boolean;
  41309. /**
  41310. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41311. */
  41312. readonly unlocked: boolean;
  41313. /**
  41314. * Event raised when audio has been unlocked on the browser.
  41315. */
  41316. onAudioUnlockedObservable: Observable<AudioEngine>;
  41317. /**
  41318. * Event raised when audio has been locked on the browser.
  41319. */
  41320. onAudioLockedObservable: Observable<AudioEngine>;
  41321. /**
  41322. * Flags the audio engine in Locked state.
  41323. * This happens due to new browser policies preventing audio to autoplay.
  41324. */
  41325. lock(): void;
  41326. /**
  41327. * Unlocks the audio engine once a user action has been done on the dom.
  41328. * This is helpful to resume play once browser policies have been satisfied.
  41329. */
  41330. unlock(): void;
  41331. /**
  41332. * Gets the global volume sets on the master gain.
  41333. * @returns the global volume if set or -1 otherwise
  41334. */
  41335. getGlobalVolume(): number;
  41336. /**
  41337. * Sets the global volume of your experience (sets on the master gain).
  41338. * @param newVolume Defines the new global volume of the application
  41339. */
  41340. setGlobalVolume(newVolume: number): void;
  41341. /**
  41342. * Connect the audio engine to an audio analyser allowing some amazing
  41343. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41344. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41345. * @param analyser The analyser to connect to the engine
  41346. */
  41347. connectToAnalyser(analyser: Analyser): void;
  41348. }
  41349. /**
  41350. * This represents the default audio engine used in babylon.
  41351. * It is responsible to play, synchronize and analyse sounds throughout the application.
  41352. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41353. */
  41354. export class AudioEngine implements IAudioEngine {
  41355. private _audioContext;
  41356. private _audioContextInitialized;
  41357. private _muteButton;
  41358. private _hostElement;
  41359. /**
  41360. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41361. */
  41362. canUseWebAudio: boolean;
  41363. /**
  41364. * The master gain node defines the global audio volume of your audio engine.
  41365. */
  41366. masterGain: GainNode;
  41367. /**
  41368. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41369. * @ignoreNaming
  41370. */
  41371. WarnedWebAudioUnsupported: boolean;
  41372. /**
  41373. * Gets whether or not mp3 are supported by your browser.
  41374. */
  41375. isMP3supported: boolean;
  41376. /**
  41377. * Gets whether or not ogg are supported by your browser.
  41378. */
  41379. isOGGsupported: boolean;
  41380. /**
  41381. * Gets whether audio has been unlocked on the device.
  41382. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  41383. * a user interaction has happened.
  41384. */
  41385. unlocked: boolean;
  41386. /**
  41387. * Defines if the audio engine relies on a custom unlocked button.
  41388. * In this case, the embedded button will not be displayed.
  41389. */
  41390. useCustomUnlockedButton: boolean;
  41391. /**
  41392. * Event raised when audio has been unlocked on the browser.
  41393. */
  41394. onAudioUnlockedObservable: Observable<AudioEngine>;
  41395. /**
  41396. * Event raised when audio has been locked on the browser.
  41397. */
  41398. onAudioLockedObservable: Observable<AudioEngine>;
  41399. /**
  41400. * Gets the current AudioContext if available.
  41401. */
  41402. get audioContext(): Nullable<AudioContext>;
  41403. private _connectedAnalyser;
  41404. /**
  41405. * Instantiates a new audio engine.
  41406. *
  41407. * There should be only one per page as some browsers restrict the number
  41408. * of audio contexts you can create.
  41409. * @param hostElement defines the host element where to display the mute icon if necessary
  41410. */
  41411. constructor(hostElement?: Nullable<HTMLElement>);
  41412. /**
  41413. * Flags the audio engine in Locked state.
  41414. * This happens due to new browser policies preventing audio to autoplay.
  41415. */
  41416. lock(): void;
  41417. /**
  41418. * Unlocks the audio engine once a user action has been done on the dom.
  41419. * This is helpful to resume play once browser policies have been satisfied.
  41420. */
  41421. unlock(): void;
  41422. private _resumeAudioContext;
  41423. private _initializeAudioContext;
  41424. private _tryToRun;
  41425. private _triggerRunningState;
  41426. private _triggerSuspendedState;
  41427. private _displayMuteButton;
  41428. private _moveButtonToTopLeft;
  41429. private _onResize;
  41430. private _hideMuteButton;
  41431. /**
  41432. * Destroy and release the resources associated with the audio ccontext.
  41433. */
  41434. dispose(): void;
  41435. /**
  41436. * Gets the global volume sets on the master gain.
  41437. * @returns the global volume if set or -1 otherwise
  41438. */
  41439. getGlobalVolume(): number;
  41440. /**
  41441. * Sets the global volume of your experience (sets on the master gain).
  41442. * @param newVolume Defines the new global volume of the application
  41443. */
  41444. setGlobalVolume(newVolume: number): void;
  41445. /**
  41446. * Connect the audio engine to an audio analyser allowing some amazing
  41447. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41448. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41449. * @param analyser The analyser to connect to the engine
  41450. */
  41451. connectToAnalyser(analyser: Analyser): void;
  41452. }
  41453. }
  41454. declare module "babylonjs/Loading/loadingScreen" {
  41455. /**
  41456. * Interface used to present a loading screen while loading a scene
  41457. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41458. */
  41459. export interface ILoadingScreen {
  41460. /**
  41461. * Function called to display the loading screen
  41462. */
  41463. displayLoadingUI: () => void;
  41464. /**
  41465. * Function called to hide the loading screen
  41466. */
  41467. hideLoadingUI: () => void;
  41468. /**
  41469. * Gets or sets the color to use for the background
  41470. */
  41471. loadingUIBackgroundColor: string;
  41472. /**
  41473. * Gets or sets the text to display while loading
  41474. */
  41475. loadingUIText: string;
  41476. }
  41477. /**
  41478. * Class used for the default loading screen
  41479. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41480. */
  41481. export class DefaultLoadingScreen implements ILoadingScreen {
  41482. private _renderingCanvas;
  41483. private _loadingText;
  41484. private _loadingDivBackgroundColor;
  41485. private _loadingDiv;
  41486. private _loadingTextDiv;
  41487. /** Gets or sets the logo url to use for the default loading screen */
  41488. static DefaultLogoUrl: string;
  41489. /** Gets or sets the spinner url to use for the default loading screen */
  41490. static DefaultSpinnerUrl: string;
  41491. /**
  41492. * Creates a new default loading screen
  41493. * @param _renderingCanvas defines the canvas used to render the scene
  41494. * @param _loadingText defines the default text to display
  41495. * @param _loadingDivBackgroundColor defines the default background color
  41496. */
  41497. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41498. /**
  41499. * Function called to display the loading screen
  41500. */
  41501. displayLoadingUI(): void;
  41502. /**
  41503. * Function called to hide the loading screen
  41504. */
  41505. hideLoadingUI(): void;
  41506. /**
  41507. * Gets or sets the text to display while loading
  41508. */
  41509. set loadingUIText(text: string);
  41510. get loadingUIText(): string;
  41511. /**
  41512. * Gets or sets the color to use for the background
  41513. */
  41514. get loadingUIBackgroundColor(): string;
  41515. set loadingUIBackgroundColor(color: string);
  41516. private _resizeLoadingUI;
  41517. }
  41518. }
  41519. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41520. /**
  41521. * Interface for any object that can request an animation frame
  41522. */
  41523. export interface ICustomAnimationFrameRequester {
  41524. /**
  41525. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41526. */
  41527. renderFunction?: Function;
  41528. /**
  41529. * Called to request the next frame to render to
  41530. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41531. */
  41532. requestAnimationFrame: Function;
  41533. /**
  41534. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41535. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41536. */
  41537. requestID?: number;
  41538. }
  41539. }
  41540. declare module "babylonjs/Misc/performanceMonitor" {
  41541. /**
  41542. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41543. */
  41544. export class PerformanceMonitor {
  41545. private _enabled;
  41546. private _rollingFrameTime;
  41547. private _lastFrameTimeMs;
  41548. /**
  41549. * constructor
  41550. * @param frameSampleSize The number of samples required to saturate the sliding window
  41551. */
  41552. constructor(frameSampleSize?: number);
  41553. /**
  41554. * Samples current frame
  41555. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41556. */
  41557. sampleFrame(timeMs?: number): void;
  41558. /**
  41559. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41560. */
  41561. get averageFrameTime(): number;
  41562. /**
  41563. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41564. */
  41565. get averageFrameTimeVariance(): number;
  41566. /**
  41567. * Returns the frame time of the most recent frame
  41568. */
  41569. get instantaneousFrameTime(): number;
  41570. /**
  41571. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41572. */
  41573. get averageFPS(): number;
  41574. /**
  41575. * Returns the average framerate in frames per second using the most recent frame time
  41576. */
  41577. get instantaneousFPS(): number;
  41578. /**
  41579. * Returns true if enough samples have been taken to completely fill the sliding window
  41580. */
  41581. get isSaturated(): boolean;
  41582. /**
  41583. * Enables contributions to the sliding window sample set
  41584. */
  41585. enable(): void;
  41586. /**
  41587. * Disables contributions to the sliding window sample set
  41588. * Samples will not be interpolated over the disabled period
  41589. */
  41590. disable(): void;
  41591. /**
  41592. * Returns true if sampling is enabled
  41593. */
  41594. get isEnabled(): boolean;
  41595. /**
  41596. * Resets performance monitor
  41597. */
  41598. reset(): void;
  41599. }
  41600. /**
  41601. * RollingAverage
  41602. *
  41603. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41604. */
  41605. export class RollingAverage {
  41606. /**
  41607. * Current average
  41608. */
  41609. average: number;
  41610. /**
  41611. * Current variance
  41612. */
  41613. variance: number;
  41614. protected _samples: Array<number>;
  41615. protected _sampleCount: number;
  41616. protected _pos: number;
  41617. protected _m2: number;
  41618. /**
  41619. * constructor
  41620. * @param length The number of samples required to saturate the sliding window
  41621. */
  41622. constructor(length: number);
  41623. /**
  41624. * Adds a sample to the sample set
  41625. * @param v The sample value
  41626. */
  41627. add(v: number): void;
  41628. /**
  41629. * Returns previously added values or null if outside of history or outside the sliding window domain
  41630. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41631. * @return Value previously recorded with add() or null if outside of range
  41632. */
  41633. history(i: number): number;
  41634. /**
  41635. * Returns true if enough samples have been taken to completely fill the sliding window
  41636. * @return true if sample-set saturated
  41637. */
  41638. isSaturated(): boolean;
  41639. /**
  41640. * Resets the rolling average (equivalent to 0 samples taken so far)
  41641. */
  41642. reset(): void;
  41643. /**
  41644. * Wraps a value around the sample range boundaries
  41645. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41646. * @return Wrapped position in sample range
  41647. */
  41648. protected _wrapPosition(i: number): number;
  41649. }
  41650. }
  41651. declare module "babylonjs/Misc/perfCounter" {
  41652. /**
  41653. * This class is used to track a performance counter which is number based.
  41654. * The user has access to many properties which give statistics of different nature.
  41655. *
  41656. * The implementer can track two kinds of Performance Counter: time and count.
  41657. * 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.
  41658. * 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.
  41659. */
  41660. export class PerfCounter {
  41661. /**
  41662. * Gets or sets a global boolean to turn on and off all the counters
  41663. */
  41664. static Enabled: boolean;
  41665. /**
  41666. * Returns the smallest value ever
  41667. */
  41668. get min(): number;
  41669. /**
  41670. * Returns the biggest value ever
  41671. */
  41672. get max(): number;
  41673. /**
  41674. * Returns the average value since the performance counter is running
  41675. */
  41676. get average(): number;
  41677. /**
  41678. * Returns the average value of the last second the counter was monitored
  41679. */
  41680. get lastSecAverage(): number;
  41681. /**
  41682. * Returns the current value
  41683. */
  41684. get current(): number;
  41685. /**
  41686. * Gets the accumulated total
  41687. */
  41688. get total(): number;
  41689. /**
  41690. * Gets the total value count
  41691. */
  41692. get count(): number;
  41693. /**
  41694. * Creates a new counter
  41695. */
  41696. constructor();
  41697. /**
  41698. * Call this method to start monitoring a new frame.
  41699. * 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.
  41700. */
  41701. fetchNewFrame(): void;
  41702. /**
  41703. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41704. * @param newCount the count value to add to the monitored count
  41705. * @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.
  41706. */
  41707. addCount(newCount: number, fetchResult: boolean): void;
  41708. /**
  41709. * Start monitoring this performance counter
  41710. */
  41711. beginMonitoring(): void;
  41712. /**
  41713. * Compute the time lapsed since the previous beginMonitoring() call.
  41714. * @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
  41715. */
  41716. endMonitoring(newFrame?: boolean): void;
  41717. private _fetchResult;
  41718. private _startMonitoringTime;
  41719. private _min;
  41720. private _max;
  41721. private _average;
  41722. private _current;
  41723. private _totalValueCount;
  41724. private _totalAccumulated;
  41725. private _lastSecAverage;
  41726. private _lastSecAccumulated;
  41727. private _lastSecTime;
  41728. private _lastSecValueCount;
  41729. }
  41730. }
  41731. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  41732. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41733. import { Nullable } from "babylonjs/types";
  41734. module "babylonjs/Engines/thinEngine" {
  41735. interface ThinEngine {
  41736. /** @hidden */
  41737. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  41738. }
  41739. }
  41740. }
  41741. declare module "babylonjs/Engines/engine" {
  41742. import { Observable } from "babylonjs/Misc/observable";
  41743. import { Nullable } from "babylonjs/types";
  41744. import { Scene } from "babylonjs/scene";
  41745. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41746. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  41747. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  41748. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  41749. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  41750. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  41751. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  41752. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  41753. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  41754. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41755. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  41756. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  41757. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  41758. import "babylonjs/Engines/Extensions/engine.alpha";
  41759. import "babylonjs/Engines/Extensions/engine.readTexture";
  41760. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  41761. import { Material } from "babylonjs/Materials/material";
  41762. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41763. /**
  41764. * Defines the interface used by display changed events
  41765. */
  41766. export interface IDisplayChangedEventArgs {
  41767. /** Gets the vrDisplay object (if any) */
  41768. vrDisplay: Nullable<any>;
  41769. /** Gets a boolean indicating if webVR is supported */
  41770. vrSupported: boolean;
  41771. }
  41772. /**
  41773. * Defines the interface used by objects containing a viewport (like a camera)
  41774. */
  41775. interface IViewportOwnerLike {
  41776. /**
  41777. * Gets or sets the viewport
  41778. */
  41779. viewport: IViewportLike;
  41780. }
  41781. /**
  41782. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41783. */
  41784. export class Engine extends ThinEngine {
  41785. /** Defines that alpha blending is disabled */
  41786. static readonly ALPHA_DISABLE: number;
  41787. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41788. static readonly ALPHA_ADD: number;
  41789. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41790. static readonly ALPHA_COMBINE: number;
  41791. /** Defines that alpha blending to DEST - SRC * DEST */
  41792. static readonly ALPHA_SUBTRACT: number;
  41793. /** Defines that alpha blending to SRC * DEST */
  41794. static readonly ALPHA_MULTIPLY: number;
  41795. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41796. static readonly ALPHA_MAXIMIZED: number;
  41797. /** Defines that alpha blending to SRC + DEST */
  41798. static readonly ALPHA_ONEONE: number;
  41799. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41800. static readonly ALPHA_PREMULTIPLIED: number;
  41801. /**
  41802. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41803. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41804. */
  41805. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41806. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41807. static readonly ALPHA_INTERPOLATE: number;
  41808. /**
  41809. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41810. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41811. */
  41812. static readonly ALPHA_SCREENMODE: number;
  41813. /** Defines that the ressource is not delayed*/
  41814. static readonly DELAYLOADSTATE_NONE: number;
  41815. /** Defines that the ressource was successfully delay loaded */
  41816. static readonly DELAYLOADSTATE_LOADED: number;
  41817. /** Defines that the ressource is currently delay loading */
  41818. static readonly DELAYLOADSTATE_LOADING: number;
  41819. /** Defines that the ressource is delayed and has not started loading */
  41820. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41821. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41822. static readonly NEVER: number;
  41823. /** 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 */
  41824. static readonly ALWAYS: number;
  41825. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41826. static readonly LESS: number;
  41827. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41828. static readonly EQUAL: number;
  41829. /** 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 */
  41830. static readonly LEQUAL: number;
  41831. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41832. static readonly GREATER: number;
  41833. /** 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 */
  41834. static readonly GEQUAL: number;
  41835. /** 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 */
  41836. static readonly NOTEQUAL: number;
  41837. /** Passed to stencilOperation to specify that stencil value must be kept */
  41838. static readonly KEEP: number;
  41839. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41840. static readonly REPLACE: number;
  41841. /** Passed to stencilOperation to specify that stencil value must be incremented */
  41842. static readonly INCR: number;
  41843. /** Passed to stencilOperation to specify that stencil value must be decremented */
  41844. static readonly DECR: number;
  41845. /** Passed to stencilOperation to specify that stencil value must be inverted */
  41846. static readonly INVERT: number;
  41847. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  41848. static readonly INCR_WRAP: number;
  41849. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  41850. static readonly DECR_WRAP: number;
  41851. /** Texture is not repeating outside of 0..1 UVs */
  41852. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  41853. /** Texture is repeating outside of 0..1 UVs */
  41854. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  41855. /** Texture is repeating and mirrored */
  41856. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  41857. /** ALPHA */
  41858. static readonly TEXTUREFORMAT_ALPHA: number;
  41859. /** LUMINANCE */
  41860. static readonly TEXTUREFORMAT_LUMINANCE: number;
  41861. /** LUMINANCE_ALPHA */
  41862. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  41863. /** RGB */
  41864. static readonly TEXTUREFORMAT_RGB: number;
  41865. /** RGBA */
  41866. static readonly TEXTUREFORMAT_RGBA: number;
  41867. /** RED */
  41868. static readonly TEXTUREFORMAT_RED: number;
  41869. /** RED (2nd reference) */
  41870. static readonly TEXTUREFORMAT_R: number;
  41871. /** RG */
  41872. static readonly TEXTUREFORMAT_RG: number;
  41873. /** RED_INTEGER */
  41874. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  41875. /** RED_INTEGER (2nd reference) */
  41876. static readonly TEXTUREFORMAT_R_INTEGER: number;
  41877. /** RG_INTEGER */
  41878. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  41879. /** RGB_INTEGER */
  41880. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  41881. /** RGBA_INTEGER */
  41882. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  41883. /** UNSIGNED_BYTE */
  41884. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  41885. /** UNSIGNED_BYTE (2nd reference) */
  41886. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  41887. /** FLOAT */
  41888. static readonly TEXTURETYPE_FLOAT: number;
  41889. /** HALF_FLOAT */
  41890. static readonly TEXTURETYPE_HALF_FLOAT: number;
  41891. /** BYTE */
  41892. static readonly TEXTURETYPE_BYTE: number;
  41893. /** SHORT */
  41894. static readonly TEXTURETYPE_SHORT: number;
  41895. /** UNSIGNED_SHORT */
  41896. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  41897. /** INT */
  41898. static readonly TEXTURETYPE_INT: number;
  41899. /** UNSIGNED_INT */
  41900. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  41901. /** UNSIGNED_SHORT_4_4_4_4 */
  41902. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  41903. /** UNSIGNED_SHORT_5_5_5_1 */
  41904. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  41905. /** UNSIGNED_SHORT_5_6_5 */
  41906. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  41907. /** UNSIGNED_INT_2_10_10_10_REV */
  41908. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  41909. /** UNSIGNED_INT_24_8 */
  41910. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  41911. /** UNSIGNED_INT_10F_11F_11F_REV */
  41912. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  41913. /** UNSIGNED_INT_5_9_9_9_REV */
  41914. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  41915. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  41916. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  41917. /** nearest is mag = nearest and min = nearest and mip = linear */
  41918. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  41919. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41920. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  41921. /** Trilinear is mag = linear and min = linear and mip = linear */
  41922. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  41923. /** nearest is mag = nearest and min = nearest and mip = linear */
  41924. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  41925. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41926. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  41927. /** Trilinear is mag = linear and min = linear and mip = linear */
  41928. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  41929. /** mag = nearest and min = nearest and mip = nearest */
  41930. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  41931. /** mag = nearest and min = linear and mip = nearest */
  41932. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  41933. /** mag = nearest and min = linear and mip = linear */
  41934. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  41935. /** mag = nearest and min = linear and mip = none */
  41936. static readonly TEXTURE_NEAREST_LINEAR: number;
  41937. /** mag = nearest and min = nearest and mip = none */
  41938. static readonly TEXTURE_NEAREST_NEAREST: number;
  41939. /** mag = linear and min = nearest and mip = nearest */
  41940. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  41941. /** mag = linear and min = nearest and mip = linear */
  41942. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  41943. /** mag = linear and min = linear and mip = none */
  41944. static readonly TEXTURE_LINEAR_LINEAR: number;
  41945. /** mag = linear and min = nearest and mip = none */
  41946. static readonly TEXTURE_LINEAR_NEAREST: number;
  41947. /** Explicit coordinates mode */
  41948. static readonly TEXTURE_EXPLICIT_MODE: number;
  41949. /** Spherical coordinates mode */
  41950. static readonly TEXTURE_SPHERICAL_MODE: number;
  41951. /** Planar coordinates mode */
  41952. static readonly TEXTURE_PLANAR_MODE: number;
  41953. /** Cubic coordinates mode */
  41954. static readonly TEXTURE_CUBIC_MODE: number;
  41955. /** Projection coordinates mode */
  41956. static readonly TEXTURE_PROJECTION_MODE: number;
  41957. /** Skybox coordinates mode */
  41958. static readonly TEXTURE_SKYBOX_MODE: number;
  41959. /** Inverse Cubic coordinates mode */
  41960. static readonly TEXTURE_INVCUBIC_MODE: number;
  41961. /** Equirectangular coordinates mode */
  41962. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  41963. /** Equirectangular Fixed coordinates mode */
  41964. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  41965. /** Equirectangular Fixed Mirrored coordinates mode */
  41966. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  41967. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  41968. static readonly SCALEMODE_FLOOR: number;
  41969. /** Defines that texture rescaling will look for the nearest power of 2 size */
  41970. static readonly SCALEMODE_NEAREST: number;
  41971. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  41972. static readonly SCALEMODE_CEILING: number;
  41973. /**
  41974. * Returns the current npm package of the sdk
  41975. */
  41976. static get NpmPackage(): string;
  41977. /**
  41978. * Returns the current version of the framework
  41979. */
  41980. static get Version(): string;
  41981. /** Gets the list of created engines */
  41982. static get Instances(): Engine[];
  41983. /**
  41984. * Gets the latest created engine
  41985. */
  41986. static get LastCreatedEngine(): Nullable<Engine>;
  41987. /**
  41988. * Gets the latest created scene
  41989. */
  41990. static get LastCreatedScene(): Nullable<Scene>;
  41991. /**
  41992. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  41993. * @param flag defines which part of the materials must be marked as dirty
  41994. * @param predicate defines a predicate used to filter which materials should be affected
  41995. */
  41996. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41997. /**
  41998. * Method called to create the default loading screen.
  41999. * This can be overriden in your own app.
  42000. * @param canvas The rendering canvas element
  42001. * @returns The loading screen
  42002. */
  42003. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42004. /**
  42005. * Method called to create the default rescale post process on each engine.
  42006. */
  42007. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42008. /**
  42009. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42010. **/
  42011. enableOfflineSupport: boolean;
  42012. /**
  42013. * 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)
  42014. **/
  42015. disableManifestCheck: boolean;
  42016. /**
  42017. * Gets the list of created scenes
  42018. */
  42019. scenes: Scene[];
  42020. /**
  42021. * Event raised when a new scene is created
  42022. */
  42023. onNewSceneAddedObservable: Observable<Scene>;
  42024. /**
  42025. * Gets the list of created postprocesses
  42026. */
  42027. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42028. /**
  42029. * Gets a boolean indicating if the pointer is currently locked
  42030. */
  42031. isPointerLock: boolean;
  42032. /**
  42033. * Observable event triggered each time the rendering canvas is resized
  42034. */
  42035. onResizeObservable: Observable<Engine>;
  42036. /**
  42037. * Observable event triggered each time the canvas loses focus
  42038. */
  42039. onCanvasBlurObservable: Observable<Engine>;
  42040. /**
  42041. * Observable event triggered each time the canvas gains focus
  42042. */
  42043. onCanvasFocusObservable: Observable<Engine>;
  42044. /**
  42045. * Observable event triggered each time the canvas receives pointerout event
  42046. */
  42047. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42048. /**
  42049. * Observable raised when the engine begins a new frame
  42050. */
  42051. onBeginFrameObservable: Observable<Engine>;
  42052. /**
  42053. * If set, will be used to request the next animation frame for the render loop
  42054. */
  42055. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42056. /**
  42057. * Observable raised when the engine ends the current frame
  42058. */
  42059. onEndFrameObservable: Observable<Engine>;
  42060. /**
  42061. * Observable raised when the engine is about to compile a shader
  42062. */
  42063. onBeforeShaderCompilationObservable: Observable<Engine>;
  42064. /**
  42065. * Observable raised when the engine has jsut compiled a shader
  42066. */
  42067. onAfterShaderCompilationObservable: Observable<Engine>;
  42068. /**
  42069. * Gets the audio engine
  42070. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42071. * @ignorenaming
  42072. */
  42073. static audioEngine: IAudioEngine;
  42074. /**
  42075. * Default AudioEngine factory responsible of creating the Audio Engine.
  42076. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42077. */
  42078. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42079. /**
  42080. * Default offline support factory responsible of creating a tool used to store data locally.
  42081. * By default, this will create a Database object if the workload has been embedded.
  42082. */
  42083. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42084. private _loadingScreen;
  42085. private _pointerLockRequested;
  42086. private _rescalePostProcess;
  42087. private _deterministicLockstep;
  42088. private _lockstepMaxSteps;
  42089. private _timeStep;
  42090. protected get _supportsHardwareTextureRescaling(): boolean;
  42091. private _fps;
  42092. private _deltaTime;
  42093. /** @hidden */
  42094. _drawCalls: PerfCounter;
  42095. /** 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 */
  42096. canvasTabIndex: number;
  42097. /**
  42098. * Turn this value on if you want to pause FPS computation when in background
  42099. */
  42100. disablePerformanceMonitorInBackground: boolean;
  42101. private _performanceMonitor;
  42102. /**
  42103. * Gets the performance monitor attached to this engine
  42104. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42105. */
  42106. get performanceMonitor(): PerformanceMonitor;
  42107. private _onFocus;
  42108. private _onBlur;
  42109. private _onCanvasPointerOut;
  42110. private _onCanvasBlur;
  42111. private _onCanvasFocus;
  42112. private _onFullscreenChange;
  42113. private _onPointerLockChange;
  42114. /**
  42115. * Gets the HTML element used to attach event listeners
  42116. * @returns a HTML element
  42117. */
  42118. getInputElement(): Nullable<HTMLElement>;
  42119. /**
  42120. * Creates a new engine
  42121. * @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
  42122. * @param antialias defines enable antialiasing (default: false)
  42123. * @param options defines further options to be sent to the getContext() function
  42124. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42125. */
  42126. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42127. /**
  42128. * Gets current aspect ratio
  42129. * @param viewportOwner defines the camera to use to get the aspect ratio
  42130. * @param useScreen defines if screen size must be used (or the current render target if any)
  42131. * @returns a number defining the aspect ratio
  42132. */
  42133. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42134. /**
  42135. * Gets current screen aspect ratio
  42136. * @returns a number defining the aspect ratio
  42137. */
  42138. getScreenAspectRatio(): number;
  42139. /**
  42140. * Gets the client rect of the HTML canvas attached with the current webGL context
  42141. * @returns a client rectanglee
  42142. */
  42143. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42144. /**
  42145. * Gets the client rect of the HTML element used for events
  42146. * @returns a client rectanglee
  42147. */
  42148. getInputElementClientRect(): Nullable<ClientRect>;
  42149. /**
  42150. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42151. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42152. * @returns true if engine is in deterministic lock step mode
  42153. */
  42154. isDeterministicLockStep(): boolean;
  42155. /**
  42156. * Gets the max steps when engine is running in deterministic lock step
  42157. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42158. * @returns the max steps
  42159. */
  42160. getLockstepMaxSteps(): number;
  42161. /**
  42162. * Returns the time in ms between steps when using deterministic lock step.
  42163. * @returns time step in (ms)
  42164. */
  42165. getTimeStep(): number;
  42166. /**
  42167. * Force the mipmap generation for the given render target texture
  42168. * @param texture defines the render target texture to use
  42169. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42170. */
  42171. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42172. /** States */
  42173. /**
  42174. * Set various states to the webGL context
  42175. * @param culling defines backface culling state
  42176. * @param zOffset defines the value to apply to zOffset (0 by default)
  42177. * @param force defines if states must be applied even if cache is up to date
  42178. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42179. */
  42180. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42181. /**
  42182. * Set the z offset to apply to current rendering
  42183. * @param value defines the offset to apply
  42184. */
  42185. setZOffset(value: number): void;
  42186. /**
  42187. * Gets the current value of the zOffset
  42188. * @returns the current zOffset state
  42189. */
  42190. getZOffset(): number;
  42191. /**
  42192. * Enable or disable depth buffering
  42193. * @param enable defines the state to set
  42194. */
  42195. setDepthBuffer(enable: boolean): void;
  42196. /**
  42197. * Gets a boolean indicating if depth writing is enabled
  42198. * @returns the current depth writing state
  42199. */
  42200. getDepthWrite(): boolean;
  42201. /**
  42202. * Enable or disable depth writing
  42203. * @param enable defines the state to set
  42204. */
  42205. setDepthWrite(enable: boolean): void;
  42206. /**
  42207. * Gets a boolean indicating if stencil buffer is enabled
  42208. * @returns the current stencil buffer state
  42209. */
  42210. getStencilBuffer(): boolean;
  42211. /**
  42212. * Enable or disable the stencil buffer
  42213. * @param enable defines if the stencil buffer must be enabled or disabled
  42214. */
  42215. setStencilBuffer(enable: boolean): void;
  42216. /**
  42217. * Gets the current stencil mask
  42218. * @returns a number defining the new stencil mask to use
  42219. */
  42220. getStencilMask(): number;
  42221. /**
  42222. * Sets the current stencil mask
  42223. * @param mask defines the new stencil mask to use
  42224. */
  42225. setStencilMask(mask: number): void;
  42226. /**
  42227. * Gets the current stencil function
  42228. * @returns a number defining the stencil function to use
  42229. */
  42230. getStencilFunction(): number;
  42231. /**
  42232. * Gets the current stencil reference value
  42233. * @returns a number defining the stencil reference value to use
  42234. */
  42235. getStencilFunctionReference(): number;
  42236. /**
  42237. * Gets the current stencil mask
  42238. * @returns a number defining the stencil mask to use
  42239. */
  42240. getStencilFunctionMask(): number;
  42241. /**
  42242. * Sets the current stencil function
  42243. * @param stencilFunc defines the new stencil function to use
  42244. */
  42245. setStencilFunction(stencilFunc: number): void;
  42246. /**
  42247. * Sets the current stencil reference
  42248. * @param reference defines the new stencil reference to use
  42249. */
  42250. setStencilFunctionReference(reference: number): void;
  42251. /**
  42252. * Sets the current stencil mask
  42253. * @param mask defines the new stencil mask to use
  42254. */
  42255. setStencilFunctionMask(mask: number): void;
  42256. /**
  42257. * Gets the current stencil operation when stencil fails
  42258. * @returns a number defining stencil operation to use when stencil fails
  42259. */
  42260. getStencilOperationFail(): number;
  42261. /**
  42262. * Gets the current stencil operation when depth fails
  42263. * @returns a number defining stencil operation to use when depth fails
  42264. */
  42265. getStencilOperationDepthFail(): number;
  42266. /**
  42267. * Gets the current stencil operation when stencil passes
  42268. * @returns a number defining stencil operation to use when stencil passes
  42269. */
  42270. getStencilOperationPass(): number;
  42271. /**
  42272. * Sets the stencil operation to use when stencil fails
  42273. * @param operation defines the stencil operation to use when stencil fails
  42274. */
  42275. setStencilOperationFail(operation: number): void;
  42276. /**
  42277. * Sets the stencil operation to use when depth fails
  42278. * @param operation defines the stencil operation to use when depth fails
  42279. */
  42280. setStencilOperationDepthFail(operation: number): void;
  42281. /**
  42282. * Sets the stencil operation to use when stencil passes
  42283. * @param operation defines the stencil operation to use when stencil passes
  42284. */
  42285. setStencilOperationPass(operation: number): void;
  42286. /**
  42287. * Sets a boolean indicating if the dithering state is enabled or disabled
  42288. * @param value defines the dithering state
  42289. */
  42290. setDitheringState(value: boolean): void;
  42291. /**
  42292. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42293. * @param value defines the rasterizer state
  42294. */
  42295. setRasterizerState(value: boolean): void;
  42296. /**
  42297. * Gets the current depth function
  42298. * @returns a number defining the depth function
  42299. */
  42300. getDepthFunction(): Nullable<number>;
  42301. /**
  42302. * Sets the current depth function
  42303. * @param depthFunc defines the function to use
  42304. */
  42305. setDepthFunction(depthFunc: number): void;
  42306. /**
  42307. * Sets the current depth function to GREATER
  42308. */
  42309. setDepthFunctionToGreater(): void;
  42310. /**
  42311. * Sets the current depth function to GEQUAL
  42312. */
  42313. setDepthFunctionToGreaterOrEqual(): void;
  42314. /**
  42315. * Sets the current depth function to LESS
  42316. */
  42317. setDepthFunctionToLess(): void;
  42318. /**
  42319. * Sets the current depth function to LEQUAL
  42320. */
  42321. setDepthFunctionToLessOrEqual(): void;
  42322. private _cachedStencilBuffer;
  42323. private _cachedStencilFunction;
  42324. private _cachedStencilMask;
  42325. private _cachedStencilOperationPass;
  42326. private _cachedStencilOperationFail;
  42327. private _cachedStencilOperationDepthFail;
  42328. private _cachedStencilReference;
  42329. /**
  42330. * Caches the the state of the stencil buffer
  42331. */
  42332. cacheStencilState(): void;
  42333. /**
  42334. * Restores the state of the stencil buffer
  42335. */
  42336. restoreStencilState(): void;
  42337. /**
  42338. * Directly set the WebGL Viewport
  42339. * @param x defines the x coordinate of the viewport (in screen space)
  42340. * @param y defines the y coordinate of the viewport (in screen space)
  42341. * @param width defines the width of the viewport (in screen space)
  42342. * @param height defines the height of the viewport (in screen space)
  42343. * @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
  42344. */
  42345. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42346. /**
  42347. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42348. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42349. * @param y defines the y-coordinate of the corner of the clear rectangle
  42350. * @param width defines the width of the clear rectangle
  42351. * @param height defines the height of the clear rectangle
  42352. * @param clearColor defines the clear color
  42353. */
  42354. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42355. /**
  42356. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42357. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42358. * @param y defines the y-coordinate of the corner of the clear rectangle
  42359. * @param width defines the width of the clear rectangle
  42360. * @param height defines the height of the clear rectangle
  42361. */
  42362. enableScissor(x: number, y: number, width: number, height: number): void;
  42363. /**
  42364. * Disable previously set scissor test rectangle
  42365. */
  42366. disableScissor(): void;
  42367. protected _reportDrawCall(): void;
  42368. /**
  42369. * Initializes a webVR display and starts listening to display change events
  42370. * The onVRDisplayChangedObservable will be notified upon these changes
  42371. * @returns The onVRDisplayChangedObservable
  42372. */
  42373. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42374. /** @hidden */
  42375. _prepareVRComponent(): void;
  42376. /** @hidden */
  42377. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42378. /** @hidden */
  42379. _submitVRFrame(): void;
  42380. /**
  42381. * Call this function to leave webVR mode
  42382. * Will do nothing if webVR is not supported or if there is no webVR device
  42383. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42384. */
  42385. disableVR(): void;
  42386. /**
  42387. * Gets a boolean indicating that the system is in VR mode and is presenting
  42388. * @returns true if VR mode is engaged
  42389. */
  42390. isVRPresenting(): boolean;
  42391. /** @hidden */
  42392. _requestVRFrame(): void;
  42393. /** @hidden */
  42394. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42395. /**
  42396. * Gets the source code of the vertex shader associated with a specific webGL program
  42397. * @param program defines the program to use
  42398. * @returns a string containing the source code of the vertex shader associated with the program
  42399. */
  42400. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42401. /**
  42402. * Gets the source code of the fragment shader associated with a specific webGL program
  42403. * @param program defines the program to use
  42404. * @returns a string containing the source code of the fragment shader associated with the program
  42405. */
  42406. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42407. /**
  42408. * Sets a depth stencil texture from a render target to the according uniform.
  42409. * @param channel The texture channel
  42410. * @param uniform The uniform to set
  42411. * @param texture The render target texture containing the depth stencil texture to apply
  42412. */
  42413. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  42414. /**
  42415. * Sets a texture to the webGL context from a postprocess
  42416. * @param channel defines the channel to use
  42417. * @param postProcess defines the source postprocess
  42418. */
  42419. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  42420. /**
  42421. * Binds the output of the passed in post process to the texture channel specified
  42422. * @param channel The channel the texture should be bound to
  42423. * @param postProcess The post process which's output should be bound
  42424. */
  42425. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  42426. protected _rebuildBuffers(): void;
  42427. /** @hidden */
  42428. _renderFrame(): void;
  42429. _renderLoop(): void;
  42430. /** @hidden */
  42431. _renderViews(): boolean;
  42432. /**
  42433. * Toggle full screen mode
  42434. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42435. */
  42436. switchFullscreen(requestPointerLock: boolean): void;
  42437. /**
  42438. * Enters full screen mode
  42439. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42440. */
  42441. enterFullscreen(requestPointerLock: boolean): void;
  42442. /**
  42443. * Exits full screen mode
  42444. */
  42445. exitFullscreen(): void;
  42446. /**
  42447. * Enters Pointerlock mode
  42448. */
  42449. enterPointerlock(): void;
  42450. /**
  42451. * Exits Pointerlock mode
  42452. */
  42453. exitPointerlock(): void;
  42454. /**
  42455. * Begin a new frame
  42456. */
  42457. beginFrame(): void;
  42458. /**
  42459. * Enf the current frame
  42460. */
  42461. endFrame(): void;
  42462. resize(): void;
  42463. /**
  42464. * Force a specific size of the canvas
  42465. * @param width defines the new canvas' width
  42466. * @param height defines the new canvas' height
  42467. * @returns true if the size was changed
  42468. */
  42469. setSize(width: number, height: number): boolean;
  42470. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42471. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42472. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42473. _releaseTexture(texture: InternalTexture): void;
  42474. /**
  42475. * @hidden
  42476. * Rescales a texture
  42477. * @param source input texutre
  42478. * @param destination destination texture
  42479. * @param scene scene to use to render the resize
  42480. * @param internalFormat format to use when resizing
  42481. * @param onComplete callback to be called when resize has completed
  42482. */
  42483. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42484. /**
  42485. * Gets the current framerate
  42486. * @returns a number representing the framerate
  42487. */
  42488. getFps(): number;
  42489. /**
  42490. * Gets the time spent between current and previous frame
  42491. * @returns a number representing the delta time in ms
  42492. */
  42493. getDeltaTime(): number;
  42494. private _measureFps;
  42495. /** @hidden */
  42496. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42497. /**
  42498. * Updates the sample count of a render target texture
  42499. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42500. * @param texture defines the texture to update
  42501. * @param samples defines the sample count to set
  42502. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42503. */
  42504. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42505. /**
  42506. * Updates a depth texture Comparison Mode and Function.
  42507. * If the comparison Function is equal to 0, the mode will be set to none.
  42508. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42509. * @param texture The texture to set the comparison function for
  42510. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42511. */
  42512. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42513. /**
  42514. * Creates a webGL buffer to use with instanciation
  42515. * @param capacity defines the size of the buffer
  42516. * @returns the webGL buffer
  42517. */
  42518. createInstancesBuffer(capacity: number): DataBuffer;
  42519. /**
  42520. * Delete a webGL buffer used with instanciation
  42521. * @param buffer defines the webGL buffer to delete
  42522. */
  42523. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42524. private _clientWaitAsync;
  42525. /** @hidden */
  42526. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  42527. dispose(): void;
  42528. private _disableTouchAction;
  42529. /**
  42530. * Display the loading screen
  42531. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42532. */
  42533. displayLoadingUI(): void;
  42534. /**
  42535. * Hide the loading screen
  42536. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42537. */
  42538. hideLoadingUI(): void;
  42539. /**
  42540. * Gets the current loading screen object
  42541. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42542. */
  42543. get loadingScreen(): ILoadingScreen;
  42544. /**
  42545. * Sets the current loading screen object
  42546. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42547. */
  42548. set loadingScreen(loadingScreen: ILoadingScreen);
  42549. /**
  42550. * Sets the current loading screen text
  42551. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42552. */
  42553. set loadingUIText(text: string);
  42554. /**
  42555. * Sets the current loading screen background color
  42556. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42557. */
  42558. set loadingUIBackgroundColor(color: string);
  42559. /** Pointerlock and fullscreen */
  42560. /**
  42561. * Ask the browser to promote the current element to pointerlock mode
  42562. * @param element defines the DOM element to promote
  42563. */
  42564. static _RequestPointerlock(element: HTMLElement): void;
  42565. /**
  42566. * Asks the browser to exit pointerlock mode
  42567. */
  42568. static _ExitPointerlock(): void;
  42569. /**
  42570. * Ask the browser to promote the current element to fullscreen rendering mode
  42571. * @param element defines the DOM element to promote
  42572. */
  42573. static _RequestFullscreen(element: HTMLElement): void;
  42574. /**
  42575. * Asks the browser to exit fullscreen mode
  42576. */
  42577. static _ExitFullscreen(): void;
  42578. }
  42579. }
  42580. declare module "babylonjs/Engines/engineStore" {
  42581. import { Nullable } from "babylonjs/types";
  42582. import { Engine } from "babylonjs/Engines/engine";
  42583. import { Scene } from "babylonjs/scene";
  42584. /**
  42585. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42586. * during the life time of the application.
  42587. */
  42588. export class EngineStore {
  42589. /** Gets the list of created engines */
  42590. static Instances: import("babylonjs/Engines/engine").Engine[];
  42591. /** @hidden */
  42592. static _LastCreatedScene: Nullable<Scene>;
  42593. /**
  42594. * Gets the latest created engine
  42595. */
  42596. static get LastCreatedEngine(): Nullable<Engine>;
  42597. /**
  42598. * Gets the latest created scene
  42599. */
  42600. static get LastCreatedScene(): Nullable<Scene>;
  42601. /**
  42602. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42603. * @ignorenaming
  42604. */
  42605. static UseFallbackTexture: boolean;
  42606. /**
  42607. * Texture content used if a texture cannot loaded
  42608. * @ignorenaming
  42609. */
  42610. static FallbackTexture: string;
  42611. }
  42612. }
  42613. declare module "babylonjs/Misc/promise" {
  42614. /**
  42615. * Helper class that provides a small promise polyfill
  42616. */
  42617. export class PromisePolyfill {
  42618. /**
  42619. * Static function used to check if the polyfill is required
  42620. * If this is the case then the function will inject the polyfill to window.Promise
  42621. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42622. */
  42623. static Apply(force?: boolean): void;
  42624. }
  42625. }
  42626. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  42627. /**
  42628. * Interface for screenshot methods with describe argument called `size` as object with options
  42629. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42630. */
  42631. export interface IScreenshotSize {
  42632. /**
  42633. * number in pixels for canvas height
  42634. */
  42635. height?: number;
  42636. /**
  42637. * multiplier allowing render at a higher or lower resolution
  42638. * If value is defined then height and width will be ignored and taken from camera
  42639. */
  42640. precision?: number;
  42641. /**
  42642. * number in pixels for canvas width
  42643. */
  42644. width?: number;
  42645. }
  42646. }
  42647. declare module "babylonjs/Misc/tools" {
  42648. import { Nullable, float } from "babylonjs/types";
  42649. import { DomManagement } from "babylonjs/Misc/domManagement";
  42650. import { WebRequest } from "babylonjs/Misc/webRequest";
  42651. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  42652. import { ReadFileError } from "babylonjs/Misc/fileTools";
  42653. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42654. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  42655. import { Camera } from "babylonjs/Cameras/camera";
  42656. import { Engine } from "babylonjs/Engines/engine";
  42657. interface IColor4Like {
  42658. r: float;
  42659. g: float;
  42660. b: float;
  42661. a: float;
  42662. }
  42663. /**
  42664. * Class containing a set of static utilities functions
  42665. */
  42666. export class Tools {
  42667. /**
  42668. * Gets or sets the base URL to use to load assets
  42669. */
  42670. static get BaseUrl(): string;
  42671. static set BaseUrl(value: string);
  42672. /**
  42673. * Enable/Disable Custom HTTP Request Headers globally.
  42674. * default = false
  42675. * @see CustomRequestHeaders
  42676. */
  42677. static UseCustomRequestHeaders: boolean;
  42678. /**
  42679. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42680. * i.e. when loading files, where the server/service expects an Authorization header
  42681. */
  42682. static CustomRequestHeaders: {
  42683. [key: string]: string;
  42684. };
  42685. /**
  42686. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42687. */
  42688. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42689. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42690. /**
  42691. * Default behaviour for cors in the application.
  42692. * It can be a string if the expected behavior is identical in the entire app.
  42693. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42694. */
  42695. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42696. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42697. /**
  42698. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42699. * @ignorenaming
  42700. */
  42701. static get UseFallbackTexture(): boolean;
  42702. static set UseFallbackTexture(value: boolean);
  42703. /**
  42704. * Use this object to register external classes like custom textures or material
  42705. * to allow the laoders to instantiate them
  42706. */
  42707. static get RegisteredExternalClasses(): {
  42708. [key: string]: Object;
  42709. };
  42710. static set RegisteredExternalClasses(classes: {
  42711. [key: string]: Object;
  42712. });
  42713. /**
  42714. * Texture content used if a texture cannot loaded
  42715. * @ignorenaming
  42716. */
  42717. static get fallbackTexture(): string;
  42718. static set fallbackTexture(value: string);
  42719. /**
  42720. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42721. * @param u defines the coordinate on X axis
  42722. * @param v defines the coordinate on Y axis
  42723. * @param width defines the width of the source data
  42724. * @param height defines the height of the source data
  42725. * @param pixels defines the source byte array
  42726. * @param color defines the output color
  42727. */
  42728. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42729. /**
  42730. * Interpolates between a and b via alpha
  42731. * @param a The lower value (returned when alpha = 0)
  42732. * @param b The upper value (returned when alpha = 1)
  42733. * @param alpha The interpolation-factor
  42734. * @return The mixed value
  42735. */
  42736. static Mix(a: number, b: number, alpha: number): number;
  42737. /**
  42738. * Tries to instantiate a new object from a given class name
  42739. * @param className defines the class name to instantiate
  42740. * @returns the new object or null if the system was not able to do the instantiation
  42741. */
  42742. static Instantiate(className: string): any;
  42743. /**
  42744. * Provides a slice function that will work even on IE
  42745. * @param data defines the array to slice
  42746. * @param start defines the start of the data (optional)
  42747. * @param end defines the end of the data (optional)
  42748. * @returns the new sliced array
  42749. */
  42750. static Slice<T>(data: T, start?: number, end?: number): T;
  42751. /**
  42752. * Polyfill for setImmediate
  42753. * @param action defines the action to execute after the current execution block
  42754. */
  42755. static SetImmediate(action: () => void): void;
  42756. /**
  42757. * Function indicating if a number is an exponent of 2
  42758. * @param value defines the value to test
  42759. * @returns true if the value is an exponent of 2
  42760. */
  42761. static IsExponentOfTwo(value: number): boolean;
  42762. private static _tmpFloatArray;
  42763. /**
  42764. * Returns the nearest 32-bit single precision float representation of a Number
  42765. * @param value A Number. If the parameter is of a different type, it will get converted
  42766. * to a number or to NaN if it cannot be converted
  42767. * @returns number
  42768. */
  42769. static FloatRound(value: number): number;
  42770. /**
  42771. * Extracts the filename from a path
  42772. * @param path defines the path to use
  42773. * @returns the filename
  42774. */
  42775. static GetFilename(path: string): string;
  42776. /**
  42777. * Extracts the "folder" part of a path (everything before the filename).
  42778. * @param uri The URI to extract the info from
  42779. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42780. * @returns The "folder" part of the path
  42781. */
  42782. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42783. /**
  42784. * Extracts text content from a DOM element hierarchy
  42785. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42786. */
  42787. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42788. /**
  42789. * Convert an angle in radians to degrees
  42790. * @param angle defines the angle to convert
  42791. * @returns the angle in degrees
  42792. */
  42793. static ToDegrees(angle: number): number;
  42794. /**
  42795. * Convert an angle in degrees to radians
  42796. * @param angle defines the angle to convert
  42797. * @returns the angle in radians
  42798. */
  42799. static ToRadians(angle: number): number;
  42800. /**
  42801. * Returns an array if obj is not an array
  42802. * @param obj defines the object to evaluate as an array
  42803. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42804. * @returns either obj directly if obj is an array or a new array containing obj
  42805. */
  42806. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42807. /**
  42808. * Gets the pointer prefix to use
  42809. * @param engine defines the engine we are finding the prefix for
  42810. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42811. */
  42812. static GetPointerPrefix(engine: Engine): string;
  42813. /**
  42814. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42815. * @param url define the url we are trying
  42816. * @param element define the dom element where to configure the cors policy
  42817. */
  42818. static SetCorsBehavior(url: string | string[], element: {
  42819. crossOrigin: string | null;
  42820. }): void;
  42821. /**
  42822. * Removes unwanted characters from an url
  42823. * @param url defines the url to clean
  42824. * @returns the cleaned url
  42825. */
  42826. static CleanUrl(url: string): string;
  42827. /**
  42828. * Gets or sets a function used to pre-process url before using them to load assets
  42829. */
  42830. static get PreprocessUrl(): (url: string) => string;
  42831. static set PreprocessUrl(processor: (url: string) => string);
  42832. /**
  42833. * Loads an image as an HTMLImageElement.
  42834. * @param input url string, ArrayBuffer, or Blob to load
  42835. * @param onLoad callback called when the image successfully loads
  42836. * @param onError callback called when the image fails to load
  42837. * @param offlineProvider offline provider for caching
  42838. * @param mimeType optional mime type
  42839. * @returns the HTMLImageElement of the loaded image
  42840. */
  42841. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42842. /**
  42843. * Loads a file from a url
  42844. * @param url url string, ArrayBuffer, or Blob to load
  42845. * @param onSuccess callback called when the file successfully loads
  42846. * @param onProgress callback called while file is loading (if the server supports this mode)
  42847. * @param offlineProvider defines the offline provider for caching
  42848. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42849. * @param onError callback called when the file fails to load
  42850. * @returns a file request object
  42851. */
  42852. 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;
  42853. /**
  42854. * Loads a file from a url
  42855. * @param url the file url to load
  42856. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42857. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  42858. */
  42859. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  42860. /**
  42861. * Load a script (identified by an url). When the url returns, the
  42862. * content of this file is added into a new script element, attached to the DOM (body element)
  42863. * @param scriptUrl defines the url of the script to laod
  42864. * @param onSuccess defines the callback called when the script is loaded
  42865. * @param onError defines the callback to call if an error occurs
  42866. * @param scriptId defines the id of the script element
  42867. */
  42868. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  42869. /**
  42870. * Load an asynchronous script (identified by an url). When the url returns, the
  42871. * content of this file is added into a new script element, attached to the DOM (body element)
  42872. * @param scriptUrl defines the url of the script to laod
  42873. * @param scriptId defines the id of the script element
  42874. * @returns a promise request object
  42875. */
  42876. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  42877. /**
  42878. * Loads a file from a blob
  42879. * @param fileToLoad defines the blob to use
  42880. * @param callback defines the callback to call when data is loaded
  42881. * @param progressCallback defines the callback to call during loading process
  42882. * @returns a file request object
  42883. */
  42884. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  42885. /**
  42886. * Reads a file from a File object
  42887. * @param file defines the file to load
  42888. * @param onSuccess defines the callback to call when data is loaded
  42889. * @param onProgress defines the callback to call during loading process
  42890. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42891. * @param onError defines the callback to call when an error occurs
  42892. * @returns a file request object
  42893. */
  42894. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42895. /**
  42896. * Creates a data url from a given string content
  42897. * @param content defines the content to convert
  42898. * @returns the new data url link
  42899. */
  42900. static FileAsURL(content: string): string;
  42901. /**
  42902. * Format the given number to a specific decimal format
  42903. * @param value defines the number to format
  42904. * @param decimals defines the number of decimals to use
  42905. * @returns the formatted string
  42906. */
  42907. static Format(value: number, decimals?: number): string;
  42908. /**
  42909. * Tries to copy an object by duplicating every property
  42910. * @param source defines the source object
  42911. * @param destination defines the target object
  42912. * @param doNotCopyList defines a list of properties to avoid
  42913. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  42914. */
  42915. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  42916. /**
  42917. * Gets a boolean indicating if the given object has no own property
  42918. * @param obj defines the object to test
  42919. * @returns true if object has no own property
  42920. */
  42921. static IsEmpty(obj: any): boolean;
  42922. /**
  42923. * Function used to register events at window level
  42924. * @param windowElement defines the Window object to use
  42925. * @param events defines the events to register
  42926. */
  42927. static RegisterTopRootEvents(windowElement: Window, events: {
  42928. name: string;
  42929. handler: Nullable<(e: FocusEvent) => any>;
  42930. }[]): void;
  42931. /**
  42932. * Function used to unregister events from window level
  42933. * @param windowElement defines the Window object to use
  42934. * @param events defines the events to unregister
  42935. */
  42936. static UnregisterTopRootEvents(windowElement: Window, events: {
  42937. name: string;
  42938. handler: Nullable<(e: FocusEvent) => any>;
  42939. }[]): void;
  42940. /**
  42941. * @ignore
  42942. */
  42943. static _ScreenshotCanvas: HTMLCanvasElement;
  42944. /**
  42945. * Dumps the current bound framebuffer
  42946. * @param width defines the rendering width
  42947. * @param height defines the rendering height
  42948. * @param engine defines the hosting engine
  42949. * @param successCallback defines the callback triggered once the data are available
  42950. * @param mimeType defines the mime type of the result
  42951. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  42952. */
  42953. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42954. /**
  42955. * Converts the canvas data to blob.
  42956. * This acts as a polyfill for browsers not supporting the to blob function.
  42957. * @param canvas Defines the canvas to extract the data from
  42958. * @param successCallback Defines the callback triggered once the data are available
  42959. * @param mimeType Defines the mime type of the result
  42960. */
  42961. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  42962. /**
  42963. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  42964. * @param successCallback defines the callback triggered once the data are available
  42965. * @param mimeType defines the mime type of the result
  42966. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  42967. */
  42968. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42969. /**
  42970. * Downloads a blob in the browser
  42971. * @param blob defines the blob to download
  42972. * @param fileName defines the name of the downloaded file
  42973. */
  42974. static Download(blob: Blob, fileName: string): void;
  42975. /**
  42976. * Captures a screenshot of the current rendering
  42977. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42978. * @param engine defines the rendering engine
  42979. * @param camera defines the source camera
  42980. * @param size This parameter can be set to a single number or to an object with the
  42981. * following (optional) properties: precision, width, height. If a single number is passed,
  42982. * it will be used for both width and height. If an object is passed, the screenshot size
  42983. * will be derived from the parameters. The precision property is a multiplier allowing
  42984. * rendering at a higher or lower resolution
  42985. * @param successCallback defines the callback receives a single parameter which contains the
  42986. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42987. * src parameter of an <img> to display it
  42988. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42989. * Check your browser for supported MIME types
  42990. */
  42991. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  42992. /**
  42993. * Captures a screenshot of the current rendering
  42994. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42995. * @param engine defines the rendering engine
  42996. * @param camera defines the source camera
  42997. * @param size This parameter can be set to a single number or to an object with the
  42998. * following (optional) properties: precision, width, height. If a single number is passed,
  42999. * it will be used for both width and height. If an object is passed, the screenshot size
  43000. * will be derived from the parameters. The precision property is a multiplier allowing
  43001. * rendering at a higher or lower resolution
  43002. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43003. * Check your browser for supported MIME types
  43004. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43005. * to the src parameter of an <img> to display it
  43006. */
  43007. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43008. /**
  43009. * Generates an image screenshot from the specified camera.
  43010. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43011. * @param engine The engine to use for rendering
  43012. * @param camera The camera to use for rendering
  43013. * @param size This parameter can be set to a single number or to an object with the
  43014. * following (optional) properties: precision, width, height. If a single number is passed,
  43015. * it will be used for both width and height. If an object is passed, the screenshot size
  43016. * will be derived from the parameters. The precision property is a multiplier allowing
  43017. * rendering at a higher or lower resolution
  43018. * @param successCallback The callback receives a single parameter which contains the
  43019. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43020. * src parameter of an <img> to display it
  43021. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43022. * Check your browser for supported MIME types
  43023. * @param samples Texture samples (default: 1)
  43024. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43025. * @param fileName A name for for the downloaded file.
  43026. */
  43027. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43028. /**
  43029. * Generates an image screenshot from the specified camera.
  43030. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43031. * @param engine The engine to use for rendering
  43032. * @param camera The camera to use for rendering
  43033. * @param size This parameter can be set to a single number or to an object with the
  43034. * following (optional) properties: precision, width, height. If a single number is passed,
  43035. * it will be used for both width and height. If an object is passed, the screenshot size
  43036. * will be derived from the parameters. The precision property is a multiplier allowing
  43037. * rendering at a higher or lower resolution
  43038. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43039. * Check your browser for supported MIME types
  43040. * @param samples Texture samples (default: 1)
  43041. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43042. * @param fileName A name for for the downloaded file.
  43043. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43044. * to the src parameter of an <img> to display it
  43045. */
  43046. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43047. /**
  43048. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43049. * Be aware Math.random() could cause collisions, but:
  43050. * "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"
  43051. * @returns a pseudo random id
  43052. */
  43053. static RandomId(): string;
  43054. /**
  43055. * Test if the given uri is a base64 string
  43056. * @param uri The uri to test
  43057. * @return True if the uri is a base64 string or false otherwise
  43058. */
  43059. static IsBase64(uri: string): boolean;
  43060. /**
  43061. * Decode the given base64 uri.
  43062. * @param uri The uri to decode
  43063. * @return The decoded base64 data.
  43064. */
  43065. static DecodeBase64(uri: string): ArrayBuffer;
  43066. /**
  43067. * Gets the absolute url.
  43068. * @param url the input url
  43069. * @return the absolute url
  43070. */
  43071. static GetAbsoluteUrl(url: string): string;
  43072. /**
  43073. * No log
  43074. */
  43075. static readonly NoneLogLevel: number;
  43076. /**
  43077. * Only message logs
  43078. */
  43079. static readonly MessageLogLevel: number;
  43080. /**
  43081. * Only warning logs
  43082. */
  43083. static readonly WarningLogLevel: number;
  43084. /**
  43085. * Only error logs
  43086. */
  43087. static readonly ErrorLogLevel: number;
  43088. /**
  43089. * All logs
  43090. */
  43091. static readonly AllLogLevel: number;
  43092. /**
  43093. * Gets a value indicating the number of loading errors
  43094. * @ignorenaming
  43095. */
  43096. static get errorsCount(): number;
  43097. /**
  43098. * Callback called when a new log is added
  43099. */
  43100. static OnNewCacheEntry: (entry: string) => void;
  43101. /**
  43102. * Log a message to the console
  43103. * @param message defines the message to log
  43104. */
  43105. static Log(message: string): void;
  43106. /**
  43107. * Write a warning message to the console
  43108. * @param message defines the message to log
  43109. */
  43110. static Warn(message: string): void;
  43111. /**
  43112. * Write an error message to the console
  43113. * @param message defines the message to log
  43114. */
  43115. static Error(message: string): void;
  43116. /**
  43117. * Gets current log cache (list of logs)
  43118. */
  43119. static get LogCache(): string;
  43120. /**
  43121. * Clears the log cache
  43122. */
  43123. static ClearLogCache(): void;
  43124. /**
  43125. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43126. */
  43127. static set LogLevels(level: number);
  43128. /**
  43129. * Checks if the window object exists
  43130. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43131. */
  43132. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43133. /**
  43134. * No performance log
  43135. */
  43136. static readonly PerformanceNoneLogLevel: number;
  43137. /**
  43138. * Use user marks to log performance
  43139. */
  43140. static readonly PerformanceUserMarkLogLevel: number;
  43141. /**
  43142. * Log performance to the console
  43143. */
  43144. static readonly PerformanceConsoleLogLevel: number;
  43145. private static _performance;
  43146. /**
  43147. * Sets the current performance log level
  43148. */
  43149. static set PerformanceLogLevel(level: number);
  43150. private static _StartPerformanceCounterDisabled;
  43151. private static _EndPerformanceCounterDisabled;
  43152. private static _StartUserMark;
  43153. private static _EndUserMark;
  43154. private static _StartPerformanceConsole;
  43155. private static _EndPerformanceConsole;
  43156. /**
  43157. * Starts a performance counter
  43158. */
  43159. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43160. /**
  43161. * Ends a specific performance coutner
  43162. */
  43163. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43164. /**
  43165. * Gets either window.performance.now() if supported or Date.now() else
  43166. */
  43167. static get Now(): number;
  43168. /**
  43169. * This method will return the name of the class used to create the instance of the given object.
  43170. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43171. * @param object the object to get the class name from
  43172. * @param isType defines if the object is actually a type
  43173. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43174. */
  43175. static GetClassName(object: any, isType?: boolean): string;
  43176. /**
  43177. * Gets the first element of an array satisfying a given predicate
  43178. * @param array defines the array to browse
  43179. * @param predicate defines the predicate to use
  43180. * @returns null if not found or the element
  43181. */
  43182. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43183. /**
  43184. * This method will return the name of the full name of the class, including its owning module (if any).
  43185. * 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).
  43186. * @param object the object to get the class name from
  43187. * @param isType defines if the object is actually a type
  43188. * @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.
  43189. * @ignorenaming
  43190. */
  43191. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43192. /**
  43193. * Returns a promise that resolves after the given amount of time.
  43194. * @param delay Number of milliseconds to delay
  43195. * @returns Promise that resolves after the given amount of time
  43196. */
  43197. static DelayAsync(delay: number): Promise<void>;
  43198. /**
  43199. * Utility function to detect if the current user agent is Safari
  43200. * @returns whether or not the current user agent is safari
  43201. */
  43202. static IsSafari(): boolean;
  43203. }
  43204. /**
  43205. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43206. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43207. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43208. * @param name The name of the class, case should be preserved
  43209. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43210. */
  43211. export function className(name: string, module?: string): (target: Object) => void;
  43212. /**
  43213. * An implementation of a loop for asynchronous functions.
  43214. */
  43215. export class AsyncLoop {
  43216. /**
  43217. * Defines the number of iterations for the loop
  43218. */
  43219. iterations: number;
  43220. /**
  43221. * Defines the current index of the loop.
  43222. */
  43223. index: number;
  43224. private _done;
  43225. private _fn;
  43226. private _successCallback;
  43227. /**
  43228. * Constructor.
  43229. * @param iterations the number of iterations.
  43230. * @param func the function to run each iteration
  43231. * @param successCallback the callback that will be called upon succesful execution
  43232. * @param offset starting offset.
  43233. */
  43234. constructor(
  43235. /**
  43236. * Defines the number of iterations for the loop
  43237. */
  43238. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43239. /**
  43240. * Execute the next iteration. Must be called after the last iteration was finished.
  43241. */
  43242. executeNext(): void;
  43243. /**
  43244. * Break the loop and run the success callback.
  43245. */
  43246. breakLoop(): void;
  43247. /**
  43248. * Create and run an async loop.
  43249. * @param iterations the number of iterations.
  43250. * @param fn the function to run each iteration
  43251. * @param successCallback the callback that will be called upon succesful execution
  43252. * @param offset starting offset.
  43253. * @returns the created async loop object
  43254. */
  43255. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43256. /**
  43257. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43258. * @param iterations total number of iterations
  43259. * @param syncedIterations number of synchronous iterations in each async iteration.
  43260. * @param fn the function to call each iteration.
  43261. * @param callback a success call back that will be called when iterating stops.
  43262. * @param breakFunction a break condition (optional)
  43263. * @param timeout timeout settings for the setTimeout function. default - 0.
  43264. * @returns the created async loop object
  43265. */
  43266. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43267. }
  43268. }
  43269. declare module "babylonjs/Misc/stringDictionary" {
  43270. import { Nullable } from "babylonjs/types";
  43271. /**
  43272. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43273. * The underlying implementation relies on an associative array to ensure the best performances.
  43274. * The value can be anything including 'null' but except 'undefined'
  43275. */
  43276. export class StringDictionary<T> {
  43277. /**
  43278. * This will clear this dictionary and copy the content from the 'source' one.
  43279. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43280. * @param source the dictionary to take the content from and copy to this dictionary
  43281. */
  43282. copyFrom(source: StringDictionary<T>): void;
  43283. /**
  43284. * Get a value based from its key
  43285. * @param key the given key to get the matching value from
  43286. * @return the value if found, otherwise undefined is returned
  43287. */
  43288. get(key: string): T | undefined;
  43289. /**
  43290. * Get a value from its key or add it if it doesn't exist.
  43291. * This method will ensure you that a given key/data will be present in the dictionary.
  43292. * @param key the given key to get the matching value from
  43293. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43294. * The factory will only be invoked if there's no data for the given key.
  43295. * @return the value corresponding to the key.
  43296. */
  43297. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43298. /**
  43299. * Get a value from its key if present in the dictionary otherwise add it
  43300. * @param key the key to get the value from
  43301. * @param val if there's no such key/value pair in the dictionary add it with this value
  43302. * @return the value corresponding to the key
  43303. */
  43304. getOrAdd(key: string, val: T): T;
  43305. /**
  43306. * Check if there's a given key in the dictionary
  43307. * @param key the key to check for
  43308. * @return true if the key is present, false otherwise
  43309. */
  43310. contains(key: string): boolean;
  43311. /**
  43312. * Add a new key and its corresponding value
  43313. * @param key the key to add
  43314. * @param value the value corresponding to the key
  43315. * @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
  43316. */
  43317. add(key: string, value: T): boolean;
  43318. /**
  43319. * Update a specific value associated to a key
  43320. * @param key defines the key to use
  43321. * @param value defines the value to store
  43322. * @returns true if the value was updated (or false if the key was not found)
  43323. */
  43324. set(key: string, value: T): boolean;
  43325. /**
  43326. * Get the element of the given key and remove it from the dictionary
  43327. * @param key defines the key to search
  43328. * @returns the value associated with the key or null if not found
  43329. */
  43330. getAndRemove(key: string): Nullable<T>;
  43331. /**
  43332. * Remove a key/value from the dictionary.
  43333. * @param key the key to remove
  43334. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43335. */
  43336. remove(key: string): boolean;
  43337. /**
  43338. * Clear the whole content of the dictionary
  43339. */
  43340. clear(): void;
  43341. /**
  43342. * Gets the current count
  43343. */
  43344. get count(): number;
  43345. /**
  43346. * Execute a callback on each key/val of the dictionary.
  43347. * Note that you can remove any element in this dictionary in the callback implementation
  43348. * @param callback the callback to execute on a given key/value pair
  43349. */
  43350. forEach(callback: (key: string, val: T) => void): void;
  43351. /**
  43352. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43353. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43354. * Note that you can remove any element in this dictionary in the callback implementation
  43355. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43356. * @returns the first item
  43357. */
  43358. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43359. private _count;
  43360. private _data;
  43361. }
  43362. }
  43363. declare module "babylonjs/Collisions/collisionCoordinator" {
  43364. import { Nullable } from "babylonjs/types";
  43365. import { Scene } from "babylonjs/scene";
  43366. import { Vector3 } from "babylonjs/Maths/math.vector";
  43367. import { Collider } from "babylonjs/Collisions/collider";
  43368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43369. /** @hidden */
  43370. export interface ICollisionCoordinator {
  43371. createCollider(): Collider;
  43372. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43373. init(scene: Scene): void;
  43374. }
  43375. /** @hidden */
  43376. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43377. private _scene;
  43378. private _scaledPosition;
  43379. private _scaledVelocity;
  43380. private _finalPosition;
  43381. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43382. createCollider(): Collider;
  43383. init(scene: Scene): void;
  43384. private _collideWithWorld;
  43385. }
  43386. }
  43387. declare module "babylonjs/Inputs/scene.inputManager" {
  43388. import { Nullable } from "babylonjs/types";
  43389. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43390. import { Vector2 } from "babylonjs/Maths/math.vector";
  43391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43392. import { Scene } from "babylonjs/scene";
  43393. /**
  43394. * Class used to manage all inputs for the scene.
  43395. */
  43396. export class InputManager {
  43397. /** The distance in pixel that you have to move to prevent some events */
  43398. static DragMovementThreshold: number;
  43399. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43400. static LongPressDelay: number;
  43401. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43402. static DoubleClickDelay: number;
  43403. /** If you need to check double click without raising a single click at first click, enable this flag */
  43404. static ExclusiveDoubleClickMode: boolean;
  43405. /** 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. */
  43406. private _alreadyAttached;
  43407. private _wheelEventName;
  43408. private _onPointerMove;
  43409. private _onPointerDown;
  43410. private _onPointerUp;
  43411. private _initClickEvent;
  43412. private _initActionManager;
  43413. private _delayedSimpleClick;
  43414. private _delayedSimpleClickTimeout;
  43415. private _previousDelayedSimpleClickTimeout;
  43416. private _meshPickProceed;
  43417. private _previousButtonPressed;
  43418. private _currentPickResult;
  43419. private _previousPickResult;
  43420. private _totalPointersPressed;
  43421. private _doubleClickOccured;
  43422. private _pointerOverMesh;
  43423. private _pickedDownMesh;
  43424. private _pickedUpMesh;
  43425. private _pointerX;
  43426. private _pointerY;
  43427. private _unTranslatedPointerX;
  43428. private _unTranslatedPointerY;
  43429. private _startingPointerPosition;
  43430. private _previousStartingPointerPosition;
  43431. private _startingPointerTime;
  43432. private _previousStartingPointerTime;
  43433. private _pointerCaptures;
  43434. private _meshUnderPointerId;
  43435. private _onKeyDown;
  43436. private _onKeyUp;
  43437. private _onCanvasFocusObserver;
  43438. private _onCanvasBlurObserver;
  43439. private _scene;
  43440. /**
  43441. * Creates a new InputManager
  43442. * @param scene defines the hosting scene
  43443. */
  43444. constructor(scene: Scene);
  43445. /**
  43446. * Gets the mesh that is currently under the pointer
  43447. */
  43448. get meshUnderPointer(): Nullable<AbstractMesh>;
  43449. /**
  43450. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43451. * @param pointerId the pointer id to use
  43452. * @returns The mesh under this pointer id or null if not found
  43453. */
  43454. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43455. /**
  43456. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43457. */
  43458. get unTranslatedPointer(): Vector2;
  43459. /**
  43460. * Gets or sets the current on-screen X position of the pointer
  43461. */
  43462. get pointerX(): number;
  43463. set pointerX(value: number);
  43464. /**
  43465. * Gets or sets the current on-screen Y position of the pointer
  43466. */
  43467. get pointerY(): number;
  43468. set pointerY(value: number);
  43469. private _updatePointerPosition;
  43470. private _processPointerMove;
  43471. private _setRayOnPointerInfo;
  43472. private _checkPrePointerObservable;
  43473. /**
  43474. * Use this method to simulate a pointer move on a mesh
  43475. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43476. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43477. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43478. */
  43479. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43480. /**
  43481. * Use this method to simulate a pointer down on a mesh
  43482. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43483. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43484. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43485. */
  43486. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43487. private _processPointerDown;
  43488. /** @hidden */
  43489. _isPointerSwiping(): boolean;
  43490. /**
  43491. * Use this method to simulate a pointer up on a mesh
  43492. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43493. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43494. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43495. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43496. */
  43497. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43498. private _processPointerUp;
  43499. /**
  43500. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43501. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43502. * @returns true if the pointer was captured
  43503. */
  43504. isPointerCaptured(pointerId?: number): boolean;
  43505. /**
  43506. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43507. * @param attachUp defines if you want to attach events to pointerup
  43508. * @param attachDown defines if you want to attach events to pointerdown
  43509. * @param attachMove defines if you want to attach events to pointermove
  43510. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43511. */
  43512. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43513. /**
  43514. * Detaches all event handlers
  43515. */
  43516. detachControl(): void;
  43517. /**
  43518. * Force the value of meshUnderPointer
  43519. * @param mesh defines the mesh to use
  43520. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43521. */
  43522. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43523. /**
  43524. * Gets the mesh under the pointer
  43525. * @returns a Mesh or null if no mesh is under the pointer
  43526. */
  43527. getPointerOverMesh(): Nullable<AbstractMesh>;
  43528. }
  43529. }
  43530. declare module "babylonjs/Animations/animationGroup" {
  43531. import { Animatable } from "babylonjs/Animations/animatable";
  43532. import { Animation } from "babylonjs/Animations/animation";
  43533. import { Scene, IDisposable } from "babylonjs/scene";
  43534. import { Observable } from "babylonjs/Misc/observable";
  43535. import { Nullable } from "babylonjs/types";
  43536. import "babylonjs/Animations/animatable";
  43537. /**
  43538. * This class defines the direct association between an animation and a target
  43539. */
  43540. export class TargetedAnimation {
  43541. /**
  43542. * Animation to perform
  43543. */
  43544. animation: Animation;
  43545. /**
  43546. * Target to animate
  43547. */
  43548. target: any;
  43549. /**
  43550. * Returns the string "TargetedAnimation"
  43551. * @returns "TargetedAnimation"
  43552. */
  43553. getClassName(): string;
  43554. /**
  43555. * Serialize the object
  43556. * @returns the JSON object representing the current entity
  43557. */
  43558. serialize(): any;
  43559. }
  43560. /**
  43561. * Use this class to create coordinated animations on multiple targets
  43562. */
  43563. export class AnimationGroup implements IDisposable {
  43564. /** The name of the animation group */
  43565. name: string;
  43566. private _scene;
  43567. private _targetedAnimations;
  43568. private _animatables;
  43569. private _from;
  43570. private _to;
  43571. private _isStarted;
  43572. private _isPaused;
  43573. private _speedRatio;
  43574. private _loopAnimation;
  43575. private _isAdditive;
  43576. /**
  43577. * Gets or sets the unique id of the node
  43578. */
  43579. uniqueId: number;
  43580. /**
  43581. * This observable will notify when one animation have ended
  43582. */
  43583. onAnimationEndObservable: Observable<TargetedAnimation>;
  43584. /**
  43585. * Observer raised when one animation loops
  43586. */
  43587. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43588. /**
  43589. * Observer raised when all animations have looped
  43590. */
  43591. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43592. /**
  43593. * This observable will notify when all animations have ended.
  43594. */
  43595. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43596. /**
  43597. * This observable will notify when all animations have paused.
  43598. */
  43599. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43600. /**
  43601. * This observable will notify when all animations are playing.
  43602. */
  43603. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43604. /**
  43605. * Gets the first frame
  43606. */
  43607. get from(): number;
  43608. /**
  43609. * Gets the last frame
  43610. */
  43611. get to(): number;
  43612. /**
  43613. * Define if the animations are started
  43614. */
  43615. get isStarted(): boolean;
  43616. /**
  43617. * Gets a value indicating that the current group is playing
  43618. */
  43619. get isPlaying(): boolean;
  43620. /**
  43621. * Gets or sets the speed ratio to use for all animations
  43622. */
  43623. get speedRatio(): number;
  43624. /**
  43625. * Gets or sets the speed ratio to use for all animations
  43626. */
  43627. set speedRatio(value: number);
  43628. /**
  43629. * Gets or sets if all animations should loop or not
  43630. */
  43631. get loopAnimation(): boolean;
  43632. set loopAnimation(value: boolean);
  43633. /**
  43634. * Gets or sets if all animations should be evaluated additively
  43635. */
  43636. get isAdditive(): boolean;
  43637. set isAdditive(value: boolean);
  43638. /**
  43639. * Gets the targeted animations for this animation group
  43640. */
  43641. get targetedAnimations(): Array<TargetedAnimation>;
  43642. /**
  43643. * returning the list of animatables controlled by this animation group.
  43644. */
  43645. get animatables(): Array<Animatable>;
  43646. /**
  43647. * Gets the list of target animations
  43648. */
  43649. get children(): TargetedAnimation[];
  43650. /**
  43651. * Instantiates a new Animation Group.
  43652. * This helps managing several animations at once.
  43653. * @see https://doc.babylonjs.com/how_to/group
  43654. * @param name Defines the name of the group
  43655. * @param scene Defines the scene the group belongs to
  43656. */
  43657. constructor(
  43658. /** The name of the animation group */
  43659. name: string, scene?: Nullable<Scene>);
  43660. /**
  43661. * Add an animation (with its target) in the group
  43662. * @param animation defines the animation we want to add
  43663. * @param target defines the target of the animation
  43664. * @returns the TargetedAnimation object
  43665. */
  43666. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43667. /**
  43668. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43669. * It can add constant keys at begin or end
  43670. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43671. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43672. * @returns the animation group
  43673. */
  43674. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43675. private _animationLoopCount;
  43676. private _animationLoopFlags;
  43677. private _processLoop;
  43678. /**
  43679. * Start all animations on given targets
  43680. * @param loop defines if animations must loop
  43681. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43682. * @param from defines the from key (optional)
  43683. * @param to defines the to key (optional)
  43684. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43685. * @returns the current animation group
  43686. */
  43687. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43688. /**
  43689. * Pause all animations
  43690. * @returns the animation group
  43691. */
  43692. pause(): AnimationGroup;
  43693. /**
  43694. * Play all animations to initial state
  43695. * This function will start() the animations if they were not started or will restart() them if they were paused
  43696. * @param loop defines if animations must loop
  43697. * @returns the animation group
  43698. */
  43699. play(loop?: boolean): AnimationGroup;
  43700. /**
  43701. * Reset all animations to initial state
  43702. * @returns the animation group
  43703. */
  43704. reset(): AnimationGroup;
  43705. /**
  43706. * Restart animations from key 0
  43707. * @returns the animation group
  43708. */
  43709. restart(): AnimationGroup;
  43710. /**
  43711. * Stop all animations
  43712. * @returns the animation group
  43713. */
  43714. stop(): AnimationGroup;
  43715. /**
  43716. * Set animation weight for all animatables
  43717. * @param weight defines the weight to use
  43718. * @return the animationGroup
  43719. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43720. */
  43721. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43722. /**
  43723. * Synchronize and normalize all animatables with a source animatable
  43724. * @param root defines the root animatable to synchronize with
  43725. * @return the animationGroup
  43726. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43727. */
  43728. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43729. /**
  43730. * Goes to a specific frame in this animation group
  43731. * @param frame the frame number to go to
  43732. * @return the animationGroup
  43733. */
  43734. goToFrame(frame: number): AnimationGroup;
  43735. /**
  43736. * Dispose all associated resources
  43737. */
  43738. dispose(): void;
  43739. private _checkAnimationGroupEnded;
  43740. /**
  43741. * Clone the current animation group and returns a copy
  43742. * @param newName defines the name of the new group
  43743. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43744. * @returns the new aniamtion group
  43745. */
  43746. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43747. /**
  43748. * Serializes the animationGroup to an object
  43749. * @returns Serialized object
  43750. */
  43751. serialize(): any;
  43752. /**
  43753. * Returns a new AnimationGroup object parsed from the source provided.
  43754. * @param parsedAnimationGroup defines the source
  43755. * @param scene defines the scene that will receive the animationGroup
  43756. * @returns a new AnimationGroup
  43757. */
  43758. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43759. /**
  43760. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43761. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43762. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43763. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43764. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43765. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43766. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43767. */
  43768. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43769. /**
  43770. * Returns the string "AnimationGroup"
  43771. * @returns "AnimationGroup"
  43772. */
  43773. getClassName(): string;
  43774. /**
  43775. * Creates a detailled string about the object
  43776. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43777. * @returns a string representing the object
  43778. */
  43779. toString(fullDetails?: boolean): string;
  43780. }
  43781. }
  43782. declare module "babylonjs/scene" {
  43783. import { Nullable } from "babylonjs/types";
  43784. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  43785. import { Observable } from "babylonjs/Misc/observable";
  43786. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43787. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  43788. import { Geometry } from "babylonjs/Meshes/geometry";
  43789. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43790. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43792. import { Mesh } from "babylonjs/Meshes/mesh";
  43793. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43794. import { Bone } from "babylonjs/Bones/bone";
  43795. import { Skeleton } from "babylonjs/Bones/skeleton";
  43796. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  43797. import { Camera } from "babylonjs/Cameras/camera";
  43798. import { AbstractScene } from "babylonjs/abstractScene";
  43799. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43800. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43801. import { Material } from "babylonjs/Materials/material";
  43802. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43803. import { Effect } from "babylonjs/Materials/effect";
  43804. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  43805. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  43806. import { Light } from "babylonjs/Lights/light";
  43807. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43808. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  43809. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  43810. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  43811. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  43812. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43813. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  43814. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  43815. import { Engine } from "babylonjs/Engines/engine";
  43816. import { Node } from "babylonjs/node";
  43817. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  43818. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  43819. import { WebRequest } from "babylonjs/Misc/webRequest";
  43820. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  43821. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  43822. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43823. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  43824. import { Plane } from "babylonjs/Maths/math.plane";
  43825. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  43826. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  43827. import { Ray } from "babylonjs/Culling/ray";
  43828. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  43829. import { Animation } from "babylonjs/Animations/animation";
  43830. import { Animatable } from "babylonjs/Animations/animatable";
  43831. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43832. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  43833. import { Collider } from "babylonjs/Collisions/collider";
  43834. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43835. /**
  43836. * Define an interface for all classes that will hold resources
  43837. */
  43838. export interface IDisposable {
  43839. /**
  43840. * Releases all held resources
  43841. */
  43842. dispose(): void;
  43843. }
  43844. /** Interface defining initialization parameters for Scene class */
  43845. export interface SceneOptions {
  43846. /**
  43847. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  43848. * It will improve performance when the number of geometries becomes important.
  43849. */
  43850. useGeometryUniqueIdsMap?: boolean;
  43851. /**
  43852. * Defines that each material of the scene should keep up-to-date a map of referencing 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. useMaterialMeshMap?: boolean;
  43856. /**
  43857. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  43858. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  43859. */
  43860. useClonedMeshMap?: boolean;
  43861. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  43862. virtual?: boolean;
  43863. }
  43864. /**
  43865. * Represents a scene to be rendered by the engine.
  43866. * @see https://doc.babylonjs.com/features/scene
  43867. */
  43868. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  43869. /** The fog is deactivated */
  43870. static readonly FOGMODE_NONE: number;
  43871. /** The fog density is following an exponential function */
  43872. static readonly FOGMODE_EXP: number;
  43873. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  43874. static readonly FOGMODE_EXP2: number;
  43875. /** The fog density is following a linear function. */
  43876. static readonly FOGMODE_LINEAR: number;
  43877. /**
  43878. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  43879. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43880. */
  43881. static MinDeltaTime: number;
  43882. /**
  43883. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  43884. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43885. */
  43886. static MaxDeltaTime: number;
  43887. /**
  43888. * Factory used to create the default material.
  43889. * @param name The name of the material to create
  43890. * @param scene The scene to create the material for
  43891. * @returns The default material
  43892. */
  43893. static DefaultMaterialFactory(scene: Scene): Material;
  43894. /**
  43895. * Factory used to create the a collision coordinator.
  43896. * @returns The collision coordinator
  43897. */
  43898. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  43899. /** @hidden */
  43900. _inputManager: InputManager;
  43901. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  43902. cameraToUseForPointers: Nullable<Camera>;
  43903. /** @hidden */
  43904. readonly _isScene: boolean;
  43905. /** @hidden */
  43906. _blockEntityCollection: boolean;
  43907. /**
  43908. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  43909. */
  43910. autoClear: boolean;
  43911. /**
  43912. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  43913. */
  43914. autoClearDepthAndStencil: boolean;
  43915. /**
  43916. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  43917. */
  43918. clearColor: Color4;
  43919. /**
  43920. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  43921. */
  43922. ambientColor: Color3;
  43923. /**
  43924. * This is use to store the default BRDF lookup for PBR materials in your scene.
  43925. * It should only be one of the following (if not the default embedded one):
  43926. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  43927. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  43928. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  43929. * The material properties need to be setup according to the type of texture in use.
  43930. */
  43931. environmentBRDFTexture: BaseTexture;
  43932. /**
  43933. * Texture used in all pbr material as the reflection texture.
  43934. * As in the majority of the scene they are the same (exception for multi room and so on),
  43935. * this is easier to reference from here than from all the materials.
  43936. */
  43937. get environmentTexture(): Nullable<BaseTexture>;
  43938. /**
  43939. * Texture used in all pbr material as the reflection texture.
  43940. * As in the majority of the scene they are the same (exception for multi room and so on),
  43941. * this is easier to set here than in all the materials.
  43942. */
  43943. set environmentTexture(value: Nullable<BaseTexture>);
  43944. /** @hidden */
  43945. protected _environmentIntensity: number;
  43946. /**
  43947. * Intensity of the environment in all pbr material.
  43948. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  43949. * As in the majority of the scene they are the same (exception for multi room and so on),
  43950. * this is easier to reference from here than from all the materials.
  43951. */
  43952. get environmentIntensity(): number;
  43953. /**
  43954. * Intensity of the environment in all pbr material.
  43955. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  43956. * As in the majority of the scene they are the same (exception for multi room and so on),
  43957. * this is easier to set here than in all the materials.
  43958. */
  43959. set environmentIntensity(value: number);
  43960. /** @hidden */
  43961. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43962. /**
  43963. * Default image processing configuration used either in the rendering
  43964. * Forward main pass or through the imageProcessingPostProcess if present.
  43965. * As in the majority of the scene they are the same (exception for multi camera),
  43966. * this is easier to reference from here than from all the materials and post process.
  43967. *
  43968. * No setter as we it is a shared configuration, you can set the values instead.
  43969. */
  43970. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43971. private _forceWireframe;
  43972. /**
  43973. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  43974. */
  43975. set forceWireframe(value: boolean);
  43976. get forceWireframe(): boolean;
  43977. private _skipFrustumClipping;
  43978. /**
  43979. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  43980. */
  43981. set skipFrustumClipping(value: boolean);
  43982. get skipFrustumClipping(): boolean;
  43983. private _forcePointsCloud;
  43984. /**
  43985. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  43986. */
  43987. set forcePointsCloud(value: boolean);
  43988. get forcePointsCloud(): boolean;
  43989. /**
  43990. * Gets or sets the active clipplane 1
  43991. */
  43992. clipPlane: Nullable<Plane>;
  43993. /**
  43994. * Gets or sets the active clipplane 2
  43995. */
  43996. clipPlane2: Nullable<Plane>;
  43997. /**
  43998. * Gets or sets the active clipplane 3
  43999. */
  44000. clipPlane3: Nullable<Plane>;
  44001. /**
  44002. * Gets or sets the active clipplane 4
  44003. */
  44004. clipPlane4: Nullable<Plane>;
  44005. /**
  44006. * Gets or sets the active clipplane 5
  44007. */
  44008. clipPlane5: Nullable<Plane>;
  44009. /**
  44010. * Gets or sets the active clipplane 6
  44011. */
  44012. clipPlane6: Nullable<Plane>;
  44013. /**
  44014. * Gets or sets a boolean indicating if animations are enabled
  44015. */
  44016. animationsEnabled: boolean;
  44017. private _animationPropertiesOverride;
  44018. /**
  44019. * Gets or sets the animation properties override
  44020. */
  44021. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44022. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44023. /**
  44024. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44025. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44026. */
  44027. useConstantAnimationDeltaTime: boolean;
  44028. /**
  44029. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44030. * Please note that it requires to run a ray cast through the scene on every frame
  44031. */
  44032. constantlyUpdateMeshUnderPointer: boolean;
  44033. /**
  44034. * Defines the HTML cursor to use when hovering over interactive elements
  44035. */
  44036. hoverCursor: string;
  44037. /**
  44038. * Defines the HTML default cursor to use (empty by default)
  44039. */
  44040. defaultCursor: string;
  44041. /**
  44042. * Defines whether cursors are handled by the scene.
  44043. */
  44044. doNotHandleCursors: boolean;
  44045. /**
  44046. * This is used to call preventDefault() on pointer down
  44047. * in order to block unwanted artifacts like system double clicks
  44048. */
  44049. preventDefaultOnPointerDown: boolean;
  44050. /**
  44051. * This is used to call preventDefault() on pointer up
  44052. * in order to block unwanted artifacts like system double clicks
  44053. */
  44054. preventDefaultOnPointerUp: boolean;
  44055. /**
  44056. * Gets or sets user defined metadata
  44057. */
  44058. metadata: any;
  44059. /**
  44060. * For internal use only. Please do not use.
  44061. */
  44062. reservedDataStore: any;
  44063. /**
  44064. * Gets the name of the plugin used to load this scene (null by default)
  44065. */
  44066. loadingPluginName: string;
  44067. /**
  44068. * Use this array to add regular expressions used to disable offline support for specific urls
  44069. */
  44070. disableOfflineSupportExceptionRules: RegExp[];
  44071. /**
  44072. * An event triggered when the scene is disposed.
  44073. */
  44074. onDisposeObservable: Observable<Scene>;
  44075. private _onDisposeObserver;
  44076. /** Sets a function to be executed when this scene is disposed. */
  44077. set onDispose(callback: () => void);
  44078. /**
  44079. * An event triggered before rendering the scene (right after animations and physics)
  44080. */
  44081. onBeforeRenderObservable: Observable<Scene>;
  44082. private _onBeforeRenderObserver;
  44083. /** Sets a function to be executed before rendering this scene */
  44084. set beforeRender(callback: Nullable<() => void>);
  44085. /**
  44086. * An event triggered after rendering the scene
  44087. */
  44088. onAfterRenderObservable: Observable<Scene>;
  44089. /**
  44090. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44091. */
  44092. onAfterRenderCameraObservable: Observable<Camera>;
  44093. private _onAfterRenderObserver;
  44094. /** Sets a function to be executed after rendering this scene */
  44095. set afterRender(callback: Nullable<() => void>);
  44096. /**
  44097. * An event triggered before animating the scene
  44098. */
  44099. onBeforeAnimationsObservable: Observable<Scene>;
  44100. /**
  44101. * An event triggered after animations processing
  44102. */
  44103. onAfterAnimationsObservable: Observable<Scene>;
  44104. /**
  44105. * An event triggered before draw calls are ready to be sent
  44106. */
  44107. onBeforeDrawPhaseObservable: Observable<Scene>;
  44108. /**
  44109. * An event triggered after draw calls have been sent
  44110. */
  44111. onAfterDrawPhaseObservable: Observable<Scene>;
  44112. /**
  44113. * An event triggered when the scene is ready
  44114. */
  44115. onReadyObservable: Observable<Scene>;
  44116. /**
  44117. * An event triggered before rendering a camera
  44118. */
  44119. onBeforeCameraRenderObservable: Observable<Camera>;
  44120. private _onBeforeCameraRenderObserver;
  44121. /** Sets a function to be executed before rendering a camera*/
  44122. set beforeCameraRender(callback: () => void);
  44123. /**
  44124. * An event triggered after rendering a camera
  44125. */
  44126. onAfterCameraRenderObservable: Observable<Camera>;
  44127. private _onAfterCameraRenderObserver;
  44128. /** Sets a function to be executed after rendering a camera*/
  44129. set afterCameraRender(callback: () => void);
  44130. /**
  44131. * An event triggered when active meshes evaluation is about to start
  44132. */
  44133. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44134. /**
  44135. * An event triggered when active meshes evaluation is done
  44136. */
  44137. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44138. /**
  44139. * An event triggered when particles rendering is about to start
  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. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44143. /**
  44144. * An event triggered when particles rendering is done
  44145. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44146. */
  44147. onAfterParticlesRenderingObservable: Observable<Scene>;
  44148. /**
  44149. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44150. */
  44151. onDataLoadedObservable: Observable<Scene>;
  44152. /**
  44153. * An event triggered when a camera is created
  44154. */
  44155. onNewCameraAddedObservable: Observable<Camera>;
  44156. /**
  44157. * An event triggered when a camera is removed
  44158. */
  44159. onCameraRemovedObservable: Observable<Camera>;
  44160. /**
  44161. * An event triggered when a light is created
  44162. */
  44163. onNewLightAddedObservable: Observable<Light>;
  44164. /**
  44165. * An event triggered when a light is removed
  44166. */
  44167. onLightRemovedObservable: Observable<Light>;
  44168. /**
  44169. * An event triggered when a geometry is created
  44170. */
  44171. onNewGeometryAddedObservable: Observable<Geometry>;
  44172. /**
  44173. * An event triggered when a geometry is removed
  44174. */
  44175. onGeometryRemovedObservable: Observable<Geometry>;
  44176. /**
  44177. * An event triggered when a transform node is created
  44178. */
  44179. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44180. /**
  44181. * An event triggered when a transform node is removed
  44182. */
  44183. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44184. /**
  44185. * An event triggered when a mesh is created
  44186. */
  44187. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44188. /**
  44189. * An event triggered when a mesh is removed
  44190. */
  44191. onMeshRemovedObservable: Observable<AbstractMesh>;
  44192. /**
  44193. * An event triggered when a skeleton is created
  44194. */
  44195. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44196. /**
  44197. * An event triggered when a skeleton is removed
  44198. */
  44199. onSkeletonRemovedObservable: Observable<Skeleton>;
  44200. /**
  44201. * An event triggered when a material is created
  44202. */
  44203. onNewMaterialAddedObservable: Observable<Material>;
  44204. /**
  44205. * An event triggered when a material is removed
  44206. */
  44207. onMaterialRemovedObservable: Observable<Material>;
  44208. /**
  44209. * An event triggered when a texture is created
  44210. */
  44211. onNewTextureAddedObservable: Observable<BaseTexture>;
  44212. /**
  44213. * An event triggered when a texture is removed
  44214. */
  44215. onTextureRemovedObservable: Observable<BaseTexture>;
  44216. /**
  44217. * An event triggered when render targets are about to be rendered
  44218. * Can happen multiple times per frame.
  44219. */
  44220. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44221. /**
  44222. * An event triggered when render targets were rendered.
  44223. * Can happen multiple times per frame.
  44224. */
  44225. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44226. /**
  44227. * An event triggered before calculating deterministic simulation step
  44228. */
  44229. onBeforeStepObservable: Observable<Scene>;
  44230. /**
  44231. * An event triggered after calculating deterministic simulation step
  44232. */
  44233. onAfterStepObservable: Observable<Scene>;
  44234. /**
  44235. * An event triggered when the activeCamera property is updated
  44236. */
  44237. onActiveCameraChanged: Observable<Scene>;
  44238. /**
  44239. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44240. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44241. * 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)
  44242. */
  44243. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44244. /**
  44245. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44246. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44247. * 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)
  44248. */
  44249. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44250. /**
  44251. * This Observable will when a mesh has been imported into the scene.
  44252. */
  44253. onMeshImportedObservable: Observable<AbstractMesh>;
  44254. /**
  44255. * This Observable will when an animation file has been imported into the scene.
  44256. */
  44257. onAnimationFileImportedObservable: Observable<Scene>;
  44258. /**
  44259. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44260. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44261. */
  44262. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44263. /** @hidden */
  44264. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44265. /**
  44266. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44267. */
  44268. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44269. /**
  44270. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44271. */
  44272. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44273. /**
  44274. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44275. */
  44276. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44277. /** Callback called when a pointer move is detected */
  44278. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44279. /** Callback called when a pointer down is detected */
  44280. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44281. /** Callback called when a pointer up is detected */
  44282. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44283. /** Callback called when a pointer pick is detected */
  44284. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44285. /**
  44286. * 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).
  44287. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44288. */
  44289. onPrePointerObservable: Observable<PointerInfoPre>;
  44290. /**
  44291. * Observable event triggered each time an input event is received from the rendering canvas
  44292. */
  44293. onPointerObservable: Observable<PointerInfo>;
  44294. /**
  44295. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44296. */
  44297. get unTranslatedPointer(): Vector2;
  44298. /**
  44299. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44300. */
  44301. static get DragMovementThreshold(): number;
  44302. static set DragMovementThreshold(value: number);
  44303. /**
  44304. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44305. */
  44306. static get LongPressDelay(): number;
  44307. static set LongPressDelay(value: number);
  44308. /**
  44309. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44310. */
  44311. static get DoubleClickDelay(): number;
  44312. static set DoubleClickDelay(value: number);
  44313. /** If you need to check double click without raising a single click at first click, enable this flag */
  44314. static get ExclusiveDoubleClickMode(): boolean;
  44315. static set ExclusiveDoubleClickMode(value: boolean);
  44316. /** @hidden */
  44317. _mirroredCameraPosition: Nullable<Vector3>;
  44318. /**
  44319. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44320. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44321. */
  44322. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44323. /**
  44324. * Observable event triggered each time an keyboard event is received from the hosting window
  44325. */
  44326. onKeyboardObservable: Observable<KeyboardInfo>;
  44327. private _useRightHandedSystem;
  44328. /**
  44329. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44330. */
  44331. set useRightHandedSystem(value: boolean);
  44332. get useRightHandedSystem(): boolean;
  44333. private _timeAccumulator;
  44334. private _currentStepId;
  44335. private _currentInternalStep;
  44336. /**
  44337. * Sets the step Id used by deterministic lock step
  44338. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44339. * @param newStepId defines the step Id
  44340. */
  44341. setStepId(newStepId: number): void;
  44342. /**
  44343. * Gets the step Id used by deterministic lock step
  44344. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44345. * @returns the step Id
  44346. */
  44347. getStepId(): number;
  44348. /**
  44349. * Gets the internal step used by deterministic lock step
  44350. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44351. * @returns the internal step
  44352. */
  44353. getInternalStep(): number;
  44354. private _fogEnabled;
  44355. /**
  44356. * Gets or sets a boolean indicating if fog is enabled on this scene
  44357. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44358. * (Default is true)
  44359. */
  44360. set fogEnabled(value: boolean);
  44361. get fogEnabled(): boolean;
  44362. private _fogMode;
  44363. /**
  44364. * Gets or sets the fog mode to use
  44365. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44366. * | mode | value |
  44367. * | --- | --- |
  44368. * | FOGMODE_NONE | 0 |
  44369. * | FOGMODE_EXP | 1 |
  44370. * | FOGMODE_EXP2 | 2 |
  44371. * | FOGMODE_LINEAR | 3 |
  44372. */
  44373. set fogMode(value: number);
  44374. get fogMode(): number;
  44375. /**
  44376. * Gets or sets the fog color to use
  44377. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44378. * (Default is Color3(0.2, 0.2, 0.3))
  44379. */
  44380. fogColor: Color3;
  44381. /**
  44382. * Gets or sets the fog density to use
  44383. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44384. * (Default is 0.1)
  44385. */
  44386. fogDensity: number;
  44387. /**
  44388. * Gets or sets the fog start distance to use
  44389. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44390. * (Default is 0)
  44391. */
  44392. fogStart: number;
  44393. /**
  44394. * Gets or sets the fog end distance to use
  44395. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44396. * (Default is 1000)
  44397. */
  44398. fogEnd: number;
  44399. /**
  44400. * Flag indicating that the frame buffer binding is handled by another component
  44401. */
  44402. prePass: boolean;
  44403. private _shadowsEnabled;
  44404. /**
  44405. * Gets or sets a boolean indicating if shadows are enabled on this scene
  44406. */
  44407. set shadowsEnabled(value: boolean);
  44408. get shadowsEnabled(): boolean;
  44409. private _lightsEnabled;
  44410. /**
  44411. * Gets or sets a boolean indicating if lights are enabled on this scene
  44412. */
  44413. set lightsEnabled(value: boolean);
  44414. get lightsEnabled(): boolean;
  44415. /** All of the active cameras added to this scene. */
  44416. activeCameras: Camera[];
  44417. /** @hidden */
  44418. _activeCamera: Nullable<Camera>;
  44419. /** Gets or sets the current active camera */
  44420. get activeCamera(): Nullable<Camera>;
  44421. set activeCamera(value: Nullable<Camera>);
  44422. private _defaultMaterial;
  44423. /** The default material used on meshes when no material is affected */
  44424. get defaultMaterial(): Material;
  44425. /** The default material used on meshes when no material is affected */
  44426. set defaultMaterial(value: Material);
  44427. private _texturesEnabled;
  44428. /**
  44429. * Gets or sets a boolean indicating if textures are enabled on this scene
  44430. */
  44431. set texturesEnabled(value: boolean);
  44432. get texturesEnabled(): boolean;
  44433. /**
  44434. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  44435. */
  44436. physicsEnabled: boolean;
  44437. /**
  44438. * Gets or sets a boolean indicating if particles are enabled on this scene
  44439. */
  44440. particlesEnabled: boolean;
  44441. /**
  44442. * Gets or sets a boolean indicating if sprites are enabled on this scene
  44443. */
  44444. spritesEnabled: boolean;
  44445. private _skeletonsEnabled;
  44446. /**
  44447. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  44448. */
  44449. set skeletonsEnabled(value: boolean);
  44450. get skeletonsEnabled(): boolean;
  44451. /**
  44452. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  44453. */
  44454. lensFlaresEnabled: boolean;
  44455. /**
  44456. * Gets or sets a boolean indicating if collisions are enabled on this scene
  44457. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44458. */
  44459. collisionsEnabled: boolean;
  44460. private _collisionCoordinator;
  44461. /** @hidden */
  44462. get collisionCoordinator(): ICollisionCoordinator;
  44463. /**
  44464. * Defines the gravity applied to this scene (used only for collisions)
  44465. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44466. */
  44467. gravity: Vector3;
  44468. /**
  44469. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  44470. */
  44471. postProcessesEnabled: boolean;
  44472. /**
  44473. * Gets the current postprocess manager
  44474. */
  44475. postProcessManager: PostProcessManager;
  44476. /**
  44477. * Gets or sets a boolean indicating if render targets are enabled on this scene
  44478. */
  44479. renderTargetsEnabled: boolean;
  44480. /**
  44481. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  44482. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  44483. */
  44484. dumpNextRenderTargets: boolean;
  44485. /**
  44486. * The list of user defined render targets added to the scene
  44487. */
  44488. customRenderTargets: RenderTargetTexture[];
  44489. /**
  44490. * Defines if texture loading must be delayed
  44491. * If true, textures will only be loaded when they need to be rendered
  44492. */
  44493. useDelayedTextureLoading: boolean;
  44494. /**
  44495. * Gets the list of meshes imported to the scene through SceneLoader
  44496. */
  44497. importedMeshesFiles: String[];
  44498. /**
  44499. * Gets or sets a boolean indicating if probes are enabled on this scene
  44500. */
  44501. probesEnabled: boolean;
  44502. /**
  44503. * Gets or sets the current offline provider to use to store scene data
  44504. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  44505. */
  44506. offlineProvider: IOfflineProvider;
  44507. /**
  44508. * Gets or sets the action manager associated with the scene
  44509. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44510. */
  44511. actionManager: AbstractActionManager;
  44512. private _meshesForIntersections;
  44513. /**
  44514. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  44515. */
  44516. proceduralTexturesEnabled: boolean;
  44517. private _engine;
  44518. private _totalVertices;
  44519. /** @hidden */
  44520. _activeIndices: PerfCounter;
  44521. /** @hidden */
  44522. _activeParticles: PerfCounter;
  44523. /** @hidden */
  44524. _activeBones: PerfCounter;
  44525. private _animationRatio;
  44526. /** @hidden */
  44527. _animationTimeLast: number;
  44528. /** @hidden */
  44529. _animationTime: number;
  44530. /**
  44531. * Gets or sets a general scale for animation speed
  44532. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  44533. */
  44534. animationTimeScale: number;
  44535. /** @hidden */
  44536. _cachedMaterial: Nullable<Material>;
  44537. /** @hidden */
  44538. _cachedEffect: Nullable<Effect>;
  44539. /** @hidden */
  44540. _cachedVisibility: Nullable<number>;
  44541. private _renderId;
  44542. private _frameId;
  44543. private _executeWhenReadyTimeoutId;
  44544. private _intermediateRendering;
  44545. private _viewUpdateFlag;
  44546. private _projectionUpdateFlag;
  44547. /** @hidden */
  44548. _toBeDisposed: Nullable<IDisposable>[];
  44549. private _activeRequests;
  44550. /** @hidden */
  44551. _pendingData: any[];
  44552. private _isDisposed;
  44553. /**
  44554. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  44555. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  44556. */
  44557. dispatchAllSubMeshesOfActiveMeshes: boolean;
  44558. private _activeMeshes;
  44559. private _processedMaterials;
  44560. private _renderTargets;
  44561. /** @hidden */
  44562. _activeParticleSystems: SmartArray<IParticleSystem>;
  44563. private _activeSkeletons;
  44564. private _softwareSkinnedMeshes;
  44565. private _renderingManager;
  44566. /** @hidden */
  44567. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  44568. private _transformMatrix;
  44569. private _sceneUbo;
  44570. /** @hidden */
  44571. _viewMatrix: Matrix;
  44572. private _projectionMatrix;
  44573. /** @hidden */
  44574. _forcedViewPosition: Nullable<Vector3>;
  44575. /** @hidden */
  44576. _frustumPlanes: Plane[];
  44577. /**
  44578. * Gets the list of frustum planes (built from the active camera)
  44579. */
  44580. get frustumPlanes(): Plane[];
  44581. /**
  44582. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  44583. * This is useful if there are more lights that the maximum simulteanous authorized
  44584. */
  44585. requireLightSorting: boolean;
  44586. /** @hidden */
  44587. readonly useMaterialMeshMap: boolean;
  44588. /** @hidden */
  44589. readonly useClonedMeshMap: boolean;
  44590. private _externalData;
  44591. private _uid;
  44592. /**
  44593. * @hidden
  44594. * Backing store of defined scene components.
  44595. */
  44596. _components: ISceneComponent[];
  44597. /**
  44598. * @hidden
  44599. * Backing store of defined scene components.
  44600. */
  44601. _serializableComponents: ISceneSerializableComponent[];
  44602. /**
  44603. * List of components to register on the next registration step.
  44604. */
  44605. private _transientComponents;
  44606. /**
  44607. * Registers the transient components if needed.
  44608. */
  44609. private _registerTransientComponents;
  44610. /**
  44611. * @hidden
  44612. * Add a component to the scene.
  44613. * Note that the ccomponent could be registered on th next frame if this is called after
  44614. * the register component stage.
  44615. * @param component Defines the component to add to the scene
  44616. */
  44617. _addComponent(component: ISceneComponent): void;
  44618. /**
  44619. * @hidden
  44620. * Gets a component from the scene.
  44621. * @param name defines the name of the component to retrieve
  44622. * @returns the component or null if not present
  44623. */
  44624. _getComponent(name: string): Nullable<ISceneComponent>;
  44625. /**
  44626. * @hidden
  44627. * Defines the actions happening before camera updates.
  44628. */
  44629. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  44630. /**
  44631. * @hidden
  44632. * Defines the actions happening before clear the canvas.
  44633. */
  44634. _beforeClearStage: Stage<SimpleStageAction>;
  44635. /**
  44636. * @hidden
  44637. * Defines the actions when collecting render targets for the frame.
  44638. */
  44639. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44640. /**
  44641. * @hidden
  44642. * Defines the actions happening for one camera in the frame.
  44643. */
  44644. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44645. /**
  44646. * @hidden
  44647. * Defines the actions happening during the per mesh ready checks.
  44648. */
  44649. _isReadyForMeshStage: Stage<MeshStageAction>;
  44650. /**
  44651. * @hidden
  44652. * Defines the actions happening before evaluate active mesh checks.
  44653. */
  44654. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  44655. /**
  44656. * @hidden
  44657. * Defines the actions happening during the evaluate sub mesh checks.
  44658. */
  44659. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  44660. /**
  44661. * @hidden
  44662. * Defines the actions happening during the active mesh stage.
  44663. */
  44664. _activeMeshStage: Stage<ActiveMeshStageAction>;
  44665. /**
  44666. * @hidden
  44667. * Defines the actions happening during the per camera render target step.
  44668. */
  44669. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  44670. /**
  44671. * @hidden
  44672. * Defines the actions happening just before the active camera is drawing.
  44673. */
  44674. _beforeCameraDrawStage: Stage<CameraStageAction>;
  44675. /**
  44676. * @hidden
  44677. * Defines the actions happening just before a render target is drawing.
  44678. */
  44679. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44680. /**
  44681. * @hidden
  44682. * Defines the actions happening just before a rendering group is drawing.
  44683. */
  44684. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44685. /**
  44686. * @hidden
  44687. * Defines the actions happening just before a mesh is drawing.
  44688. */
  44689. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44690. /**
  44691. * @hidden
  44692. * Defines the actions happening just after a mesh has been drawn.
  44693. */
  44694. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44695. /**
  44696. * @hidden
  44697. * Defines the actions happening just after a rendering group has been drawn.
  44698. */
  44699. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44700. /**
  44701. * @hidden
  44702. * Defines the actions happening just after the active camera has been drawn.
  44703. */
  44704. _afterCameraDrawStage: Stage<CameraStageAction>;
  44705. /**
  44706. * @hidden
  44707. * Defines the actions happening just after a render target has been drawn.
  44708. */
  44709. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44710. /**
  44711. * @hidden
  44712. * Defines the actions happening just after rendering all cameras and computing intersections.
  44713. */
  44714. _afterRenderStage: Stage<SimpleStageAction>;
  44715. /**
  44716. * @hidden
  44717. * Defines the actions happening when a pointer move event happens.
  44718. */
  44719. _pointerMoveStage: Stage<PointerMoveStageAction>;
  44720. /**
  44721. * @hidden
  44722. * Defines the actions happening when a pointer down event happens.
  44723. */
  44724. _pointerDownStage: Stage<PointerUpDownStageAction>;
  44725. /**
  44726. * @hidden
  44727. * Defines the actions happening when a pointer up event happens.
  44728. */
  44729. _pointerUpStage: Stage<PointerUpDownStageAction>;
  44730. /**
  44731. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  44732. */
  44733. private geometriesByUniqueId;
  44734. /**
  44735. * Creates a new Scene
  44736. * @param engine defines the engine to use to render this scene
  44737. * @param options defines the scene options
  44738. */
  44739. constructor(engine: Engine, options?: SceneOptions);
  44740. /**
  44741. * Gets a string identifying the name of the class
  44742. * @returns "Scene" string
  44743. */
  44744. getClassName(): string;
  44745. private _defaultMeshCandidates;
  44746. /**
  44747. * @hidden
  44748. */
  44749. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44750. private _defaultSubMeshCandidates;
  44751. /**
  44752. * @hidden
  44753. */
  44754. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44755. /**
  44756. * Sets the default candidate providers for the scene.
  44757. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  44758. * and getCollidingSubMeshCandidates to their default function
  44759. */
  44760. setDefaultCandidateProviders(): void;
  44761. /**
  44762. * Gets the mesh that is currently under the pointer
  44763. */
  44764. get meshUnderPointer(): Nullable<AbstractMesh>;
  44765. /**
  44766. * Gets or sets the current on-screen X position of the pointer
  44767. */
  44768. get pointerX(): number;
  44769. set pointerX(value: number);
  44770. /**
  44771. * Gets or sets the current on-screen Y position of the pointer
  44772. */
  44773. get pointerY(): number;
  44774. set pointerY(value: number);
  44775. /**
  44776. * Gets the cached material (ie. the latest rendered one)
  44777. * @returns the cached material
  44778. */
  44779. getCachedMaterial(): Nullable<Material>;
  44780. /**
  44781. * Gets the cached effect (ie. the latest rendered one)
  44782. * @returns the cached effect
  44783. */
  44784. getCachedEffect(): Nullable<Effect>;
  44785. /**
  44786. * Gets the cached visibility state (ie. the latest rendered one)
  44787. * @returns the cached visibility state
  44788. */
  44789. getCachedVisibility(): Nullable<number>;
  44790. /**
  44791. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  44792. * @param material defines the current material
  44793. * @param effect defines the current effect
  44794. * @param visibility defines the current visibility state
  44795. * @returns true if one parameter is not cached
  44796. */
  44797. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  44798. /**
  44799. * Gets the engine associated with the scene
  44800. * @returns an Engine
  44801. */
  44802. getEngine(): Engine;
  44803. /**
  44804. * Gets the total number of vertices rendered per frame
  44805. * @returns the total number of vertices rendered per frame
  44806. */
  44807. getTotalVertices(): number;
  44808. /**
  44809. * Gets the performance counter for total vertices
  44810. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44811. */
  44812. get totalVerticesPerfCounter(): PerfCounter;
  44813. /**
  44814. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  44815. * @returns the total number of active indices rendered per frame
  44816. */
  44817. getActiveIndices(): number;
  44818. /**
  44819. * Gets the performance counter for active indices
  44820. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44821. */
  44822. get totalActiveIndicesPerfCounter(): PerfCounter;
  44823. /**
  44824. * Gets the total number of active particles rendered per frame
  44825. * @returns the total number of active particles rendered per frame
  44826. */
  44827. getActiveParticles(): number;
  44828. /**
  44829. * Gets the performance counter for active particles
  44830. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44831. */
  44832. get activeParticlesPerfCounter(): PerfCounter;
  44833. /**
  44834. * Gets the total number of active bones rendered per frame
  44835. * @returns the total number of active bones rendered per frame
  44836. */
  44837. getActiveBones(): number;
  44838. /**
  44839. * Gets the performance counter for active bones
  44840. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44841. */
  44842. get activeBonesPerfCounter(): PerfCounter;
  44843. /**
  44844. * Gets the array of active meshes
  44845. * @returns an array of AbstractMesh
  44846. */
  44847. getActiveMeshes(): SmartArray<AbstractMesh>;
  44848. /**
  44849. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  44850. * @returns a number
  44851. */
  44852. getAnimationRatio(): number;
  44853. /**
  44854. * Gets an unique Id for the current render phase
  44855. * @returns a number
  44856. */
  44857. getRenderId(): number;
  44858. /**
  44859. * Gets an unique Id for the current frame
  44860. * @returns a number
  44861. */
  44862. getFrameId(): number;
  44863. /** Call this function if you want to manually increment the render Id*/
  44864. incrementRenderId(): void;
  44865. private _createUbo;
  44866. /**
  44867. * Use this method to simulate a pointer move on a mesh
  44868. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44869. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44870. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44871. * @returns the current scene
  44872. */
  44873. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  44874. /**
  44875. * Use this method to simulate a pointer down on a mesh
  44876. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44877. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44878. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44879. * @returns the current scene
  44880. */
  44881. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  44882. /**
  44883. * Use this method to simulate a pointer up on a mesh
  44884. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44885. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44886. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44887. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44888. * @returns the current scene
  44889. */
  44890. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  44891. /**
  44892. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44893. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44894. * @returns true if the pointer was captured
  44895. */
  44896. isPointerCaptured(pointerId?: number): boolean;
  44897. /**
  44898. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44899. * @param attachUp defines if you want to attach events to pointerup
  44900. * @param attachDown defines if you want to attach events to pointerdown
  44901. * @param attachMove defines if you want to attach events to pointermove
  44902. */
  44903. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  44904. /** Detaches all event handlers*/
  44905. detachControl(): void;
  44906. /**
  44907. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  44908. * Delay loaded resources are not taking in account
  44909. * @return true if all required resources are ready
  44910. */
  44911. isReady(): boolean;
  44912. /** Resets all cached information relative to material (including effect and visibility) */
  44913. resetCachedMaterial(): void;
  44914. /**
  44915. * Registers a function to be called before every frame render
  44916. * @param func defines the function to register
  44917. */
  44918. registerBeforeRender(func: () => void): void;
  44919. /**
  44920. * Unregisters a function called before every frame render
  44921. * @param func defines the function to unregister
  44922. */
  44923. unregisterBeforeRender(func: () => void): void;
  44924. /**
  44925. * Registers a function to be called after every frame render
  44926. * @param func defines the function to register
  44927. */
  44928. registerAfterRender(func: () => void): void;
  44929. /**
  44930. * Unregisters a function called after every frame render
  44931. * @param func defines the function to unregister
  44932. */
  44933. unregisterAfterRender(func: () => void): void;
  44934. private _executeOnceBeforeRender;
  44935. /**
  44936. * The provided function will run before render once and will be disposed afterwards.
  44937. * A timeout delay can be provided so that the function will be executed in N ms.
  44938. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  44939. * @param func The function to be executed.
  44940. * @param timeout optional delay in ms
  44941. */
  44942. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  44943. /** @hidden */
  44944. _addPendingData(data: any): void;
  44945. /** @hidden */
  44946. _removePendingData(data: any): void;
  44947. /**
  44948. * Returns the number of items waiting to be loaded
  44949. * @returns the number of items waiting to be loaded
  44950. */
  44951. getWaitingItemsCount(): number;
  44952. /**
  44953. * Returns a boolean indicating if the scene is still loading data
  44954. */
  44955. get isLoading(): boolean;
  44956. /**
  44957. * Registers a function to be executed when the scene is ready
  44958. * @param {Function} func - the function to be executed
  44959. */
  44960. executeWhenReady(func: () => void): void;
  44961. /**
  44962. * Returns a promise that resolves when the scene is ready
  44963. * @returns A promise that resolves when the scene is ready
  44964. */
  44965. whenReadyAsync(): Promise<void>;
  44966. /** @hidden */
  44967. _checkIsReady(): void;
  44968. /**
  44969. * Gets all animatable attached to the scene
  44970. */
  44971. get animatables(): Animatable[];
  44972. /**
  44973. * Resets the last animation time frame.
  44974. * Useful to override when animations start running when loading a scene for the first time.
  44975. */
  44976. resetLastAnimationTimeFrame(): void;
  44977. /**
  44978. * Gets the current view matrix
  44979. * @returns a Matrix
  44980. */
  44981. getViewMatrix(): Matrix;
  44982. /**
  44983. * Gets the current projection matrix
  44984. * @returns a Matrix
  44985. */
  44986. getProjectionMatrix(): Matrix;
  44987. /**
  44988. * Gets the current transform matrix
  44989. * @returns a Matrix made of View * Projection
  44990. */
  44991. getTransformMatrix(): Matrix;
  44992. /**
  44993. * Sets the current transform matrix
  44994. * @param viewL defines the View matrix to use
  44995. * @param projectionL defines the Projection matrix to use
  44996. * @param viewR defines the right View matrix to use (if provided)
  44997. * @param projectionR defines the right Projection matrix to use (if provided)
  44998. */
  44999. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45000. /**
  45001. * Gets the uniform buffer used to store scene data
  45002. * @returns a UniformBuffer
  45003. */
  45004. getSceneUniformBuffer(): UniformBuffer;
  45005. /**
  45006. * Gets an unique (relatively to the current scene) Id
  45007. * @returns an unique number for the scene
  45008. */
  45009. getUniqueId(): number;
  45010. /**
  45011. * Add a mesh to the list of scene's meshes
  45012. * @param newMesh defines the mesh to add
  45013. * @param recursive if all child meshes should also be added to the scene
  45014. */
  45015. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45016. /**
  45017. * Remove a mesh for the list of scene's meshes
  45018. * @param toRemove defines the mesh to remove
  45019. * @param recursive if all child meshes should also be removed from the scene
  45020. * @returns the index where the mesh was in the mesh list
  45021. */
  45022. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45023. /**
  45024. * Add a transform node to the list of scene's transform nodes
  45025. * @param newTransformNode defines the transform node to add
  45026. */
  45027. addTransformNode(newTransformNode: TransformNode): void;
  45028. /**
  45029. * Remove a transform node for the list of scene's transform nodes
  45030. * @param toRemove defines the transform node to remove
  45031. * @returns the index where the transform node was in the transform node list
  45032. */
  45033. removeTransformNode(toRemove: TransformNode): number;
  45034. /**
  45035. * Remove a skeleton for the list of scene's skeletons
  45036. * @param toRemove defines the skeleton to remove
  45037. * @returns the index where the skeleton was in the skeleton list
  45038. */
  45039. removeSkeleton(toRemove: Skeleton): number;
  45040. /**
  45041. * Remove a morph target for the list of scene's morph targets
  45042. * @param toRemove defines the morph target to remove
  45043. * @returns the index where the morph target was in the morph target list
  45044. */
  45045. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45046. /**
  45047. * Remove a light for the list of scene's lights
  45048. * @param toRemove defines the light to remove
  45049. * @returns the index where the light was in the light list
  45050. */
  45051. removeLight(toRemove: Light): number;
  45052. /**
  45053. * Remove a camera for the list of scene's cameras
  45054. * @param toRemove defines the camera to remove
  45055. * @returns the index where the camera was in the camera list
  45056. */
  45057. removeCamera(toRemove: Camera): number;
  45058. /**
  45059. * Remove a particle system for the list of scene's particle systems
  45060. * @param toRemove defines the particle system to remove
  45061. * @returns the index where the particle system was in the particle system list
  45062. */
  45063. removeParticleSystem(toRemove: IParticleSystem): number;
  45064. /**
  45065. * Remove a animation for the list of scene's animations
  45066. * @param toRemove defines the animation to remove
  45067. * @returns the index where the animation was in the animation list
  45068. */
  45069. removeAnimation(toRemove: Animation): number;
  45070. /**
  45071. * Will stop the animation of the given target
  45072. * @param target - the target
  45073. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45074. * @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)
  45075. */
  45076. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45077. /**
  45078. * Removes the given animation group from this scene.
  45079. * @param toRemove The animation group to remove
  45080. * @returns The index of the removed animation group
  45081. */
  45082. removeAnimationGroup(toRemove: AnimationGroup): number;
  45083. /**
  45084. * Removes the given multi-material from this scene.
  45085. * @param toRemove The multi-material to remove
  45086. * @returns The index of the removed multi-material
  45087. */
  45088. removeMultiMaterial(toRemove: MultiMaterial): number;
  45089. /**
  45090. * Removes the given material from this scene.
  45091. * @param toRemove The material to remove
  45092. * @returns The index of the removed material
  45093. */
  45094. removeMaterial(toRemove: Material): number;
  45095. /**
  45096. * Removes the given action manager from this scene.
  45097. * @param toRemove The action manager to remove
  45098. * @returns The index of the removed action manager
  45099. */
  45100. removeActionManager(toRemove: AbstractActionManager): number;
  45101. /**
  45102. * Removes the given texture from this scene.
  45103. * @param toRemove The texture to remove
  45104. * @returns The index of the removed texture
  45105. */
  45106. removeTexture(toRemove: BaseTexture): number;
  45107. /**
  45108. * Adds the given light to this scene
  45109. * @param newLight The light to add
  45110. */
  45111. addLight(newLight: Light): void;
  45112. /**
  45113. * Sorts the list list based on light priorities
  45114. */
  45115. sortLightsByPriority(): void;
  45116. /**
  45117. * Adds the given camera to this scene
  45118. * @param newCamera The camera to add
  45119. */
  45120. addCamera(newCamera: Camera): void;
  45121. /**
  45122. * Adds the given skeleton to this scene
  45123. * @param newSkeleton The skeleton to add
  45124. */
  45125. addSkeleton(newSkeleton: Skeleton): void;
  45126. /**
  45127. * Adds the given particle system to this scene
  45128. * @param newParticleSystem The particle system to add
  45129. */
  45130. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45131. /**
  45132. * Adds the given animation to this scene
  45133. * @param newAnimation The animation to add
  45134. */
  45135. addAnimation(newAnimation: Animation): void;
  45136. /**
  45137. * Adds the given animation group to this scene.
  45138. * @param newAnimationGroup The animation group to add
  45139. */
  45140. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45141. /**
  45142. * Adds the given multi-material to this scene
  45143. * @param newMultiMaterial The multi-material to add
  45144. */
  45145. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45146. /**
  45147. * Adds the given material to this scene
  45148. * @param newMaterial The material to add
  45149. */
  45150. addMaterial(newMaterial: Material): void;
  45151. /**
  45152. * Adds the given morph target to this scene
  45153. * @param newMorphTargetManager The morph target to add
  45154. */
  45155. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45156. /**
  45157. * Adds the given geometry to this scene
  45158. * @param newGeometry The geometry to add
  45159. */
  45160. addGeometry(newGeometry: Geometry): void;
  45161. /**
  45162. * Adds the given action manager to this scene
  45163. * @param newActionManager The action manager to add
  45164. */
  45165. addActionManager(newActionManager: AbstractActionManager): void;
  45166. /**
  45167. * Adds the given texture to this scene.
  45168. * @param newTexture The texture to add
  45169. */
  45170. addTexture(newTexture: BaseTexture): void;
  45171. /**
  45172. * Switch active camera
  45173. * @param newCamera defines the new active camera
  45174. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45175. */
  45176. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45177. /**
  45178. * sets the active camera of the scene using its ID
  45179. * @param id defines the camera's ID
  45180. * @return the new active camera or null if none found.
  45181. */
  45182. setActiveCameraByID(id: string): Nullable<Camera>;
  45183. /**
  45184. * sets the active camera of the scene using its name
  45185. * @param name defines the camera's name
  45186. * @returns the new active camera or null if none found.
  45187. */
  45188. setActiveCameraByName(name: string): Nullable<Camera>;
  45189. /**
  45190. * get an animation group using its name
  45191. * @param name defines the material's name
  45192. * @return the animation group or null if none found.
  45193. */
  45194. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45195. /**
  45196. * Get a material using its unique id
  45197. * @param uniqueId defines the material's unique id
  45198. * @return the material or null if none found.
  45199. */
  45200. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45201. /**
  45202. * get a material using its id
  45203. * @param id defines the material's ID
  45204. * @return the material or null if none found.
  45205. */
  45206. getMaterialByID(id: string): Nullable<Material>;
  45207. /**
  45208. * Gets a the last added material using a given id
  45209. * @param id defines the material's ID
  45210. * @return the last material with the given id or null if none found.
  45211. */
  45212. getLastMaterialByID(id: string): Nullable<Material>;
  45213. /**
  45214. * Gets a material using its name
  45215. * @param name defines the material's name
  45216. * @return the material or null if none found.
  45217. */
  45218. getMaterialByName(name: string): Nullable<Material>;
  45219. /**
  45220. * Get a texture using its unique id
  45221. * @param uniqueId defines the texture's unique id
  45222. * @return the texture or null if none found.
  45223. */
  45224. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45225. /**
  45226. * Gets a camera using its id
  45227. * @param id defines the id to look for
  45228. * @returns the camera or null if not found
  45229. */
  45230. getCameraByID(id: string): Nullable<Camera>;
  45231. /**
  45232. * Gets a camera using its unique id
  45233. * @param uniqueId defines the unique id to look for
  45234. * @returns the camera or null if not found
  45235. */
  45236. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45237. /**
  45238. * Gets a camera using its name
  45239. * @param name defines the camera's name
  45240. * @return the camera or null if none found.
  45241. */
  45242. getCameraByName(name: string): Nullable<Camera>;
  45243. /**
  45244. * Gets a bone using its id
  45245. * @param id defines the bone's id
  45246. * @return the bone or null if not found
  45247. */
  45248. getBoneByID(id: string): Nullable<Bone>;
  45249. /**
  45250. * Gets a bone using its id
  45251. * @param name defines the bone's name
  45252. * @return the bone or null if not found
  45253. */
  45254. getBoneByName(name: string): Nullable<Bone>;
  45255. /**
  45256. * Gets a light node using its name
  45257. * @param name defines the the light's name
  45258. * @return the light or null if none found.
  45259. */
  45260. getLightByName(name: string): Nullable<Light>;
  45261. /**
  45262. * Gets a light node using its id
  45263. * @param id defines the light's id
  45264. * @return the light or null if none found.
  45265. */
  45266. getLightByID(id: string): Nullable<Light>;
  45267. /**
  45268. * Gets a light node using its scene-generated unique ID
  45269. * @param uniqueId defines the light's unique id
  45270. * @return the light or null if none found.
  45271. */
  45272. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45273. /**
  45274. * Gets a particle system by id
  45275. * @param id defines the particle system id
  45276. * @return the corresponding system or null if none found
  45277. */
  45278. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45279. /**
  45280. * Gets a geometry using its ID
  45281. * @param id defines the geometry's id
  45282. * @return the geometry or null if none found.
  45283. */
  45284. getGeometryByID(id: string): Nullable<Geometry>;
  45285. private _getGeometryByUniqueID;
  45286. /**
  45287. * Add a new geometry to this scene
  45288. * @param geometry defines the geometry to be added to the scene.
  45289. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45290. * @return a boolean defining if the geometry was added or not
  45291. */
  45292. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45293. /**
  45294. * Removes an existing geometry
  45295. * @param geometry defines the geometry to be removed from the scene
  45296. * @return a boolean defining if the geometry was removed or not
  45297. */
  45298. removeGeometry(geometry: Geometry): boolean;
  45299. /**
  45300. * Gets the list of geometries attached to the scene
  45301. * @returns an array of Geometry
  45302. */
  45303. getGeometries(): Geometry[];
  45304. /**
  45305. * Gets the first added mesh found of a given ID
  45306. * @param id defines the id to search for
  45307. * @return the mesh found or null if not found at all
  45308. */
  45309. getMeshByID(id: string): Nullable<AbstractMesh>;
  45310. /**
  45311. * Gets a list of meshes using their id
  45312. * @param id defines the id to search for
  45313. * @returns a list of meshes
  45314. */
  45315. getMeshesByID(id: string): Array<AbstractMesh>;
  45316. /**
  45317. * Gets the first added transform node found of a given ID
  45318. * @param id defines the id to search for
  45319. * @return the found transform node or null if not found at all.
  45320. */
  45321. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45322. /**
  45323. * Gets a transform node with its auto-generated unique id
  45324. * @param uniqueId efines the unique id to search for
  45325. * @return the found transform node or null if not found at all.
  45326. */
  45327. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45328. /**
  45329. * Gets a list of transform nodes using their id
  45330. * @param id defines the id to search for
  45331. * @returns a list of transform nodes
  45332. */
  45333. getTransformNodesByID(id: string): Array<TransformNode>;
  45334. /**
  45335. * Gets a mesh with its auto-generated unique id
  45336. * @param uniqueId defines the unique id to search for
  45337. * @return the found mesh or null if not found at all.
  45338. */
  45339. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45340. /**
  45341. * Gets a the last added mesh using a given id
  45342. * @param id defines the id to search for
  45343. * @return the found mesh or null if not found at all.
  45344. */
  45345. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45346. /**
  45347. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45348. * @param id defines the id to search for
  45349. * @return the found node or null if not found at all
  45350. */
  45351. getLastEntryByID(id: string): Nullable<Node>;
  45352. /**
  45353. * Gets a node (Mesh, Camera, Light) using a given id
  45354. * @param id defines the id to search for
  45355. * @return the found node or null if not found at all
  45356. */
  45357. getNodeByID(id: string): Nullable<Node>;
  45358. /**
  45359. * Gets a node (Mesh, Camera, Light) using a given name
  45360. * @param name defines the name to search for
  45361. * @return the found node or null if not found at all.
  45362. */
  45363. getNodeByName(name: string): Nullable<Node>;
  45364. /**
  45365. * Gets a mesh using a given name
  45366. * @param name defines the name to search for
  45367. * @return the found mesh or null if not found at all.
  45368. */
  45369. getMeshByName(name: string): Nullable<AbstractMesh>;
  45370. /**
  45371. * Gets a transform node using a given name
  45372. * @param name defines the name to search for
  45373. * @return the found transform node or null if not found at all.
  45374. */
  45375. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45376. /**
  45377. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45378. * @param id defines the id to search for
  45379. * @return the found skeleton or null if not found at all.
  45380. */
  45381. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  45382. /**
  45383. * Gets a skeleton using a given auto generated unique id
  45384. * @param uniqueId defines the unique id to search for
  45385. * @return the found skeleton or null if not found at all.
  45386. */
  45387. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  45388. /**
  45389. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  45390. * @param id defines the id to search for
  45391. * @return the found skeleton or null if not found at all.
  45392. */
  45393. getSkeletonById(id: string): Nullable<Skeleton>;
  45394. /**
  45395. * Gets a skeleton using a given name
  45396. * @param name defines the name to search for
  45397. * @return the found skeleton or null if not found at all.
  45398. */
  45399. getSkeletonByName(name: string): Nullable<Skeleton>;
  45400. /**
  45401. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  45402. * @param id defines the id to search for
  45403. * @return the found morph target manager or null if not found at all.
  45404. */
  45405. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  45406. /**
  45407. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  45408. * @param id defines the id to search for
  45409. * @return the found morph target or null if not found at all.
  45410. */
  45411. getMorphTargetById(id: string): Nullable<MorphTarget>;
  45412. /**
  45413. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  45414. * @param name defines the name to search for
  45415. * @return the found morph target or null if not found at all.
  45416. */
  45417. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  45418. /**
  45419. * Gets a post process using a given name (if many are found, this function will pick the first one)
  45420. * @param name defines the name to search for
  45421. * @return the found post process or null if not found at all.
  45422. */
  45423. getPostProcessByName(name: string): Nullable<PostProcess>;
  45424. /**
  45425. * Gets a boolean indicating if the given mesh is active
  45426. * @param mesh defines the mesh to look for
  45427. * @returns true if the mesh is in the active list
  45428. */
  45429. isActiveMesh(mesh: AbstractMesh): boolean;
  45430. /**
  45431. * Return a unique id as a string which can serve as an identifier for the scene
  45432. */
  45433. get uid(): string;
  45434. /**
  45435. * Add an externaly attached data from its key.
  45436. * This method call will fail and return false, if such key already exists.
  45437. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  45438. * @param key the unique key that identifies the data
  45439. * @param data the data object to associate to the key for this Engine instance
  45440. * @return true if no such key were already present and the data was added successfully, false otherwise
  45441. */
  45442. addExternalData<T>(key: string, data: T): boolean;
  45443. /**
  45444. * Get an externaly attached data from its key
  45445. * @param key the unique key that identifies the data
  45446. * @return the associated data, if present (can be null), or undefined if not present
  45447. */
  45448. getExternalData<T>(key: string): Nullable<T>;
  45449. /**
  45450. * Get an externaly attached data from its key, create it using a factory if it's not already present
  45451. * @param key the unique key that identifies the data
  45452. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  45453. * @return the associated data, can be null if the factory returned null.
  45454. */
  45455. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  45456. /**
  45457. * Remove an externaly attached data from the Engine instance
  45458. * @param key the unique key that identifies the data
  45459. * @return true if the data was successfully removed, false if it doesn't exist
  45460. */
  45461. removeExternalData(key: string): boolean;
  45462. private _evaluateSubMesh;
  45463. /**
  45464. * Clear the processed materials smart array preventing retention point in material dispose.
  45465. */
  45466. freeProcessedMaterials(): void;
  45467. private _preventFreeActiveMeshesAndRenderingGroups;
  45468. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  45469. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  45470. * when disposing several meshes in a row or a hierarchy of meshes.
  45471. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  45472. */
  45473. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  45474. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  45475. /**
  45476. * Clear the active meshes smart array preventing retention point in mesh dispose.
  45477. */
  45478. freeActiveMeshes(): void;
  45479. /**
  45480. * Clear the info related to rendering groups preventing retention points during dispose.
  45481. */
  45482. freeRenderingGroups(): void;
  45483. /** @hidden */
  45484. _isInIntermediateRendering(): boolean;
  45485. /**
  45486. * Lambda returning the list of potentially active meshes.
  45487. */
  45488. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  45489. /**
  45490. * Lambda returning the list of potentially active sub meshes.
  45491. */
  45492. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  45493. /**
  45494. * Lambda returning the list of potentially intersecting sub meshes.
  45495. */
  45496. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  45497. /**
  45498. * Lambda returning the list of potentially colliding sub meshes.
  45499. */
  45500. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  45501. private _activeMeshesFrozen;
  45502. private _skipEvaluateActiveMeshesCompletely;
  45503. /**
  45504. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  45505. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  45506. * @param onSuccess optional success callback
  45507. * @param onError optional error callback
  45508. * @returns the current scene
  45509. */
  45510. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  45511. /**
  45512. * Use this function to restart evaluating active meshes on every frame
  45513. * @returns the current scene
  45514. */
  45515. unfreezeActiveMeshes(): Scene;
  45516. private _evaluateActiveMeshes;
  45517. private _activeMesh;
  45518. /**
  45519. * Update the transform matrix to update from the current active camera
  45520. * @param force defines a boolean used to force the update even if cache is up to date
  45521. */
  45522. updateTransformMatrix(force?: boolean): void;
  45523. private _bindFrameBuffer;
  45524. /** @hidden */
  45525. _allowPostProcessClearColor: boolean;
  45526. /** @hidden */
  45527. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  45528. private _processSubCameras;
  45529. private _checkIntersections;
  45530. /** @hidden */
  45531. _advancePhysicsEngineStep(step: number): void;
  45532. /**
  45533. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  45534. */
  45535. getDeterministicFrameTime: () => number;
  45536. /** @hidden */
  45537. _animate(): void;
  45538. /** Execute all animations (for a frame) */
  45539. animate(): void;
  45540. /**
  45541. * Render the scene
  45542. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  45543. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  45544. */
  45545. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  45546. /**
  45547. * Freeze all materials
  45548. * A frozen material will not be updatable but should be faster to render
  45549. */
  45550. freezeMaterials(): void;
  45551. /**
  45552. * Unfreeze all materials
  45553. * A frozen material will not be updatable but should be faster to render
  45554. */
  45555. unfreezeMaterials(): void;
  45556. /**
  45557. * Releases all held ressources
  45558. */
  45559. dispose(): void;
  45560. /**
  45561. * Gets if the scene is already disposed
  45562. */
  45563. get isDisposed(): boolean;
  45564. /**
  45565. * Call this function to reduce memory footprint of the scene.
  45566. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  45567. */
  45568. clearCachedVertexData(): void;
  45569. /**
  45570. * This function will remove the local cached buffer data from texture.
  45571. * It will save memory but will prevent the texture from being rebuilt
  45572. */
  45573. cleanCachedTextureBuffer(): void;
  45574. /**
  45575. * Get the world extend vectors with an optional filter
  45576. *
  45577. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  45578. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  45579. */
  45580. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  45581. min: Vector3;
  45582. max: Vector3;
  45583. };
  45584. /**
  45585. * Creates a ray that can be used to pick in the scene
  45586. * @param x defines the x coordinate of the origin (on-screen)
  45587. * @param y defines the y coordinate of the origin (on-screen)
  45588. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45589. * @param camera defines the camera to use for the picking
  45590. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45591. * @returns a Ray
  45592. */
  45593. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  45594. /**
  45595. * Creates a ray that can be used to pick in the scene
  45596. * @param x defines the x coordinate of the origin (on-screen)
  45597. * @param y defines the y coordinate of the origin (on-screen)
  45598. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45599. * @param result defines the ray where to store the picking ray
  45600. * @param camera defines the camera to use for the picking
  45601. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45602. * @returns the current scene
  45603. */
  45604. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  45605. /**
  45606. * Creates a ray that can be used to pick in the scene
  45607. * @param x defines the x coordinate of the origin (on-screen)
  45608. * @param y defines the y coordinate of the origin (on-screen)
  45609. * @param camera defines the camera to use for the picking
  45610. * @returns a Ray
  45611. */
  45612. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  45613. /**
  45614. * Creates a ray that can be used to pick in the scene
  45615. * @param x defines the x coordinate of the origin (on-screen)
  45616. * @param y defines the y coordinate of the origin (on-screen)
  45617. * @param result defines the ray where to store the picking ray
  45618. * @param camera defines the camera to use for the picking
  45619. * @returns the current scene
  45620. */
  45621. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  45622. /** Launch a ray to try to pick a mesh in the scene
  45623. * @param x position on screen
  45624. * @param y position on screen
  45625. * @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
  45626. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45627. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45628. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45629. * @returns a PickingInfo
  45630. */
  45631. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45632. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  45633. * @param x position on screen
  45634. * @param y position on screen
  45635. * @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
  45636. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45637. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45638. * @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)
  45639. */
  45640. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  45641. /** Use the given ray to pick a mesh in the scene
  45642. * @param ray The ray to use to pick meshes
  45643. * @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
  45644. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45645. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45646. * @returns a PickingInfo
  45647. */
  45648. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45649. /**
  45650. * Launch a ray to try to pick a mesh in the scene
  45651. * @param x X position on screen
  45652. * @param y Y position on screen
  45653. * @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
  45654. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45655. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45656. * @returns an array of PickingInfo
  45657. */
  45658. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45659. /**
  45660. * Launch a ray to try to pick a mesh in the scene
  45661. * @param ray Ray to use
  45662. * @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
  45663. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45664. * @returns an array of PickingInfo
  45665. */
  45666. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45667. /**
  45668. * Force the value of meshUnderPointer
  45669. * @param mesh defines the mesh to use
  45670. * @param pointerId optional pointer id when using more than one pointer
  45671. */
  45672. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  45673. /**
  45674. * Gets the mesh under the pointer
  45675. * @returns a Mesh or null if no mesh is under the pointer
  45676. */
  45677. getPointerOverMesh(): Nullable<AbstractMesh>;
  45678. /** @hidden */
  45679. _rebuildGeometries(): void;
  45680. /** @hidden */
  45681. _rebuildTextures(): void;
  45682. private _getByTags;
  45683. /**
  45684. * Get a list of meshes by tags
  45685. * @param tagsQuery defines the tags query to use
  45686. * @param forEach defines a predicate used to filter results
  45687. * @returns an array of Mesh
  45688. */
  45689. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  45690. /**
  45691. * Get a list of cameras by tags
  45692. * @param tagsQuery defines the tags query to use
  45693. * @param forEach defines a predicate used to filter results
  45694. * @returns an array of Camera
  45695. */
  45696. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  45697. /**
  45698. * Get a list of lights by tags
  45699. * @param tagsQuery defines the tags query to use
  45700. * @param forEach defines a predicate used to filter results
  45701. * @returns an array of Light
  45702. */
  45703. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  45704. /**
  45705. * Get a list of materials by tags
  45706. * @param tagsQuery defines the tags query to use
  45707. * @param forEach defines a predicate used to filter results
  45708. * @returns an array of Material
  45709. */
  45710. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  45711. /**
  45712. * Get a list of transform nodes by tags
  45713. * @param tagsQuery defines the tags query to use
  45714. * @param forEach defines a predicate used to filter results
  45715. * @returns an array of TransformNode
  45716. */
  45717. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  45718. /**
  45719. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  45720. * This allowed control for front to back rendering or reversly depending of the special needs.
  45721. *
  45722. * @param renderingGroupId The rendering group id corresponding to its index
  45723. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  45724. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  45725. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  45726. */
  45727. 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;
  45728. /**
  45729. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  45730. *
  45731. * @param renderingGroupId The rendering group id corresponding to its index
  45732. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  45733. * @param depth Automatically clears depth between groups if true and autoClear is true.
  45734. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  45735. */
  45736. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  45737. /**
  45738. * Gets the current auto clear configuration for one rendering group of the rendering
  45739. * manager.
  45740. * @param index the rendering group index to get the information for
  45741. * @returns The auto clear setup for the requested rendering group
  45742. */
  45743. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  45744. private _blockMaterialDirtyMechanism;
  45745. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  45746. get blockMaterialDirtyMechanism(): boolean;
  45747. set blockMaterialDirtyMechanism(value: boolean);
  45748. /**
  45749. * Will flag all materials as dirty to trigger new shader compilation
  45750. * @param flag defines the flag used to specify which material part must be marked as dirty
  45751. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  45752. */
  45753. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  45754. /** @hidden */
  45755. _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;
  45756. /** @hidden */
  45757. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45758. /** @hidden */
  45759. _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;
  45760. /** @hidden */
  45761. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  45762. /** @hidden */
  45763. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  45764. /** @hidden */
  45765. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45766. }
  45767. }
  45768. declare module "babylonjs/assetContainer" {
  45769. import { AbstractScene } from "babylonjs/abstractScene";
  45770. import { Scene } from "babylonjs/scene";
  45771. import { Mesh } from "babylonjs/Meshes/mesh";
  45772. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45773. import { Skeleton } from "babylonjs/Bones/skeleton";
  45774. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45775. import { Animatable } from "babylonjs/Animations/animatable";
  45776. import { Nullable } from "babylonjs/types";
  45777. import { Node } from "babylonjs/node";
  45778. /**
  45779. * Set of assets to keep when moving a scene into an asset container.
  45780. */
  45781. export class KeepAssets extends AbstractScene {
  45782. }
  45783. /**
  45784. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  45785. */
  45786. export class InstantiatedEntries {
  45787. /**
  45788. * List of new root nodes (eg. nodes with no parent)
  45789. */
  45790. rootNodes: TransformNode[];
  45791. /**
  45792. * List of new skeletons
  45793. */
  45794. skeletons: Skeleton[];
  45795. /**
  45796. * List of new animation groups
  45797. */
  45798. animationGroups: AnimationGroup[];
  45799. }
  45800. /**
  45801. * Container with a set of assets that can be added or removed from a scene.
  45802. */
  45803. export class AssetContainer extends AbstractScene {
  45804. private _wasAddedToScene;
  45805. /**
  45806. * The scene the AssetContainer belongs to.
  45807. */
  45808. scene: Scene;
  45809. /**
  45810. * Instantiates an AssetContainer.
  45811. * @param scene The scene the AssetContainer belongs to.
  45812. */
  45813. constructor(scene: Scene);
  45814. /**
  45815. * Instantiate or clone all meshes and add the new ones to the scene.
  45816. * Skeletons and animation groups will all be cloned
  45817. * @param nameFunction defines an optional function used to get new names for clones
  45818. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  45819. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  45820. */
  45821. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  45822. /**
  45823. * Adds all the assets from the container to the scene.
  45824. */
  45825. addAllToScene(): void;
  45826. /**
  45827. * Removes all the assets in the container from the scene
  45828. */
  45829. removeAllFromScene(): void;
  45830. /**
  45831. * Disposes all the assets in the container
  45832. */
  45833. dispose(): void;
  45834. private _moveAssets;
  45835. /**
  45836. * Removes all the assets contained in the scene and adds them to the container.
  45837. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  45838. */
  45839. moveAllFromScene(keepAssets?: KeepAssets): void;
  45840. /**
  45841. * 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.
  45842. * @returns the root mesh
  45843. */
  45844. createRootMesh(): Mesh;
  45845. /**
  45846. * Merge animations (direct and animation groups) from this asset container into a scene
  45847. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45848. * @param animatables set of animatables to retarget to a node from the scene
  45849. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  45850. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  45851. */
  45852. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  45853. }
  45854. }
  45855. declare module "babylonjs/abstractScene" {
  45856. import { Scene } from "babylonjs/scene";
  45857. import { Nullable } from "babylonjs/types";
  45858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45859. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45860. import { Geometry } from "babylonjs/Meshes/geometry";
  45861. import { Skeleton } from "babylonjs/Bones/skeleton";
  45862. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  45863. import { AssetContainer } from "babylonjs/assetContainer";
  45864. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45865. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45866. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45867. import { Material } from "babylonjs/Materials/material";
  45868. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  45869. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  45870. import { Camera } from "babylonjs/Cameras/camera";
  45871. import { Light } from "babylonjs/Lights/light";
  45872. import { Node } from "babylonjs/node";
  45873. import { Animation } from "babylonjs/Animations/animation";
  45874. /**
  45875. * Defines how the parser contract is defined.
  45876. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  45877. */
  45878. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  45879. /**
  45880. * Defines how the individual parser contract is defined.
  45881. * These parser can parse an individual asset
  45882. */
  45883. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  45884. /**
  45885. * Base class of the scene acting as a container for the different elements composing a scene.
  45886. * This class is dynamically extended by the different components of the scene increasing
  45887. * flexibility and reducing coupling
  45888. */
  45889. export abstract class AbstractScene {
  45890. /**
  45891. * Stores the list of available parsers in the application.
  45892. */
  45893. private static _BabylonFileParsers;
  45894. /**
  45895. * Stores the list of available individual parsers in the application.
  45896. */
  45897. private static _IndividualBabylonFileParsers;
  45898. /**
  45899. * Adds a parser in the list of available ones
  45900. * @param name Defines the name of the parser
  45901. * @param parser Defines the parser to add
  45902. */
  45903. static AddParser(name: string, parser: BabylonFileParser): void;
  45904. /**
  45905. * Gets a general parser from the list of avaialble ones
  45906. * @param name Defines the name of the parser
  45907. * @returns the requested parser or null
  45908. */
  45909. static GetParser(name: string): Nullable<BabylonFileParser>;
  45910. /**
  45911. * Adds n individual parser in the list of available ones
  45912. * @param name Defines the name of the parser
  45913. * @param parser Defines the parser to add
  45914. */
  45915. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  45916. /**
  45917. * Gets an individual parser from the list of avaialble ones
  45918. * @param name Defines the name of the parser
  45919. * @returns the requested parser or null
  45920. */
  45921. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  45922. /**
  45923. * Parser json data and populate both a scene and its associated container object
  45924. * @param jsonData Defines the data to parse
  45925. * @param scene Defines the scene to parse the data for
  45926. * @param container Defines the container attached to the parsing sequence
  45927. * @param rootUrl Defines the root url of the data
  45928. */
  45929. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  45930. /**
  45931. * Gets the list of root nodes (ie. nodes with no parent)
  45932. */
  45933. rootNodes: Node[];
  45934. /** All of the cameras added to this scene
  45935. * @see https://doc.babylonjs.com/babylon101/cameras
  45936. */
  45937. cameras: Camera[];
  45938. /**
  45939. * All of the lights added to this scene
  45940. * @see https://doc.babylonjs.com/babylon101/lights
  45941. */
  45942. lights: Light[];
  45943. /**
  45944. * All of the (abstract) meshes added to this scene
  45945. */
  45946. meshes: AbstractMesh[];
  45947. /**
  45948. * The list of skeletons added to the scene
  45949. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  45950. */
  45951. skeletons: Skeleton[];
  45952. /**
  45953. * All of the particle systems added to this scene
  45954. * @see https://doc.babylonjs.com/babylon101/particles
  45955. */
  45956. particleSystems: IParticleSystem[];
  45957. /**
  45958. * Gets a list of Animations associated with the scene
  45959. */
  45960. animations: Animation[];
  45961. /**
  45962. * All of the animation groups added to this scene
  45963. * @see https://doc.babylonjs.com/how_to/group
  45964. */
  45965. animationGroups: AnimationGroup[];
  45966. /**
  45967. * All of the multi-materials added to this scene
  45968. * @see https://doc.babylonjs.com/how_to/multi_materials
  45969. */
  45970. multiMaterials: MultiMaterial[];
  45971. /**
  45972. * All of the materials added to this scene
  45973. * In the context of a Scene, it is not supposed to be modified manually.
  45974. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  45975. * Note also that the order of the Material within the array is not significant and might change.
  45976. * @see https://doc.babylonjs.com/babylon101/materials
  45977. */
  45978. materials: Material[];
  45979. /**
  45980. * The list of morph target managers added to the scene
  45981. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  45982. */
  45983. morphTargetManagers: MorphTargetManager[];
  45984. /**
  45985. * The list of geometries used in the scene.
  45986. */
  45987. geometries: Geometry[];
  45988. /**
  45989. * All of the tranform nodes added to this scene
  45990. * In the context of a Scene, it is not supposed to be modified manually.
  45991. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  45992. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  45993. * @see https://doc.babylonjs.com/how_to/transformnode
  45994. */
  45995. transformNodes: TransformNode[];
  45996. /**
  45997. * ActionManagers available on the scene.
  45998. */
  45999. actionManagers: AbstractActionManager[];
  46000. /**
  46001. * Textures to keep.
  46002. */
  46003. textures: BaseTexture[];
  46004. /** @hidden */
  46005. protected _environmentTexture: Nullable<BaseTexture>;
  46006. /**
  46007. * Texture used in all pbr material as the reflection texture.
  46008. * As in the majority of the scene they are the same (exception for multi room and so on),
  46009. * this is easier to reference from here than from all the materials.
  46010. */
  46011. get environmentTexture(): Nullable<BaseTexture>;
  46012. set environmentTexture(value: Nullable<BaseTexture>);
  46013. /**
  46014. * The list of postprocesses added to the scene
  46015. */
  46016. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46017. /**
  46018. * @returns all meshes, lights, cameras, transformNodes and bones
  46019. */
  46020. getNodes(): Array<Node>;
  46021. }
  46022. }
  46023. declare module "babylonjs/Audio/sound" {
  46024. import { Observable } from "babylonjs/Misc/observable";
  46025. import { Vector3 } from "babylonjs/Maths/math.vector";
  46026. import { Nullable } from "babylonjs/types";
  46027. import { Scene } from "babylonjs/scene";
  46028. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46029. /**
  46030. * Interface used to define options for Sound class
  46031. */
  46032. export interface ISoundOptions {
  46033. /**
  46034. * Does the sound autoplay once loaded.
  46035. */
  46036. autoplay?: boolean;
  46037. /**
  46038. * Does the sound loop after it finishes playing once.
  46039. */
  46040. loop?: boolean;
  46041. /**
  46042. * Sound's volume
  46043. */
  46044. volume?: number;
  46045. /**
  46046. * Is it a spatial sound?
  46047. */
  46048. spatialSound?: boolean;
  46049. /**
  46050. * Maximum distance to hear that sound
  46051. */
  46052. maxDistance?: number;
  46053. /**
  46054. * Uses user defined attenuation function
  46055. */
  46056. useCustomAttenuation?: boolean;
  46057. /**
  46058. * Define the roll off factor of spatial sounds.
  46059. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46060. */
  46061. rolloffFactor?: number;
  46062. /**
  46063. * Define the reference distance the sound should be heard perfectly.
  46064. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46065. */
  46066. refDistance?: number;
  46067. /**
  46068. * Define the distance attenuation model the sound will follow.
  46069. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46070. */
  46071. distanceModel?: string;
  46072. /**
  46073. * Defines the playback speed (1 by default)
  46074. */
  46075. playbackRate?: number;
  46076. /**
  46077. * Defines if the sound is from a streaming source
  46078. */
  46079. streaming?: boolean;
  46080. /**
  46081. * Defines an optional length (in seconds) inside the sound file
  46082. */
  46083. length?: number;
  46084. /**
  46085. * Defines an optional offset (in seconds) inside the sound file
  46086. */
  46087. offset?: number;
  46088. /**
  46089. * If true, URLs will not be required to state the audio file codec to use.
  46090. */
  46091. skipCodecCheck?: boolean;
  46092. }
  46093. /**
  46094. * Defines a sound that can be played in the application.
  46095. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46096. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46097. */
  46098. export class Sound {
  46099. /**
  46100. * The name of the sound in the scene.
  46101. */
  46102. name: string;
  46103. /**
  46104. * Does the sound autoplay once loaded.
  46105. */
  46106. autoplay: boolean;
  46107. /**
  46108. * Does the sound loop after it finishes playing once.
  46109. */
  46110. loop: boolean;
  46111. /**
  46112. * Does the sound use a custom attenuation curve to simulate the falloff
  46113. * happening when the source gets further away from the camera.
  46114. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46115. */
  46116. useCustomAttenuation: boolean;
  46117. /**
  46118. * The sound track id this sound belongs to.
  46119. */
  46120. soundTrackId: number;
  46121. /**
  46122. * Is this sound currently played.
  46123. */
  46124. isPlaying: boolean;
  46125. /**
  46126. * Is this sound currently paused.
  46127. */
  46128. isPaused: boolean;
  46129. /**
  46130. * Does this sound enables spatial sound.
  46131. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46132. */
  46133. spatialSound: boolean;
  46134. /**
  46135. * Define the reference distance the sound should be heard perfectly.
  46136. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46137. */
  46138. refDistance: number;
  46139. /**
  46140. * Define the roll off factor of spatial sounds.
  46141. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46142. */
  46143. rolloffFactor: number;
  46144. /**
  46145. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46146. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46147. */
  46148. maxDistance: number;
  46149. /**
  46150. * Define the distance attenuation model the sound will follow.
  46151. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46152. */
  46153. distanceModel: string;
  46154. /**
  46155. * @hidden
  46156. * Back Compat
  46157. **/
  46158. onended: () => any;
  46159. /**
  46160. * Gets or sets an object used to store user defined information for the sound.
  46161. */
  46162. metadata: any;
  46163. /**
  46164. * Observable event when the current playing sound finishes.
  46165. */
  46166. onEndedObservable: Observable<Sound>;
  46167. private _panningModel;
  46168. private _playbackRate;
  46169. private _streaming;
  46170. private _startTime;
  46171. private _startOffset;
  46172. private _position;
  46173. /** @hidden */
  46174. _positionInEmitterSpace: boolean;
  46175. private _localDirection;
  46176. private _volume;
  46177. private _isReadyToPlay;
  46178. private _isDirectional;
  46179. private _readyToPlayCallback;
  46180. private _audioBuffer;
  46181. private _soundSource;
  46182. private _streamingSource;
  46183. private _soundPanner;
  46184. private _soundGain;
  46185. private _inputAudioNode;
  46186. private _outputAudioNode;
  46187. private _coneInnerAngle;
  46188. private _coneOuterAngle;
  46189. private _coneOuterGain;
  46190. private _scene;
  46191. private _connectedTransformNode;
  46192. private _customAttenuationFunction;
  46193. private _registerFunc;
  46194. private _isOutputConnected;
  46195. private _htmlAudioElement;
  46196. private _urlType;
  46197. private _length?;
  46198. private _offset?;
  46199. /** @hidden */
  46200. static _SceneComponentInitialization: (scene: Scene) => void;
  46201. /**
  46202. * Create a sound and attach it to a scene
  46203. * @param name Name of your sound
  46204. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46205. * @param scene defines the scene the sound belongs to
  46206. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46207. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46208. */
  46209. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46210. /**
  46211. * Release the sound and its associated resources
  46212. */
  46213. dispose(): void;
  46214. /**
  46215. * Gets if the sounds is ready to be played or not.
  46216. * @returns true if ready, otherwise false
  46217. */
  46218. isReady(): boolean;
  46219. private _soundLoaded;
  46220. /**
  46221. * Sets the data of the sound from an audiobuffer
  46222. * @param audioBuffer The audioBuffer containing the data
  46223. */
  46224. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46225. /**
  46226. * Updates the current sounds options such as maxdistance, loop...
  46227. * @param options A JSON object containing values named as the object properties
  46228. */
  46229. updateOptions(options: ISoundOptions): void;
  46230. private _createSpatialParameters;
  46231. private _updateSpatialParameters;
  46232. /**
  46233. * Switch the panning model to HRTF:
  46234. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46235. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46236. */
  46237. switchPanningModelToHRTF(): void;
  46238. /**
  46239. * Switch the panning model to Equal Power:
  46240. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46241. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46242. */
  46243. switchPanningModelToEqualPower(): void;
  46244. private _switchPanningModel;
  46245. /**
  46246. * Connect this sound to a sound track audio node like gain...
  46247. * @param soundTrackAudioNode the sound track audio node to connect to
  46248. */
  46249. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46250. /**
  46251. * Transform this sound into a directional source
  46252. * @param coneInnerAngle Size of the inner cone in degree
  46253. * @param coneOuterAngle Size of the outer cone in degree
  46254. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46255. */
  46256. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46257. /**
  46258. * Gets or sets the inner angle for the directional cone.
  46259. */
  46260. get directionalConeInnerAngle(): number;
  46261. /**
  46262. * Gets or sets the inner angle for the directional cone.
  46263. */
  46264. set directionalConeInnerAngle(value: number);
  46265. /**
  46266. * Gets or sets the outer angle for the directional cone.
  46267. */
  46268. get directionalConeOuterAngle(): number;
  46269. /**
  46270. * Gets or sets the outer angle for the directional cone.
  46271. */
  46272. set directionalConeOuterAngle(value: number);
  46273. /**
  46274. * Sets the position of the emitter if spatial sound is enabled
  46275. * @param newPosition Defines the new posisiton
  46276. */
  46277. setPosition(newPosition: Vector3): void;
  46278. /**
  46279. * Sets the local direction of the emitter if spatial sound is enabled
  46280. * @param newLocalDirection Defines the new local direction
  46281. */
  46282. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46283. private _updateDirection;
  46284. /** @hidden */
  46285. updateDistanceFromListener(): void;
  46286. /**
  46287. * Sets a new custom attenuation function for the sound.
  46288. * @param callback Defines the function used for the attenuation
  46289. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46290. */
  46291. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46292. /**
  46293. * Play the sound
  46294. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46295. * @param offset (optional) Start the sound at a specific time in seconds
  46296. * @param length (optional) Sound duration (in seconds)
  46297. */
  46298. play(time?: number, offset?: number, length?: number): void;
  46299. private _onended;
  46300. /**
  46301. * Stop the sound
  46302. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46303. */
  46304. stop(time?: number): void;
  46305. /**
  46306. * Put the sound in pause
  46307. */
  46308. pause(): void;
  46309. /**
  46310. * Sets a dedicated volume for this sounds
  46311. * @param newVolume Define the new volume of the sound
  46312. * @param time Define time for gradual change to new volume
  46313. */
  46314. setVolume(newVolume: number, time?: number): void;
  46315. /**
  46316. * Set the sound play back rate
  46317. * @param newPlaybackRate Define the playback rate the sound should be played at
  46318. */
  46319. setPlaybackRate(newPlaybackRate: number): void;
  46320. /**
  46321. * Gets the volume of the sound.
  46322. * @returns the volume of the sound
  46323. */
  46324. getVolume(): number;
  46325. /**
  46326. * Attach the sound to a dedicated mesh
  46327. * @param transformNode The transform node to connect the sound with
  46328. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46329. */
  46330. attachToMesh(transformNode: TransformNode): void;
  46331. /**
  46332. * Detach the sound from the previously attached mesh
  46333. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46334. */
  46335. detachFromMesh(): void;
  46336. private _onRegisterAfterWorldMatrixUpdate;
  46337. /**
  46338. * Clone the current sound in the scene.
  46339. * @returns the new sound clone
  46340. */
  46341. clone(): Nullable<Sound>;
  46342. /**
  46343. * Gets the current underlying audio buffer containing the data
  46344. * @returns the audio buffer
  46345. */
  46346. getAudioBuffer(): Nullable<AudioBuffer>;
  46347. /**
  46348. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46349. * @returns the source node
  46350. */
  46351. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46352. /**
  46353. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46354. * @returns the gain node
  46355. */
  46356. getSoundGain(): Nullable<GainNode>;
  46357. /**
  46358. * Serializes the Sound in a JSON representation
  46359. * @returns the JSON representation of the sound
  46360. */
  46361. serialize(): any;
  46362. /**
  46363. * Parse a JSON representation of a sound to innstantiate in a given scene
  46364. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46365. * @param scene Define the scene the new parsed sound should be created in
  46366. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46367. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46368. * @returns the newly parsed sound
  46369. */
  46370. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46371. }
  46372. }
  46373. declare module "babylonjs/Actions/directAudioActions" {
  46374. import { Action } from "babylonjs/Actions/action";
  46375. import { Condition } from "babylonjs/Actions/condition";
  46376. import { Sound } from "babylonjs/Audio/sound";
  46377. /**
  46378. * This defines an action helpful to play a defined sound on a triggered action.
  46379. */
  46380. export class PlaySoundAction extends Action {
  46381. private _sound;
  46382. /**
  46383. * Instantiate the action
  46384. * @param triggerOptions defines the trigger options
  46385. * @param sound defines the sound to play
  46386. * @param condition defines the trigger related conditions
  46387. */
  46388. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46389. /** @hidden */
  46390. _prepare(): void;
  46391. /**
  46392. * Execute the action and play the sound.
  46393. */
  46394. execute(): void;
  46395. /**
  46396. * Serializes the actions and its related information.
  46397. * @param parent defines the object to serialize in
  46398. * @returns the serialized object
  46399. */
  46400. serialize(parent: any): any;
  46401. }
  46402. /**
  46403. * This defines an action helpful to stop a defined sound on a triggered action.
  46404. */
  46405. export class StopSoundAction extends Action {
  46406. private _sound;
  46407. /**
  46408. * Instantiate the action
  46409. * @param triggerOptions defines the trigger options
  46410. * @param sound defines the sound to stop
  46411. * @param condition defines the trigger related conditions
  46412. */
  46413. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46414. /** @hidden */
  46415. _prepare(): void;
  46416. /**
  46417. * Execute the action and stop the sound.
  46418. */
  46419. execute(): void;
  46420. /**
  46421. * Serializes the actions and its related information.
  46422. * @param parent defines the object to serialize in
  46423. * @returns the serialized object
  46424. */
  46425. serialize(parent: any): any;
  46426. }
  46427. }
  46428. declare module "babylonjs/Actions/interpolateValueAction" {
  46429. import { Action } from "babylonjs/Actions/action";
  46430. import { Condition } from "babylonjs/Actions/condition";
  46431. import { Observable } from "babylonjs/Misc/observable";
  46432. /**
  46433. * This defines an action responsible to change the value of a property
  46434. * by interpolating between its current value and the newly set one once triggered.
  46435. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46436. */
  46437. export class InterpolateValueAction extends Action {
  46438. /**
  46439. * Defines the path of the property where the value should be interpolated
  46440. */
  46441. propertyPath: string;
  46442. /**
  46443. * Defines the target value at the end of the interpolation.
  46444. */
  46445. value: any;
  46446. /**
  46447. * Defines the time it will take for the property to interpolate to the value.
  46448. */
  46449. duration: number;
  46450. /**
  46451. * Defines if the other scene animations should be stopped when the action has been triggered
  46452. */
  46453. stopOtherAnimations?: boolean;
  46454. /**
  46455. * Defines a callback raised once the interpolation animation has been done.
  46456. */
  46457. onInterpolationDone?: () => void;
  46458. /**
  46459. * Observable triggered once the interpolation animation has been done.
  46460. */
  46461. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  46462. private _target;
  46463. private _effectiveTarget;
  46464. private _property;
  46465. /**
  46466. * Instantiate the action
  46467. * @param triggerOptions defines the trigger options
  46468. * @param target defines the object containing the value to interpolate
  46469. * @param propertyPath defines the path to the property in the target object
  46470. * @param value defines the target value at the end of the interpolation
  46471. * @param duration deines the time it will take for the property to interpolate to the value.
  46472. * @param condition defines the trigger related conditions
  46473. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  46474. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  46475. */
  46476. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  46477. /** @hidden */
  46478. _prepare(): void;
  46479. /**
  46480. * Execute the action starts the value interpolation.
  46481. */
  46482. execute(): void;
  46483. /**
  46484. * Serializes the actions and its related information.
  46485. * @param parent defines the object to serialize in
  46486. * @returns the serialized object
  46487. */
  46488. serialize(parent: any): any;
  46489. }
  46490. }
  46491. declare module "babylonjs/Actions/index" {
  46492. export * from "babylonjs/Actions/abstractActionManager";
  46493. export * from "babylonjs/Actions/action";
  46494. export * from "babylonjs/Actions/actionEvent";
  46495. export * from "babylonjs/Actions/actionManager";
  46496. export * from "babylonjs/Actions/condition";
  46497. export * from "babylonjs/Actions/directActions";
  46498. export * from "babylonjs/Actions/directAudioActions";
  46499. export * from "babylonjs/Actions/interpolateValueAction";
  46500. }
  46501. declare module "babylonjs/Animations/index" {
  46502. export * from "babylonjs/Animations/animatable";
  46503. export * from "babylonjs/Animations/animation";
  46504. export * from "babylonjs/Animations/animationGroup";
  46505. export * from "babylonjs/Animations/animationPropertiesOverride";
  46506. export * from "babylonjs/Animations/easing";
  46507. export * from "babylonjs/Animations/runtimeAnimation";
  46508. export * from "babylonjs/Animations/animationEvent";
  46509. export * from "babylonjs/Animations/animationGroup";
  46510. export * from "babylonjs/Animations/animationKey";
  46511. export * from "babylonjs/Animations/animationRange";
  46512. export * from "babylonjs/Animations/animatable.interface";
  46513. }
  46514. declare module "babylonjs/Audio/soundTrack" {
  46515. import { Sound } from "babylonjs/Audio/sound";
  46516. import { Analyser } from "babylonjs/Audio/analyser";
  46517. import { Scene } from "babylonjs/scene";
  46518. /**
  46519. * Options allowed during the creation of a sound track.
  46520. */
  46521. export interface ISoundTrackOptions {
  46522. /**
  46523. * The volume the sound track should take during creation
  46524. */
  46525. volume?: number;
  46526. /**
  46527. * Define if the sound track is the main sound track of the scene
  46528. */
  46529. mainTrack?: boolean;
  46530. }
  46531. /**
  46532. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  46533. * It will be also used in a future release to apply effects on a specific track.
  46534. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46535. */
  46536. export class SoundTrack {
  46537. /**
  46538. * The unique identifier of the sound track in the scene.
  46539. */
  46540. id: number;
  46541. /**
  46542. * The list of sounds included in the sound track.
  46543. */
  46544. soundCollection: Array<Sound>;
  46545. private _outputAudioNode;
  46546. private _scene;
  46547. private _connectedAnalyser;
  46548. private _options;
  46549. private _isInitialized;
  46550. /**
  46551. * Creates a new sound track.
  46552. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46553. * @param scene Define the scene the sound track belongs to
  46554. * @param options
  46555. */
  46556. constructor(scene: Scene, options?: ISoundTrackOptions);
  46557. private _initializeSoundTrackAudioGraph;
  46558. /**
  46559. * Release the sound track and its associated resources
  46560. */
  46561. dispose(): void;
  46562. /**
  46563. * Adds a sound to this sound track
  46564. * @param sound define the cound to add
  46565. * @ignoreNaming
  46566. */
  46567. AddSound(sound: Sound): void;
  46568. /**
  46569. * Removes a sound to this sound track
  46570. * @param sound define the cound to remove
  46571. * @ignoreNaming
  46572. */
  46573. RemoveSound(sound: Sound): void;
  46574. /**
  46575. * Set a global volume for the full sound track.
  46576. * @param newVolume Define the new volume of the sound track
  46577. */
  46578. setVolume(newVolume: number): void;
  46579. /**
  46580. * Switch the panning model to HRTF:
  46581. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46582. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46583. */
  46584. switchPanningModelToHRTF(): void;
  46585. /**
  46586. * Switch the panning model to Equal Power:
  46587. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46588. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46589. */
  46590. switchPanningModelToEqualPower(): void;
  46591. /**
  46592. * Connect the sound track to an audio analyser allowing some amazing
  46593. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  46594. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  46595. * @param analyser The analyser to connect to the engine
  46596. */
  46597. connectToAnalyser(analyser: Analyser): void;
  46598. }
  46599. }
  46600. declare module "babylonjs/Audio/audioSceneComponent" {
  46601. import { Sound } from "babylonjs/Audio/sound";
  46602. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  46603. import { Nullable } from "babylonjs/types";
  46604. import { Vector3 } from "babylonjs/Maths/math.vector";
  46605. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46606. import { Scene } from "babylonjs/scene";
  46607. import { AbstractScene } from "babylonjs/abstractScene";
  46608. import "babylonjs/Audio/audioEngine";
  46609. module "babylonjs/abstractScene" {
  46610. interface AbstractScene {
  46611. /**
  46612. * The list of sounds used in the scene.
  46613. */
  46614. sounds: Nullable<Array<Sound>>;
  46615. }
  46616. }
  46617. module "babylonjs/scene" {
  46618. interface Scene {
  46619. /**
  46620. * @hidden
  46621. * Backing field
  46622. */
  46623. _mainSoundTrack: SoundTrack;
  46624. /**
  46625. * The main sound track played by the scene.
  46626. * It cotains your primary collection of sounds.
  46627. */
  46628. mainSoundTrack: SoundTrack;
  46629. /**
  46630. * The list of sound tracks added to the scene
  46631. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46632. */
  46633. soundTracks: Nullable<Array<SoundTrack>>;
  46634. /**
  46635. * Gets a sound using a given name
  46636. * @param name defines the name to search for
  46637. * @return the found sound or null if not found at all.
  46638. */
  46639. getSoundByName(name: string): Nullable<Sound>;
  46640. /**
  46641. * Gets or sets if audio support is enabled
  46642. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46643. */
  46644. audioEnabled: boolean;
  46645. /**
  46646. * Gets or sets if audio will be output to headphones
  46647. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46648. */
  46649. headphone: boolean;
  46650. /**
  46651. * Gets or sets custom audio listener position provider
  46652. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46653. */
  46654. audioListenerPositionProvider: Nullable<() => Vector3>;
  46655. /**
  46656. * Gets or sets a refresh rate when using 3D audio positioning
  46657. */
  46658. audioPositioningRefreshRate: number;
  46659. }
  46660. }
  46661. /**
  46662. * Defines the sound scene component responsible to manage any sounds
  46663. * in a given scene.
  46664. */
  46665. export class AudioSceneComponent implements ISceneSerializableComponent {
  46666. private static _CameraDirectionLH;
  46667. private static _CameraDirectionRH;
  46668. /**
  46669. * The component name helpfull to identify the component in the list of scene components.
  46670. */
  46671. readonly name: string;
  46672. /**
  46673. * The scene the component belongs to.
  46674. */
  46675. scene: Scene;
  46676. private _audioEnabled;
  46677. /**
  46678. * Gets whether audio is enabled or not.
  46679. * Please use related enable/disable method to switch state.
  46680. */
  46681. get audioEnabled(): boolean;
  46682. private _headphone;
  46683. /**
  46684. * Gets whether audio is outputing to headphone or not.
  46685. * Please use the according Switch methods to change output.
  46686. */
  46687. get headphone(): boolean;
  46688. /**
  46689. * Gets or sets a refresh rate when using 3D audio positioning
  46690. */
  46691. audioPositioningRefreshRate: number;
  46692. private _audioListenerPositionProvider;
  46693. /**
  46694. * Gets the current audio listener position provider
  46695. */
  46696. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  46697. /**
  46698. * Sets a custom listener position for all sounds in the scene
  46699. * By default, this is the position of the first active camera
  46700. */
  46701. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  46702. /**
  46703. * Creates a new instance of the component for the given scene
  46704. * @param scene Defines the scene to register the component in
  46705. */
  46706. constructor(scene: Scene);
  46707. /**
  46708. * Registers the component in a given scene
  46709. */
  46710. register(): void;
  46711. /**
  46712. * Rebuilds the elements related to this component in case of
  46713. * context lost for instance.
  46714. */
  46715. rebuild(): void;
  46716. /**
  46717. * Serializes the component data to the specified json object
  46718. * @param serializationObject The object to serialize to
  46719. */
  46720. serialize(serializationObject: any): void;
  46721. /**
  46722. * Adds all the elements from the container to the scene
  46723. * @param container the container holding the elements
  46724. */
  46725. addFromContainer(container: AbstractScene): void;
  46726. /**
  46727. * Removes all the elements in the container from the scene
  46728. * @param container contains the elements to remove
  46729. * @param dispose if the removed element should be disposed (default: false)
  46730. */
  46731. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46732. /**
  46733. * Disposes the component and the associated ressources.
  46734. */
  46735. dispose(): void;
  46736. /**
  46737. * Disables audio in the associated scene.
  46738. */
  46739. disableAudio(): void;
  46740. /**
  46741. * Enables audio in the associated scene.
  46742. */
  46743. enableAudio(): void;
  46744. /**
  46745. * Switch audio to headphone output.
  46746. */
  46747. switchAudioModeForHeadphones(): void;
  46748. /**
  46749. * Switch audio to normal speakers.
  46750. */
  46751. switchAudioModeForNormalSpeakers(): void;
  46752. private _cachedCameraDirection;
  46753. private _cachedCameraPosition;
  46754. private _lastCheck;
  46755. private _afterRender;
  46756. }
  46757. }
  46758. declare module "babylonjs/Audio/weightedsound" {
  46759. import { Sound } from "babylonjs/Audio/sound";
  46760. /**
  46761. * Wraps one or more Sound objects and selects one with random weight for playback.
  46762. */
  46763. export class WeightedSound {
  46764. /** When true a Sound will be selected and played when the current playing Sound completes. */
  46765. loop: boolean;
  46766. private _coneInnerAngle;
  46767. private _coneOuterAngle;
  46768. private _volume;
  46769. /** A Sound is currently playing. */
  46770. isPlaying: boolean;
  46771. /** A Sound is currently paused. */
  46772. isPaused: boolean;
  46773. private _sounds;
  46774. private _weights;
  46775. private _currentIndex?;
  46776. /**
  46777. * Creates a new WeightedSound from the list of sounds given.
  46778. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  46779. * @param sounds Array of Sounds that will be selected from.
  46780. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  46781. */
  46782. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  46783. /**
  46784. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  46785. */
  46786. get directionalConeInnerAngle(): number;
  46787. /**
  46788. * The size of cone in degress for a directional sound in which there will be no attenuation.
  46789. */
  46790. set directionalConeInnerAngle(value: 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. get directionalConeOuterAngle(): number;
  46796. /**
  46797. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  46798. * Listener angles between innerAngle and outerAngle will falloff linearly.
  46799. */
  46800. set directionalConeOuterAngle(value: number);
  46801. /**
  46802. * Playback volume.
  46803. */
  46804. get volume(): number;
  46805. /**
  46806. * Playback volume.
  46807. */
  46808. set volume(value: number);
  46809. private _onended;
  46810. /**
  46811. * Suspend playback
  46812. */
  46813. pause(): void;
  46814. /**
  46815. * Stop playback
  46816. */
  46817. stop(): void;
  46818. /**
  46819. * Start playback.
  46820. * @param startOffset Position the clip head at a specific time in seconds.
  46821. */
  46822. play(startOffset?: number): void;
  46823. }
  46824. }
  46825. declare module "babylonjs/Audio/index" {
  46826. export * from "babylonjs/Audio/analyser";
  46827. export * from "babylonjs/Audio/audioEngine";
  46828. export * from "babylonjs/Audio/audioSceneComponent";
  46829. export * from "babylonjs/Audio/sound";
  46830. export * from "babylonjs/Audio/soundTrack";
  46831. export * from "babylonjs/Audio/weightedsound";
  46832. }
  46833. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  46834. import { Behavior } from "babylonjs/Behaviors/behavior";
  46835. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46836. import { BackEase } from "babylonjs/Animations/easing";
  46837. /**
  46838. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  46839. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46840. */
  46841. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  46842. /**
  46843. * Gets the name of the behavior.
  46844. */
  46845. get name(): string;
  46846. /**
  46847. * The easing function used by animations
  46848. */
  46849. static EasingFunction: BackEase;
  46850. /**
  46851. * The easing mode used by animations
  46852. */
  46853. static EasingMode: number;
  46854. /**
  46855. * The duration of the animation, in milliseconds
  46856. */
  46857. transitionDuration: number;
  46858. /**
  46859. * Length of the distance animated by the transition when lower radius is reached
  46860. */
  46861. lowerRadiusTransitionRange: number;
  46862. /**
  46863. * Length of the distance animated by the transition when upper radius is reached
  46864. */
  46865. upperRadiusTransitionRange: number;
  46866. private _autoTransitionRange;
  46867. /**
  46868. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46869. */
  46870. get autoTransitionRange(): boolean;
  46871. /**
  46872. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46873. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  46874. */
  46875. set autoTransitionRange(value: boolean);
  46876. private _attachedCamera;
  46877. private _onAfterCheckInputsObserver;
  46878. private _onMeshTargetChangedObserver;
  46879. /**
  46880. * Initializes the behavior.
  46881. */
  46882. init(): void;
  46883. /**
  46884. * Attaches the behavior to its arc rotate camera.
  46885. * @param camera Defines the camera to attach the behavior to
  46886. */
  46887. attach(camera: ArcRotateCamera): void;
  46888. /**
  46889. * Detaches the behavior from its current arc rotate camera.
  46890. */
  46891. detach(): void;
  46892. private _radiusIsAnimating;
  46893. private _radiusBounceTransition;
  46894. private _animatables;
  46895. private _cachedWheelPrecision;
  46896. /**
  46897. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  46898. * @param radiusLimit The limit to check against.
  46899. * @return Bool to indicate if at limit.
  46900. */
  46901. private _isRadiusAtLimit;
  46902. /**
  46903. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  46904. * @param radiusDelta The delta by which to animate to. Can be negative.
  46905. */
  46906. private _applyBoundRadiusAnimation;
  46907. /**
  46908. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  46909. */
  46910. protected _clearAnimationLocks(): void;
  46911. /**
  46912. * Stops and removes all animations that have been applied to the camera
  46913. */
  46914. stopAllAnimations(): void;
  46915. }
  46916. }
  46917. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  46918. import { Behavior } from "babylonjs/Behaviors/behavior";
  46919. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46920. import { ExponentialEase } from "babylonjs/Animations/easing";
  46921. import { Nullable } from "babylonjs/types";
  46922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46923. import { Vector3 } from "babylonjs/Maths/math.vector";
  46924. /**
  46925. * 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.
  46926. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46927. */
  46928. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  46929. /**
  46930. * Gets the name of the behavior.
  46931. */
  46932. get name(): string;
  46933. private _mode;
  46934. private _radiusScale;
  46935. private _positionScale;
  46936. private _defaultElevation;
  46937. private _elevationReturnTime;
  46938. private _elevationReturnWaitTime;
  46939. private _zoomStopsAnimation;
  46940. private _framingTime;
  46941. /**
  46942. * The easing function used by animations
  46943. */
  46944. static EasingFunction: ExponentialEase;
  46945. /**
  46946. * The easing mode used by animations
  46947. */
  46948. static EasingMode: number;
  46949. /**
  46950. * Sets the current mode used by the behavior
  46951. */
  46952. set mode(mode: number);
  46953. /**
  46954. * Gets current mode used by the behavior.
  46955. */
  46956. get mode(): number;
  46957. /**
  46958. * Sets the scale applied to the radius (1 by default)
  46959. */
  46960. set radiusScale(radius: number);
  46961. /**
  46962. * Gets the scale applied to the radius
  46963. */
  46964. get radiusScale(): number;
  46965. /**
  46966. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46967. */
  46968. set positionScale(scale: number);
  46969. /**
  46970. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46971. */
  46972. get positionScale(): number;
  46973. /**
  46974. * Sets 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. set defaultElevation(elevation: number);
  46978. /**
  46979. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46980. * behaviour is triggered, in radians.
  46981. */
  46982. get defaultElevation(): number;
  46983. /**
  46984. * Sets the time (in milliseconds) taken to return to the default beta position.
  46985. * Negative value indicates camera should not return to default.
  46986. */
  46987. set elevationReturnTime(speed: number);
  46988. /**
  46989. * Gets the time (in milliseconds) taken to return to the default beta position.
  46990. * Negative value indicates camera should not return to default.
  46991. */
  46992. get elevationReturnTime(): number;
  46993. /**
  46994. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46995. */
  46996. set elevationReturnWaitTime(time: number);
  46997. /**
  46998. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46999. */
  47000. get elevationReturnWaitTime(): number;
  47001. /**
  47002. * Sets the flag that indicates if user zooming should stop animation.
  47003. */
  47004. set zoomStopsAnimation(flag: boolean);
  47005. /**
  47006. * Gets the flag that indicates if user zooming should stop animation.
  47007. */
  47008. get zoomStopsAnimation(): boolean;
  47009. /**
  47010. * Sets the transition time when framing the mesh, in milliseconds
  47011. */
  47012. set framingTime(time: number);
  47013. /**
  47014. * Gets the transition time when framing the mesh, in milliseconds
  47015. */
  47016. get framingTime(): number;
  47017. /**
  47018. * Define if the behavior should automatically change the configured
  47019. * camera limits and sensibilities.
  47020. */
  47021. autoCorrectCameraLimitsAndSensibility: boolean;
  47022. private _onPrePointerObservableObserver;
  47023. private _onAfterCheckInputsObserver;
  47024. private _onMeshTargetChangedObserver;
  47025. private _attachedCamera;
  47026. private _isPointerDown;
  47027. private _lastInteractionTime;
  47028. /**
  47029. * Initializes the behavior.
  47030. */
  47031. init(): void;
  47032. /**
  47033. * Attaches the behavior to its arc rotate camera.
  47034. * @param camera Defines the camera to attach the behavior to
  47035. */
  47036. attach(camera: ArcRotateCamera): void;
  47037. /**
  47038. * Detaches the behavior from its current arc rotate camera.
  47039. */
  47040. detach(): void;
  47041. private _animatables;
  47042. private _betaIsAnimating;
  47043. private _betaTransition;
  47044. private _radiusTransition;
  47045. private _vectorTransition;
  47046. /**
  47047. * Targets the given mesh and updates zoom level accordingly.
  47048. * @param mesh The mesh to target.
  47049. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47050. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47051. */
  47052. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47053. /**
  47054. * Targets the given mesh with its children and updates zoom level accordingly.
  47055. * @param mesh The mesh to target.
  47056. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47057. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47058. */
  47059. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47060. /**
  47061. * Targets the given meshes with their children and updates zoom level accordingly.
  47062. * @param meshes The mesh to target.
  47063. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47064. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47065. */
  47066. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47067. /**
  47068. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47069. * @param minimumWorld Determines the smaller position of the bounding box extend
  47070. * @param maximumWorld Determines the bigger position of the bounding box extend
  47071. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47072. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47073. */
  47074. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47075. /**
  47076. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47077. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47078. * frustum width.
  47079. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47080. * to fully enclose the mesh in the viewing frustum.
  47081. */
  47082. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47083. /**
  47084. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47085. * is automatically returned to its default position (expected to be above ground plane).
  47086. */
  47087. private _maintainCameraAboveGround;
  47088. /**
  47089. * Returns the frustum slope based on the canvas ratio and camera FOV
  47090. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47091. */
  47092. private _getFrustumSlope;
  47093. /**
  47094. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47095. */
  47096. private _clearAnimationLocks;
  47097. /**
  47098. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47099. */
  47100. private _applyUserInteraction;
  47101. /**
  47102. * Stops and removes all animations that have been applied to the camera
  47103. */
  47104. stopAllAnimations(): void;
  47105. /**
  47106. * Gets a value indicating if the user is moving the camera
  47107. */
  47108. get isUserIsMoving(): boolean;
  47109. /**
  47110. * The camera can move all the way towards the mesh.
  47111. */
  47112. static IgnoreBoundsSizeMode: number;
  47113. /**
  47114. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47115. */
  47116. static FitFrustumSidesMode: number;
  47117. }
  47118. }
  47119. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47120. import { Nullable } from "babylonjs/types";
  47121. import { Camera } from "babylonjs/Cameras/camera";
  47122. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47123. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47124. /**
  47125. * Base class for Camera Pointer Inputs.
  47126. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47127. * for example usage.
  47128. */
  47129. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47130. /**
  47131. * Defines the camera the input is attached to.
  47132. */
  47133. abstract camera: Camera;
  47134. /**
  47135. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47136. */
  47137. protected _altKey: boolean;
  47138. protected _ctrlKey: boolean;
  47139. protected _metaKey: boolean;
  47140. protected _shiftKey: boolean;
  47141. /**
  47142. * Which mouse buttons were pressed at time of last mouse event.
  47143. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47144. */
  47145. protected _buttonsPressed: number;
  47146. /**
  47147. * Defines the buttons associated with the input to handle camera move.
  47148. */
  47149. buttons: number[];
  47150. /**
  47151. * Attach the input controls to a specific dom element to get the input from.
  47152. * @param element Defines the element the controls should be listened from
  47153. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47154. */
  47155. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47156. /**
  47157. * Detach the current controls from the specified dom element.
  47158. * @param element Defines the element to stop listening the inputs from
  47159. */
  47160. detachControl(element: Nullable<HTMLElement>): void;
  47161. /**
  47162. * Gets the class name of the current input.
  47163. * @returns the class name
  47164. */
  47165. getClassName(): string;
  47166. /**
  47167. * Get the friendly name associated with the input class.
  47168. * @returns the input friendly name
  47169. */
  47170. getSimpleName(): string;
  47171. /**
  47172. * Called on pointer POINTERDOUBLETAP event.
  47173. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47174. */
  47175. protected onDoubleTap(type: string): void;
  47176. /**
  47177. * Called on pointer POINTERMOVE event if only a single touch is active.
  47178. * Override this method to provide functionality.
  47179. */
  47180. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47181. /**
  47182. * Called on pointer POINTERMOVE event if multiple touches are active.
  47183. * Override this method to provide functionality.
  47184. */
  47185. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47186. /**
  47187. * Called on JS contextmenu event.
  47188. * Override this method to provide functionality.
  47189. */
  47190. protected onContextMenu(evt: PointerEvent): void;
  47191. /**
  47192. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47193. * press.
  47194. * Override this method to provide functionality.
  47195. */
  47196. protected onButtonDown(evt: PointerEvent): void;
  47197. /**
  47198. * Called each time a new POINTERUP event occurs. Ie, for each button
  47199. * release.
  47200. * Override this method to provide functionality.
  47201. */
  47202. protected onButtonUp(evt: PointerEvent): void;
  47203. /**
  47204. * Called when window becomes inactive.
  47205. * Override this method to provide functionality.
  47206. */
  47207. protected onLostFocus(): void;
  47208. private _pointerInput;
  47209. private _observer;
  47210. private _onLostFocus;
  47211. private pointA;
  47212. private pointB;
  47213. }
  47214. }
  47215. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47216. import { Nullable } from "babylonjs/types";
  47217. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47218. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47219. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47220. /**
  47221. * Manage the pointers inputs to control an arc rotate camera.
  47222. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47223. */
  47224. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47225. /**
  47226. * Defines the camera the input is attached to.
  47227. */
  47228. camera: ArcRotateCamera;
  47229. /**
  47230. * Gets the class name of the current input.
  47231. * @returns the class name
  47232. */
  47233. getClassName(): string;
  47234. /**
  47235. * Defines the buttons associated with the input to handle camera move.
  47236. */
  47237. buttons: number[];
  47238. /**
  47239. * Defines the pointer angular sensibility along the X axis or how fast is
  47240. * the camera rotating.
  47241. */
  47242. angularSensibilityX: number;
  47243. /**
  47244. * Defines the pointer angular sensibility along the Y axis or how fast is
  47245. * the camera rotating.
  47246. */
  47247. angularSensibilityY: number;
  47248. /**
  47249. * Defines the pointer pinch precision or how fast is the camera zooming.
  47250. */
  47251. pinchPrecision: number;
  47252. /**
  47253. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47254. * from 0.
  47255. * It defines the percentage of current camera.radius to use as delta when
  47256. * pinch zoom is used.
  47257. */
  47258. pinchDeltaPercentage: number;
  47259. /**
  47260. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47261. * that any object in the plane at the camera's target point will scale
  47262. * perfectly with finger motion.
  47263. * Overrides pinchDeltaPercentage and pinchPrecision.
  47264. */
  47265. useNaturalPinchZoom: boolean;
  47266. /**
  47267. * Defines the pointer panning sensibility or how fast is the camera moving.
  47268. */
  47269. panningSensibility: number;
  47270. /**
  47271. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  47272. */
  47273. multiTouchPanning: boolean;
  47274. /**
  47275. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  47276. * zoom (pinch) through multitouch.
  47277. */
  47278. multiTouchPanAndZoom: boolean;
  47279. /**
  47280. * Revers pinch action direction.
  47281. */
  47282. pinchInwards: boolean;
  47283. private _isPanClick;
  47284. private _twoFingerActivityCount;
  47285. private _isPinching;
  47286. /**
  47287. * Called on pointer POINTERMOVE event if only a single touch is active.
  47288. */
  47289. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47290. /**
  47291. * Called on pointer POINTERDOUBLETAP event.
  47292. */
  47293. protected onDoubleTap(type: string): void;
  47294. /**
  47295. * Called on pointer POINTERMOVE event if multiple touches are active.
  47296. */
  47297. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47298. /**
  47299. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47300. * press.
  47301. */
  47302. protected onButtonDown(evt: PointerEvent): void;
  47303. /**
  47304. * Called each time a new POINTERUP event occurs. Ie, for each button
  47305. * release.
  47306. */
  47307. protected onButtonUp(evt: PointerEvent): void;
  47308. /**
  47309. * Called when window becomes inactive.
  47310. */
  47311. protected onLostFocus(): void;
  47312. }
  47313. }
  47314. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  47315. import { Nullable } from "babylonjs/types";
  47316. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47317. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47318. /**
  47319. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  47320. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47321. */
  47322. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  47323. /**
  47324. * Defines the camera the input is attached to.
  47325. */
  47326. camera: ArcRotateCamera;
  47327. /**
  47328. * Defines the list of key codes associated with the up action (increase alpha)
  47329. */
  47330. keysUp: number[];
  47331. /**
  47332. * Defines the list of key codes associated with the down action (decrease alpha)
  47333. */
  47334. keysDown: number[];
  47335. /**
  47336. * Defines the list of key codes associated with the left action (increase beta)
  47337. */
  47338. keysLeft: number[];
  47339. /**
  47340. * Defines the list of key codes associated with the right action (decrease beta)
  47341. */
  47342. keysRight: number[];
  47343. /**
  47344. * Defines the list of key codes associated with the reset action.
  47345. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  47346. */
  47347. keysReset: number[];
  47348. /**
  47349. * Defines the panning sensibility of the inputs.
  47350. * (How fast is the camera panning)
  47351. */
  47352. panningSensibility: number;
  47353. /**
  47354. * Defines the zooming sensibility of the inputs.
  47355. * (How fast is the camera zooming)
  47356. */
  47357. zoomingSensibility: number;
  47358. /**
  47359. * Defines whether maintaining the alt key down switch the movement mode from
  47360. * orientation to zoom.
  47361. */
  47362. useAltToZoom: boolean;
  47363. /**
  47364. * Rotation speed of the camera
  47365. */
  47366. angularSpeed: number;
  47367. private _keys;
  47368. private _ctrlPressed;
  47369. private _altPressed;
  47370. private _onCanvasBlurObserver;
  47371. private _onKeyboardObserver;
  47372. private _engine;
  47373. private _scene;
  47374. /**
  47375. * Attach the input controls to a specific dom element to get the input from.
  47376. * @param element Defines the element the controls should be listened from
  47377. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47378. */
  47379. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47380. /**
  47381. * Detach the current controls from the specified dom element.
  47382. * @param element Defines the element to stop listening the inputs from
  47383. */
  47384. detachControl(element: Nullable<HTMLElement>): void;
  47385. /**
  47386. * Update the current camera state depending on the inputs that have been used this frame.
  47387. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47388. */
  47389. checkInputs(): void;
  47390. /**
  47391. * Gets the class name of the current intput.
  47392. * @returns the class name
  47393. */
  47394. getClassName(): string;
  47395. /**
  47396. * Get the friendly name associated with the input class.
  47397. * @returns the input friendly name
  47398. */
  47399. getSimpleName(): string;
  47400. }
  47401. }
  47402. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  47403. import { Nullable } from "babylonjs/types";
  47404. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47405. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47406. /**
  47407. * Manage the mouse wheel inputs to control an arc rotate camera.
  47408. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47409. */
  47410. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  47411. /**
  47412. * Defines the camera the input is attached to.
  47413. */
  47414. camera: ArcRotateCamera;
  47415. /**
  47416. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47417. */
  47418. wheelPrecision: number;
  47419. /**
  47420. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47421. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47422. */
  47423. wheelDeltaPercentage: number;
  47424. private _wheel;
  47425. private _observer;
  47426. private computeDeltaFromMouseWheelLegacyEvent;
  47427. /**
  47428. * Attach the input controls to a specific dom element to get the input from.
  47429. * @param element Defines the element the controls should be listened from
  47430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47431. */
  47432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47433. /**
  47434. * Detach the current controls from the specified dom element.
  47435. * @param element Defines the element to stop listening the inputs from
  47436. */
  47437. detachControl(element: Nullable<HTMLElement>): void;
  47438. /**
  47439. * Gets the class name of the current intput.
  47440. * @returns the class name
  47441. */
  47442. getClassName(): string;
  47443. /**
  47444. * Get the friendly name associated with the input class.
  47445. * @returns the input friendly name
  47446. */
  47447. getSimpleName(): string;
  47448. }
  47449. }
  47450. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47451. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47452. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  47453. /**
  47454. * Default Inputs manager for the ArcRotateCamera.
  47455. * It groups all the default supported inputs for ease of use.
  47456. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47457. */
  47458. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  47459. /**
  47460. * Instantiates a new ArcRotateCameraInputsManager.
  47461. * @param camera Defines the camera the inputs belong to
  47462. */
  47463. constructor(camera: ArcRotateCamera);
  47464. /**
  47465. * Add mouse wheel input support to the input manager.
  47466. * @returns the current input manager
  47467. */
  47468. addMouseWheel(): ArcRotateCameraInputsManager;
  47469. /**
  47470. * Add pointers input support to the input manager.
  47471. * @returns the current input manager
  47472. */
  47473. addPointers(): ArcRotateCameraInputsManager;
  47474. /**
  47475. * Add keyboard input support to the input manager.
  47476. * @returns the current input manager
  47477. */
  47478. addKeyboard(): ArcRotateCameraInputsManager;
  47479. }
  47480. }
  47481. declare module "babylonjs/Cameras/arcRotateCamera" {
  47482. import { Observable } from "babylonjs/Misc/observable";
  47483. import { Nullable } from "babylonjs/types";
  47484. import { Scene } from "babylonjs/scene";
  47485. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47487. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  47488. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  47489. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  47490. import { Camera } from "babylonjs/Cameras/camera";
  47491. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  47492. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47493. import { Collider } from "babylonjs/Collisions/collider";
  47494. /**
  47495. * This represents an orbital type of camera.
  47496. *
  47497. * 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.
  47498. * 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.
  47499. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  47500. */
  47501. export class ArcRotateCamera extends TargetCamera {
  47502. /**
  47503. * Defines the rotation angle of the camera along the longitudinal axis.
  47504. */
  47505. alpha: number;
  47506. /**
  47507. * Defines the rotation angle of the camera along the latitudinal axis.
  47508. */
  47509. beta: number;
  47510. /**
  47511. * Defines the radius of the camera from it s target point.
  47512. */
  47513. radius: number;
  47514. protected _target: Vector3;
  47515. protected _targetHost: Nullable<AbstractMesh>;
  47516. /**
  47517. * Defines the target point of the camera.
  47518. * The camera looks towards it form the radius distance.
  47519. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  47520. */
  47521. get target(): Vector3;
  47522. set target(value: Vector3);
  47523. /**
  47524. * Define the current local position of the camera in the scene
  47525. */
  47526. get position(): Vector3;
  47527. set position(newPosition: Vector3);
  47528. protected _upToYMatrix: Matrix;
  47529. protected _YToUpMatrix: Matrix;
  47530. /**
  47531. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  47532. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  47533. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  47534. */
  47535. set upVector(vec: Vector3);
  47536. get upVector(): Vector3;
  47537. /**
  47538. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  47539. */
  47540. setMatUp(): void;
  47541. /**
  47542. * Current inertia value on the longitudinal axis.
  47543. * The bigger this number the longer it will take for the camera to stop.
  47544. */
  47545. inertialAlphaOffset: number;
  47546. /**
  47547. * Current inertia value on the latitudinal axis.
  47548. * The bigger this number the longer it will take for the camera to stop.
  47549. */
  47550. inertialBetaOffset: number;
  47551. /**
  47552. * Current inertia value on the radius axis.
  47553. * The bigger this number the longer it will take for the camera to stop.
  47554. */
  47555. inertialRadiusOffset: number;
  47556. /**
  47557. * Minimum allowed angle on the longitudinal axis.
  47558. * This can help limiting how the Camera is able to move in the scene.
  47559. */
  47560. lowerAlphaLimit: Nullable<number>;
  47561. /**
  47562. * Maximum allowed angle on the longitudinal axis.
  47563. * This can help limiting how the Camera is able to move in the scene.
  47564. */
  47565. upperAlphaLimit: Nullable<number>;
  47566. /**
  47567. * Minimum allowed angle on the latitudinal axis.
  47568. * This can help limiting how the Camera is able to move in the scene.
  47569. */
  47570. lowerBetaLimit: number;
  47571. /**
  47572. * Maximum allowed angle on the latitudinal axis.
  47573. * This can help limiting how the Camera is able to move in the scene.
  47574. */
  47575. upperBetaLimit: number;
  47576. /**
  47577. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  47578. * This can help limiting how the Camera is able to move in the scene.
  47579. */
  47580. lowerRadiusLimit: Nullable<number>;
  47581. /**
  47582. * Maximum allowed distance of the camera to the target (The camera can not get further).
  47583. * This can help limiting how the Camera is able to move in the scene.
  47584. */
  47585. upperRadiusLimit: Nullable<number>;
  47586. /**
  47587. * Defines the current inertia value used during panning of the camera along the X axis.
  47588. */
  47589. inertialPanningX: number;
  47590. /**
  47591. * Defines the current inertia value used during panning of the camera along the Y axis.
  47592. */
  47593. inertialPanningY: number;
  47594. /**
  47595. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  47596. * Basically if your fingers moves away from more than this distance you will be considered
  47597. * in pinch mode.
  47598. */
  47599. pinchToPanMaxDistance: number;
  47600. /**
  47601. * Defines the maximum distance the camera can pan.
  47602. * This could help keeping the cammera always in your scene.
  47603. */
  47604. panningDistanceLimit: Nullable<number>;
  47605. /**
  47606. * Defines the target of the camera before paning.
  47607. */
  47608. panningOriginTarget: Vector3;
  47609. /**
  47610. * Defines the value of the inertia used during panning.
  47611. * 0 would mean stop inertia and one would mean no decelleration at all.
  47612. */
  47613. panningInertia: number;
  47614. /**
  47615. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  47616. */
  47617. get angularSensibilityX(): number;
  47618. set angularSensibilityX(value: number);
  47619. /**
  47620. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  47621. */
  47622. get angularSensibilityY(): number;
  47623. set angularSensibilityY(value: number);
  47624. /**
  47625. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  47626. */
  47627. get pinchPrecision(): number;
  47628. set pinchPrecision(value: number);
  47629. /**
  47630. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  47631. * It will be used instead of pinchDeltaPrecision if different from 0.
  47632. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47633. */
  47634. get pinchDeltaPercentage(): number;
  47635. set pinchDeltaPercentage(value: number);
  47636. /**
  47637. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  47638. * and pinch delta percentage.
  47639. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47640. * that any object in the plane at the camera's target point will scale
  47641. * perfectly with finger motion.
  47642. */
  47643. get useNaturalPinchZoom(): boolean;
  47644. set useNaturalPinchZoom(value: boolean);
  47645. /**
  47646. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  47647. */
  47648. get panningSensibility(): number;
  47649. set panningSensibility(value: number);
  47650. /**
  47651. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  47652. */
  47653. get keysUp(): number[];
  47654. set keysUp(value: number[]);
  47655. /**
  47656. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  47657. */
  47658. get keysDown(): number[];
  47659. set keysDown(value: number[]);
  47660. /**
  47661. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  47662. */
  47663. get keysLeft(): number[];
  47664. set keysLeft(value: number[]);
  47665. /**
  47666. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  47667. */
  47668. get keysRight(): number[];
  47669. set keysRight(value: number[]);
  47670. /**
  47671. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47672. */
  47673. get wheelPrecision(): number;
  47674. set wheelPrecision(value: number);
  47675. /**
  47676. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  47677. * It will be used instead of pinchDeltaPrecision if different from 0.
  47678. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47679. */
  47680. get wheelDeltaPercentage(): number;
  47681. set wheelDeltaPercentage(value: number);
  47682. /**
  47683. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  47684. */
  47685. zoomOnFactor: number;
  47686. /**
  47687. * Defines a screen offset for the camera position.
  47688. */
  47689. targetScreenOffset: Vector2;
  47690. /**
  47691. * Allows the camera to be completely reversed.
  47692. * If false the camera can not arrive upside down.
  47693. */
  47694. allowUpsideDown: boolean;
  47695. /**
  47696. * Define if double tap/click is used to restore the previously saved state of the camera.
  47697. */
  47698. useInputToRestoreState: boolean;
  47699. /** @hidden */
  47700. _viewMatrix: Matrix;
  47701. /** @hidden */
  47702. _useCtrlForPanning: boolean;
  47703. /** @hidden */
  47704. _panningMouseButton: number;
  47705. /**
  47706. * Defines the input associated to the camera.
  47707. */
  47708. inputs: ArcRotateCameraInputsManager;
  47709. /** @hidden */
  47710. _reset: () => void;
  47711. /**
  47712. * Defines the allowed panning axis.
  47713. */
  47714. panningAxis: Vector3;
  47715. protected _localDirection: Vector3;
  47716. protected _transformedDirection: Vector3;
  47717. private _bouncingBehavior;
  47718. /**
  47719. * Gets the bouncing behavior of the camera if it has been enabled.
  47720. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47721. */
  47722. get bouncingBehavior(): Nullable<BouncingBehavior>;
  47723. /**
  47724. * Defines if the bouncing behavior of the camera is enabled on the camera.
  47725. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47726. */
  47727. get useBouncingBehavior(): boolean;
  47728. set useBouncingBehavior(value: boolean);
  47729. private _framingBehavior;
  47730. /**
  47731. * Gets the framing behavior of the camera if it has been enabled.
  47732. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47733. */
  47734. get framingBehavior(): Nullable<FramingBehavior>;
  47735. /**
  47736. * Defines if the framing behavior of the camera is enabled on the camera.
  47737. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47738. */
  47739. get useFramingBehavior(): boolean;
  47740. set useFramingBehavior(value: boolean);
  47741. private _autoRotationBehavior;
  47742. /**
  47743. * Gets the auto rotation behavior of the camera if it has been enabled.
  47744. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47745. */
  47746. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  47747. /**
  47748. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  47749. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47750. */
  47751. get useAutoRotationBehavior(): boolean;
  47752. set useAutoRotationBehavior(value: boolean);
  47753. /**
  47754. * Observable triggered when the mesh target has been changed on the camera.
  47755. */
  47756. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  47757. /**
  47758. * Event raised when the camera is colliding with a mesh.
  47759. */
  47760. onCollide: (collidedMesh: AbstractMesh) => void;
  47761. /**
  47762. * Defines whether the camera should check collision with the objects oh the scene.
  47763. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  47764. */
  47765. checkCollisions: boolean;
  47766. /**
  47767. * Defines the collision radius of the camera.
  47768. * This simulates a sphere around the camera.
  47769. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47770. */
  47771. collisionRadius: Vector3;
  47772. protected _collider: Collider;
  47773. protected _previousPosition: Vector3;
  47774. protected _collisionVelocity: Vector3;
  47775. protected _newPosition: Vector3;
  47776. protected _previousAlpha: number;
  47777. protected _previousBeta: number;
  47778. protected _previousRadius: number;
  47779. protected _collisionTriggered: boolean;
  47780. protected _targetBoundingCenter: Nullable<Vector3>;
  47781. private _computationVector;
  47782. /**
  47783. * Instantiates a new ArcRotateCamera in a given scene
  47784. * @param name Defines the name of the camera
  47785. * @param alpha Defines the camera rotation along the logitudinal axis
  47786. * @param beta Defines the camera rotation along the latitudinal axis
  47787. * @param radius Defines the camera distance from its target
  47788. * @param target Defines the camera target
  47789. * @param scene Defines the scene the camera belongs to
  47790. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  47791. */
  47792. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47793. /** @hidden */
  47794. _initCache(): void;
  47795. /** @hidden */
  47796. _updateCache(ignoreParentClass?: boolean): void;
  47797. protected _getTargetPosition(): Vector3;
  47798. private _storedAlpha;
  47799. private _storedBeta;
  47800. private _storedRadius;
  47801. private _storedTarget;
  47802. private _storedTargetScreenOffset;
  47803. /**
  47804. * Stores the current state of the camera (alpha, beta, radius and target)
  47805. * @returns the camera itself
  47806. */
  47807. storeState(): Camera;
  47808. /**
  47809. * @hidden
  47810. * Restored camera state. You must call storeState() first
  47811. */
  47812. _restoreStateValues(): boolean;
  47813. /** @hidden */
  47814. _isSynchronizedViewMatrix(): boolean;
  47815. /**
  47816. * Attached controls to the current camera.
  47817. * @param element Defines the element the controls should be listened from
  47818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47819. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  47820. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  47821. */
  47822. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  47823. /**
  47824. * Detach the current controls from the camera.
  47825. * The camera will stop reacting to inputs.
  47826. * @param element Defines the element to stop listening the inputs from
  47827. */
  47828. detachControl(element: HTMLElement): void;
  47829. /** @hidden */
  47830. _checkInputs(): void;
  47831. protected _checkLimits(): void;
  47832. /**
  47833. * Rebuilds angles (alpha, beta) and radius from the give position and target
  47834. */
  47835. rebuildAnglesAndRadius(): void;
  47836. /**
  47837. * Use a position to define the current camera related information like alpha, beta and radius
  47838. * @param position Defines the position to set the camera at
  47839. */
  47840. setPosition(position: Vector3): void;
  47841. /**
  47842. * Defines the target the camera should look at.
  47843. * This will automatically adapt alpha beta and radius to fit within the new target.
  47844. * @param target Defines the new target as a Vector or a mesh
  47845. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  47846. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  47847. */
  47848. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  47849. /** @hidden */
  47850. _getViewMatrix(): Matrix;
  47851. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  47852. /**
  47853. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  47854. * @param meshes Defines the mesh to zoom on
  47855. * @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)
  47856. */
  47857. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  47858. /**
  47859. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  47860. * The target will be changed but the radius
  47861. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  47862. * @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)
  47863. */
  47864. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  47865. min: Vector3;
  47866. max: Vector3;
  47867. distance: number;
  47868. }, doNotUpdateMaxZ?: boolean): void;
  47869. /**
  47870. * @override
  47871. * Override Camera.createRigCamera
  47872. */
  47873. createRigCamera(name: string, cameraIndex: number): Camera;
  47874. /**
  47875. * @hidden
  47876. * @override
  47877. * Override Camera._updateRigCameras
  47878. */
  47879. _updateRigCameras(): void;
  47880. /**
  47881. * Destroy the camera and release the current resources hold by it.
  47882. */
  47883. dispose(): void;
  47884. /**
  47885. * Gets the current object class name.
  47886. * @return the class name
  47887. */
  47888. getClassName(): string;
  47889. }
  47890. }
  47891. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  47892. import { Behavior } from "babylonjs/Behaviors/behavior";
  47893. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47894. /**
  47895. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  47896. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47897. */
  47898. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  47899. /**
  47900. * Gets the name of the behavior.
  47901. */
  47902. get name(): string;
  47903. private _zoomStopsAnimation;
  47904. private _idleRotationSpeed;
  47905. private _idleRotationWaitTime;
  47906. private _idleRotationSpinupTime;
  47907. /**
  47908. * Sets the flag that indicates if user zooming should stop animation.
  47909. */
  47910. set zoomStopsAnimation(flag: boolean);
  47911. /**
  47912. * Gets the flag that indicates if user zooming should stop animation.
  47913. */
  47914. get zoomStopsAnimation(): boolean;
  47915. /**
  47916. * Sets the default speed at which the camera rotates around the model.
  47917. */
  47918. set idleRotationSpeed(speed: number);
  47919. /**
  47920. * Gets the default speed at which the camera rotates around the model.
  47921. */
  47922. get idleRotationSpeed(): number;
  47923. /**
  47924. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  47925. */
  47926. set idleRotationWaitTime(time: number);
  47927. /**
  47928. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  47929. */
  47930. get idleRotationWaitTime(): number;
  47931. /**
  47932. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  47933. */
  47934. set idleRotationSpinupTime(time: number);
  47935. /**
  47936. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  47937. */
  47938. get idleRotationSpinupTime(): number;
  47939. /**
  47940. * Gets a value indicating if the camera is currently rotating because of this behavior
  47941. */
  47942. get rotationInProgress(): boolean;
  47943. private _onPrePointerObservableObserver;
  47944. private _onAfterCheckInputsObserver;
  47945. private _attachedCamera;
  47946. private _isPointerDown;
  47947. private _lastFrameTime;
  47948. private _lastInteractionTime;
  47949. private _cameraRotationSpeed;
  47950. /**
  47951. * Initializes the behavior.
  47952. */
  47953. init(): void;
  47954. /**
  47955. * Attaches the behavior to its arc rotate camera.
  47956. * @param camera Defines the camera to attach the behavior to
  47957. */
  47958. attach(camera: ArcRotateCamera): void;
  47959. /**
  47960. * Detaches the behavior from its current arc rotate camera.
  47961. */
  47962. detach(): void;
  47963. /**
  47964. * Returns true if user is scrolling.
  47965. * @return true if user is scrolling.
  47966. */
  47967. private _userIsZooming;
  47968. private _lastFrameRadius;
  47969. private _shouldAnimationStopForInteraction;
  47970. /**
  47971. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47972. */
  47973. private _applyUserInteraction;
  47974. private _userIsMoving;
  47975. }
  47976. }
  47977. declare module "babylonjs/Behaviors/Cameras/index" {
  47978. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  47979. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  47980. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  47981. }
  47982. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  47983. import { Mesh } from "babylonjs/Meshes/mesh";
  47984. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47985. import { Behavior } from "babylonjs/Behaviors/behavior";
  47986. /**
  47987. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  47988. */
  47989. export class AttachToBoxBehavior implements Behavior<Mesh> {
  47990. private ui;
  47991. /**
  47992. * The name of the behavior
  47993. */
  47994. name: string;
  47995. /**
  47996. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  47997. */
  47998. distanceAwayFromFace: number;
  47999. /**
  48000. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48001. */
  48002. distanceAwayFromBottomOfFace: number;
  48003. private _faceVectors;
  48004. private _target;
  48005. private _scene;
  48006. private _onRenderObserver;
  48007. private _tmpMatrix;
  48008. private _tmpVector;
  48009. /**
  48010. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48011. * @param ui The transform node that should be attched to the mesh
  48012. */
  48013. constructor(ui: TransformNode);
  48014. /**
  48015. * Initializes the behavior
  48016. */
  48017. init(): void;
  48018. private _closestFace;
  48019. private _zeroVector;
  48020. private _lookAtTmpMatrix;
  48021. private _lookAtToRef;
  48022. /**
  48023. * Attaches the AttachToBoxBehavior to the passed in mesh
  48024. * @param target The mesh that the specified node will be attached to
  48025. */
  48026. attach(target: Mesh): void;
  48027. /**
  48028. * Detaches the behavior from the mesh
  48029. */
  48030. detach(): void;
  48031. }
  48032. }
  48033. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48034. import { Behavior } from "babylonjs/Behaviors/behavior";
  48035. import { Mesh } from "babylonjs/Meshes/mesh";
  48036. /**
  48037. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48038. */
  48039. export class FadeInOutBehavior implements Behavior<Mesh> {
  48040. /**
  48041. * Time in milliseconds to delay before fading in (Default: 0)
  48042. */
  48043. delay: number;
  48044. /**
  48045. * Time in milliseconds for the mesh to fade in (Default: 300)
  48046. */
  48047. fadeInTime: number;
  48048. private _millisecondsPerFrame;
  48049. private _hovered;
  48050. private _hoverValue;
  48051. private _ownerNode;
  48052. /**
  48053. * Instatiates the FadeInOutBehavior
  48054. */
  48055. constructor();
  48056. /**
  48057. * The name of the behavior
  48058. */
  48059. get name(): string;
  48060. /**
  48061. * Initializes the behavior
  48062. */
  48063. init(): void;
  48064. /**
  48065. * Attaches the fade behavior on the passed in mesh
  48066. * @param ownerNode The mesh that will be faded in/out once attached
  48067. */
  48068. attach(ownerNode: Mesh): void;
  48069. /**
  48070. * Detaches the behavior from the mesh
  48071. */
  48072. detach(): void;
  48073. /**
  48074. * Triggers the mesh to begin fading in or out
  48075. * @param value if the object should fade in or out (true to fade in)
  48076. */
  48077. fadeIn(value: boolean): void;
  48078. private _update;
  48079. private _setAllVisibility;
  48080. }
  48081. }
  48082. declare module "babylonjs/Misc/pivotTools" {
  48083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48084. /**
  48085. * Class containing a set of static utilities functions for managing Pivots
  48086. * @hidden
  48087. */
  48088. export class PivotTools {
  48089. private static _PivotCached;
  48090. private static _OldPivotPoint;
  48091. private static _PivotTranslation;
  48092. private static _PivotTmpVector;
  48093. private static _PivotPostMultiplyPivotMatrix;
  48094. /** @hidden */
  48095. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48096. /** @hidden */
  48097. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48098. }
  48099. }
  48100. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48101. import { Scene } from "babylonjs/scene";
  48102. import { Vector4 } from "babylonjs/Maths/math.vector";
  48103. import { Mesh } from "babylonjs/Meshes/mesh";
  48104. import { Nullable } from "babylonjs/types";
  48105. import { Plane } from "babylonjs/Maths/math.plane";
  48106. /**
  48107. * Class containing static functions to help procedurally build meshes
  48108. */
  48109. export class PlaneBuilder {
  48110. /**
  48111. * Creates a plane mesh
  48112. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48113. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48114. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48118. * @param name defines the name of the mesh
  48119. * @param options defines the options used to create the mesh
  48120. * @param scene defines the hosting scene
  48121. * @returns the plane mesh
  48122. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48123. */
  48124. static CreatePlane(name: string, options: {
  48125. size?: number;
  48126. width?: number;
  48127. height?: number;
  48128. sideOrientation?: number;
  48129. frontUVs?: Vector4;
  48130. backUVs?: Vector4;
  48131. updatable?: boolean;
  48132. sourcePlane?: Plane;
  48133. }, scene?: Nullable<Scene>): Mesh;
  48134. }
  48135. }
  48136. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48137. import { Behavior } from "babylonjs/Behaviors/behavior";
  48138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48139. import { Observable } from "babylonjs/Misc/observable";
  48140. import { Vector3 } from "babylonjs/Maths/math.vector";
  48141. import { Ray } from "babylonjs/Culling/ray";
  48142. import "babylonjs/Meshes/Builders/planeBuilder";
  48143. /**
  48144. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48145. */
  48146. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48147. private static _AnyMouseID;
  48148. /**
  48149. * Abstract mesh the behavior is set on
  48150. */
  48151. attachedNode: AbstractMesh;
  48152. private _dragPlane;
  48153. private _scene;
  48154. private _pointerObserver;
  48155. private _beforeRenderObserver;
  48156. private static _planeScene;
  48157. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48158. /**
  48159. * 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)
  48160. */
  48161. maxDragAngle: number;
  48162. /**
  48163. * @hidden
  48164. */
  48165. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48166. /**
  48167. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48168. */
  48169. currentDraggingPointerID: number;
  48170. /**
  48171. * The last position where the pointer hit the drag plane in world space
  48172. */
  48173. lastDragPosition: Vector3;
  48174. /**
  48175. * If the behavior is currently in a dragging state
  48176. */
  48177. dragging: boolean;
  48178. /**
  48179. * 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)
  48180. */
  48181. dragDeltaRatio: number;
  48182. /**
  48183. * If the drag plane orientation should be updated during the dragging (Default: true)
  48184. */
  48185. updateDragPlane: boolean;
  48186. private _debugMode;
  48187. private _moving;
  48188. /**
  48189. * Fires each time the attached mesh is dragged with the pointer
  48190. * * delta between last drag position and current drag position in world space
  48191. * * dragDistance along the drag axis
  48192. * * dragPlaneNormal normal of the current drag plane used during the drag
  48193. * * dragPlanePoint in world space where the drag intersects the drag plane
  48194. */
  48195. onDragObservable: Observable<{
  48196. delta: Vector3;
  48197. dragPlanePoint: Vector3;
  48198. dragPlaneNormal: Vector3;
  48199. dragDistance: number;
  48200. pointerId: number;
  48201. }>;
  48202. /**
  48203. * Fires each time a drag begins (eg. mouse down on mesh)
  48204. */
  48205. onDragStartObservable: Observable<{
  48206. dragPlanePoint: Vector3;
  48207. pointerId: number;
  48208. }>;
  48209. /**
  48210. * Fires each time a drag ends (eg. mouse release after drag)
  48211. */
  48212. onDragEndObservable: Observable<{
  48213. dragPlanePoint: Vector3;
  48214. pointerId: number;
  48215. }>;
  48216. /**
  48217. * If the attached mesh should be moved when dragged
  48218. */
  48219. moveAttached: boolean;
  48220. /**
  48221. * If the drag behavior will react to drag events (Default: true)
  48222. */
  48223. enabled: boolean;
  48224. /**
  48225. * If pointer events should start and release the drag (Default: true)
  48226. */
  48227. startAndReleaseDragOnPointerEvents: boolean;
  48228. /**
  48229. * If camera controls should be detached during the drag
  48230. */
  48231. detachCameraControls: boolean;
  48232. /**
  48233. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48234. */
  48235. useObjectOrientationForDragging: boolean;
  48236. private _options;
  48237. /**
  48238. * Gets the options used by the behavior
  48239. */
  48240. get options(): {
  48241. dragAxis?: Vector3;
  48242. dragPlaneNormal?: Vector3;
  48243. };
  48244. /**
  48245. * Sets the options used by the behavior
  48246. */
  48247. set options(options: {
  48248. dragAxis?: Vector3;
  48249. dragPlaneNormal?: Vector3;
  48250. });
  48251. /**
  48252. * Creates a pointer drag behavior that can be attached to a mesh
  48253. * @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)
  48254. */
  48255. constructor(options?: {
  48256. dragAxis?: Vector3;
  48257. dragPlaneNormal?: Vector3;
  48258. });
  48259. /**
  48260. * Predicate to determine if it is valid to move the object to a new position when it is moved
  48261. */
  48262. validateDrag: (targetPosition: Vector3) => boolean;
  48263. /**
  48264. * The name of the behavior
  48265. */
  48266. get name(): string;
  48267. /**
  48268. * Initializes the behavior
  48269. */
  48270. init(): void;
  48271. private _tmpVector;
  48272. private _alternatePickedPoint;
  48273. private _worldDragAxis;
  48274. private _targetPosition;
  48275. private _attachedElement;
  48276. /**
  48277. * Attaches the drag behavior the passed in mesh
  48278. * @param ownerNode The mesh that will be dragged around once attached
  48279. * @param predicate Predicate to use for pick filtering
  48280. */
  48281. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  48282. /**
  48283. * Force relase the drag action by code.
  48284. */
  48285. releaseDrag(): void;
  48286. private _startDragRay;
  48287. private _lastPointerRay;
  48288. /**
  48289. * Simulates the start of a pointer drag event on the behavior
  48290. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  48291. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  48292. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  48293. */
  48294. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48295. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48296. private _dragDelta;
  48297. protected _moveDrag(ray: Ray): void;
  48298. private _pickWithRayOnDragPlane;
  48299. private _pointA;
  48300. private _pointC;
  48301. private _localAxis;
  48302. private _lookAt;
  48303. private _updateDragPlanePosition;
  48304. /**
  48305. * Detaches the behavior from the mesh
  48306. */
  48307. detach(): void;
  48308. }
  48309. }
  48310. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  48311. import { Mesh } from "babylonjs/Meshes/mesh";
  48312. import { Behavior } from "babylonjs/Behaviors/behavior";
  48313. /**
  48314. * A behavior that when attached to a mesh will allow the mesh to be scaled
  48315. */
  48316. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  48317. private _dragBehaviorA;
  48318. private _dragBehaviorB;
  48319. private _startDistance;
  48320. private _initialScale;
  48321. private _targetScale;
  48322. private _ownerNode;
  48323. private _sceneRenderObserver;
  48324. /**
  48325. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  48326. */
  48327. constructor();
  48328. /**
  48329. * The name of the behavior
  48330. */
  48331. get name(): string;
  48332. /**
  48333. * Initializes the behavior
  48334. */
  48335. init(): void;
  48336. private _getCurrentDistance;
  48337. /**
  48338. * Attaches the scale behavior the passed in mesh
  48339. * @param ownerNode The mesh that will be scaled around once attached
  48340. */
  48341. attach(ownerNode: Mesh): void;
  48342. /**
  48343. * Detaches the behavior from the mesh
  48344. */
  48345. detach(): void;
  48346. }
  48347. }
  48348. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  48349. import { Behavior } from "babylonjs/Behaviors/behavior";
  48350. import { Mesh } from "babylonjs/Meshes/mesh";
  48351. import { Observable } from "babylonjs/Misc/observable";
  48352. /**
  48353. * 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
  48354. */
  48355. export class SixDofDragBehavior implements Behavior<Mesh> {
  48356. private static _virtualScene;
  48357. private _ownerNode;
  48358. private _sceneRenderObserver;
  48359. private _scene;
  48360. private _targetPosition;
  48361. private _virtualOriginMesh;
  48362. private _virtualDragMesh;
  48363. private _pointerObserver;
  48364. private _moving;
  48365. private _startingOrientation;
  48366. private _attachedElement;
  48367. /**
  48368. * 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)
  48369. */
  48370. private zDragFactor;
  48371. /**
  48372. * If the object should rotate to face the drag origin
  48373. */
  48374. rotateDraggedObject: boolean;
  48375. /**
  48376. * If the behavior is currently in a dragging state
  48377. */
  48378. dragging: boolean;
  48379. /**
  48380. * 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)
  48381. */
  48382. dragDeltaRatio: number;
  48383. /**
  48384. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48385. */
  48386. currentDraggingPointerID: number;
  48387. /**
  48388. * If camera controls should be detached during the drag
  48389. */
  48390. detachCameraControls: boolean;
  48391. /**
  48392. * Fires each time a drag starts
  48393. */
  48394. onDragStartObservable: Observable<{}>;
  48395. /**
  48396. * Fires each time a drag ends (eg. mouse release after drag)
  48397. */
  48398. onDragEndObservable: Observable<{}>;
  48399. /**
  48400. * 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
  48401. */
  48402. constructor();
  48403. /**
  48404. * The name of the behavior
  48405. */
  48406. get name(): string;
  48407. /**
  48408. * Initializes the behavior
  48409. */
  48410. init(): void;
  48411. /**
  48412. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  48413. */
  48414. private get _pointerCamera();
  48415. /**
  48416. * Attaches the scale behavior the passed in mesh
  48417. * @param ownerNode The mesh that will be scaled around once attached
  48418. */
  48419. attach(ownerNode: Mesh): void;
  48420. /**
  48421. * Detaches the behavior from the mesh
  48422. */
  48423. detach(): void;
  48424. }
  48425. }
  48426. declare module "babylonjs/Behaviors/Meshes/index" {
  48427. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  48428. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  48429. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  48430. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48431. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48432. }
  48433. declare module "babylonjs/Behaviors/index" {
  48434. export * from "babylonjs/Behaviors/behavior";
  48435. export * from "babylonjs/Behaviors/Cameras/index";
  48436. export * from "babylonjs/Behaviors/Meshes/index";
  48437. }
  48438. declare module "babylonjs/Bones/boneIKController" {
  48439. import { Bone } from "babylonjs/Bones/bone";
  48440. import { Vector3 } from "babylonjs/Maths/math.vector";
  48441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48442. import { Nullable } from "babylonjs/types";
  48443. /**
  48444. * Class used to apply inverse kinematics to bones
  48445. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  48446. */
  48447. export class BoneIKController {
  48448. private static _tmpVecs;
  48449. private static _tmpQuat;
  48450. private static _tmpMats;
  48451. /**
  48452. * Gets or sets the target mesh
  48453. */
  48454. targetMesh: AbstractMesh;
  48455. /** Gets or sets the mesh used as pole */
  48456. poleTargetMesh: AbstractMesh;
  48457. /**
  48458. * Gets or sets the bone used as pole
  48459. */
  48460. poleTargetBone: Nullable<Bone>;
  48461. /**
  48462. * Gets or sets the target position
  48463. */
  48464. targetPosition: Vector3;
  48465. /**
  48466. * Gets or sets the pole target position
  48467. */
  48468. poleTargetPosition: Vector3;
  48469. /**
  48470. * Gets or sets the pole target local offset
  48471. */
  48472. poleTargetLocalOffset: Vector3;
  48473. /**
  48474. * Gets or sets the pole angle
  48475. */
  48476. poleAngle: number;
  48477. /**
  48478. * Gets or sets the mesh associated with the controller
  48479. */
  48480. mesh: AbstractMesh;
  48481. /**
  48482. * 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)
  48483. */
  48484. slerpAmount: number;
  48485. private _bone1Quat;
  48486. private _bone1Mat;
  48487. private _bone2Ang;
  48488. private _bone1;
  48489. private _bone2;
  48490. private _bone1Length;
  48491. private _bone2Length;
  48492. private _maxAngle;
  48493. private _maxReach;
  48494. private _rightHandedSystem;
  48495. private _bendAxis;
  48496. private _slerping;
  48497. private _adjustRoll;
  48498. /**
  48499. * Gets or sets maximum allowed angle
  48500. */
  48501. get maxAngle(): number;
  48502. set maxAngle(value: number);
  48503. /**
  48504. * Creates a new BoneIKController
  48505. * @param mesh defines the mesh to control
  48506. * @param bone defines the bone to control
  48507. * @param options defines options to set up the controller
  48508. */
  48509. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  48510. targetMesh?: AbstractMesh;
  48511. poleTargetMesh?: AbstractMesh;
  48512. poleTargetBone?: Bone;
  48513. poleTargetLocalOffset?: Vector3;
  48514. poleAngle?: number;
  48515. bendAxis?: Vector3;
  48516. maxAngle?: number;
  48517. slerpAmount?: number;
  48518. });
  48519. private _setMaxAngle;
  48520. /**
  48521. * Force the controller to update the bones
  48522. */
  48523. update(): void;
  48524. }
  48525. }
  48526. declare module "babylonjs/Bones/boneLookController" {
  48527. import { Vector3 } from "babylonjs/Maths/math.vector";
  48528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48529. import { Bone } from "babylonjs/Bones/bone";
  48530. import { Space } from "babylonjs/Maths/math.axis";
  48531. /**
  48532. * Class used to make a bone look toward a point in space
  48533. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  48534. */
  48535. export class BoneLookController {
  48536. private static _tmpVecs;
  48537. private static _tmpQuat;
  48538. private static _tmpMats;
  48539. /**
  48540. * The target Vector3 that the bone will look at
  48541. */
  48542. target: Vector3;
  48543. /**
  48544. * The mesh that the bone is attached to
  48545. */
  48546. mesh: AbstractMesh;
  48547. /**
  48548. * The bone that will be looking to the target
  48549. */
  48550. bone: Bone;
  48551. /**
  48552. * The up axis of the coordinate system that is used when the bone is rotated
  48553. */
  48554. upAxis: Vector3;
  48555. /**
  48556. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  48557. */
  48558. upAxisSpace: Space;
  48559. /**
  48560. * Used to make an adjustment to the yaw of the bone
  48561. */
  48562. adjustYaw: number;
  48563. /**
  48564. * Used to make an adjustment to the pitch of the bone
  48565. */
  48566. adjustPitch: number;
  48567. /**
  48568. * Used to make an adjustment to the roll of the bone
  48569. */
  48570. adjustRoll: number;
  48571. /**
  48572. * 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)
  48573. */
  48574. slerpAmount: number;
  48575. private _minYaw;
  48576. private _maxYaw;
  48577. private _minPitch;
  48578. private _maxPitch;
  48579. private _minYawSin;
  48580. private _minYawCos;
  48581. private _maxYawSin;
  48582. private _maxYawCos;
  48583. private _midYawConstraint;
  48584. private _minPitchTan;
  48585. private _maxPitchTan;
  48586. private _boneQuat;
  48587. private _slerping;
  48588. private _transformYawPitch;
  48589. private _transformYawPitchInv;
  48590. private _firstFrameSkipped;
  48591. private _yawRange;
  48592. private _fowardAxis;
  48593. /**
  48594. * Gets or sets the minimum yaw angle that the bone can look to
  48595. */
  48596. get minYaw(): number;
  48597. set minYaw(value: number);
  48598. /**
  48599. * Gets or sets the maximum yaw angle that the bone can look to
  48600. */
  48601. get maxYaw(): number;
  48602. set maxYaw(value: number);
  48603. /**
  48604. * Gets or sets the minimum pitch angle that the bone can look to
  48605. */
  48606. get minPitch(): number;
  48607. set minPitch(value: number);
  48608. /**
  48609. * Gets or sets the maximum pitch angle that the bone can look to
  48610. */
  48611. get maxPitch(): number;
  48612. set maxPitch(value: number);
  48613. /**
  48614. * Create a BoneLookController
  48615. * @param mesh the mesh that the bone belongs to
  48616. * @param bone the bone that will be looking to the target
  48617. * @param target the target Vector3 to look at
  48618. * @param options optional settings:
  48619. * * maxYaw: the maximum angle the bone will yaw to
  48620. * * minYaw: the minimum angle the bone will yaw to
  48621. * * maxPitch: the maximum angle the bone will pitch to
  48622. * * minPitch: the minimum angle the bone will yaw to
  48623. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  48624. * * upAxis: the up axis of the coordinate system
  48625. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  48626. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  48627. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  48628. * * adjustYaw: used to make an adjustment to the yaw of the bone
  48629. * * adjustPitch: used to make an adjustment to the pitch of the bone
  48630. * * adjustRoll: used to make an adjustment to the roll of the bone
  48631. **/
  48632. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  48633. maxYaw?: number;
  48634. minYaw?: number;
  48635. maxPitch?: number;
  48636. minPitch?: number;
  48637. slerpAmount?: number;
  48638. upAxis?: Vector3;
  48639. upAxisSpace?: Space;
  48640. yawAxis?: Vector3;
  48641. pitchAxis?: Vector3;
  48642. adjustYaw?: number;
  48643. adjustPitch?: number;
  48644. adjustRoll?: number;
  48645. });
  48646. /**
  48647. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  48648. */
  48649. update(): void;
  48650. private _getAngleDiff;
  48651. private _getAngleBetween;
  48652. private _isAngleBetween;
  48653. }
  48654. }
  48655. declare module "babylonjs/Bones/index" {
  48656. export * from "babylonjs/Bones/bone";
  48657. export * from "babylonjs/Bones/boneIKController";
  48658. export * from "babylonjs/Bones/boneLookController";
  48659. export * from "babylonjs/Bones/skeleton";
  48660. }
  48661. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  48662. import { Nullable } from "babylonjs/types";
  48663. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48664. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48665. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  48666. /**
  48667. * Manage the gamepad inputs to control an arc rotate camera.
  48668. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48669. */
  48670. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  48671. /**
  48672. * Defines the camera the input is attached to.
  48673. */
  48674. camera: ArcRotateCamera;
  48675. /**
  48676. * Defines the gamepad the input is gathering event from.
  48677. */
  48678. gamepad: Nullable<Gamepad>;
  48679. /**
  48680. * Defines the gamepad rotation sensiblity.
  48681. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48682. */
  48683. gamepadRotationSensibility: number;
  48684. /**
  48685. * Defines the gamepad move sensiblity.
  48686. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48687. */
  48688. gamepadMoveSensibility: number;
  48689. private _yAxisScale;
  48690. /**
  48691. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48692. */
  48693. get invertYAxis(): boolean;
  48694. set invertYAxis(value: boolean);
  48695. private _onGamepadConnectedObserver;
  48696. private _onGamepadDisconnectedObserver;
  48697. /**
  48698. * Attach the input controls to a specific dom element to get the input from.
  48699. * @param element Defines the element the controls should be listened from
  48700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48701. */
  48702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48703. /**
  48704. * Detach the current controls from the specified dom element.
  48705. * @param element Defines the element to stop listening the inputs from
  48706. */
  48707. detachControl(element: Nullable<HTMLElement>): void;
  48708. /**
  48709. * Update the current camera state depending on the inputs that have been used this frame.
  48710. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48711. */
  48712. checkInputs(): void;
  48713. /**
  48714. * Gets the class name of the current intput.
  48715. * @returns the class name
  48716. */
  48717. getClassName(): string;
  48718. /**
  48719. * Get the friendly name associated with the input class.
  48720. * @returns the input friendly name
  48721. */
  48722. getSimpleName(): string;
  48723. }
  48724. }
  48725. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  48726. import { Nullable } from "babylonjs/types";
  48727. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48728. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48729. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  48730. interface ArcRotateCameraInputsManager {
  48731. /**
  48732. * Add orientation input support to the input manager.
  48733. * @returns the current input manager
  48734. */
  48735. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  48736. }
  48737. }
  48738. /**
  48739. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  48740. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48741. */
  48742. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  48743. /**
  48744. * Defines the camera the input is attached to.
  48745. */
  48746. camera: ArcRotateCamera;
  48747. /**
  48748. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  48749. */
  48750. alphaCorrection: number;
  48751. /**
  48752. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  48753. */
  48754. gammaCorrection: number;
  48755. private _alpha;
  48756. private _gamma;
  48757. private _dirty;
  48758. private _deviceOrientationHandler;
  48759. /**
  48760. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  48761. */
  48762. constructor();
  48763. /**
  48764. * Attach the input controls to a specific dom element to get the input from.
  48765. * @param element Defines the element the controls should be listened from
  48766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48767. */
  48768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48769. /** @hidden */
  48770. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  48771. /**
  48772. * Update the current camera state depending on the inputs that have been used this frame.
  48773. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48774. */
  48775. checkInputs(): void;
  48776. /**
  48777. * Detach the current controls from the specified dom element.
  48778. * @param element Defines the element to stop listening the inputs from
  48779. */
  48780. detachControl(element: Nullable<HTMLElement>): void;
  48781. /**
  48782. * Gets the class name of the current intput.
  48783. * @returns the class name
  48784. */
  48785. getClassName(): string;
  48786. /**
  48787. * Get the friendly name associated with the input class.
  48788. * @returns the input friendly name
  48789. */
  48790. getSimpleName(): string;
  48791. }
  48792. }
  48793. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  48794. import { Nullable } from "babylonjs/types";
  48795. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48796. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  48797. /**
  48798. * Listen to mouse events to control the camera.
  48799. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48800. */
  48801. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  48802. /**
  48803. * Defines the camera the input is attached to.
  48804. */
  48805. camera: FlyCamera;
  48806. /**
  48807. * Defines if touch is enabled. (Default is true.)
  48808. */
  48809. touchEnabled: boolean;
  48810. /**
  48811. * Defines the buttons associated with the input to handle camera rotation.
  48812. */
  48813. buttons: number[];
  48814. /**
  48815. * Assign buttons for Yaw control.
  48816. */
  48817. buttonsYaw: number[];
  48818. /**
  48819. * Assign buttons for Pitch control.
  48820. */
  48821. buttonsPitch: number[];
  48822. /**
  48823. * Assign buttons for Roll control.
  48824. */
  48825. buttonsRoll: number[];
  48826. /**
  48827. * Detect if any button is being pressed while mouse is moved.
  48828. * -1 = Mouse locked.
  48829. * 0 = Left button.
  48830. * 1 = Middle Button.
  48831. * 2 = Right Button.
  48832. */
  48833. activeButton: number;
  48834. /**
  48835. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  48836. * Higher values reduce its sensitivity.
  48837. */
  48838. angularSensibility: number;
  48839. private _observer;
  48840. private _rollObserver;
  48841. private previousPosition;
  48842. private noPreventDefault;
  48843. private element;
  48844. /**
  48845. * Listen to mouse events to control the camera.
  48846. * @param touchEnabled Define if touch is enabled. (Default is true.)
  48847. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48848. */
  48849. constructor(touchEnabled?: boolean);
  48850. /**
  48851. * Attach the mouse control to the HTML DOM element.
  48852. * @param element Defines the element that listens to the input events.
  48853. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  48854. */
  48855. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48856. /**
  48857. * Detach the current controls from the specified dom element.
  48858. * @param element Defines the element to stop listening the inputs from
  48859. */
  48860. detachControl(element: Nullable<HTMLElement>): void;
  48861. /**
  48862. * Gets the class name of the current input.
  48863. * @returns the class name.
  48864. */
  48865. getClassName(): string;
  48866. /**
  48867. * Get the friendly name associated with the input class.
  48868. * @returns the input's friendly name.
  48869. */
  48870. getSimpleName(): string;
  48871. private _pointerInput;
  48872. private _onMouseMove;
  48873. /**
  48874. * Rotate camera by mouse offset.
  48875. */
  48876. private rotateCamera;
  48877. }
  48878. }
  48879. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  48880. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  48881. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  48882. /**
  48883. * Default Inputs manager for the FlyCamera.
  48884. * It groups all the default supported inputs for ease of use.
  48885. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48886. */
  48887. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  48888. /**
  48889. * Instantiates a new FlyCameraInputsManager.
  48890. * @param camera Defines the camera the inputs belong to.
  48891. */
  48892. constructor(camera: FlyCamera);
  48893. /**
  48894. * Add keyboard input support to the input manager.
  48895. * @returns the new FlyCameraKeyboardMoveInput().
  48896. */
  48897. addKeyboard(): FlyCameraInputsManager;
  48898. /**
  48899. * Add mouse input support to the input manager.
  48900. * @param touchEnabled Enable touch screen support.
  48901. * @returns the new FlyCameraMouseInput().
  48902. */
  48903. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  48904. }
  48905. }
  48906. declare module "babylonjs/Cameras/flyCamera" {
  48907. import { Scene } from "babylonjs/scene";
  48908. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  48909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48910. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  48911. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  48912. /**
  48913. * This is a flying camera, designed for 3D movement and rotation in all directions,
  48914. * such as in a 3D Space Shooter or a Flight Simulator.
  48915. */
  48916. export class FlyCamera extends TargetCamera {
  48917. /**
  48918. * Define the collision ellipsoid of the camera.
  48919. * This is helpful for simulating a camera body, like a player's body.
  48920. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  48921. */
  48922. ellipsoid: Vector3;
  48923. /**
  48924. * Define an offset for the position of the ellipsoid around the camera.
  48925. * This can be helpful if the camera is attached away from the player's body center,
  48926. * such as at its head.
  48927. */
  48928. ellipsoidOffset: Vector3;
  48929. /**
  48930. * Enable or disable collisions of the camera with the rest of the scene objects.
  48931. */
  48932. checkCollisions: boolean;
  48933. /**
  48934. * Enable or disable gravity on the camera.
  48935. */
  48936. applyGravity: boolean;
  48937. /**
  48938. * Define the current direction the camera is moving to.
  48939. */
  48940. cameraDirection: Vector3;
  48941. /**
  48942. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  48943. * This overrides and empties cameraRotation.
  48944. */
  48945. rotationQuaternion: Quaternion;
  48946. /**
  48947. * Track Roll to maintain the wanted Rolling when looking around.
  48948. */
  48949. _trackRoll: number;
  48950. /**
  48951. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  48952. */
  48953. rollCorrect: number;
  48954. /**
  48955. * Mimic a banked turn, Rolling the camera when Yawing.
  48956. * It's recommended to use rollCorrect = 10 for faster banking correction.
  48957. */
  48958. bankedTurn: boolean;
  48959. /**
  48960. * Limit in radians for how much Roll banking will add. (Default: 90°)
  48961. */
  48962. bankedTurnLimit: number;
  48963. /**
  48964. * Value of 0 disables the banked Roll.
  48965. * Value of 1 is equal to the Yaw angle in radians.
  48966. */
  48967. bankedTurnMultiplier: number;
  48968. /**
  48969. * The inputs manager loads all the input sources, such as keyboard and mouse.
  48970. */
  48971. inputs: FlyCameraInputsManager;
  48972. /**
  48973. * Gets the input sensibility for mouse input.
  48974. * Higher values reduce sensitivity.
  48975. */
  48976. get angularSensibility(): number;
  48977. /**
  48978. * Sets the input sensibility for a mouse input.
  48979. * Higher values reduce sensitivity.
  48980. */
  48981. set angularSensibility(value: number);
  48982. /**
  48983. * Get the keys for camera movement forward.
  48984. */
  48985. get keysForward(): number[];
  48986. /**
  48987. * Set the keys for camera movement forward.
  48988. */
  48989. set keysForward(value: number[]);
  48990. /**
  48991. * Get the keys for camera movement backward.
  48992. */
  48993. get keysBackward(): number[];
  48994. set keysBackward(value: number[]);
  48995. /**
  48996. * Get the keys for camera movement up.
  48997. */
  48998. get keysUp(): number[];
  48999. /**
  49000. * Set the keys for camera movement up.
  49001. */
  49002. set keysUp(value: number[]);
  49003. /**
  49004. * Get the keys for camera movement down.
  49005. */
  49006. get keysDown(): number[];
  49007. /**
  49008. * Set the keys for camera movement down.
  49009. */
  49010. set keysDown(value: number[]);
  49011. /**
  49012. * Get the keys for camera movement left.
  49013. */
  49014. get keysLeft(): number[];
  49015. /**
  49016. * Set the keys for camera movement left.
  49017. */
  49018. set keysLeft(value: number[]);
  49019. /**
  49020. * Set the keys for camera movement right.
  49021. */
  49022. get keysRight(): number[];
  49023. /**
  49024. * Set the keys for camera movement right.
  49025. */
  49026. set keysRight(value: number[]);
  49027. /**
  49028. * Event raised when the camera collides with a mesh in the scene.
  49029. */
  49030. onCollide: (collidedMesh: AbstractMesh) => void;
  49031. private _collider;
  49032. private _needMoveForGravity;
  49033. private _oldPosition;
  49034. private _diffPosition;
  49035. private _newPosition;
  49036. /** @hidden */
  49037. _localDirection: Vector3;
  49038. /** @hidden */
  49039. _transformedDirection: Vector3;
  49040. /**
  49041. * Instantiates a FlyCamera.
  49042. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49043. * such as in a 3D Space Shooter or a Flight Simulator.
  49044. * @param name Define the name of the camera in the scene.
  49045. * @param position Define the starting position of the camera in the scene.
  49046. * @param scene Define the scene the camera belongs to.
  49047. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49048. */
  49049. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49050. /**
  49051. * Attach a control to the HTML DOM element.
  49052. * @param element Defines the element that listens to the input events.
  49053. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  49054. */
  49055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49056. /**
  49057. * Detach a control from the HTML DOM element.
  49058. * The camera will stop reacting to that input.
  49059. * @param element Defines the element that listens to the input events.
  49060. */
  49061. detachControl(element: HTMLElement): void;
  49062. private _collisionMask;
  49063. /**
  49064. * Get the mask that the camera ignores in collision events.
  49065. */
  49066. get collisionMask(): number;
  49067. /**
  49068. * Set the mask that the camera ignores in collision events.
  49069. */
  49070. set collisionMask(mask: number);
  49071. /** @hidden */
  49072. _collideWithWorld(displacement: Vector3): void;
  49073. /** @hidden */
  49074. private _onCollisionPositionChange;
  49075. /** @hidden */
  49076. _checkInputs(): void;
  49077. /** @hidden */
  49078. _decideIfNeedsToMove(): boolean;
  49079. /** @hidden */
  49080. _updatePosition(): void;
  49081. /**
  49082. * Restore the Roll to its target value at the rate specified.
  49083. * @param rate - Higher means slower restoring.
  49084. * @hidden
  49085. */
  49086. restoreRoll(rate: number): void;
  49087. /**
  49088. * Destroy the camera and release the current resources held by it.
  49089. */
  49090. dispose(): void;
  49091. /**
  49092. * Get the current object class name.
  49093. * @returns the class name.
  49094. */
  49095. getClassName(): string;
  49096. }
  49097. }
  49098. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49099. import { Nullable } from "babylonjs/types";
  49100. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49101. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49102. /**
  49103. * Listen to keyboard events to control the camera.
  49104. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49105. */
  49106. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49107. /**
  49108. * Defines the camera the input is attached to.
  49109. */
  49110. camera: FlyCamera;
  49111. /**
  49112. * The list of keyboard keys used to control the forward move of the camera.
  49113. */
  49114. keysForward: number[];
  49115. /**
  49116. * The list of keyboard keys used to control the backward move of the camera.
  49117. */
  49118. keysBackward: number[];
  49119. /**
  49120. * The list of keyboard keys used to control the forward move of the camera.
  49121. */
  49122. keysUp: number[];
  49123. /**
  49124. * The list of keyboard keys used to control the backward move of the camera.
  49125. */
  49126. keysDown: number[];
  49127. /**
  49128. * The list of keyboard keys used to control the right strafe move of the camera.
  49129. */
  49130. keysRight: number[];
  49131. /**
  49132. * The list of keyboard keys used to control the left strafe move of the camera.
  49133. */
  49134. keysLeft: number[];
  49135. private _keys;
  49136. private _onCanvasBlurObserver;
  49137. private _onKeyboardObserver;
  49138. private _engine;
  49139. private _scene;
  49140. /**
  49141. * Attach the input controls to a specific dom element to get the input from.
  49142. * @param element Defines the element the controls should be listened from
  49143. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49144. */
  49145. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49146. /**
  49147. * Detach the current controls from the specified dom element.
  49148. * @param element Defines the element to stop listening the inputs from
  49149. */
  49150. detachControl(element: Nullable<HTMLElement>): void;
  49151. /**
  49152. * Gets the class name of the current intput.
  49153. * @returns the class name
  49154. */
  49155. getClassName(): string;
  49156. /** @hidden */
  49157. _onLostFocus(e: FocusEvent): void;
  49158. /**
  49159. * Get the friendly name associated with the input class.
  49160. * @returns the input friendly name
  49161. */
  49162. getSimpleName(): string;
  49163. /**
  49164. * Update the current camera state depending on the inputs that have been used this frame.
  49165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49166. */
  49167. checkInputs(): void;
  49168. }
  49169. }
  49170. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49171. import { Nullable } from "babylonjs/types";
  49172. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49173. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49174. /**
  49175. * Manage the mouse wheel inputs to control a follow camera.
  49176. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49177. */
  49178. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49179. /**
  49180. * Defines the camera the input is attached to.
  49181. */
  49182. camera: FollowCamera;
  49183. /**
  49184. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49185. */
  49186. axisControlRadius: boolean;
  49187. /**
  49188. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49189. */
  49190. axisControlHeight: boolean;
  49191. /**
  49192. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49193. */
  49194. axisControlRotation: boolean;
  49195. /**
  49196. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49197. * relation to mouseWheel events.
  49198. */
  49199. wheelPrecision: number;
  49200. /**
  49201. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49202. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49203. */
  49204. wheelDeltaPercentage: number;
  49205. private _wheel;
  49206. private _observer;
  49207. /**
  49208. * Attach the input controls to a specific dom element to get the input from.
  49209. * @param element Defines the element the controls should be listened from
  49210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49211. */
  49212. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49213. /**
  49214. * Detach the current controls from the specified dom element.
  49215. * @param element Defines the element to stop listening the inputs from
  49216. */
  49217. detachControl(element: Nullable<HTMLElement>): void;
  49218. /**
  49219. * Gets the class name of the current intput.
  49220. * @returns the class name
  49221. */
  49222. getClassName(): string;
  49223. /**
  49224. * Get the friendly name associated with the input class.
  49225. * @returns the input friendly name
  49226. */
  49227. getSimpleName(): string;
  49228. }
  49229. }
  49230. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49231. import { Nullable } from "babylonjs/types";
  49232. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49233. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49234. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49235. /**
  49236. * Manage the pointers inputs to control an follow camera.
  49237. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49238. */
  49239. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49240. /**
  49241. * Defines the camera the input is attached to.
  49242. */
  49243. camera: FollowCamera;
  49244. /**
  49245. * Gets the class name of the current input.
  49246. * @returns the class name
  49247. */
  49248. getClassName(): string;
  49249. /**
  49250. * Defines the pointer angular sensibility along the X axis or how fast is
  49251. * the camera rotating.
  49252. * A negative number will reverse the axis direction.
  49253. */
  49254. angularSensibilityX: number;
  49255. /**
  49256. * Defines the pointer angular sensibility along the Y axis or how fast is
  49257. * the camera rotating.
  49258. * A negative number will reverse the axis direction.
  49259. */
  49260. angularSensibilityY: number;
  49261. /**
  49262. * Defines the pointer pinch precision or how fast is the camera zooming.
  49263. * A negative number will reverse the axis direction.
  49264. */
  49265. pinchPrecision: number;
  49266. /**
  49267. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49268. * from 0.
  49269. * It defines the percentage of current camera.radius to use as delta when
  49270. * pinch zoom is used.
  49271. */
  49272. pinchDeltaPercentage: number;
  49273. /**
  49274. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  49275. */
  49276. axisXControlRadius: boolean;
  49277. /**
  49278. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  49279. */
  49280. axisXControlHeight: boolean;
  49281. /**
  49282. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  49283. */
  49284. axisXControlRotation: boolean;
  49285. /**
  49286. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  49287. */
  49288. axisYControlRadius: boolean;
  49289. /**
  49290. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  49291. */
  49292. axisYControlHeight: boolean;
  49293. /**
  49294. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  49295. */
  49296. axisYControlRotation: boolean;
  49297. /**
  49298. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  49299. */
  49300. axisPinchControlRadius: boolean;
  49301. /**
  49302. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  49303. */
  49304. axisPinchControlHeight: boolean;
  49305. /**
  49306. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  49307. */
  49308. axisPinchControlRotation: boolean;
  49309. /**
  49310. * Log error messages if basic misconfiguration has occurred.
  49311. */
  49312. warningEnable: boolean;
  49313. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49314. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49315. private _warningCounter;
  49316. private _warning;
  49317. }
  49318. }
  49319. declare module "babylonjs/Cameras/followCameraInputsManager" {
  49320. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49321. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49322. /**
  49323. * Default Inputs manager for the FollowCamera.
  49324. * It groups all the default supported inputs for ease of use.
  49325. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49326. */
  49327. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  49328. /**
  49329. * Instantiates a new FollowCameraInputsManager.
  49330. * @param camera Defines the camera the inputs belong to
  49331. */
  49332. constructor(camera: FollowCamera);
  49333. /**
  49334. * Add keyboard input support to the input manager.
  49335. * @returns the current input manager
  49336. */
  49337. addKeyboard(): FollowCameraInputsManager;
  49338. /**
  49339. * Add mouse wheel input support to the input manager.
  49340. * @returns the current input manager
  49341. */
  49342. addMouseWheel(): FollowCameraInputsManager;
  49343. /**
  49344. * Add pointers input support to the input manager.
  49345. * @returns the current input manager
  49346. */
  49347. addPointers(): FollowCameraInputsManager;
  49348. /**
  49349. * Add orientation input support to the input manager.
  49350. * @returns the current input manager
  49351. */
  49352. addVRDeviceOrientation(): FollowCameraInputsManager;
  49353. }
  49354. }
  49355. declare module "babylonjs/Cameras/followCamera" {
  49356. import { Nullable } from "babylonjs/types";
  49357. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49358. import { Scene } from "babylonjs/scene";
  49359. import { Vector3 } from "babylonjs/Maths/math.vector";
  49360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49361. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  49362. /**
  49363. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  49364. * an arc rotate version arcFollowCamera are available.
  49365. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49366. */
  49367. export class FollowCamera extends TargetCamera {
  49368. /**
  49369. * Distance the follow camera should follow an object at
  49370. */
  49371. radius: number;
  49372. /**
  49373. * Minimum allowed distance of the camera to the axis of rotation
  49374. * (The camera can not get closer).
  49375. * This can help limiting how the Camera is able to move in the scene.
  49376. */
  49377. lowerRadiusLimit: Nullable<number>;
  49378. /**
  49379. * Maximum allowed distance of the camera to the axis of rotation
  49380. * (The camera can not get further).
  49381. * This can help limiting how the Camera is able to move in the scene.
  49382. */
  49383. upperRadiusLimit: Nullable<number>;
  49384. /**
  49385. * Define a rotation offset between the camera and the object it follows
  49386. */
  49387. rotationOffset: number;
  49388. /**
  49389. * Minimum 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. lowerRotationOffsetLimit: Nullable<number>;
  49393. /**
  49394. * Maximum allowed angle to camera position relative to target object.
  49395. * This can help limiting how the Camera is able to move in the scene.
  49396. */
  49397. upperRotationOffsetLimit: Nullable<number>;
  49398. /**
  49399. * Define a height offset between the camera and the object it follows.
  49400. * It can help following an object from the top (like a car chaing a plane)
  49401. */
  49402. heightOffset: number;
  49403. /**
  49404. * Minimum 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. lowerHeightOffsetLimit: Nullable<number>;
  49408. /**
  49409. * Maximum allowed height of camera position relative to target object.
  49410. * This can help limiting how the Camera is able to move in the scene.
  49411. */
  49412. upperHeightOffsetLimit: Nullable<number>;
  49413. /**
  49414. * Define how fast the camera can accelerate to follow it s target.
  49415. */
  49416. cameraAcceleration: number;
  49417. /**
  49418. * Define the speed limit of the camera following an object.
  49419. */
  49420. maxCameraSpeed: number;
  49421. /**
  49422. * Define the target of the camera.
  49423. */
  49424. lockedTarget: Nullable<AbstractMesh>;
  49425. /**
  49426. * Defines the input associated with the camera.
  49427. */
  49428. inputs: FollowCameraInputsManager;
  49429. /**
  49430. * Instantiates the follow camera.
  49431. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49432. * @param name Define the name of the camera in the scene
  49433. * @param position Define the position of the camera
  49434. * @param scene Define the scene the camera belong to
  49435. * @param lockedTarget Define the target of the camera
  49436. */
  49437. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  49438. private _follow;
  49439. /**
  49440. * Attached controls to the current camera.
  49441. * @param element Defines the element the controls should be listened from
  49442. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49443. */
  49444. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49445. /**
  49446. * Detach the current controls from the camera.
  49447. * The camera will stop reacting to inputs.
  49448. * @param element Defines the element to stop listening the inputs from
  49449. */
  49450. detachControl(element: HTMLElement): void;
  49451. /** @hidden */
  49452. _checkInputs(): void;
  49453. private _checkLimits;
  49454. /**
  49455. * Gets the camera class name.
  49456. * @returns the class name
  49457. */
  49458. getClassName(): string;
  49459. }
  49460. /**
  49461. * Arc Rotate version of the follow camera.
  49462. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  49463. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49464. */
  49465. export class ArcFollowCamera extends TargetCamera {
  49466. /** The longitudinal angle of the camera */
  49467. alpha: number;
  49468. /** The latitudinal angle of the camera */
  49469. beta: number;
  49470. /** The radius of the camera from its target */
  49471. radius: number;
  49472. private _cartesianCoordinates;
  49473. /** Define the camera target (the mesh it should follow) */
  49474. private _meshTarget;
  49475. /**
  49476. * Instantiates a new ArcFollowCamera
  49477. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49478. * @param name Define the name of the camera
  49479. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  49480. * @param beta Define the rotation angle of the camera around the elevation axis
  49481. * @param radius Define the radius of the camera from its target point
  49482. * @param target Define the target of the camera
  49483. * @param scene Define the scene the camera belongs to
  49484. */
  49485. constructor(name: string,
  49486. /** The longitudinal angle of the camera */
  49487. alpha: number,
  49488. /** The latitudinal angle of the camera */
  49489. beta: number,
  49490. /** The radius of the camera from its target */
  49491. radius: number,
  49492. /** Define the camera target (the mesh it should follow) */
  49493. target: Nullable<AbstractMesh>, scene: Scene);
  49494. private _follow;
  49495. /** @hidden */
  49496. _checkInputs(): void;
  49497. /**
  49498. * Returns the class name of the object.
  49499. * It is mostly used internally for serialization purposes.
  49500. */
  49501. getClassName(): string;
  49502. }
  49503. }
  49504. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  49505. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49506. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49507. import { Nullable } from "babylonjs/types";
  49508. /**
  49509. * Manage the keyboard inputs to control the movement of a follow camera.
  49510. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49511. */
  49512. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  49513. /**
  49514. * Defines the camera the input is attached to.
  49515. */
  49516. camera: FollowCamera;
  49517. /**
  49518. * Defines the list of key codes associated with the up action (increase heightOffset)
  49519. */
  49520. keysHeightOffsetIncr: number[];
  49521. /**
  49522. * Defines the list of key codes associated with the down action (decrease heightOffset)
  49523. */
  49524. keysHeightOffsetDecr: number[];
  49525. /**
  49526. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  49527. */
  49528. keysHeightOffsetModifierAlt: boolean;
  49529. /**
  49530. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  49531. */
  49532. keysHeightOffsetModifierCtrl: boolean;
  49533. /**
  49534. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  49535. */
  49536. keysHeightOffsetModifierShift: boolean;
  49537. /**
  49538. * Defines the list of key codes associated with the left action (increase rotationOffset)
  49539. */
  49540. keysRotationOffsetIncr: number[];
  49541. /**
  49542. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  49543. */
  49544. keysRotationOffsetDecr: number[];
  49545. /**
  49546. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  49547. */
  49548. keysRotationOffsetModifierAlt: boolean;
  49549. /**
  49550. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  49551. */
  49552. keysRotationOffsetModifierCtrl: boolean;
  49553. /**
  49554. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  49555. */
  49556. keysRotationOffsetModifierShift: boolean;
  49557. /**
  49558. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  49559. */
  49560. keysRadiusIncr: number[];
  49561. /**
  49562. * Defines the list of key codes associated with the zoom-out action (increase radius)
  49563. */
  49564. keysRadiusDecr: number[];
  49565. /**
  49566. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  49567. */
  49568. keysRadiusModifierAlt: boolean;
  49569. /**
  49570. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  49571. */
  49572. keysRadiusModifierCtrl: boolean;
  49573. /**
  49574. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  49575. */
  49576. keysRadiusModifierShift: boolean;
  49577. /**
  49578. * Defines the rate of change of heightOffset.
  49579. */
  49580. heightSensibility: number;
  49581. /**
  49582. * Defines the rate of change of rotationOffset.
  49583. */
  49584. rotationSensibility: number;
  49585. /**
  49586. * Defines the rate of change of radius.
  49587. */
  49588. radiusSensibility: number;
  49589. private _keys;
  49590. private _ctrlPressed;
  49591. private _altPressed;
  49592. private _shiftPressed;
  49593. private _onCanvasBlurObserver;
  49594. private _onKeyboardObserver;
  49595. private _engine;
  49596. private _scene;
  49597. /**
  49598. * Attach the input controls to a specific dom element to get the input from.
  49599. * @param element Defines the element the controls should be listened from
  49600. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49601. */
  49602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49603. /**
  49604. * Detach the current controls from the specified dom element.
  49605. * @param element Defines the element to stop listening the inputs from
  49606. */
  49607. detachControl(element: Nullable<HTMLElement>): void;
  49608. /**
  49609. * Update the current camera state depending on the inputs that have been used this frame.
  49610. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49611. */
  49612. checkInputs(): void;
  49613. /**
  49614. * Gets the class name of the current input.
  49615. * @returns the class name
  49616. */
  49617. getClassName(): string;
  49618. /**
  49619. * Get the friendly name associated with the input class.
  49620. * @returns the input friendly name
  49621. */
  49622. getSimpleName(): string;
  49623. /**
  49624. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49625. * allow modification of the heightOffset value.
  49626. */
  49627. private _modifierHeightOffset;
  49628. /**
  49629. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49630. * allow modification of the rotationOffset value.
  49631. */
  49632. private _modifierRotationOffset;
  49633. /**
  49634. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49635. * allow modification of the radius value.
  49636. */
  49637. private _modifierRadius;
  49638. }
  49639. }
  49640. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  49641. import { Nullable } from "babylonjs/types";
  49642. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49643. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49644. import { Observable } from "babylonjs/Misc/observable";
  49645. module "babylonjs/Cameras/freeCameraInputsManager" {
  49646. interface FreeCameraInputsManager {
  49647. /**
  49648. * @hidden
  49649. */
  49650. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  49651. /**
  49652. * Add orientation input support to the input manager.
  49653. * @returns the current input manager
  49654. */
  49655. addDeviceOrientation(): FreeCameraInputsManager;
  49656. }
  49657. }
  49658. /**
  49659. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  49660. * Screen rotation is taken into account.
  49661. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49662. */
  49663. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  49664. private _camera;
  49665. private _screenOrientationAngle;
  49666. private _constantTranform;
  49667. private _screenQuaternion;
  49668. private _alpha;
  49669. private _beta;
  49670. private _gamma;
  49671. /**
  49672. * Can be used to detect if a device orientation sensor is available on a device
  49673. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  49674. * @returns a promise that will resolve on orientation change
  49675. */
  49676. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  49677. /**
  49678. * @hidden
  49679. */
  49680. _onDeviceOrientationChangedObservable: Observable<void>;
  49681. /**
  49682. * Instantiates a new input
  49683. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49684. */
  49685. constructor();
  49686. /**
  49687. * Define the camera controlled by the input.
  49688. */
  49689. get camera(): FreeCamera;
  49690. set camera(camera: FreeCamera);
  49691. /**
  49692. * Attach the input controls to a specific dom element to get the input from.
  49693. * @param element Defines the element the controls should be listened from
  49694. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49695. */
  49696. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49697. private _orientationChanged;
  49698. private _deviceOrientation;
  49699. /**
  49700. * Detach the current controls from the specified dom element.
  49701. * @param element Defines the element to stop listening the inputs from
  49702. */
  49703. detachControl(element: Nullable<HTMLElement>): void;
  49704. /**
  49705. * Update the current camera state depending on the inputs that have been used this frame.
  49706. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49707. */
  49708. checkInputs(): void;
  49709. /**
  49710. * Gets the class name of the current intput.
  49711. * @returns the class name
  49712. */
  49713. getClassName(): string;
  49714. /**
  49715. * Get the friendly name associated with the input class.
  49716. * @returns the input friendly name
  49717. */
  49718. getSimpleName(): string;
  49719. }
  49720. }
  49721. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  49722. import { Nullable } from "babylonjs/types";
  49723. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49724. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49725. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49726. /**
  49727. * Manage the gamepad inputs to control a free camera.
  49728. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49729. */
  49730. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  49731. /**
  49732. * Define the camera the input is attached to.
  49733. */
  49734. camera: FreeCamera;
  49735. /**
  49736. * Define the Gamepad controlling the input
  49737. */
  49738. gamepad: Nullable<Gamepad>;
  49739. /**
  49740. * Defines the gamepad rotation sensiblity.
  49741. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49742. */
  49743. gamepadAngularSensibility: number;
  49744. /**
  49745. * Defines the gamepad move sensiblity.
  49746. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49747. */
  49748. gamepadMoveSensibility: number;
  49749. private _yAxisScale;
  49750. /**
  49751. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49752. */
  49753. get invertYAxis(): boolean;
  49754. set invertYAxis(value: boolean);
  49755. private _onGamepadConnectedObserver;
  49756. private _onGamepadDisconnectedObserver;
  49757. private _cameraTransform;
  49758. private _deltaTransform;
  49759. private _vector3;
  49760. private _vector2;
  49761. /**
  49762. * Attach the input controls to a specific dom element to get the input from.
  49763. * @param element Defines the element the controls should be listened from
  49764. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49765. */
  49766. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49767. /**
  49768. * Detach the current controls from the specified dom element.
  49769. * @param element Defines the element to stop listening the inputs from
  49770. */
  49771. detachControl(element: Nullable<HTMLElement>): void;
  49772. /**
  49773. * Update the current camera state depending on the inputs that have been used this frame.
  49774. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49775. */
  49776. checkInputs(): void;
  49777. /**
  49778. * Gets the class name of the current intput.
  49779. * @returns the class name
  49780. */
  49781. getClassName(): string;
  49782. /**
  49783. * Get the friendly name associated with the input class.
  49784. * @returns the input friendly name
  49785. */
  49786. getSimpleName(): string;
  49787. }
  49788. }
  49789. declare module "babylonjs/Misc/virtualJoystick" {
  49790. import { Nullable } from "babylonjs/types";
  49791. import { Vector3 } from "babylonjs/Maths/math.vector";
  49792. /**
  49793. * Defines the potential axis of a Joystick
  49794. */
  49795. export enum JoystickAxis {
  49796. /** X axis */
  49797. X = 0,
  49798. /** Y axis */
  49799. Y = 1,
  49800. /** Z axis */
  49801. Z = 2
  49802. }
  49803. /**
  49804. * Represents the different customization options available
  49805. * for VirtualJoystick
  49806. */
  49807. interface VirtualJoystickCustomizations {
  49808. /**
  49809. * Size of the joystick's puck
  49810. */
  49811. puckSize: number;
  49812. /**
  49813. * Size of the joystick's container
  49814. */
  49815. containerSize: number;
  49816. /**
  49817. * Color of the joystick && puck
  49818. */
  49819. color: string;
  49820. /**
  49821. * Image URL for the joystick's puck
  49822. */
  49823. puckImage?: string;
  49824. /**
  49825. * Image URL for the joystick's container
  49826. */
  49827. containerImage?: string;
  49828. /**
  49829. * Defines the unmoving position of the joystick container
  49830. */
  49831. position?: {
  49832. x: number;
  49833. y: number;
  49834. };
  49835. /**
  49836. * Defines whether or not the joystick container is always visible
  49837. */
  49838. alwaysVisible: boolean;
  49839. /**
  49840. * Defines whether or not to limit the movement of the puck to the joystick's container
  49841. */
  49842. limitToContainer: boolean;
  49843. }
  49844. /**
  49845. * Class used to define virtual joystick (used in touch mode)
  49846. */
  49847. export class VirtualJoystick {
  49848. /**
  49849. * Gets or sets a boolean indicating that left and right values must be inverted
  49850. */
  49851. reverseLeftRight: boolean;
  49852. /**
  49853. * Gets or sets a boolean indicating that up and down values must be inverted
  49854. */
  49855. reverseUpDown: boolean;
  49856. /**
  49857. * Gets the offset value for the position (ie. the change of the position value)
  49858. */
  49859. deltaPosition: Vector3;
  49860. /**
  49861. * Gets a boolean indicating if the virtual joystick was pressed
  49862. */
  49863. pressed: boolean;
  49864. /**
  49865. * Canvas the virtual joystick will render onto, default z-index of this is 5
  49866. */
  49867. static Canvas: Nullable<HTMLCanvasElement>;
  49868. /**
  49869. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  49870. */
  49871. limitToContainer: boolean;
  49872. private static _globalJoystickIndex;
  49873. private static _alwaysVisibleSticks;
  49874. private static vjCanvasContext;
  49875. private static vjCanvasWidth;
  49876. private static vjCanvasHeight;
  49877. private static halfWidth;
  49878. private static _GetDefaultOptions;
  49879. private _action;
  49880. private _axisTargetedByLeftAndRight;
  49881. private _axisTargetedByUpAndDown;
  49882. private _joystickSensibility;
  49883. private _inversedSensibility;
  49884. private _joystickPointerID;
  49885. private _joystickColor;
  49886. private _joystickPointerPos;
  49887. private _joystickPreviousPointerPos;
  49888. private _joystickPointerStartPos;
  49889. private _deltaJoystickVector;
  49890. private _leftJoystick;
  49891. private _touches;
  49892. private _joystickPosition;
  49893. private _alwaysVisible;
  49894. private _puckImage;
  49895. private _containerImage;
  49896. private _joystickPuckSize;
  49897. private _joystickContainerSize;
  49898. private _clearPuckSize;
  49899. private _clearContainerSize;
  49900. private _clearPuckSizeOffset;
  49901. private _clearContainerSizeOffset;
  49902. private _onPointerDownHandlerRef;
  49903. private _onPointerMoveHandlerRef;
  49904. private _onPointerUpHandlerRef;
  49905. private _onResize;
  49906. /**
  49907. * Creates a new virtual joystick
  49908. * @param leftJoystick defines that the joystick is for left hand (false by default)
  49909. * @param customizations Defines the options we want to customize the VirtualJoystick
  49910. */
  49911. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  49912. /**
  49913. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  49914. * @param newJoystickSensibility defines the new sensibility
  49915. */
  49916. setJoystickSensibility(newJoystickSensibility: number): void;
  49917. private _onPointerDown;
  49918. private _onPointerMove;
  49919. private _onPointerUp;
  49920. /**
  49921. * Change the color of the virtual joystick
  49922. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  49923. */
  49924. setJoystickColor(newColor: string): void;
  49925. /**
  49926. * Size of the joystick's container
  49927. */
  49928. set containerSize(newSize: number);
  49929. get containerSize(): number;
  49930. /**
  49931. * Size of the joystick's puck
  49932. */
  49933. set puckSize(newSize: number);
  49934. get puckSize(): number;
  49935. /**
  49936. * Clears the set position of the joystick
  49937. */
  49938. clearPosition(): void;
  49939. /**
  49940. * Defines whether or not the joystick container is always visible
  49941. */
  49942. set alwaysVisible(value: boolean);
  49943. get alwaysVisible(): boolean;
  49944. /**
  49945. * Sets the constant position of the Joystick container
  49946. * @param x X axis coordinate
  49947. * @param y Y axis coordinate
  49948. */
  49949. setPosition(x: number, y: number): void;
  49950. /**
  49951. * Defines a callback to call when the joystick is touched
  49952. * @param action defines the callback
  49953. */
  49954. setActionOnTouch(action: () => any): void;
  49955. /**
  49956. * Defines which axis you'd like to control for left & right
  49957. * @param axis defines the axis to use
  49958. */
  49959. setAxisForLeftRight(axis: JoystickAxis): void;
  49960. /**
  49961. * Defines which axis you'd like to control for up & down
  49962. * @param axis defines the axis to use
  49963. */
  49964. setAxisForUpDown(axis: JoystickAxis): void;
  49965. /**
  49966. * Clears the canvas from the previous puck / container draw
  49967. */
  49968. private _clearPreviousDraw;
  49969. /**
  49970. * Loads `urlPath` to be used for the container's image
  49971. * @param urlPath defines the urlPath of an image to use
  49972. */
  49973. setContainerImage(urlPath: string): void;
  49974. /**
  49975. * Loads `urlPath` to be used for the puck's image
  49976. * @param urlPath defines the urlPath of an image to use
  49977. */
  49978. setPuckImage(urlPath: string): void;
  49979. /**
  49980. * Draws the Virtual Joystick's container
  49981. */
  49982. private _drawContainer;
  49983. /**
  49984. * Draws the Virtual Joystick's puck
  49985. */
  49986. private _drawPuck;
  49987. private _drawVirtualJoystick;
  49988. /**
  49989. * Release internal HTML canvas
  49990. */
  49991. releaseCanvas(): void;
  49992. }
  49993. }
  49994. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  49995. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  49996. import { Nullable } from "babylonjs/types";
  49997. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49998. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49999. module "babylonjs/Cameras/freeCameraInputsManager" {
  50000. interface FreeCameraInputsManager {
  50001. /**
  50002. * Add virtual joystick input support to the input manager.
  50003. * @returns the current input manager
  50004. */
  50005. addVirtualJoystick(): FreeCameraInputsManager;
  50006. }
  50007. }
  50008. /**
  50009. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50010. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50011. */
  50012. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50013. /**
  50014. * Defines the camera the input is attached to.
  50015. */
  50016. camera: FreeCamera;
  50017. private _leftjoystick;
  50018. private _rightjoystick;
  50019. /**
  50020. * Gets the left stick of the virtual joystick.
  50021. * @returns The virtual Joystick
  50022. */
  50023. getLeftJoystick(): VirtualJoystick;
  50024. /**
  50025. * Gets the right stick of the virtual joystick.
  50026. * @returns The virtual Joystick
  50027. */
  50028. getRightJoystick(): VirtualJoystick;
  50029. /**
  50030. * Update the current camera state depending on the inputs that have been used this frame.
  50031. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50032. */
  50033. checkInputs(): void;
  50034. /**
  50035. * Attach the input controls to a specific dom element to get the input from.
  50036. * @param element Defines the element the controls should be listened from
  50037. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50038. */
  50039. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  50040. /**
  50041. * Detach the current controls from the specified dom element.
  50042. * @param element Defines the element to stop listening the inputs from
  50043. */
  50044. detachControl(element: Nullable<HTMLElement>): void;
  50045. /**
  50046. * Gets the class name of the current intput.
  50047. * @returns the class name
  50048. */
  50049. getClassName(): string;
  50050. /**
  50051. * Get the friendly name associated with the input class.
  50052. * @returns the input friendly name
  50053. */
  50054. getSimpleName(): string;
  50055. }
  50056. }
  50057. declare module "babylonjs/Cameras/Inputs/index" {
  50058. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50059. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50060. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50061. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50062. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50063. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50064. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50065. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50066. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50067. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50068. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50069. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50070. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50071. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50072. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50073. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50074. }
  50075. declare module "babylonjs/Cameras/touchCamera" {
  50076. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50077. import { Scene } from "babylonjs/scene";
  50078. import { Vector3 } from "babylonjs/Maths/math.vector";
  50079. /**
  50080. * This represents a FPS type of camera controlled by touch.
  50081. * This is like a universal camera minus the Gamepad controls.
  50082. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50083. */
  50084. export class TouchCamera extends FreeCamera {
  50085. /**
  50086. * Defines the touch sensibility for rotation.
  50087. * The higher the faster.
  50088. */
  50089. get touchAngularSensibility(): number;
  50090. set touchAngularSensibility(value: number);
  50091. /**
  50092. * Defines the touch sensibility for move.
  50093. * The higher the faster.
  50094. */
  50095. get touchMoveSensibility(): number;
  50096. set touchMoveSensibility(value: number);
  50097. /**
  50098. * Instantiates a new touch camera.
  50099. * This represents a FPS type of camera controlled by touch.
  50100. * This is like a universal camera minus the Gamepad controls.
  50101. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50102. * @param name Define the name of the camera in the scene
  50103. * @param position Define the start position of the camera in the scene
  50104. * @param scene Define the scene the camera belongs to
  50105. */
  50106. constructor(name: string, position: Vector3, scene: Scene);
  50107. /**
  50108. * Gets the current object class name.
  50109. * @return the class name
  50110. */
  50111. getClassName(): string;
  50112. /** @hidden */
  50113. _setupInputs(): void;
  50114. }
  50115. }
  50116. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50117. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50118. import { Scene } from "babylonjs/scene";
  50119. import { Vector3 } from "babylonjs/Maths/math.vector";
  50120. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50121. import { Axis } from "babylonjs/Maths/math.axis";
  50122. /**
  50123. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50124. * being tilted forward or back and left or right.
  50125. */
  50126. export class DeviceOrientationCamera extends FreeCamera {
  50127. private _initialQuaternion;
  50128. private _quaternionCache;
  50129. private _tmpDragQuaternion;
  50130. private _disablePointerInputWhenUsingDeviceOrientation;
  50131. /**
  50132. * Creates a new device orientation camera
  50133. * @param name The name of the camera
  50134. * @param position The start position camera
  50135. * @param scene The scene the camera belongs to
  50136. */
  50137. constructor(name: string, position: Vector3, scene: Scene);
  50138. /**
  50139. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50140. */
  50141. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50142. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50143. private _dragFactor;
  50144. /**
  50145. * Enabled turning on the y axis when the orientation sensor is active
  50146. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50147. */
  50148. enableHorizontalDragging(dragFactor?: number): void;
  50149. /**
  50150. * Gets the current instance class name ("DeviceOrientationCamera").
  50151. * This helps avoiding instanceof at run time.
  50152. * @returns the class name
  50153. */
  50154. getClassName(): string;
  50155. /**
  50156. * @hidden
  50157. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50158. */
  50159. _checkInputs(): void;
  50160. /**
  50161. * Reset the camera to its default orientation on the specified axis only.
  50162. * @param axis The axis to reset
  50163. */
  50164. resetToCurrentRotation(axis?: Axis): void;
  50165. }
  50166. }
  50167. declare module "babylonjs/Gamepads/xboxGamepad" {
  50168. import { Observable } from "babylonjs/Misc/observable";
  50169. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50170. /**
  50171. * Defines supported buttons for XBox360 compatible gamepads
  50172. */
  50173. export enum Xbox360Button {
  50174. /** A */
  50175. A = 0,
  50176. /** B */
  50177. B = 1,
  50178. /** X */
  50179. X = 2,
  50180. /** Y */
  50181. Y = 3,
  50182. /** Left button */
  50183. LB = 4,
  50184. /** Right button */
  50185. RB = 5,
  50186. /** Back */
  50187. Back = 8,
  50188. /** Start */
  50189. Start = 9,
  50190. /** Left stick */
  50191. LeftStick = 10,
  50192. /** Right stick */
  50193. RightStick = 11
  50194. }
  50195. /** Defines values for XBox360 DPad */
  50196. export enum Xbox360Dpad {
  50197. /** Up */
  50198. Up = 12,
  50199. /** Down */
  50200. Down = 13,
  50201. /** Left */
  50202. Left = 14,
  50203. /** Right */
  50204. Right = 15
  50205. }
  50206. /**
  50207. * Defines a XBox360 gamepad
  50208. */
  50209. export class Xbox360Pad extends Gamepad {
  50210. private _leftTrigger;
  50211. private _rightTrigger;
  50212. private _onlefttriggerchanged;
  50213. private _onrighttriggerchanged;
  50214. private _onbuttondown;
  50215. private _onbuttonup;
  50216. private _ondpaddown;
  50217. private _ondpadup;
  50218. /** Observable raised when a button is pressed */
  50219. onButtonDownObservable: Observable<Xbox360Button>;
  50220. /** Observable raised when a button is released */
  50221. onButtonUpObservable: Observable<Xbox360Button>;
  50222. /** Observable raised when a pad is pressed */
  50223. onPadDownObservable: Observable<Xbox360Dpad>;
  50224. /** Observable raised when a pad is released */
  50225. onPadUpObservable: Observable<Xbox360Dpad>;
  50226. private _buttonA;
  50227. private _buttonB;
  50228. private _buttonX;
  50229. private _buttonY;
  50230. private _buttonBack;
  50231. private _buttonStart;
  50232. private _buttonLB;
  50233. private _buttonRB;
  50234. private _buttonLeftStick;
  50235. private _buttonRightStick;
  50236. private _dPadUp;
  50237. private _dPadDown;
  50238. private _dPadLeft;
  50239. private _dPadRight;
  50240. private _isXboxOnePad;
  50241. /**
  50242. * Creates a new XBox360 gamepad object
  50243. * @param id defines the id of this gamepad
  50244. * @param index defines its index
  50245. * @param gamepad defines the internal HTML gamepad object
  50246. * @param xboxOne defines if it is a XBox One gamepad
  50247. */
  50248. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50249. /**
  50250. * Defines the callback to call when left trigger is pressed
  50251. * @param callback defines the callback to use
  50252. */
  50253. onlefttriggerchanged(callback: (value: number) => void): void;
  50254. /**
  50255. * Defines the callback to call when right trigger is pressed
  50256. * @param callback defines the callback to use
  50257. */
  50258. onrighttriggerchanged(callback: (value: number) => void): void;
  50259. /**
  50260. * Gets the left trigger value
  50261. */
  50262. get leftTrigger(): number;
  50263. /**
  50264. * Sets the left trigger value
  50265. */
  50266. set leftTrigger(newValue: number);
  50267. /**
  50268. * Gets the right trigger value
  50269. */
  50270. get rightTrigger(): number;
  50271. /**
  50272. * Sets the right trigger value
  50273. */
  50274. set rightTrigger(newValue: number);
  50275. /**
  50276. * Defines the callback to call when a button is pressed
  50277. * @param callback defines the callback to use
  50278. */
  50279. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  50280. /**
  50281. * Defines the callback to call when a button is released
  50282. * @param callback defines the callback to use
  50283. */
  50284. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  50285. /**
  50286. * Defines the callback to call when a pad is pressed
  50287. * @param callback defines the callback to use
  50288. */
  50289. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  50290. /**
  50291. * Defines the callback to call when a pad is released
  50292. * @param callback defines the callback to use
  50293. */
  50294. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  50295. private _setButtonValue;
  50296. private _setDPadValue;
  50297. /**
  50298. * Gets the value of the `A` button
  50299. */
  50300. get buttonA(): number;
  50301. /**
  50302. * Sets the value of the `A` button
  50303. */
  50304. set buttonA(value: number);
  50305. /**
  50306. * Gets the value of the `B` button
  50307. */
  50308. get buttonB(): number;
  50309. /**
  50310. * Sets the value of the `B` button
  50311. */
  50312. set buttonB(value: number);
  50313. /**
  50314. * Gets the value of the `X` button
  50315. */
  50316. get buttonX(): number;
  50317. /**
  50318. * Sets the value of the `X` button
  50319. */
  50320. set buttonX(value: number);
  50321. /**
  50322. * Gets the value of the `Y` button
  50323. */
  50324. get buttonY(): number;
  50325. /**
  50326. * Sets the value of the `Y` button
  50327. */
  50328. set buttonY(value: number);
  50329. /**
  50330. * Gets the value of the `Start` button
  50331. */
  50332. get buttonStart(): number;
  50333. /**
  50334. * Sets the value of the `Start` button
  50335. */
  50336. set buttonStart(value: number);
  50337. /**
  50338. * Gets the value of the `Back` button
  50339. */
  50340. get buttonBack(): number;
  50341. /**
  50342. * Sets the value of the `Back` button
  50343. */
  50344. set buttonBack(value: number);
  50345. /**
  50346. * Gets the value of the `Left` button
  50347. */
  50348. get buttonLB(): number;
  50349. /**
  50350. * Sets the value of the `Left` button
  50351. */
  50352. set buttonLB(value: number);
  50353. /**
  50354. * Gets the value of the `Right` button
  50355. */
  50356. get buttonRB(): number;
  50357. /**
  50358. * Sets the value of the `Right` button
  50359. */
  50360. set buttonRB(value: number);
  50361. /**
  50362. * Gets the value of the Left joystick
  50363. */
  50364. get buttonLeftStick(): number;
  50365. /**
  50366. * Sets the value of the Left joystick
  50367. */
  50368. set buttonLeftStick(value: number);
  50369. /**
  50370. * Gets the value of the Right joystick
  50371. */
  50372. get buttonRightStick(): number;
  50373. /**
  50374. * Sets the value of the Right joystick
  50375. */
  50376. set buttonRightStick(value: number);
  50377. /**
  50378. * Gets the value of D-pad up
  50379. */
  50380. get dPadUp(): number;
  50381. /**
  50382. * Sets the value of D-pad up
  50383. */
  50384. set dPadUp(value: number);
  50385. /**
  50386. * Gets the value of D-pad down
  50387. */
  50388. get dPadDown(): number;
  50389. /**
  50390. * Sets the value of D-pad down
  50391. */
  50392. set dPadDown(value: number);
  50393. /**
  50394. * Gets the value of D-pad left
  50395. */
  50396. get dPadLeft(): number;
  50397. /**
  50398. * Sets the value of D-pad left
  50399. */
  50400. set dPadLeft(value: number);
  50401. /**
  50402. * Gets the value of D-pad right
  50403. */
  50404. get dPadRight(): number;
  50405. /**
  50406. * Sets the value of D-pad right
  50407. */
  50408. set dPadRight(value: number);
  50409. /**
  50410. * Force the gamepad to synchronize with device values
  50411. */
  50412. update(): void;
  50413. /**
  50414. * Disposes the gamepad
  50415. */
  50416. dispose(): void;
  50417. }
  50418. }
  50419. declare module "babylonjs/Gamepads/dualShockGamepad" {
  50420. import { Observable } from "babylonjs/Misc/observable";
  50421. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50422. /**
  50423. * Defines supported buttons for DualShock compatible gamepads
  50424. */
  50425. export enum DualShockButton {
  50426. /** Cross */
  50427. Cross = 0,
  50428. /** Circle */
  50429. Circle = 1,
  50430. /** Square */
  50431. Square = 2,
  50432. /** Triangle */
  50433. Triangle = 3,
  50434. /** L1 */
  50435. L1 = 4,
  50436. /** R1 */
  50437. R1 = 5,
  50438. /** Share */
  50439. Share = 8,
  50440. /** Options */
  50441. Options = 9,
  50442. /** Left stick */
  50443. LeftStick = 10,
  50444. /** Right stick */
  50445. RightStick = 11
  50446. }
  50447. /** Defines values for DualShock DPad */
  50448. export enum DualShockDpad {
  50449. /** Up */
  50450. Up = 12,
  50451. /** Down */
  50452. Down = 13,
  50453. /** Left */
  50454. Left = 14,
  50455. /** Right */
  50456. Right = 15
  50457. }
  50458. /**
  50459. * Defines a DualShock gamepad
  50460. */
  50461. export class DualShockPad extends Gamepad {
  50462. private _leftTrigger;
  50463. private _rightTrigger;
  50464. private _onlefttriggerchanged;
  50465. private _onrighttriggerchanged;
  50466. private _onbuttondown;
  50467. private _onbuttonup;
  50468. private _ondpaddown;
  50469. private _ondpadup;
  50470. /** Observable raised when a button is pressed */
  50471. onButtonDownObservable: Observable<DualShockButton>;
  50472. /** Observable raised when a button is released */
  50473. onButtonUpObservable: Observable<DualShockButton>;
  50474. /** Observable raised when a pad is pressed */
  50475. onPadDownObservable: Observable<DualShockDpad>;
  50476. /** Observable raised when a pad is released */
  50477. onPadUpObservable: Observable<DualShockDpad>;
  50478. private _buttonCross;
  50479. private _buttonCircle;
  50480. private _buttonSquare;
  50481. private _buttonTriangle;
  50482. private _buttonShare;
  50483. private _buttonOptions;
  50484. private _buttonL1;
  50485. private _buttonR1;
  50486. private _buttonLeftStick;
  50487. private _buttonRightStick;
  50488. private _dPadUp;
  50489. private _dPadDown;
  50490. private _dPadLeft;
  50491. private _dPadRight;
  50492. /**
  50493. * Creates a new DualShock gamepad object
  50494. * @param id defines the id of this gamepad
  50495. * @param index defines its index
  50496. * @param gamepad defines the internal HTML gamepad object
  50497. */
  50498. constructor(id: string, index: number, gamepad: any);
  50499. /**
  50500. * Defines the callback to call when left trigger is pressed
  50501. * @param callback defines the callback to use
  50502. */
  50503. onlefttriggerchanged(callback: (value: number) => void): void;
  50504. /**
  50505. * Defines the callback to call when right trigger is pressed
  50506. * @param callback defines the callback to use
  50507. */
  50508. onrighttriggerchanged(callback: (value: number) => void): void;
  50509. /**
  50510. * Gets the left trigger value
  50511. */
  50512. get leftTrigger(): number;
  50513. /**
  50514. * Sets the left trigger value
  50515. */
  50516. set leftTrigger(newValue: number);
  50517. /**
  50518. * Gets the right trigger value
  50519. */
  50520. get rightTrigger(): number;
  50521. /**
  50522. * Sets the right trigger value
  50523. */
  50524. set rightTrigger(newValue: number);
  50525. /**
  50526. * Defines the callback to call when a button is pressed
  50527. * @param callback defines the callback to use
  50528. */
  50529. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  50530. /**
  50531. * Defines the callback to call when a button is released
  50532. * @param callback defines the callback to use
  50533. */
  50534. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  50535. /**
  50536. * Defines the callback to call when a pad is pressed
  50537. * @param callback defines the callback to use
  50538. */
  50539. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  50540. /**
  50541. * Defines the callback to call when a pad is released
  50542. * @param callback defines the callback to use
  50543. */
  50544. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  50545. private _setButtonValue;
  50546. private _setDPadValue;
  50547. /**
  50548. * Gets the value of the `Cross` button
  50549. */
  50550. get buttonCross(): number;
  50551. /**
  50552. * Sets the value of the `Cross` button
  50553. */
  50554. set buttonCross(value: number);
  50555. /**
  50556. * Gets the value of the `Circle` button
  50557. */
  50558. get buttonCircle(): number;
  50559. /**
  50560. * Sets the value of the `Circle` button
  50561. */
  50562. set buttonCircle(value: number);
  50563. /**
  50564. * Gets the value of the `Square` button
  50565. */
  50566. get buttonSquare(): number;
  50567. /**
  50568. * Sets the value of the `Square` button
  50569. */
  50570. set buttonSquare(value: number);
  50571. /**
  50572. * Gets the value of the `Triangle` button
  50573. */
  50574. get buttonTriangle(): number;
  50575. /**
  50576. * Sets the value of the `Triangle` button
  50577. */
  50578. set buttonTriangle(value: number);
  50579. /**
  50580. * Gets the value of the `Options` button
  50581. */
  50582. get buttonOptions(): number;
  50583. /**
  50584. * Sets the value of the `Options` button
  50585. */
  50586. set buttonOptions(value: number);
  50587. /**
  50588. * Gets the value of the `Share` button
  50589. */
  50590. get buttonShare(): number;
  50591. /**
  50592. * Sets the value of the `Share` button
  50593. */
  50594. set buttonShare(value: number);
  50595. /**
  50596. * Gets the value of the `L1` button
  50597. */
  50598. get buttonL1(): number;
  50599. /**
  50600. * Sets the value of the `L1` button
  50601. */
  50602. set buttonL1(value: number);
  50603. /**
  50604. * Gets the value of the `R1` button
  50605. */
  50606. get buttonR1(): number;
  50607. /**
  50608. * Sets the value of the `R1` button
  50609. */
  50610. set buttonR1(value: number);
  50611. /**
  50612. * Gets the value of the Left joystick
  50613. */
  50614. get buttonLeftStick(): number;
  50615. /**
  50616. * Sets the value of the Left joystick
  50617. */
  50618. set buttonLeftStick(value: number);
  50619. /**
  50620. * Gets the value of the Right joystick
  50621. */
  50622. get buttonRightStick(): number;
  50623. /**
  50624. * Sets the value of the Right joystick
  50625. */
  50626. set buttonRightStick(value: number);
  50627. /**
  50628. * Gets the value of D-pad up
  50629. */
  50630. get dPadUp(): number;
  50631. /**
  50632. * Sets the value of D-pad up
  50633. */
  50634. set dPadUp(value: number);
  50635. /**
  50636. * Gets the value of D-pad down
  50637. */
  50638. get dPadDown(): number;
  50639. /**
  50640. * Sets the value of D-pad down
  50641. */
  50642. set dPadDown(value: number);
  50643. /**
  50644. * Gets the value of D-pad left
  50645. */
  50646. get dPadLeft(): number;
  50647. /**
  50648. * Sets the value of D-pad left
  50649. */
  50650. set dPadLeft(value: number);
  50651. /**
  50652. * Gets the value of D-pad right
  50653. */
  50654. get dPadRight(): number;
  50655. /**
  50656. * Sets the value of D-pad right
  50657. */
  50658. set dPadRight(value: number);
  50659. /**
  50660. * Force the gamepad to synchronize with device values
  50661. */
  50662. update(): void;
  50663. /**
  50664. * Disposes the gamepad
  50665. */
  50666. dispose(): void;
  50667. }
  50668. }
  50669. declare module "babylonjs/Gamepads/gamepadManager" {
  50670. import { Observable } from "babylonjs/Misc/observable";
  50671. import { Nullable } from "babylonjs/types";
  50672. import { Scene } from "babylonjs/scene";
  50673. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50674. /**
  50675. * Manager for handling gamepads
  50676. */
  50677. export class GamepadManager {
  50678. private _scene?;
  50679. private _babylonGamepads;
  50680. private _oneGamepadConnected;
  50681. /** @hidden */
  50682. _isMonitoring: boolean;
  50683. private _gamepadEventSupported;
  50684. private _gamepadSupport?;
  50685. /**
  50686. * observable to be triggered when the gamepad controller has been connected
  50687. */
  50688. onGamepadConnectedObservable: Observable<Gamepad>;
  50689. /**
  50690. * observable to be triggered when the gamepad controller has been disconnected
  50691. */
  50692. onGamepadDisconnectedObservable: Observable<Gamepad>;
  50693. private _onGamepadConnectedEvent;
  50694. private _onGamepadDisconnectedEvent;
  50695. /**
  50696. * Initializes the gamepad manager
  50697. * @param _scene BabylonJS scene
  50698. */
  50699. constructor(_scene?: Scene | undefined);
  50700. /**
  50701. * The gamepads in the game pad manager
  50702. */
  50703. get gamepads(): Gamepad[];
  50704. /**
  50705. * Get the gamepad controllers based on type
  50706. * @param type The type of gamepad controller
  50707. * @returns Nullable gamepad
  50708. */
  50709. getGamepadByType(type?: number): Nullable<Gamepad>;
  50710. /**
  50711. * Disposes the gamepad manager
  50712. */
  50713. dispose(): void;
  50714. private _addNewGamepad;
  50715. private _startMonitoringGamepads;
  50716. private _stopMonitoringGamepads;
  50717. /** @hidden */
  50718. _checkGamepadsStatus(): void;
  50719. private _updateGamepadObjects;
  50720. }
  50721. }
  50722. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  50723. import { Nullable } from "babylonjs/types";
  50724. import { Scene } from "babylonjs/scene";
  50725. import { ISceneComponent } from "babylonjs/sceneComponent";
  50726. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  50727. module "babylonjs/scene" {
  50728. interface Scene {
  50729. /** @hidden */
  50730. _gamepadManager: Nullable<GamepadManager>;
  50731. /**
  50732. * Gets the gamepad manager associated with the scene
  50733. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  50734. */
  50735. gamepadManager: GamepadManager;
  50736. }
  50737. }
  50738. module "babylonjs/Cameras/freeCameraInputsManager" {
  50739. /**
  50740. * Interface representing a free camera inputs manager
  50741. */
  50742. interface FreeCameraInputsManager {
  50743. /**
  50744. * Adds gamepad input support to the FreeCameraInputsManager.
  50745. * @returns the FreeCameraInputsManager
  50746. */
  50747. addGamepad(): FreeCameraInputsManager;
  50748. }
  50749. }
  50750. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  50751. /**
  50752. * Interface representing an arc rotate camera inputs manager
  50753. */
  50754. interface ArcRotateCameraInputsManager {
  50755. /**
  50756. * Adds gamepad input support to the ArcRotateCamera InputManager.
  50757. * @returns the camera inputs manager
  50758. */
  50759. addGamepad(): ArcRotateCameraInputsManager;
  50760. }
  50761. }
  50762. /**
  50763. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  50764. */
  50765. export class GamepadSystemSceneComponent implements ISceneComponent {
  50766. /**
  50767. * The component name helpfull to identify the component in the list of scene components.
  50768. */
  50769. readonly name: string;
  50770. /**
  50771. * The scene the component belongs to.
  50772. */
  50773. scene: Scene;
  50774. /**
  50775. * Creates a new instance of the component for the given scene
  50776. * @param scene Defines the scene to register the component in
  50777. */
  50778. constructor(scene: Scene);
  50779. /**
  50780. * Registers the component in a given scene
  50781. */
  50782. register(): void;
  50783. /**
  50784. * Rebuilds the elements related to this component in case of
  50785. * context lost for instance.
  50786. */
  50787. rebuild(): void;
  50788. /**
  50789. * Disposes the component and the associated ressources
  50790. */
  50791. dispose(): void;
  50792. private _beforeCameraUpdate;
  50793. }
  50794. }
  50795. declare module "babylonjs/Cameras/universalCamera" {
  50796. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  50797. import { Scene } from "babylonjs/scene";
  50798. import { Vector3 } from "babylonjs/Maths/math.vector";
  50799. import "babylonjs/Gamepads/gamepadSceneComponent";
  50800. /**
  50801. * 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,
  50802. * which still works and will still be found in many Playgrounds.
  50803. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50804. */
  50805. export class UniversalCamera extends TouchCamera {
  50806. /**
  50807. * Defines the gamepad rotation sensiblity.
  50808. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50809. */
  50810. get gamepadAngularSensibility(): number;
  50811. set gamepadAngularSensibility(value: number);
  50812. /**
  50813. * Defines the gamepad move sensiblity.
  50814. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50815. */
  50816. get gamepadMoveSensibility(): number;
  50817. set gamepadMoveSensibility(value: number);
  50818. /**
  50819. * 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,
  50820. * which still works and will still be found in many Playgrounds.
  50821. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50822. * @param name Define the name of the camera in the scene
  50823. * @param position Define the start position of the camera in the scene
  50824. * @param scene Define the scene the camera belongs to
  50825. */
  50826. constructor(name: string, position: Vector3, scene: Scene);
  50827. /**
  50828. * Gets the current object class name.
  50829. * @return the class name
  50830. */
  50831. getClassName(): string;
  50832. }
  50833. }
  50834. declare module "babylonjs/Cameras/gamepadCamera" {
  50835. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  50836. import { Scene } from "babylonjs/scene";
  50837. import { Vector3 } from "babylonjs/Maths/math.vector";
  50838. /**
  50839. * This represents a FPS type of camera. This is only here for back compat purpose.
  50840. * Please use the UniversalCamera instead as both are identical.
  50841. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50842. */
  50843. export class GamepadCamera extends UniversalCamera {
  50844. /**
  50845. * Instantiates a new Gamepad Camera
  50846. * This represents a FPS type of camera. This is only here for back compat purpose.
  50847. * Please use the UniversalCamera instead as both are identical.
  50848. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50849. * @param name Define the name of the camera in the scene
  50850. * @param position Define the start position of the camera in the scene
  50851. * @param scene Define the scene the camera belongs to
  50852. */
  50853. constructor(name: string, position: Vector3, scene: Scene);
  50854. /**
  50855. * Gets the current object class name.
  50856. * @return the class name
  50857. */
  50858. getClassName(): string;
  50859. }
  50860. }
  50861. declare module "babylonjs/Shaders/pass.fragment" {
  50862. /** @hidden */
  50863. export var passPixelShader: {
  50864. name: string;
  50865. shader: string;
  50866. };
  50867. }
  50868. declare module "babylonjs/Shaders/passCube.fragment" {
  50869. /** @hidden */
  50870. export var passCubePixelShader: {
  50871. name: string;
  50872. shader: string;
  50873. };
  50874. }
  50875. declare module "babylonjs/PostProcesses/passPostProcess" {
  50876. import { Nullable } from "babylonjs/types";
  50877. import { Camera } from "babylonjs/Cameras/camera";
  50878. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50879. import { Engine } from "babylonjs/Engines/engine";
  50880. import "babylonjs/Shaders/pass.fragment";
  50881. import "babylonjs/Shaders/passCube.fragment";
  50882. import { Scene } from "babylonjs/scene";
  50883. /**
  50884. * PassPostProcess which produces an output the same as it's input
  50885. */
  50886. export class PassPostProcess extends PostProcess {
  50887. /**
  50888. * Gets a string identifying the name of the class
  50889. * @returns "PassPostProcess" string
  50890. */
  50891. getClassName(): string;
  50892. /**
  50893. * Creates the PassPostProcess
  50894. * @param name The name of the effect.
  50895. * @param options The required width/height ratio to downsize to before computing the render pass.
  50896. * @param camera The camera to apply the render pass to.
  50897. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50898. * @param engine The engine which the post process will be applied. (default: current engine)
  50899. * @param reusable If the post process can be reused on the same frame. (default: false)
  50900. * @param textureType The type of texture to be used when performing the post processing.
  50901. * @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)
  50902. */
  50903. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50904. /** @hidden */
  50905. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  50906. }
  50907. /**
  50908. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  50909. */
  50910. export class PassCubePostProcess extends PostProcess {
  50911. private _face;
  50912. /**
  50913. * Gets or sets the cube face to display.
  50914. * * 0 is +X
  50915. * * 1 is -X
  50916. * * 2 is +Y
  50917. * * 3 is -Y
  50918. * * 4 is +Z
  50919. * * 5 is -Z
  50920. */
  50921. get face(): number;
  50922. set face(value: number);
  50923. /**
  50924. * Gets a string identifying the name of the class
  50925. * @returns "PassCubePostProcess" string
  50926. */
  50927. getClassName(): string;
  50928. /**
  50929. * Creates the PassCubePostProcess
  50930. * @param name The name of the effect.
  50931. * @param options The required width/height ratio to downsize to before computing the render pass.
  50932. * @param camera The camera to apply the render pass to.
  50933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50934. * @param engine The engine which the post process will be applied. (default: current engine)
  50935. * @param reusable If the post process can be reused on the same frame. (default: false)
  50936. * @param textureType The type of texture to be used when performing the post processing.
  50937. * @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)
  50938. */
  50939. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50940. /** @hidden */
  50941. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  50942. }
  50943. }
  50944. declare module "babylonjs/Shaders/anaglyph.fragment" {
  50945. /** @hidden */
  50946. export var anaglyphPixelShader: {
  50947. name: string;
  50948. shader: string;
  50949. };
  50950. }
  50951. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  50952. import { Engine } from "babylonjs/Engines/engine";
  50953. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50954. import { Camera } from "babylonjs/Cameras/camera";
  50955. import "babylonjs/Shaders/anaglyph.fragment";
  50956. /**
  50957. * Postprocess used to generate anaglyphic rendering
  50958. */
  50959. export class AnaglyphPostProcess extends PostProcess {
  50960. private _passedProcess;
  50961. /**
  50962. * Gets a string identifying the name of the class
  50963. * @returns "AnaglyphPostProcess" string
  50964. */
  50965. getClassName(): string;
  50966. /**
  50967. * Creates a new AnaglyphPostProcess
  50968. * @param name defines postprocess name
  50969. * @param options defines creation options or target ratio scale
  50970. * @param rigCameras defines cameras using this postprocess
  50971. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  50972. * @param engine defines hosting engine
  50973. * @param reusable defines if the postprocess will be reused multiple times per frame
  50974. */
  50975. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  50976. }
  50977. }
  50978. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  50979. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  50980. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50981. import { Scene } from "babylonjs/scene";
  50982. import { Vector3 } from "babylonjs/Maths/math.vector";
  50983. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50984. /**
  50985. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  50986. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  50987. */
  50988. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  50989. /**
  50990. * Creates a new AnaglyphArcRotateCamera
  50991. * @param name defines camera name
  50992. * @param alpha defines alpha angle (in radians)
  50993. * @param beta defines beta angle (in radians)
  50994. * @param radius defines radius
  50995. * @param target defines camera target
  50996. * @param interaxialDistance defines distance between each color axis
  50997. * @param scene defines the hosting scene
  50998. */
  50999. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51000. /**
  51001. * Gets camera class name
  51002. * @returns AnaglyphArcRotateCamera
  51003. */
  51004. getClassName(): string;
  51005. }
  51006. }
  51007. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51008. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51009. import { Scene } from "babylonjs/scene";
  51010. import { Vector3 } from "babylonjs/Maths/math.vector";
  51011. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51012. /**
  51013. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51014. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51015. */
  51016. export class AnaglyphFreeCamera extends FreeCamera {
  51017. /**
  51018. * Creates a new AnaglyphFreeCamera
  51019. * @param name defines camera name
  51020. * @param position defines initial position
  51021. * @param interaxialDistance defines distance between each color axis
  51022. * @param scene defines the hosting scene
  51023. */
  51024. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51025. /**
  51026. * Gets camera class name
  51027. * @returns AnaglyphFreeCamera
  51028. */
  51029. getClassName(): string;
  51030. }
  51031. }
  51032. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51033. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51034. import { Scene } from "babylonjs/scene";
  51035. import { Vector3 } from "babylonjs/Maths/math.vector";
  51036. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51037. /**
  51038. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51039. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51040. */
  51041. export class AnaglyphGamepadCamera extends GamepadCamera {
  51042. /**
  51043. * Creates a new AnaglyphGamepadCamera
  51044. * @param name defines camera name
  51045. * @param position defines initial position
  51046. * @param interaxialDistance defines distance between each color axis
  51047. * @param scene defines the hosting scene
  51048. */
  51049. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51050. /**
  51051. * Gets camera class name
  51052. * @returns AnaglyphGamepadCamera
  51053. */
  51054. getClassName(): string;
  51055. }
  51056. }
  51057. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51058. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51059. import { Scene } from "babylonjs/scene";
  51060. import { Vector3 } from "babylonjs/Maths/math.vector";
  51061. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51062. /**
  51063. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51064. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51065. */
  51066. export class AnaglyphUniversalCamera extends UniversalCamera {
  51067. /**
  51068. * Creates a new AnaglyphUniversalCamera
  51069. * @param name defines camera name
  51070. * @param position defines initial position
  51071. * @param interaxialDistance defines distance between each color axis
  51072. * @param scene defines the hosting scene
  51073. */
  51074. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51075. /**
  51076. * Gets camera class name
  51077. * @returns AnaglyphUniversalCamera
  51078. */
  51079. getClassName(): string;
  51080. }
  51081. }
  51082. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51083. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51084. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51085. import { Scene } from "babylonjs/scene";
  51086. import { Vector3 } from "babylonjs/Maths/math.vector";
  51087. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51088. /**
  51089. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51090. * @see https://doc.babylonjs.com/features/cameras
  51091. */
  51092. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51093. /**
  51094. * Creates a new StereoscopicArcRotateCamera
  51095. * @param name defines camera name
  51096. * @param alpha defines alpha angle (in radians)
  51097. * @param beta defines beta angle (in radians)
  51098. * @param radius defines radius
  51099. * @param target defines camera target
  51100. * @param interaxialDistance defines distance between each color axis
  51101. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51102. * @param scene defines the hosting scene
  51103. */
  51104. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51105. /**
  51106. * Gets camera class name
  51107. * @returns StereoscopicArcRotateCamera
  51108. */
  51109. getClassName(): string;
  51110. }
  51111. }
  51112. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51113. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51114. import { Scene } from "babylonjs/scene";
  51115. import { Vector3 } from "babylonjs/Maths/math.vector";
  51116. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51117. /**
  51118. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51119. * @see https://doc.babylonjs.com/features/cameras
  51120. */
  51121. export class StereoscopicFreeCamera extends FreeCamera {
  51122. /**
  51123. * Creates a new StereoscopicFreeCamera
  51124. * @param name defines camera name
  51125. * @param position defines initial position
  51126. * @param interaxialDistance defines distance between each color axis
  51127. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51128. * @param scene defines the hosting scene
  51129. */
  51130. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51131. /**
  51132. * Gets camera class name
  51133. * @returns StereoscopicFreeCamera
  51134. */
  51135. getClassName(): string;
  51136. }
  51137. }
  51138. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51139. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51140. import { Scene } from "babylonjs/scene";
  51141. import { Vector3 } from "babylonjs/Maths/math.vector";
  51142. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51143. /**
  51144. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51145. * @see https://doc.babylonjs.com/features/cameras
  51146. */
  51147. export class StereoscopicGamepadCamera extends GamepadCamera {
  51148. /**
  51149. * Creates a new StereoscopicGamepadCamera
  51150. * @param name defines camera name
  51151. * @param position defines initial position
  51152. * @param interaxialDistance defines distance between each color axis
  51153. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51154. * @param scene defines the hosting scene
  51155. */
  51156. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51157. /**
  51158. * Gets camera class name
  51159. * @returns StereoscopicGamepadCamera
  51160. */
  51161. getClassName(): string;
  51162. }
  51163. }
  51164. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51165. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51166. import { Scene } from "babylonjs/scene";
  51167. import { Vector3 } from "babylonjs/Maths/math.vector";
  51168. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51169. /**
  51170. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51171. * @see https://doc.babylonjs.com/features/cameras
  51172. */
  51173. export class StereoscopicUniversalCamera extends UniversalCamera {
  51174. /**
  51175. * Creates a new StereoscopicUniversalCamera
  51176. * @param name defines camera name
  51177. * @param position defines initial position
  51178. * @param interaxialDistance defines distance between each color axis
  51179. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51180. * @param scene defines the hosting scene
  51181. */
  51182. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51183. /**
  51184. * Gets camera class name
  51185. * @returns StereoscopicUniversalCamera
  51186. */
  51187. getClassName(): string;
  51188. }
  51189. }
  51190. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51191. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51192. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51193. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51194. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51195. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51196. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51197. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51198. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51199. }
  51200. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51201. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51202. import { Scene } from "babylonjs/scene";
  51203. import { Vector3 } from "babylonjs/Maths/math.vector";
  51204. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51205. /**
  51206. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51207. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51208. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51209. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51210. */
  51211. export class VirtualJoysticksCamera extends FreeCamera {
  51212. /**
  51213. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51214. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51215. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51216. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51217. * @param name Define the name of the camera in the scene
  51218. * @param position Define the start position of the camera in the scene
  51219. * @param scene Define the scene the camera belongs to
  51220. */
  51221. constructor(name: string, position: Vector3, scene: Scene);
  51222. /**
  51223. * Gets the current object class name.
  51224. * @return the class name
  51225. */
  51226. getClassName(): string;
  51227. }
  51228. }
  51229. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51230. import { Matrix } from "babylonjs/Maths/math.vector";
  51231. /**
  51232. * This represents all the required metrics to create a VR camera.
  51233. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51234. */
  51235. export class VRCameraMetrics {
  51236. /**
  51237. * Define the horizontal resolution off the screen.
  51238. */
  51239. hResolution: number;
  51240. /**
  51241. * Define the vertical resolution off the screen.
  51242. */
  51243. vResolution: number;
  51244. /**
  51245. * Define the horizontal screen size.
  51246. */
  51247. hScreenSize: number;
  51248. /**
  51249. * Define the vertical screen size.
  51250. */
  51251. vScreenSize: number;
  51252. /**
  51253. * Define the vertical screen center position.
  51254. */
  51255. vScreenCenter: number;
  51256. /**
  51257. * Define the distance of the eyes to the screen.
  51258. */
  51259. eyeToScreenDistance: number;
  51260. /**
  51261. * Define the distance between both lenses
  51262. */
  51263. lensSeparationDistance: number;
  51264. /**
  51265. * Define the distance between both viewer's eyes.
  51266. */
  51267. interpupillaryDistance: number;
  51268. /**
  51269. * Define the distortion factor of the VR postprocess.
  51270. * Please, touch with care.
  51271. */
  51272. distortionK: number[];
  51273. /**
  51274. * Define the chromatic aberration correction factors for the VR post process.
  51275. */
  51276. chromaAbCorrection: number[];
  51277. /**
  51278. * Define the scale factor of the post process.
  51279. * The smaller the better but the slower.
  51280. */
  51281. postProcessScaleFactor: number;
  51282. /**
  51283. * Define an offset for the lens center.
  51284. */
  51285. lensCenterOffset: number;
  51286. /**
  51287. * Define if the current vr camera should compensate the distortion of the lense or not.
  51288. */
  51289. compensateDistortion: boolean;
  51290. /**
  51291. * Defines if multiview should be enabled when rendering (Default: false)
  51292. */
  51293. multiviewEnabled: boolean;
  51294. /**
  51295. * Gets the rendering aspect ratio based on the provided resolutions.
  51296. */
  51297. get aspectRatio(): number;
  51298. /**
  51299. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  51300. */
  51301. get aspectRatioFov(): number;
  51302. /**
  51303. * @hidden
  51304. */
  51305. get leftHMatrix(): Matrix;
  51306. /**
  51307. * @hidden
  51308. */
  51309. get rightHMatrix(): Matrix;
  51310. /**
  51311. * @hidden
  51312. */
  51313. get leftPreViewMatrix(): Matrix;
  51314. /**
  51315. * @hidden
  51316. */
  51317. get rightPreViewMatrix(): Matrix;
  51318. /**
  51319. * Get the default VRMetrics based on the most generic setup.
  51320. * @returns the default vr metrics
  51321. */
  51322. static GetDefault(): VRCameraMetrics;
  51323. }
  51324. }
  51325. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  51326. /** @hidden */
  51327. export var vrDistortionCorrectionPixelShader: {
  51328. name: string;
  51329. shader: string;
  51330. };
  51331. }
  51332. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  51333. import { Camera } from "babylonjs/Cameras/camera";
  51334. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51335. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51336. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  51337. /**
  51338. * VRDistortionCorrectionPostProcess used for mobile VR
  51339. */
  51340. export class VRDistortionCorrectionPostProcess extends PostProcess {
  51341. private _isRightEye;
  51342. private _distortionFactors;
  51343. private _postProcessScaleFactor;
  51344. private _lensCenterOffset;
  51345. private _scaleIn;
  51346. private _scaleFactor;
  51347. private _lensCenter;
  51348. /**
  51349. * Gets a string identifying the name of the class
  51350. * @returns "VRDistortionCorrectionPostProcess" string
  51351. */
  51352. getClassName(): string;
  51353. /**
  51354. * Initializes the VRDistortionCorrectionPostProcess
  51355. * @param name The name of the effect.
  51356. * @param camera The camera to apply the render pass to.
  51357. * @param isRightEye If this is for the right eye distortion
  51358. * @param vrMetrics All the required metrics for the VR camera
  51359. */
  51360. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  51361. }
  51362. }
  51363. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  51364. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  51365. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51366. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51367. import { Scene } from "babylonjs/scene";
  51368. import { Vector3 } from "babylonjs/Maths/math.vector";
  51369. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  51370. import "babylonjs/Cameras/RigModes/vrRigMode";
  51371. /**
  51372. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  51373. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51374. */
  51375. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  51376. /**
  51377. * Creates a new VRDeviceOrientationArcRotateCamera
  51378. * @param name defines camera name
  51379. * @param alpha defines the camera rotation along the logitudinal axis
  51380. * @param beta defines the camera rotation along the latitudinal axis
  51381. * @param radius defines the camera distance from its target
  51382. * @param target defines the camera target
  51383. * @param scene defines the scene the camera belongs to
  51384. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51385. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51386. */
  51387. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51388. /**
  51389. * Gets camera class name
  51390. * @returns VRDeviceOrientationArcRotateCamera
  51391. */
  51392. getClassName(): string;
  51393. }
  51394. }
  51395. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  51396. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51397. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51398. import { Scene } from "babylonjs/scene";
  51399. import { Vector3 } from "babylonjs/Maths/math.vector";
  51400. import "babylonjs/Cameras/RigModes/vrRigMode";
  51401. /**
  51402. * Camera used to simulate VR rendering (based on FreeCamera)
  51403. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51404. */
  51405. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  51406. /**
  51407. * Creates a new VRDeviceOrientationFreeCamera
  51408. * @param name defines camera name
  51409. * @param position defines the start position of the camera
  51410. * @param scene defines the scene the camera belongs to
  51411. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51412. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51413. */
  51414. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51415. /**
  51416. * Gets camera class name
  51417. * @returns VRDeviceOrientationFreeCamera
  51418. */
  51419. getClassName(): string;
  51420. }
  51421. }
  51422. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  51423. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51424. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51425. import { Scene } from "babylonjs/scene";
  51426. import { Vector3 } from "babylonjs/Maths/math.vector";
  51427. import "babylonjs/Gamepads/gamepadSceneComponent";
  51428. /**
  51429. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  51430. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51431. */
  51432. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  51433. /**
  51434. * Creates a new VRDeviceOrientationGamepadCamera
  51435. * @param name defines camera name
  51436. * @param position defines the start position of the camera
  51437. * @param scene defines the scene the camera belongs to
  51438. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51439. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51440. */
  51441. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51442. /**
  51443. * Gets camera class name
  51444. * @returns VRDeviceOrientationGamepadCamera
  51445. */
  51446. getClassName(): string;
  51447. }
  51448. }
  51449. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  51450. import { Scene } from "babylonjs/scene";
  51451. import { Texture } from "babylonjs/Materials/Textures/texture";
  51452. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  51453. /**
  51454. * A class extending Texture allowing drawing on a texture
  51455. * @see https://doc.babylonjs.com/how_to/dynamictexture
  51456. */
  51457. export class DynamicTexture extends Texture {
  51458. private _generateMipMaps;
  51459. private _canvas;
  51460. private _context;
  51461. /**
  51462. * Creates a DynamicTexture
  51463. * @param name defines the name of the texture
  51464. * @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
  51465. * @param scene defines the scene where you want the texture
  51466. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  51467. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51468. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  51469. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  51470. */
  51471. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  51472. /**
  51473. * Get the current class name of the texture useful for serialization or dynamic coding.
  51474. * @returns "DynamicTexture"
  51475. */
  51476. getClassName(): string;
  51477. /**
  51478. * Gets the current state of canRescale
  51479. */
  51480. get canRescale(): boolean;
  51481. private _recreate;
  51482. /**
  51483. * Scales the texture
  51484. * @param ratio the scale factor to apply to both width and height
  51485. */
  51486. scale(ratio: number): void;
  51487. /**
  51488. * Resizes the texture
  51489. * @param width the new width
  51490. * @param height the new height
  51491. */
  51492. scaleTo(width: number, height: number): void;
  51493. /**
  51494. * Gets the context of the canvas used by the texture
  51495. * @returns the canvas context of the dynamic texture
  51496. */
  51497. getContext(): CanvasRenderingContext2D;
  51498. /**
  51499. * Clears the texture
  51500. */
  51501. clear(): void;
  51502. /**
  51503. * Updates the texture
  51504. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51505. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  51506. */
  51507. update(invertY?: boolean, premulAlpha?: boolean): void;
  51508. /**
  51509. * Draws text onto the texture
  51510. * @param text defines the text to be drawn
  51511. * @param x defines the placement of the text from the left
  51512. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  51513. * @param font defines the font to be used with font-style, font-size, font-name
  51514. * @param color defines the color used for the text
  51515. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  51516. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51517. * @param update defines whether texture is immediately update (default is true)
  51518. */
  51519. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  51520. /**
  51521. * Clones the texture
  51522. * @returns the clone of the texture.
  51523. */
  51524. clone(): DynamicTexture;
  51525. /**
  51526. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  51527. * @returns a serialized dynamic texture object
  51528. */
  51529. serialize(): any;
  51530. private _IsCanvasElement;
  51531. /** @hidden */
  51532. _rebuild(): void;
  51533. }
  51534. }
  51535. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  51536. import { Scene } from "babylonjs/scene";
  51537. import { Color3 } from "babylonjs/Maths/math.color";
  51538. import { Mesh } from "babylonjs/Meshes/mesh";
  51539. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51540. import { Nullable } from "babylonjs/types";
  51541. /**
  51542. * Class containing static functions to help procedurally build meshes
  51543. */
  51544. export class GroundBuilder {
  51545. /**
  51546. * Creates a ground mesh
  51547. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51548. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51550. * @param name defines the name of the mesh
  51551. * @param options defines the options used to create the mesh
  51552. * @param scene defines the hosting scene
  51553. * @returns the ground mesh
  51554. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51555. */
  51556. static CreateGround(name: string, options: {
  51557. width?: number;
  51558. height?: number;
  51559. subdivisions?: number;
  51560. subdivisionsX?: number;
  51561. subdivisionsY?: number;
  51562. updatable?: boolean;
  51563. }, scene: any): Mesh;
  51564. /**
  51565. * Creates a tiled ground mesh
  51566. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51567. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51568. * * 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
  51569. * * 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
  51570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51571. * @param name defines the name of the mesh
  51572. * @param options defines the options used to create the mesh
  51573. * @param scene defines the hosting scene
  51574. * @returns the tiled ground mesh
  51575. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51576. */
  51577. static CreateTiledGround(name: string, options: {
  51578. xmin: number;
  51579. zmin: number;
  51580. xmax: number;
  51581. zmax: number;
  51582. subdivisions?: {
  51583. w: number;
  51584. h: number;
  51585. };
  51586. precision?: {
  51587. w: number;
  51588. h: number;
  51589. };
  51590. updatable?: boolean;
  51591. }, scene?: Nullable<Scene>): Mesh;
  51592. /**
  51593. * Creates a ground mesh from a height map
  51594. * * The parameter `url` sets the URL of the height map image resource.
  51595. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51596. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51597. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51598. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51599. * * 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.
  51600. * * 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).
  51601. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51603. * @param name defines the name of the mesh
  51604. * @param url defines the url to the height map
  51605. * @param options defines the options used to create the mesh
  51606. * @param scene defines the hosting scene
  51607. * @returns the ground mesh
  51608. * @see https://doc.babylonjs.com/babylon101/height_map
  51609. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51610. */
  51611. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51612. width?: number;
  51613. height?: number;
  51614. subdivisions?: number;
  51615. minHeight?: number;
  51616. maxHeight?: number;
  51617. colorFilter?: Color3;
  51618. alphaFilter?: number;
  51619. updatable?: boolean;
  51620. onReady?: (mesh: GroundMesh) => void;
  51621. }, scene?: Nullable<Scene>): GroundMesh;
  51622. }
  51623. }
  51624. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  51625. import { Vector4 } from "babylonjs/Maths/math.vector";
  51626. import { Mesh } from "babylonjs/Meshes/mesh";
  51627. /**
  51628. * Class containing static functions to help procedurally build meshes
  51629. */
  51630. export class TorusBuilder {
  51631. /**
  51632. * Creates a torus mesh
  51633. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51634. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51635. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51637. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51639. * @param name defines the name of the mesh
  51640. * @param options defines the options used to create the mesh
  51641. * @param scene defines the hosting scene
  51642. * @returns the torus mesh
  51643. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51644. */
  51645. static CreateTorus(name: string, options: {
  51646. diameter?: number;
  51647. thickness?: number;
  51648. tessellation?: number;
  51649. updatable?: boolean;
  51650. sideOrientation?: number;
  51651. frontUVs?: Vector4;
  51652. backUVs?: Vector4;
  51653. }, scene: any): Mesh;
  51654. }
  51655. }
  51656. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  51657. import { Vector4 } from "babylonjs/Maths/math.vector";
  51658. import { Color4 } from "babylonjs/Maths/math.color";
  51659. import { Mesh } from "babylonjs/Meshes/mesh";
  51660. /**
  51661. * Class containing static functions to help procedurally build meshes
  51662. */
  51663. export class CylinderBuilder {
  51664. /**
  51665. * Creates a cylinder or a cone mesh
  51666. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51667. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51668. * * 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.
  51669. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51670. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51671. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51672. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51673. * * 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).
  51674. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51675. * * 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).
  51676. * * 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
  51677. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51678. * * 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
  51679. * * 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.
  51680. * * If `enclose` is false, a ring surface is one element.
  51681. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51682. * * 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
  51683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51686. * @param name defines the name of the mesh
  51687. * @param options defines the options used to create the mesh
  51688. * @param scene defines the hosting scene
  51689. * @returns the cylinder mesh
  51690. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51691. */
  51692. static CreateCylinder(name: string, options: {
  51693. height?: number;
  51694. diameterTop?: number;
  51695. diameterBottom?: number;
  51696. diameter?: number;
  51697. tessellation?: number;
  51698. subdivisions?: number;
  51699. arc?: number;
  51700. faceColors?: Color4[];
  51701. faceUV?: Vector4[];
  51702. updatable?: boolean;
  51703. hasRings?: boolean;
  51704. enclose?: boolean;
  51705. cap?: number;
  51706. sideOrientation?: number;
  51707. frontUVs?: Vector4;
  51708. backUVs?: Vector4;
  51709. }, scene: any): Mesh;
  51710. }
  51711. }
  51712. declare module "babylonjs/XR/webXRTypes" {
  51713. import { Nullable } from "babylonjs/types";
  51714. import { IDisposable } from "babylonjs/scene";
  51715. /**
  51716. * States of the webXR experience
  51717. */
  51718. export enum WebXRState {
  51719. /**
  51720. * Transitioning to being in XR mode
  51721. */
  51722. ENTERING_XR = 0,
  51723. /**
  51724. * Transitioning to non XR mode
  51725. */
  51726. EXITING_XR = 1,
  51727. /**
  51728. * In XR mode and presenting
  51729. */
  51730. IN_XR = 2,
  51731. /**
  51732. * Not entered XR mode
  51733. */
  51734. NOT_IN_XR = 3
  51735. }
  51736. /**
  51737. * Abstraction of the XR render target
  51738. */
  51739. export interface WebXRRenderTarget extends IDisposable {
  51740. /**
  51741. * xrpresent context of the canvas which can be used to display/mirror xr content
  51742. */
  51743. canvasContext: WebGLRenderingContext;
  51744. /**
  51745. * xr layer for the canvas
  51746. */
  51747. xrLayer: Nullable<XRWebGLLayer>;
  51748. /**
  51749. * Initializes the xr layer for the session
  51750. * @param xrSession xr session
  51751. * @returns a promise that will resolve once the XR Layer has been created
  51752. */
  51753. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51754. }
  51755. }
  51756. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  51757. import { Nullable } from "babylonjs/types";
  51758. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51759. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51760. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51761. import { Observable } from "babylonjs/Misc/observable";
  51762. /**
  51763. * COnfiguration object for WebXR output canvas
  51764. */
  51765. export class WebXRManagedOutputCanvasOptions {
  51766. /**
  51767. * An optional canvas in case you wish to create it yourself and provide it here.
  51768. * If not provided, a new canvas will be created
  51769. */
  51770. canvasElement?: HTMLCanvasElement;
  51771. /**
  51772. * Options for this XR Layer output
  51773. */
  51774. canvasOptions?: XRWebGLLayerOptions;
  51775. /**
  51776. * CSS styling for a newly created canvas (if not provided)
  51777. */
  51778. newCanvasCssStyle?: string;
  51779. /**
  51780. * Get the default values of the configuration object
  51781. * @param engine defines the engine to use (can be null)
  51782. * @returns default values of this configuration object
  51783. */
  51784. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  51785. }
  51786. /**
  51787. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  51788. */
  51789. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  51790. private _options;
  51791. private _canvas;
  51792. private _engine;
  51793. private _originalCanvasSize;
  51794. /**
  51795. * Rendering context of the canvas which can be used to display/mirror xr content
  51796. */
  51797. canvasContext: WebGLRenderingContext;
  51798. /**
  51799. * xr layer for the canvas
  51800. */
  51801. xrLayer: Nullable<XRWebGLLayer>;
  51802. /**
  51803. * Obseervers registered here will be triggered when the xr layer was initialized
  51804. */
  51805. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  51806. /**
  51807. * Initializes the canvas to be added/removed upon entering/exiting xr
  51808. * @param _xrSessionManager The XR Session manager
  51809. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  51810. */
  51811. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  51812. /**
  51813. * Disposes of the object
  51814. */
  51815. dispose(): void;
  51816. /**
  51817. * Initializes the xr layer for the session
  51818. * @param xrSession xr session
  51819. * @returns a promise that will resolve once the XR Layer has been created
  51820. */
  51821. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51822. private _addCanvas;
  51823. private _removeCanvas;
  51824. private _setCanvasSize;
  51825. private _setManagedOutputCanvas;
  51826. }
  51827. }
  51828. declare module "babylonjs/XR/webXRSessionManager" {
  51829. import { Observable } from "babylonjs/Misc/observable";
  51830. import { Nullable } from "babylonjs/types";
  51831. import { IDisposable, Scene } from "babylonjs/scene";
  51832. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51833. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51834. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51835. /**
  51836. * Manages an XRSession to work with Babylon's engine
  51837. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  51838. */
  51839. export class WebXRSessionManager implements IDisposable {
  51840. /** The scene which the session should be created for */
  51841. scene: Scene;
  51842. private _referenceSpace;
  51843. private _rttProvider;
  51844. private _sessionEnded;
  51845. private _xrNavigator;
  51846. private baseLayer;
  51847. /**
  51848. * The base reference space from which the session started. good if you want to reset your
  51849. * reference space
  51850. */
  51851. baseReferenceSpace: XRReferenceSpace;
  51852. /**
  51853. * Current XR frame
  51854. */
  51855. currentFrame: Nullable<XRFrame>;
  51856. /** WebXR timestamp updated every frame */
  51857. currentTimestamp: number;
  51858. /**
  51859. * Used just in case of a failure to initialize an immersive session.
  51860. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  51861. */
  51862. defaultHeightCompensation: number;
  51863. /**
  51864. * Fires every time a new xrFrame arrives which can be used to update the camera
  51865. */
  51866. onXRFrameObservable: Observable<XRFrame>;
  51867. /**
  51868. * Fires when the reference space changed
  51869. */
  51870. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  51871. /**
  51872. * Fires when the xr session is ended either by the device or manually done
  51873. */
  51874. onXRSessionEnded: Observable<any>;
  51875. /**
  51876. * Fires when the xr session is ended either by the device or manually done
  51877. */
  51878. onXRSessionInit: Observable<XRSession>;
  51879. /**
  51880. * Underlying xr session
  51881. */
  51882. session: XRSession;
  51883. /**
  51884. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  51885. * or get the offset the player is currently at.
  51886. */
  51887. viewerReferenceSpace: XRReferenceSpace;
  51888. /**
  51889. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  51890. * @param scene The scene which the session should be created for
  51891. */
  51892. constructor(
  51893. /** The scene which the session should be created for */
  51894. scene: Scene);
  51895. /**
  51896. * The current reference space used in this session. This reference space can constantly change!
  51897. * It is mainly used to offset the camera's position.
  51898. */
  51899. get referenceSpace(): XRReferenceSpace;
  51900. /**
  51901. * Set a new reference space and triggers the observable
  51902. */
  51903. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  51904. /**
  51905. * Disposes of the session manager
  51906. */
  51907. dispose(): void;
  51908. /**
  51909. * Stops the xrSession and restores the render loop
  51910. * @returns Promise which resolves after it exits XR
  51911. */
  51912. exitXRAsync(): Promise<void>;
  51913. /**
  51914. * Gets the correct render target texture to be rendered this frame for this eye
  51915. * @param eye the eye for which to get the render target
  51916. * @returns the render target for the specified eye
  51917. */
  51918. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  51919. /**
  51920. * Creates a WebXRRenderTarget object for the XR session
  51921. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  51922. * @param options optional options to provide when creating a new render target
  51923. * @returns a WebXR render target to which the session can render
  51924. */
  51925. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  51926. /**
  51927. * Initializes the manager
  51928. * After initialization enterXR can be called to start an XR session
  51929. * @returns Promise which resolves after it is initialized
  51930. */
  51931. initializeAsync(): Promise<void>;
  51932. /**
  51933. * Initializes an xr session
  51934. * @param xrSessionMode mode to initialize
  51935. * @param xrSessionInit defines optional and required values to pass to the session builder
  51936. * @returns a promise which will resolve once the session has been initialized
  51937. */
  51938. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  51939. /**
  51940. * Checks if a session would be supported for the creation options specified
  51941. * @param sessionMode session mode to check if supported eg. immersive-vr
  51942. * @returns A Promise that resolves to true if supported and false if not
  51943. */
  51944. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  51945. /**
  51946. * Resets the reference space to the one started the session
  51947. */
  51948. resetReferenceSpace(): void;
  51949. /**
  51950. * Starts rendering to the xr layer
  51951. */
  51952. runXRRenderLoop(): void;
  51953. /**
  51954. * Sets the reference space on the xr session
  51955. * @param referenceSpaceType space to set
  51956. * @returns a promise that will resolve once the reference space has been set
  51957. */
  51958. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  51959. /**
  51960. * Updates the render state of the session
  51961. * @param state state to set
  51962. * @returns a promise that resolves once the render state has been updated
  51963. */
  51964. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  51965. /**
  51966. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  51967. * @param sessionMode defines the session to test
  51968. * @returns a promise with boolean as final value
  51969. */
  51970. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  51971. private _createRenderTargetTexture;
  51972. }
  51973. }
  51974. declare module "babylonjs/XR/webXRCamera" {
  51975. import { Vector3 } from "babylonjs/Maths/math.vector";
  51976. import { Scene } from "babylonjs/scene";
  51977. import { Camera } from "babylonjs/Cameras/camera";
  51978. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51979. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51980. import { Observable } from "babylonjs/Misc/observable";
  51981. /**
  51982. * WebXR Camera which holds the views for the xrSession
  51983. * @see https://doc.babylonjs.com/how_to/webxr_camera
  51984. */
  51985. export class WebXRCamera extends FreeCamera {
  51986. private _xrSessionManager;
  51987. private _firstFrame;
  51988. private _referenceQuaternion;
  51989. private _referencedPosition;
  51990. private _xrInvPositionCache;
  51991. private _xrInvQuaternionCache;
  51992. /**
  51993. * Observable raised before camera teleportation
  51994. */
  51995. onBeforeCameraTeleport: Observable<Vector3>;
  51996. /**
  51997. * Observable raised after camera teleportation
  51998. */
  51999. onAfterCameraTeleport: Observable<Vector3>;
  52000. /**
  52001. * Should position compensation execute on first frame.
  52002. * This is used when copying the position from a native (non XR) camera
  52003. */
  52004. compensateOnFirstFrame: boolean;
  52005. /**
  52006. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52007. * @param name the name of the camera
  52008. * @param scene the scene to add the camera to
  52009. * @param _xrSessionManager a constructed xr session manager
  52010. */
  52011. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52012. /**
  52013. * Return the user's height, unrelated to the current ground.
  52014. * This will be the y position of this camera, when ground level is 0.
  52015. */
  52016. get realWorldHeight(): number;
  52017. /** @hidden */
  52018. _updateForDualEyeDebugging(): void;
  52019. /**
  52020. * Sets this camera's transformation based on a non-vr camera
  52021. * @param otherCamera the non-vr camera to copy the transformation from
  52022. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52023. */
  52024. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52025. /**
  52026. * Gets the current instance class name ("WebXRCamera").
  52027. * @returns the class name
  52028. */
  52029. getClassName(): string;
  52030. private _rotate180;
  52031. private _updateFromXRSession;
  52032. private _updateNumberOfRigCameras;
  52033. private _updateReferenceSpace;
  52034. private _updateReferenceSpaceOffset;
  52035. }
  52036. }
  52037. declare module "babylonjs/XR/webXRFeaturesManager" {
  52038. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52039. import { IDisposable } from "babylonjs/scene";
  52040. /**
  52041. * Defining the interface required for a (webxr) feature
  52042. */
  52043. export interface IWebXRFeature extends IDisposable {
  52044. /**
  52045. * Is this feature attached
  52046. */
  52047. attached: boolean;
  52048. /**
  52049. * Should auto-attach be disabled?
  52050. */
  52051. disableAutoAttach: boolean;
  52052. /**
  52053. * Attach the feature to the session
  52054. * Will usually be called by the features manager
  52055. *
  52056. * @param force should attachment be forced (even when already attached)
  52057. * @returns true if successful.
  52058. */
  52059. attach(force?: boolean): boolean;
  52060. /**
  52061. * Detach the feature from the session
  52062. * Will usually be called by the features manager
  52063. *
  52064. * @returns true if successful.
  52065. */
  52066. detach(): boolean;
  52067. /**
  52068. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52069. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52070. *
  52071. * @returns whether or not the feature is compatible in this environment
  52072. */
  52073. isCompatible(): boolean;
  52074. /**
  52075. * Was this feature disposed;
  52076. */
  52077. isDisposed: boolean;
  52078. /**
  52079. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52080. */
  52081. xrNativeFeatureName?: string;
  52082. /**
  52083. * A list of (Babylon WebXR) features this feature depends on
  52084. */
  52085. dependsOn?: string[];
  52086. }
  52087. /**
  52088. * A list of the currently available features without referencing them
  52089. */
  52090. export class WebXRFeatureName {
  52091. /**
  52092. * The name of the anchor system feature
  52093. */
  52094. static readonly ANCHOR_SYSTEM: string;
  52095. /**
  52096. * The name of the background remover feature
  52097. */
  52098. static readonly BACKGROUND_REMOVER: string;
  52099. /**
  52100. * The name of the hit test feature
  52101. */
  52102. static readonly HIT_TEST: string;
  52103. /**
  52104. * physics impostors for xr controllers feature
  52105. */
  52106. static readonly PHYSICS_CONTROLLERS: string;
  52107. /**
  52108. * The name of the plane detection feature
  52109. */
  52110. static readonly PLANE_DETECTION: string;
  52111. /**
  52112. * The name of the pointer selection feature
  52113. */
  52114. static readonly POINTER_SELECTION: string;
  52115. /**
  52116. * The name of the teleportation feature
  52117. */
  52118. static readonly TELEPORTATION: string;
  52119. /**
  52120. * The name of the feature points feature.
  52121. */
  52122. static readonly FEATURE_POINTS: string;
  52123. /**
  52124. * The name of the hand tracking feature.
  52125. */
  52126. static readonly HAND_TRACKING: string;
  52127. }
  52128. /**
  52129. * Defining the constructor of a feature. Used to register the modules.
  52130. */
  52131. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52132. /**
  52133. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52134. * It is mainly used in AR sessions.
  52135. *
  52136. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52137. */
  52138. export class WebXRFeaturesManager implements IDisposable {
  52139. private _xrSessionManager;
  52140. private static readonly _AvailableFeatures;
  52141. private _features;
  52142. /**
  52143. * constructs a new features manages.
  52144. *
  52145. * @param _xrSessionManager an instance of WebXRSessionManager
  52146. */
  52147. constructor(_xrSessionManager: WebXRSessionManager);
  52148. /**
  52149. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52150. * Mainly used internally.
  52151. *
  52152. * @param featureName the name of the feature to register
  52153. * @param constructorFunction the function used to construct the module
  52154. * @param version the (babylon) version of the module
  52155. * @param stable is that a stable version of this module
  52156. */
  52157. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52158. /**
  52159. * Returns a constructor of a specific feature.
  52160. *
  52161. * @param featureName the name of the feature to construct
  52162. * @param version the version of the feature to load
  52163. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52164. * @param options optional options provided to the module.
  52165. * @returns a function that, when called, will return a new instance of this feature
  52166. */
  52167. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52168. /**
  52169. * Can be used to return the list of features currently registered
  52170. *
  52171. * @returns an Array of available features
  52172. */
  52173. static GetAvailableFeatures(): string[];
  52174. /**
  52175. * Gets the versions available for a specific feature
  52176. * @param featureName the name of the feature
  52177. * @returns an array with the available versions
  52178. */
  52179. static GetAvailableVersions(featureName: string): string[];
  52180. /**
  52181. * Return the latest unstable version of this feature
  52182. * @param featureName the name of the feature to search
  52183. * @returns the version number. if not found will return -1
  52184. */
  52185. static GetLatestVersionOfFeature(featureName: string): number;
  52186. /**
  52187. * Return the latest stable version of this feature
  52188. * @param featureName the name of the feature to search
  52189. * @returns the version number. if not found will return -1
  52190. */
  52191. static GetStableVersionOfFeature(featureName: string): number;
  52192. /**
  52193. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52194. * Can be used during a session to start a feature
  52195. * @param featureName the name of feature to attach
  52196. */
  52197. attachFeature(featureName: string): void;
  52198. /**
  52199. * Can be used inside a session or when the session ends to detach a specific feature
  52200. * @param featureName the name of the feature to detach
  52201. */
  52202. detachFeature(featureName: string): void;
  52203. /**
  52204. * Used to disable an already-enabled feature
  52205. * The feature will be disposed and will be recreated once enabled.
  52206. * @param featureName the feature to disable
  52207. * @returns true if disable was successful
  52208. */
  52209. disableFeature(featureName: string | {
  52210. Name: string;
  52211. }): boolean;
  52212. /**
  52213. * dispose this features manager
  52214. */
  52215. dispose(): void;
  52216. /**
  52217. * 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.
  52218. * 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.
  52219. *
  52220. * @param featureName the name of the feature to load or the class of the feature
  52221. * @param version optional version to load. if not provided the latest version will be enabled
  52222. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52223. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52224. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52225. * @returns a new constructed feature or throws an error if feature not found.
  52226. */
  52227. enableFeature(featureName: string | {
  52228. Name: string;
  52229. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52230. /**
  52231. * get the implementation of an enabled feature.
  52232. * @param featureName the name of the feature to load
  52233. * @returns the feature class, if found
  52234. */
  52235. getEnabledFeature(featureName: string): IWebXRFeature;
  52236. /**
  52237. * Get the list of enabled features
  52238. * @returns an array of enabled features
  52239. */
  52240. getEnabledFeatures(): string[];
  52241. /**
  52242. * This function will exten the session creation configuration object with enabled features.
  52243. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  52244. * according to the defined "required" variable, provided during enableFeature call
  52245. * @param xrSessionInit the xr Session init object to extend
  52246. *
  52247. * @returns an extended XRSessionInit object
  52248. */
  52249. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  52250. }
  52251. }
  52252. declare module "babylonjs/XR/webXRExperienceHelper" {
  52253. import { Observable } from "babylonjs/Misc/observable";
  52254. import { IDisposable, Scene } from "babylonjs/scene";
  52255. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52256. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  52257. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52258. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  52259. /**
  52260. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  52261. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  52262. */
  52263. export class WebXRExperienceHelper implements IDisposable {
  52264. private scene;
  52265. private _nonVRCamera;
  52266. private _originalSceneAutoClear;
  52267. private _supported;
  52268. /**
  52269. * Camera used to render xr content
  52270. */
  52271. camera: WebXRCamera;
  52272. /** A features manager for this xr session */
  52273. featuresManager: WebXRFeaturesManager;
  52274. /**
  52275. * Observers registered here will be triggered after the camera's initial transformation is set
  52276. * This can be used to set a different ground level or an extra rotation.
  52277. *
  52278. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  52279. * to the position set after this observable is done executing.
  52280. */
  52281. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  52282. /**
  52283. * Fires when the state of the experience helper has changed
  52284. */
  52285. onStateChangedObservable: Observable<WebXRState>;
  52286. /** Session manager used to keep track of xr session */
  52287. sessionManager: WebXRSessionManager;
  52288. /**
  52289. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  52290. */
  52291. state: WebXRState;
  52292. /**
  52293. * Creates a WebXRExperienceHelper
  52294. * @param scene The scene the helper should be created in
  52295. */
  52296. private constructor();
  52297. /**
  52298. * Creates the experience helper
  52299. * @param scene the scene to attach the experience helper to
  52300. * @returns a promise for the experience helper
  52301. */
  52302. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  52303. /**
  52304. * Disposes of the experience helper
  52305. */
  52306. dispose(): void;
  52307. /**
  52308. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  52309. * @param sessionMode options for the XR session
  52310. * @param referenceSpaceType frame of reference of the XR session
  52311. * @param renderTarget the output canvas that will be used to enter XR mode
  52312. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  52313. * @returns promise that resolves after xr mode has entered
  52314. */
  52315. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  52316. /**
  52317. * Exits XR mode and returns the scene to its original state
  52318. * @returns promise that resolves after xr mode has exited
  52319. */
  52320. exitXRAsync(): Promise<void>;
  52321. private _nonXRToXRCamera;
  52322. private _setState;
  52323. }
  52324. }
  52325. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  52326. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  52327. import { Observable } from "babylonjs/Misc/observable";
  52328. import { IDisposable } from "babylonjs/scene";
  52329. /**
  52330. * X-Y values for axes in WebXR
  52331. */
  52332. export interface IWebXRMotionControllerAxesValue {
  52333. /**
  52334. * The value of the x axis
  52335. */
  52336. x: number;
  52337. /**
  52338. * The value of the y-axis
  52339. */
  52340. y: number;
  52341. }
  52342. /**
  52343. * changed / previous values for the values of this component
  52344. */
  52345. export interface IWebXRMotionControllerComponentChangesValues<T> {
  52346. /**
  52347. * current (this frame) value
  52348. */
  52349. current: T;
  52350. /**
  52351. * previous (last change) value
  52352. */
  52353. previous: T;
  52354. }
  52355. /**
  52356. * Represents changes in the component between current frame and last values recorded
  52357. */
  52358. export interface IWebXRMotionControllerComponentChanges {
  52359. /**
  52360. * will be populated with previous and current values if axes changed
  52361. */
  52362. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  52363. /**
  52364. * will be populated with previous and current values if pressed changed
  52365. */
  52366. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52367. /**
  52368. * will be populated with previous and current values if touched changed
  52369. */
  52370. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52371. /**
  52372. * will be populated with previous and current values if value changed
  52373. */
  52374. value?: IWebXRMotionControllerComponentChangesValues<number>;
  52375. }
  52376. /**
  52377. * This class represents a single component (for example button or thumbstick) of a motion controller
  52378. */
  52379. export class WebXRControllerComponent implements IDisposable {
  52380. /**
  52381. * the id of this component
  52382. */
  52383. id: string;
  52384. /**
  52385. * the type of the component
  52386. */
  52387. type: MotionControllerComponentType;
  52388. private _buttonIndex;
  52389. private _axesIndices;
  52390. private _axes;
  52391. private _changes;
  52392. private _currentValue;
  52393. private _hasChanges;
  52394. private _pressed;
  52395. private _touched;
  52396. /**
  52397. * button component type
  52398. */
  52399. static BUTTON_TYPE: MotionControllerComponentType;
  52400. /**
  52401. * squeeze component type
  52402. */
  52403. static SQUEEZE_TYPE: MotionControllerComponentType;
  52404. /**
  52405. * Thumbstick component type
  52406. */
  52407. static THUMBSTICK_TYPE: MotionControllerComponentType;
  52408. /**
  52409. * Touchpad component type
  52410. */
  52411. static TOUCHPAD_TYPE: MotionControllerComponentType;
  52412. /**
  52413. * trigger component type
  52414. */
  52415. static TRIGGER_TYPE: MotionControllerComponentType;
  52416. /**
  52417. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  52418. * the axes data changes
  52419. */
  52420. onAxisValueChangedObservable: Observable<{
  52421. x: number;
  52422. y: number;
  52423. }>;
  52424. /**
  52425. * Observers registered here will be triggered when the state of a button changes
  52426. * State change is either pressed / touched / value
  52427. */
  52428. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  52429. /**
  52430. * Creates a new component for a motion controller.
  52431. * It is created by the motion controller itself
  52432. *
  52433. * @param id the id of this component
  52434. * @param type the type of the component
  52435. * @param _buttonIndex index in the buttons array of the gamepad
  52436. * @param _axesIndices indices of the values in the axes array of the gamepad
  52437. */
  52438. constructor(
  52439. /**
  52440. * the id of this component
  52441. */
  52442. id: string,
  52443. /**
  52444. * the type of the component
  52445. */
  52446. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  52447. /**
  52448. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  52449. */
  52450. get axes(): IWebXRMotionControllerAxesValue;
  52451. /**
  52452. * Get the changes. Elements will be populated only if they changed with their previous and current value
  52453. */
  52454. get changes(): IWebXRMotionControllerComponentChanges;
  52455. /**
  52456. * Return whether or not the component changed the last frame
  52457. */
  52458. get hasChanges(): boolean;
  52459. /**
  52460. * is the button currently pressed
  52461. */
  52462. get pressed(): boolean;
  52463. /**
  52464. * is the button currently touched
  52465. */
  52466. get touched(): boolean;
  52467. /**
  52468. * Get the current value of this component
  52469. */
  52470. get value(): number;
  52471. /**
  52472. * Dispose this component
  52473. */
  52474. dispose(): void;
  52475. /**
  52476. * Are there axes correlating to this component
  52477. * @return true is axes data is available
  52478. */
  52479. isAxes(): boolean;
  52480. /**
  52481. * Is this component a button (hence - pressable)
  52482. * @returns true if can be pressed
  52483. */
  52484. isButton(): boolean;
  52485. /**
  52486. * update this component using the gamepad object it is in. Called on every frame
  52487. * @param nativeController the native gamepad controller object
  52488. */
  52489. update(nativeController: IMinimalMotionControllerObject): void;
  52490. }
  52491. }
  52492. declare module "babylonjs/Loading/sceneLoader" {
  52493. import { Observable } from "babylonjs/Misc/observable";
  52494. import { Nullable } from "babylonjs/types";
  52495. import { Scene } from "babylonjs/scene";
  52496. import { Engine } from "babylonjs/Engines/engine";
  52497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52498. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  52499. import { AssetContainer } from "babylonjs/assetContainer";
  52500. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52501. import { Skeleton } from "babylonjs/Bones/skeleton";
  52502. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  52503. import { WebRequest } from "babylonjs/Misc/webRequest";
  52504. /**
  52505. * Interface used to represent data loading progression
  52506. */
  52507. export interface ISceneLoaderProgressEvent {
  52508. /**
  52509. * Defines if data length to load can be evaluated
  52510. */
  52511. readonly lengthComputable: boolean;
  52512. /**
  52513. * Defines the loaded data length
  52514. */
  52515. readonly loaded: number;
  52516. /**
  52517. * Defines the data length to load
  52518. */
  52519. readonly total: number;
  52520. }
  52521. /**
  52522. * Interface used by SceneLoader plugins to define supported file extensions
  52523. */
  52524. export interface ISceneLoaderPluginExtensions {
  52525. /**
  52526. * Defines the list of supported extensions
  52527. */
  52528. [extension: string]: {
  52529. isBinary: boolean;
  52530. };
  52531. }
  52532. /**
  52533. * Interface used by SceneLoader plugin factory
  52534. */
  52535. export interface ISceneLoaderPluginFactory {
  52536. /**
  52537. * Defines the name of the factory
  52538. */
  52539. name: string;
  52540. /**
  52541. * Function called to create a new plugin
  52542. * @return the new plugin
  52543. */
  52544. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  52545. /**
  52546. * The callback that returns true if the data can be directly loaded.
  52547. * @param data string containing the file data
  52548. * @returns if the data can be loaded directly
  52549. */
  52550. canDirectLoad?(data: string): boolean;
  52551. }
  52552. /**
  52553. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  52554. */
  52555. export interface ISceneLoaderPluginBase {
  52556. /**
  52557. * The friendly name of this plugin.
  52558. */
  52559. name: string;
  52560. /**
  52561. * The file extensions supported by this plugin.
  52562. */
  52563. extensions: string | ISceneLoaderPluginExtensions;
  52564. /**
  52565. * The callback called when loading from a url.
  52566. * @param scene scene loading this url
  52567. * @param url url to load
  52568. * @param onSuccess callback called when the file successfully loads
  52569. * @param onProgress callback called while file is loading (if the server supports this mode)
  52570. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  52571. * @param onError callback called when the file fails to load
  52572. * @returns a file request object
  52573. */
  52574. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52575. /**
  52576. * The callback called when loading from a file object.
  52577. * @param scene scene loading this file
  52578. * @param file defines the file to load
  52579. * @param onSuccess defines the callback to call when data is loaded
  52580. * @param onProgress defines the callback to call during loading process
  52581. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  52582. * @param onError defines the callback to call when an error occurs
  52583. * @returns a file request object
  52584. */
  52585. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52586. /**
  52587. * The callback that returns true if the data can be directly loaded.
  52588. * @param data string containing the file data
  52589. * @returns if the data can be loaded directly
  52590. */
  52591. canDirectLoad?(data: string): boolean;
  52592. /**
  52593. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  52594. * @param scene scene loading this data
  52595. * @param data string containing the data
  52596. * @returns data to pass to the plugin
  52597. */
  52598. directLoad?(scene: Scene, data: string): any;
  52599. /**
  52600. * The callback that allows custom handling of the root url based on the response url.
  52601. * @param rootUrl the original root url
  52602. * @param responseURL the response url if available
  52603. * @returns the new root url
  52604. */
  52605. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  52606. }
  52607. /**
  52608. * Interface used to define a SceneLoader plugin
  52609. */
  52610. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  52611. /**
  52612. * Import meshes into a scene.
  52613. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52614. * @param scene The scene to import into
  52615. * @param data The data to import
  52616. * @param rootUrl The root url for scene and resources
  52617. * @param meshes The meshes array to import into
  52618. * @param particleSystems The particle systems array to import into
  52619. * @param skeletons The skeletons array to import into
  52620. * @param onError The callback when import fails
  52621. * @returns True if successful or false otherwise
  52622. */
  52623. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  52624. /**
  52625. * Load into a scene.
  52626. * @param scene The scene to load into
  52627. * @param data The data to import
  52628. * @param rootUrl The root url for scene and resources
  52629. * @param onError The callback when import fails
  52630. * @returns True if successful or false otherwise
  52631. */
  52632. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  52633. /**
  52634. * Load into an asset container.
  52635. * @param scene The scene to load into
  52636. * @param data The data to import
  52637. * @param rootUrl The root url for scene and resources
  52638. * @param onError The callback when import fails
  52639. * @returns The loaded asset container
  52640. */
  52641. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  52642. }
  52643. /**
  52644. * Interface used to define an async SceneLoader plugin
  52645. */
  52646. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  52647. /**
  52648. * Import meshes into a scene.
  52649. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52650. * @param scene The scene to import into
  52651. * @param data The data to import
  52652. * @param rootUrl The root url for scene and resources
  52653. * @param onProgress The callback when the load progresses
  52654. * @param fileName Defines the name of the file to load
  52655. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  52656. */
  52657. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  52658. meshes: AbstractMesh[];
  52659. particleSystems: IParticleSystem[];
  52660. skeletons: Skeleton[];
  52661. animationGroups: AnimationGroup[];
  52662. }>;
  52663. /**
  52664. * Load into a scene.
  52665. * @param scene The scene to load into
  52666. * @param data The data to import
  52667. * @param rootUrl The root url for scene and resources
  52668. * @param onProgress The callback when the load progresses
  52669. * @param fileName Defines the name of the file to load
  52670. * @returns Nothing
  52671. */
  52672. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  52673. /**
  52674. * Load into an asset container.
  52675. * @param scene The scene to load into
  52676. * @param data The data to import
  52677. * @param rootUrl The root url for scene and resources
  52678. * @param onProgress The callback when the load progresses
  52679. * @param fileName Defines the name of the file to load
  52680. * @returns The loaded asset container
  52681. */
  52682. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  52683. }
  52684. /**
  52685. * Mode that determines how to handle old animation groups before loading new ones.
  52686. */
  52687. export enum SceneLoaderAnimationGroupLoadingMode {
  52688. /**
  52689. * Reset all old animations to initial state then dispose them.
  52690. */
  52691. Clean = 0,
  52692. /**
  52693. * Stop all old animations.
  52694. */
  52695. Stop = 1,
  52696. /**
  52697. * Restart old animations from first frame.
  52698. */
  52699. Sync = 2,
  52700. /**
  52701. * Old animations remains untouched.
  52702. */
  52703. NoSync = 3
  52704. }
  52705. /**
  52706. * Defines a plugin registered by the SceneLoader
  52707. */
  52708. interface IRegisteredPlugin {
  52709. /**
  52710. * Defines the plugin to use
  52711. */
  52712. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52713. /**
  52714. * Defines if the plugin supports binary data
  52715. */
  52716. isBinary: boolean;
  52717. }
  52718. /**
  52719. * Class used to load scene from various file formats using registered plugins
  52720. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  52721. */
  52722. export class SceneLoader {
  52723. /**
  52724. * No logging while loading
  52725. */
  52726. static readonly NO_LOGGING: number;
  52727. /**
  52728. * Minimal logging while loading
  52729. */
  52730. static readonly MINIMAL_LOGGING: number;
  52731. /**
  52732. * Summary logging while loading
  52733. */
  52734. static readonly SUMMARY_LOGGING: number;
  52735. /**
  52736. * Detailled logging while loading
  52737. */
  52738. static readonly DETAILED_LOGGING: number;
  52739. /**
  52740. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  52741. */
  52742. static get ForceFullSceneLoadingForIncremental(): boolean;
  52743. static set ForceFullSceneLoadingForIncremental(value: boolean);
  52744. /**
  52745. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  52746. */
  52747. static get ShowLoadingScreen(): boolean;
  52748. static set ShowLoadingScreen(value: boolean);
  52749. /**
  52750. * Defines the current logging level (while loading the scene)
  52751. * @ignorenaming
  52752. */
  52753. static get loggingLevel(): number;
  52754. static set loggingLevel(value: number);
  52755. /**
  52756. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  52757. */
  52758. static get CleanBoneMatrixWeights(): boolean;
  52759. static set CleanBoneMatrixWeights(value: boolean);
  52760. /**
  52761. * Event raised when a plugin is used to load a scene
  52762. */
  52763. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  52764. private static _registeredPlugins;
  52765. private static _showingLoadingScreen;
  52766. /**
  52767. * Gets the default plugin (used to load Babylon files)
  52768. * @returns the .babylon plugin
  52769. */
  52770. static GetDefaultPlugin(): IRegisteredPlugin;
  52771. private static _GetPluginForExtension;
  52772. private static _GetPluginForDirectLoad;
  52773. private static _GetPluginForFilename;
  52774. private static _GetDirectLoad;
  52775. private static _LoadData;
  52776. private static _GetFileInfo;
  52777. /**
  52778. * Gets a plugin that can load the given extension
  52779. * @param extension defines the extension to load
  52780. * @returns a plugin or null if none works
  52781. */
  52782. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52783. /**
  52784. * Gets a boolean indicating that the given extension can be loaded
  52785. * @param extension defines the extension to load
  52786. * @returns true if the extension is supported
  52787. */
  52788. static IsPluginForExtensionAvailable(extension: string): boolean;
  52789. /**
  52790. * Adds a new plugin to the list of registered plugins
  52791. * @param plugin defines the plugin to add
  52792. */
  52793. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  52794. /**
  52795. * Import meshes into a scene
  52796. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52797. * @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)
  52798. * @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)
  52799. * @param scene the instance of BABYLON.Scene to append to
  52800. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  52801. * @param onProgress a callback with a progress event for each file being loaded
  52802. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52803. * @param pluginExtension the extension used to determine the plugin
  52804. * @returns The loaded plugin
  52805. */
  52806. 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>;
  52807. /**
  52808. * Import meshes into a scene
  52809. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52810. * @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)
  52811. * @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)
  52812. * @param scene the instance of BABYLON.Scene to append to
  52813. * @param onProgress a callback with a progress event for each file being loaded
  52814. * @param pluginExtension the extension used to determine the plugin
  52815. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  52816. */
  52817. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  52818. meshes: AbstractMesh[];
  52819. particleSystems: IParticleSystem[];
  52820. skeletons: Skeleton[];
  52821. animationGroups: AnimationGroup[];
  52822. }>;
  52823. /**
  52824. * Load a scene
  52825. * @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)
  52826. * @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)
  52827. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52828. * @param onSuccess a callback with the scene when import succeeds
  52829. * @param onProgress a callback with a progress event for each file being loaded
  52830. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52831. * @param pluginExtension the extension used to determine the plugin
  52832. * @returns The loaded plugin
  52833. */
  52834. 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>;
  52835. /**
  52836. * Load a scene
  52837. * @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)
  52838. * @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)
  52839. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52840. * @param onProgress a callback with a progress event for each file being loaded
  52841. * @param pluginExtension the extension used to determine the plugin
  52842. * @returns The loaded scene
  52843. */
  52844. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  52845. /**
  52846. * Append a scene
  52847. * @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)
  52848. * @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)
  52849. * @param scene is the instance of BABYLON.Scene to append to
  52850. * @param onSuccess a callback with the scene when import succeeds
  52851. * @param onProgress a callback with a progress event for each file being loaded
  52852. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52853. * @param pluginExtension the extension used to determine the plugin
  52854. * @returns The loaded plugin
  52855. */
  52856. 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>;
  52857. /**
  52858. * Append a scene
  52859. * @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)
  52860. * @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)
  52861. * @param scene is the instance of BABYLON.Scene to append to
  52862. * @param onProgress a callback with a progress event for each file being loaded
  52863. * @param pluginExtension the extension used to determine the plugin
  52864. * @returns The given scene
  52865. */
  52866. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  52867. /**
  52868. * Load a scene into an asset container
  52869. * @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)
  52870. * @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)
  52871. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  52872. * @param onSuccess a callback with the scene when import succeeds
  52873. * @param onProgress a callback with a progress event for each file being loaded
  52874. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52875. * @param pluginExtension the extension used to determine the plugin
  52876. * @returns The loaded plugin
  52877. */
  52878. 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>;
  52879. /**
  52880. * Load a scene into an asset container
  52881. * @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)
  52882. * @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)
  52883. * @param scene is the instance of Scene to append to
  52884. * @param onProgress a callback with a progress event for each file being loaded
  52885. * @param pluginExtension the extension used to determine the plugin
  52886. * @returns The loaded asset container
  52887. */
  52888. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  52889. /**
  52890. * Import animations from a file into a scene
  52891. * @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)
  52892. * @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)
  52893. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  52894. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  52895. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  52896. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  52897. * @param onSuccess a callback with the scene when import succeeds
  52898. * @param onProgress a callback with a progress event for each file being loaded
  52899. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52900. * @param pluginExtension the extension used to determine the plugin
  52901. */
  52902. 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;
  52903. /**
  52904. * Import animations from a file into a scene
  52905. * @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)
  52906. * @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)
  52907. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  52908. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  52909. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  52910. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  52911. * @param onSuccess a callback with the scene when import succeeds
  52912. * @param onProgress a callback with a progress event for each file being loaded
  52913. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52914. * @param pluginExtension the extension used to determine the plugin
  52915. * @returns the updated scene with imported animations
  52916. */
  52917. 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>;
  52918. }
  52919. }
  52920. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  52921. import { IDisposable, Scene } from "babylonjs/scene";
  52922. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  52923. import { Observable } from "babylonjs/Misc/observable";
  52924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52925. import { Nullable } from "babylonjs/types";
  52926. /**
  52927. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  52928. */
  52929. export type MotionControllerHandedness = "none" | "left" | "right";
  52930. /**
  52931. * The type of components available in motion controllers.
  52932. * This is not the name of the component.
  52933. */
  52934. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  52935. /**
  52936. * The state of a controller component
  52937. */
  52938. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  52939. /**
  52940. * The schema of motion controller layout.
  52941. * No object will be initialized using this interface
  52942. * This is used just to define the profile.
  52943. */
  52944. export interface IMotionControllerLayout {
  52945. /**
  52946. * Path to load the assets. Usually relative to the base path
  52947. */
  52948. assetPath: string;
  52949. /**
  52950. * Available components (unsorted)
  52951. */
  52952. components: {
  52953. /**
  52954. * A map of component Ids
  52955. */
  52956. [componentId: string]: {
  52957. /**
  52958. * The type of input the component outputs
  52959. */
  52960. type: MotionControllerComponentType;
  52961. /**
  52962. * The indices of this component in the gamepad object
  52963. */
  52964. gamepadIndices: {
  52965. /**
  52966. * Index of button
  52967. */
  52968. button?: number;
  52969. /**
  52970. * If available, index of x-axis
  52971. */
  52972. xAxis?: number;
  52973. /**
  52974. * If available, index of y-axis
  52975. */
  52976. yAxis?: number;
  52977. };
  52978. /**
  52979. * The mesh's root node name
  52980. */
  52981. rootNodeName: string;
  52982. /**
  52983. * Animation definitions for this model
  52984. */
  52985. visualResponses: {
  52986. [stateKey: string]: {
  52987. /**
  52988. * What property will be animated
  52989. */
  52990. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  52991. /**
  52992. * What states influence this visual response
  52993. */
  52994. states: MotionControllerComponentStateType[];
  52995. /**
  52996. * Type of animation - movement or visibility
  52997. */
  52998. valueNodeProperty: "transform" | "visibility";
  52999. /**
  53000. * Base node name to move. Its position will be calculated according to the min and max nodes
  53001. */
  53002. valueNodeName?: string;
  53003. /**
  53004. * Minimum movement node
  53005. */
  53006. minNodeName?: string;
  53007. /**
  53008. * Max movement node
  53009. */
  53010. maxNodeName?: string;
  53011. };
  53012. };
  53013. /**
  53014. * If touch enabled, what is the name of node to display user feedback
  53015. */
  53016. touchPointNodeName?: string;
  53017. };
  53018. };
  53019. /**
  53020. * Is it xr standard mapping or not
  53021. */
  53022. gamepadMapping: "" | "xr-standard";
  53023. /**
  53024. * Base root node of this entire model
  53025. */
  53026. rootNodeName: string;
  53027. /**
  53028. * Defines the main button component id
  53029. */
  53030. selectComponentId: string;
  53031. }
  53032. /**
  53033. * A definition for the layout map in the input profile
  53034. */
  53035. export interface IMotionControllerLayoutMap {
  53036. /**
  53037. * Layouts with handedness type as a key
  53038. */
  53039. [handedness: string]: IMotionControllerLayout;
  53040. }
  53041. /**
  53042. * The XR Input profile schema
  53043. * Profiles can be found here:
  53044. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53045. */
  53046. export interface IMotionControllerProfile {
  53047. /**
  53048. * fallback profiles for this profileId
  53049. */
  53050. fallbackProfileIds: string[];
  53051. /**
  53052. * The layout map, with handedness as key
  53053. */
  53054. layouts: IMotionControllerLayoutMap;
  53055. /**
  53056. * The id of this profile
  53057. * correlates to the profile(s) in the xrInput.profiles array
  53058. */
  53059. profileId: string;
  53060. }
  53061. /**
  53062. * A helper-interface for the 3 meshes needed for controller button animation
  53063. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53064. */
  53065. export interface IMotionControllerButtonMeshMap {
  53066. /**
  53067. * the mesh that defines the pressed value mesh position.
  53068. * This is used to find the max-position of this button
  53069. */
  53070. pressedMesh: AbstractMesh;
  53071. /**
  53072. * the mesh that defines the unpressed value mesh position.
  53073. * This is used to find the min (or initial) position of this button
  53074. */
  53075. unpressedMesh: AbstractMesh;
  53076. /**
  53077. * The mesh that will be changed when value changes
  53078. */
  53079. valueMesh: AbstractMesh;
  53080. }
  53081. /**
  53082. * A helper-interface for the 3 meshes needed for controller axis animation.
  53083. * This will be expanded when touchpad animations are fully supported
  53084. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53085. */
  53086. export interface IMotionControllerMeshMap {
  53087. /**
  53088. * the mesh that defines the maximum value mesh position.
  53089. */
  53090. maxMesh?: AbstractMesh;
  53091. /**
  53092. * the mesh that defines the minimum value mesh position.
  53093. */
  53094. minMesh?: AbstractMesh;
  53095. /**
  53096. * The mesh that will be changed when axis value changes
  53097. */
  53098. valueMesh?: AbstractMesh;
  53099. }
  53100. /**
  53101. * The elements needed for change-detection of the gamepad objects in motion controllers
  53102. */
  53103. export interface IMinimalMotionControllerObject {
  53104. /**
  53105. * Available axes of this controller
  53106. */
  53107. axes: number[];
  53108. /**
  53109. * An array of available buttons
  53110. */
  53111. buttons: Array<{
  53112. /**
  53113. * Value of the button/trigger
  53114. */
  53115. value: number;
  53116. /**
  53117. * If the button/trigger is currently touched
  53118. */
  53119. touched: boolean;
  53120. /**
  53121. * If the button/trigger is currently pressed
  53122. */
  53123. pressed: boolean;
  53124. }>;
  53125. /**
  53126. * EXPERIMENTAL haptic support.
  53127. */
  53128. hapticActuators?: Array<{
  53129. pulse: (value: number, duration: number) => Promise<boolean>;
  53130. }>;
  53131. }
  53132. /**
  53133. * An Abstract Motion controller
  53134. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53135. * Each component has an observable to check for changes in value and state
  53136. */
  53137. export abstract class WebXRAbstractMotionController implements IDisposable {
  53138. protected scene: Scene;
  53139. protected layout: IMotionControllerLayout;
  53140. /**
  53141. * The gamepad object correlating to this controller
  53142. */
  53143. gamepadObject: IMinimalMotionControllerObject;
  53144. /**
  53145. * handedness (left/right/none) of this controller
  53146. */
  53147. handedness: MotionControllerHandedness;
  53148. private _initComponent;
  53149. private _modelReady;
  53150. /**
  53151. * A map of components (WebXRControllerComponent) in this motion controller
  53152. * Components have a ComponentType and can also have both button and axis definitions
  53153. */
  53154. readonly components: {
  53155. [id: string]: WebXRControllerComponent;
  53156. };
  53157. /**
  53158. * Disable the model's animation. Can be set at any time.
  53159. */
  53160. disableAnimation: boolean;
  53161. /**
  53162. * Observers registered here will be triggered when the model of this controller is done loading
  53163. */
  53164. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53165. /**
  53166. * The profile id of this motion controller
  53167. */
  53168. abstract profileId: string;
  53169. /**
  53170. * The root mesh of the model. It is null if the model was not yet initialized
  53171. */
  53172. rootMesh: Nullable<AbstractMesh>;
  53173. /**
  53174. * constructs a new abstract motion controller
  53175. * @param scene the scene to which the model of the controller will be added
  53176. * @param layout The profile layout to load
  53177. * @param gamepadObject The gamepad object correlating to this controller
  53178. * @param handedness handedness (left/right/none) of this controller
  53179. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53180. */
  53181. constructor(scene: Scene, layout: IMotionControllerLayout,
  53182. /**
  53183. * The gamepad object correlating to this controller
  53184. */
  53185. gamepadObject: IMinimalMotionControllerObject,
  53186. /**
  53187. * handedness (left/right/none) of this controller
  53188. */
  53189. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53190. /**
  53191. * Dispose this controller, the model mesh and all its components
  53192. */
  53193. dispose(): void;
  53194. /**
  53195. * Returns all components of specific type
  53196. * @param type the type to search for
  53197. * @return an array of components with this type
  53198. */
  53199. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53200. /**
  53201. * get a component based an its component id as defined in layout.components
  53202. * @param id the id of the component
  53203. * @returns the component correlates to the id or undefined if not found
  53204. */
  53205. getComponent(id: string): WebXRControllerComponent;
  53206. /**
  53207. * Get the list of components available in this motion controller
  53208. * @returns an array of strings correlating to available components
  53209. */
  53210. getComponentIds(): string[];
  53211. /**
  53212. * Get the first component of specific type
  53213. * @param type type of component to find
  53214. * @return a controller component or null if not found
  53215. */
  53216. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  53217. /**
  53218. * Get the main (Select) component of this controller as defined in the layout
  53219. * @returns the main component of this controller
  53220. */
  53221. getMainComponent(): WebXRControllerComponent;
  53222. /**
  53223. * Loads the model correlating to this controller
  53224. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  53225. * @returns A promise fulfilled with the result of the model loading
  53226. */
  53227. loadModel(): Promise<boolean>;
  53228. /**
  53229. * Update this model using the current XRFrame
  53230. * @param xrFrame the current xr frame to use and update the model
  53231. */
  53232. updateFromXRFrame(xrFrame: XRFrame): void;
  53233. /**
  53234. * Backwards compatibility due to a deeply-integrated typo
  53235. */
  53236. get handness(): XREye;
  53237. /**
  53238. * Pulse (vibrate) this controller
  53239. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  53240. * Consecutive calls to this function will cancel the last pulse call
  53241. *
  53242. * @param value the strength of the pulse in 0.0...1.0 range
  53243. * @param duration Duration of the pulse in milliseconds
  53244. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  53245. * @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
  53246. */
  53247. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  53248. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53249. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53250. /**
  53251. * Moves the axis on the controller mesh based on its current state
  53252. * @param axis the index of the axis
  53253. * @param axisValue the value of the axis which determines the meshes new position
  53254. * @hidden
  53255. */
  53256. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  53257. /**
  53258. * Update the model itself with the current frame data
  53259. * @param xrFrame the frame to use for updating the model mesh
  53260. */
  53261. protected updateModel(xrFrame: XRFrame): void;
  53262. /**
  53263. * Get the filename and path for this controller's model
  53264. * @returns a map of filename and path
  53265. */
  53266. protected abstract _getFilenameAndPath(): {
  53267. filename: string;
  53268. path: string;
  53269. };
  53270. /**
  53271. * This function is called before the mesh is loaded. It checks for loading constraints.
  53272. * For example, this function can check if the GLB loader is available
  53273. * If this function returns false, the generic controller will be loaded instead
  53274. * @returns Is the client ready to load the mesh
  53275. */
  53276. protected abstract _getModelLoadingConstraints(): boolean;
  53277. /**
  53278. * This function will be called after the model was successfully loaded and can be used
  53279. * for mesh transformations before it is available for the user
  53280. * @param meshes the loaded meshes
  53281. */
  53282. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  53283. /**
  53284. * Set the root mesh for this controller. Important for the WebXR controller class
  53285. * @param meshes the loaded meshes
  53286. */
  53287. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  53288. /**
  53289. * A function executed each frame that updates the mesh (if needed)
  53290. * @param xrFrame the current xrFrame
  53291. */
  53292. protected abstract _updateModel(xrFrame: XRFrame): void;
  53293. private _getGenericFilenameAndPath;
  53294. private _getGenericParentMesh;
  53295. }
  53296. }
  53297. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  53298. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53300. import { Scene } from "babylonjs/scene";
  53301. /**
  53302. * A generic trigger-only motion controller for WebXR
  53303. */
  53304. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  53305. /**
  53306. * Static version of the profile id of this controller
  53307. */
  53308. static ProfileId: string;
  53309. profileId: string;
  53310. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  53311. protected _getFilenameAndPath(): {
  53312. filename: string;
  53313. path: string;
  53314. };
  53315. protected _getModelLoadingConstraints(): boolean;
  53316. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  53317. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53318. protected _updateModel(): void;
  53319. }
  53320. }
  53321. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  53322. import { Vector4 } from "babylonjs/Maths/math.vector";
  53323. import { Mesh } from "babylonjs/Meshes/mesh";
  53324. import { Scene } from "babylonjs/scene";
  53325. import { Nullable } from "babylonjs/types";
  53326. /**
  53327. * Class containing static functions to help procedurally build meshes
  53328. */
  53329. export class SphereBuilder {
  53330. /**
  53331. * Creates a sphere mesh
  53332. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53333. * * 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`)
  53334. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53335. * * 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
  53336. * * 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)
  53337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53340. * @param name defines the name of the mesh
  53341. * @param options defines the options used to create the mesh
  53342. * @param scene defines the hosting scene
  53343. * @returns the sphere mesh
  53344. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53345. */
  53346. static CreateSphere(name: string, options: {
  53347. segments?: number;
  53348. diameter?: number;
  53349. diameterX?: number;
  53350. diameterY?: number;
  53351. diameterZ?: number;
  53352. arc?: number;
  53353. slice?: number;
  53354. sideOrientation?: number;
  53355. frontUVs?: Vector4;
  53356. backUVs?: Vector4;
  53357. updatable?: boolean;
  53358. }, scene?: Nullable<Scene>): Mesh;
  53359. }
  53360. }
  53361. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  53362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53363. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53364. import { Scene } from "babylonjs/scene";
  53365. /**
  53366. * A profiled motion controller has its profile loaded from an online repository.
  53367. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  53368. */
  53369. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  53370. private _repositoryUrl;
  53371. private _buttonMeshMapping;
  53372. private _touchDots;
  53373. /**
  53374. * The profile ID of this controller. Will be populated when the controller initializes.
  53375. */
  53376. profileId: string;
  53377. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  53378. dispose(): void;
  53379. protected _getFilenameAndPath(): {
  53380. filename: string;
  53381. path: string;
  53382. };
  53383. protected _getModelLoadingConstraints(): boolean;
  53384. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  53385. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53386. protected _updateModel(_xrFrame: XRFrame): void;
  53387. }
  53388. }
  53389. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  53390. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53391. import { Scene } from "babylonjs/scene";
  53392. /**
  53393. * A construction function type to create a new controller based on an xrInput object
  53394. */
  53395. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  53396. /**
  53397. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  53398. *
  53399. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  53400. * it should be replaced with auto-loaded controllers.
  53401. *
  53402. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  53403. */
  53404. export class WebXRMotionControllerManager {
  53405. private static _AvailableControllers;
  53406. private static _Fallbacks;
  53407. private static _ProfileLoadingPromises;
  53408. private static _ProfilesList;
  53409. /**
  53410. * The base URL of the online controller repository. Can be changed at any time.
  53411. */
  53412. static BaseRepositoryUrl: string;
  53413. /**
  53414. * Which repository gets priority - local or online
  53415. */
  53416. static PrioritizeOnlineRepository: boolean;
  53417. /**
  53418. * Use the online repository, or use only locally-defined controllers
  53419. */
  53420. static UseOnlineRepository: boolean;
  53421. /**
  53422. * Clear the cache used for profile loading and reload when requested again
  53423. */
  53424. static ClearProfilesCache(): void;
  53425. /**
  53426. * Register the default fallbacks.
  53427. * This function is called automatically when this file is imported.
  53428. */
  53429. static DefaultFallbacks(): void;
  53430. /**
  53431. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  53432. * @param profileId the profile to which a fallback needs to be found
  53433. * @return an array with corresponding fallback profiles
  53434. */
  53435. static FindFallbackWithProfileId(profileId: string): string[];
  53436. /**
  53437. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  53438. * The order of search:
  53439. *
  53440. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  53441. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  53442. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  53443. * 4) return the generic trigger controller if none were found
  53444. *
  53445. * @param xrInput the xrInput to which a new controller is initialized
  53446. * @param scene the scene to which the model will be added
  53447. * @param forceProfile force a certain profile for this controller
  53448. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  53449. */
  53450. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  53451. /**
  53452. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  53453. *
  53454. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  53455. *
  53456. * @param type the profile type to register
  53457. * @param constructFunction the function to be called when loading this profile
  53458. */
  53459. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  53460. /**
  53461. * Register a fallback to a specific profile.
  53462. * @param profileId the profileId that will receive the fallbacks
  53463. * @param fallbacks A list of fallback profiles
  53464. */
  53465. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  53466. /**
  53467. * Will update the list of profiles available in the repository
  53468. * @return a promise that resolves to a map of profiles available online
  53469. */
  53470. static UpdateProfilesList(): Promise<{
  53471. [profile: string]: string;
  53472. }>;
  53473. private static _LoadProfileFromRepository;
  53474. private static _LoadProfilesFromAvailableControllers;
  53475. }
  53476. }
  53477. declare module "babylonjs/XR/webXRInputSource" {
  53478. import { Observable } from "babylonjs/Misc/observable";
  53479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53480. import { Ray } from "babylonjs/Culling/ray";
  53481. import { Scene } from "babylonjs/scene";
  53482. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53483. /**
  53484. * Configuration options for the WebXR controller creation
  53485. */
  53486. export interface IWebXRControllerOptions {
  53487. /**
  53488. * Should the controller mesh be animated when a user interacts with it
  53489. * The pressed buttons / thumbstick and touchpad animations will be disabled
  53490. */
  53491. disableMotionControllerAnimation?: boolean;
  53492. /**
  53493. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  53494. */
  53495. doNotLoadControllerMesh?: boolean;
  53496. /**
  53497. * Force a specific controller type for this controller.
  53498. * This can be used when creating your own profile or when testing different controllers
  53499. */
  53500. forceControllerProfile?: string;
  53501. /**
  53502. * Defines a rendering group ID for meshes that will be loaded.
  53503. * This is for the default controllers only.
  53504. */
  53505. renderingGroupId?: number;
  53506. }
  53507. /**
  53508. * Represents an XR controller
  53509. */
  53510. export class WebXRInputSource {
  53511. private _scene;
  53512. /** The underlying input source for the controller */
  53513. inputSource: XRInputSource;
  53514. private _options;
  53515. private _tmpVector;
  53516. private _uniqueId;
  53517. private _disposed;
  53518. /**
  53519. * 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
  53520. */
  53521. grip?: AbstractMesh;
  53522. /**
  53523. * If available, this is the gamepad object related to this controller.
  53524. * Using this object it is possible to get click events and trackpad changes of the
  53525. * webxr controller that is currently being used.
  53526. */
  53527. motionController?: WebXRAbstractMotionController;
  53528. /**
  53529. * Event that fires when the controller is removed/disposed.
  53530. * The object provided as event data is this controller, after associated assets were disposed.
  53531. * uniqueId is still available.
  53532. */
  53533. onDisposeObservable: Observable<WebXRInputSource>;
  53534. /**
  53535. * Will be triggered when the mesh associated with the motion controller is done loading.
  53536. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  53537. * A shortened version of controller -> motion controller -> on mesh loaded.
  53538. */
  53539. onMeshLoadedObservable: Observable<AbstractMesh>;
  53540. /**
  53541. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  53542. */
  53543. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  53544. /**
  53545. * Pointer which can be used to select objects or attach a visible laser to
  53546. */
  53547. pointer: AbstractMesh;
  53548. /**
  53549. * Creates the input source object
  53550. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  53551. * @param _scene the scene which the controller should be associated to
  53552. * @param inputSource the underlying input source for the controller
  53553. * @param _options options for this controller creation
  53554. */
  53555. constructor(_scene: Scene,
  53556. /** The underlying input source for the controller */
  53557. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  53558. /**
  53559. * Get this controllers unique id
  53560. */
  53561. get uniqueId(): string;
  53562. /**
  53563. * Disposes of the object
  53564. */
  53565. dispose(): void;
  53566. /**
  53567. * Gets a world space ray coming from the pointer or grip
  53568. * @param result the resulting ray
  53569. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  53570. */
  53571. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  53572. /**
  53573. * Updates the controller pose based on the given XRFrame
  53574. * @param xrFrame xr frame to update the pose with
  53575. * @param referenceSpace reference space to use
  53576. */
  53577. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  53578. }
  53579. }
  53580. declare module "babylonjs/XR/webXRInput" {
  53581. import { Observable } from "babylonjs/Misc/observable";
  53582. import { IDisposable } from "babylonjs/scene";
  53583. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  53584. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53585. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53586. /**
  53587. * The schema for initialization options of the XR Input class
  53588. */
  53589. export interface IWebXRInputOptions {
  53590. /**
  53591. * If set to true no model will be automatically loaded
  53592. */
  53593. doNotLoadControllerMeshes?: boolean;
  53594. /**
  53595. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  53596. * If not found, the xr input profile data will be used.
  53597. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  53598. */
  53599. forceInputProfile?: string;
  53600. /**
  53601. * Do not send a request to the controller repository to load the profile.
  53602. *
  53603. * Instead, use the controllers available in babylon itself.
  53604. */
  53605. disableOnlineControllerRepository?: boolean;
  53606. /**
  53607. * A custom URL for the controllers repository
  53608. */
  53609. customControllersRepositoryURL?: string;
  53610. /**
  53611. * Should the controller model's components not move according to the user input
  53612. */
  53613. disableControllerAnimation?: boolean;
  53614. /**
  53615. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  53616. */
  53617. controllerOptions?: IWebXRControllerOptions;
  53618. }
  53619. /**
  53620. * XR input used to track XR inputs such as controllers/rays
  53621. */
  53622. export class WebXRInput implements IDisposable {
  53623. /**
  53624. * the xr session manager for this session
  53625. */
  53626. xrSessionManager: WebXRSessionManager;
  53627. /**
  53628. * the WebXR camera for this session. Mainly used for teleportation
  53629. */
  53630. xrCamera: WebXRCamera;
  53631. private readonly options;
  53632. /**
  53633. * XR controllers being tracked
  53634. */
  53635. controllers: Array<WebXRInputSource>;
  53636. private _frameObserver;
  53637. private _sessionEndedObserver;
  53638. private _sessionInitObserver;
  53639. /**
  53640. * Event when a controller has been connected/added
  53641. */
  53642. onControllerAddedObservable: Observable<WebXRInputSource>;
  53643. /**
  53644. * Event when a controller has been removed/disconnected
  53645. */
  53646. onControllerRemovedObservable: Observable<WebXRInputSource>;
  53647. /**
  53648. * Initializes the WebXRInput
  53649. * @param xrSessionManager the xr session manager for this session
  53650. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  53651. * @param options = initialization options for this xr input
  53652. */
  53653. constructor(
  53654. /**
  53655. * the xr session manager for this session
  53656. */
  53657. xrSessionManager: WebXRSessionManager,
  53658. /**
  53659. * the WebXR camera for this session. Mainly used for teleportation
  53660. */
  53661. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  53662. private _onInputSourcesChange;
  53663. private _addAndRemoveControllers;
  53664. /**
  53665. * Disposes of the object
  53666. */
  53667. dispose(): void;
  53668. }
  53669. }
  53670. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  53671. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  53672. import { Observable, EventState } from "babylonjs/Misc/observable";
  53673. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53674. /**
  53675. * This is the base class for all WebXR features.
  53676. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  53677. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  53678. */
  53679. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  53680. protected _xrSessionManager: WebXRSessionManager;
  53681. private _attached;
  53682. private _removeOnDetach;
  53683. /**
  53684. * Is this feature disposed?
  53685. */
  53686. isDisposed: boolean;
  53687. /**
  53688. * Should auto-attach be disabled?
  53689. */
  53690. disableAutoAttach: boolean;
  53691. /**
  53692. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  53693. */
  53694. xrNativeFeatureName: string;
  53695. /**
  53696. * Construct a new (abstract) WebXR feature
  53697. * @param _xrSessionManager the xr session manager for this feature
  53698. */
  53699. constructor(_xrSessionManager: WebXRSessionManager);
  53700. /**
  53701. * Is this feature attached
  53702. */
  53703. get attached(): boolean;
  53704. /**
  53705. * attach this feature
  53706. *
  53707. * @param force should attachment be forced (even when already attached)
  53708. * @returns true if successful, false is failed or already attached
  53709. */
  53710. attach(force?: boolean): boolean;
  53711. /**
  53712. * detach this feature.
  53713. *
  53714. * @returns true if successful, false if failed or already detached
  53715. */
  53716. detach(): boolean;
  53717. /**
  53718. * Dispose this feature and all of the resources attached
  53719. */
  53720. dispose(): void;
  53721. /**
  53722. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53723. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53724. *
  53725. * @returns whether or not the feature is compatible in this environment
  53726. */
  53727. isCompatible(): boolean;
  53728. /**
  53729. * This is used to register callbacks that will automatically be removed when detach is called.
  53730. * @param observable the observable to which the observer will be attached
  53731. * @param callback the callback to register
  53732. */
  53733. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  53734. /**
  53735. * Code in this function will be executed on each xrFrame received from the browser.
  53736. * This function will not execute after the feature is detached.
  53737. * @param _xrFrame the current frame
  53738. */
  53739. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  53740. }
  53741. }
  53742. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  53743. import { IDisposable, Scene } from "babylonjs/scene";
  53744. import { Nullable } from "babylonjs/types";
  53745. import { Observable } from "babylonjs/Misc/observable";
  53746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53747. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  53748. import { Camera } from "babylonjs/Cameras/camera";
  53749. /**
  53750. * Renders a layer on top of an existing scene
  53751. */
  53752. export class UtilityLayerRenderer implements IDisposable {
  53753. /** the original scene that will be rendered on top of */
  53754. originalScene: Scene;
  53755. private _pointerCaptures;
  53756. private _lastPointerEvents;
  53757. private static _DefaultUtilityLayer;
  53758. private static _DefaultKeepDepthUtilityLayer;
  53759. private _sharedGizmoLight;
  53760. private _renderCamera;
  53761. /**
  53762. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  53763. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  53764. * @returns the camera that is used when rendering the utility layer
  53765. */
  53766. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  53767. /**
  53768. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  53769. * @param cam the camera that should be used when rendering the utility layer
  53770. */
  53771. setRenderCamera(cam: Nullable<Camera>): void;
  53772. /**
  53773. * @hidden
  53774. * Light which used by gizmos to get light shading
  53775. */
  53776. _getSharedGizmoLight(): HemisphericLight;
  53777. /**
  53778. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  53779. */
  53780. pickUtilitySceneFirst: boolean;
  53781. /**
  53782. * 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)
  53783. */
  53784. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  53785. /**
  53786. * 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)
  53787. */
  53788. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  53789. /**
  53790. * The scene that is rendered on top of the original scene
  53791. */
  53792. utilityLayerScene: Scene;
  53793. /**
  53794. * If the utility layer should automatically be rendered on top of existing scene
  53795. */
  53796. shouldRender: boolean;
  53797. /**
  53798. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  53799. */
  53800. onlyCheckPointerDownEvents: boolean;
  53801. /**
  53802. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  53803. */
  53804. processAllEvents: boolean;
  53805. /**
  53806. * Observable raised when the pointer move from the utility layer scene to the main scene
  53807. */
  53808. onPointerOutObservable: Observable<number>;
  53809. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  53810. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  53811. private _afterRenderObserver;
  53812. private _sceneDisposeObserver;
  53813. private _originalPointerObserver;
  53814. /**
  53815. * Instantiates a UtilityLayerRenderer
  53816. * @param originalScene the original scene that will be rendered on top of
  53817. * @param handleEvents boolean indicating if the utility layer should handle events
  53818. */
  53819. constructor(
  53820. /** the original scene that will be rendered on top of */
  53821. originalScene: Scene, handleEvents?: boolean);
  53822. private _notifyObservers;
  53823. /**
  53824. * Renders the utility layers scene on top of the original scene
  53825. */
  53826. render(): void;
  53827. /**
  53828. * Disposes of the renderer
  53829. */
  53830. dispose(): void;
  53831. private _updateCamera;
  53832. }
  53833. }
  53834. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  53835. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53837. import { WebXRInput } from "babylonjs/XR/webXRInput";
  53838. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  53839. import { Scene } from "babylonjs/scene";
  53840. import { Nullable } from "babylonjs/types";
  53841. import { Color3 } from "babylonjs/Maths/math.color";
  53842. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  53843. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53844. /**
  53845. * Options interface for the pointer selection module
  53846. */
  53847. export interface IWebXRControllerPointerSelectionOptions {
  53848. /**
  53849. * if provided, this scene will be used to render meshes.
  53850. */
  53851. customUtilityLayerScene?: Scene;
  53852. /**
  53853. * 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)
  53854. * If not disabled, the last picked point will be used to execute a pointer up event
  53855. * If disabled, pointer up event will be triggered right after the pointer down event.
  53856. * Used in screen and gaze target ray mode only
  53857. */
  53858. disablePointerUpOnTouchOut: boolean;
  53859. /**
  53860. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  53861. */
  53862. forceGazeMode: boolean;
  53863. /**
  53864. * 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
  53865. * to start a new countdown to the pointer down event.
  53866. * Defaults to 1.
  53867. */
  53868. gazeModePointerMovedFactor?: number;
  53869. /**
  53870. * Different button type to use instead of the main component
  53871. */
  53872. overrideButtonId?: string;
  53873. /**
  53874. * use this rendering group id for the meshes (optional)
  53875. */
  53876. renderingGroupId?: number;
  53877. /**
  53878. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  53879. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  53880. * 3000 means 3 seconds between pointing at something and selecting it
  53881. */
  53882. timeToSelect?: number;
  53883. /**
  53884. * Should meshes created here be added to a utility layer or the main scene
  53885. */
  53886. useUtilityLayer?: boolean;
  53887. /**
  53888. * Optional WebXR camera to be used for gaze selection
  53889. */
  53890. gazeCamera?: WebXRCamera;
  53891. /**
  53892. * the xr input to use with this pointer selection
  53893. */
  53894. xrInput: WebXRInput;
  53895. }
  53896. /**
  53897. * A module that will enable pointer selection for motion controllers of XR Input Sources
  53898. */
  53899. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  53900. private readonly _options;
  53901. private static _idCounter;
  53902. private _attachController;
  53903. private _controllers;
  53904. private _scene;
  53905. private _tmpVectorForPickCompare;
  53906. /**
  53907. * The module's name
  53908. */
  53909. static readonly Name: string;
  53910. /**
  53911. * The (Babylon) version of this module.
  53912. * This is an integer representing the implementation version.
  53913. * This number does not correspond to the WebXR specs version
  53914. */
  53915. static readonly Version: number;
  53916. /**
  53917. * Disable lighting on the laser pointer (so it will always be visible)
  53918. */
  53919. disablePointerLighting: boolean;
  53920. /**
  53921. * Disable lighting on the selection mesh (so it will always be visible)
  53922. */
  53923. disableSelectionMeshLighting: boolean;
  53924. /**
  53925. * Should the laser pointer be displayed
  53926. */
  53927. displayLaserPointer: boolean;
  53928. /**
  53929. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  53930. */
  53931. displaySelectionMesh: boolean;
  53932. /**
  53933. * This color will be set to the laser pointer when selection is triggered
  53934. */
  53935. laserPointerPickedColor: Color3;
  53936. /**
  53937. * Default color of the laser pointer
  53938. */
  53939. laserPointerDefaultColor: Color3;
  53940. /**
  53941. * default color of the selection ring
  53942. */
  53943. selectionMeshDefaultColor: Color3;
  53944. /**
  53945. * This color will be applied to the selection ring when selection is triggered
  53946. */
  53947. selectionMeshPickedColor: Color3;
  53948. /**
  53949. * Optional filter to be used for ray selection. This predicate shares behavior with
  53950. * scene.pointerMovePredicate which takes priority if it is also assigned.
  53951. */
  53952. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53953. /**
  53954. * constructs a new background remover module
  53955. * @param _xrSessionManager the session manager for this module
  53956. * @param _options read-only options to be used in this module
  53957. */
  53958. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  53959. /**
  53960. * attach this feature
  53961. * Will usually be called by the features manager
  53962. *
  53963. * @returns true if successful.
  53964. */
  53965. attach(): boolean;
  53966. /**
  53967. * detach this feature.
  53968. * Will usually be called by the features manager
  53969. *
  53970. * @returns true if successful.
  53971. */
  53972. detach(): boolean;
  53973. /**
  53974. * Will get the mesh under a specific pointer.
  53975. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  53976. * @param controllerId the controllerId to check
  53977. * @returns The mesh under pointer or null if no mesh is under the pointer
  53978. */
  53979. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  53980. /**
  53981. * Get the xr controller that correlates to the pointer id in the pointer event
  53982. *
  53983. * @param id the pointer id to search for
  53984. * @returns the controller that correlates to this id or null if not found
  53985. */
  53986. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  53987. protected _onXRFrame(_xrFrame: XRFrame): void;
  53988. private _attachGazeMode;
  53989. private _attachScreenRayMode;
  53990. private _attachTrackedPointerRayMode;
  53991. private _convertNormalToDirectionOfRay;
  53992. private _detachController;
  53993. private _generateNewMeshPair;
  53994. private _pickingMoved;
  53995. private _updatePointerDistance;
  53996. /** @hidden */
  53997. get lasterPointerDefaultColor(): Color3;
  53998. }
  53999. }
  54000. declare module "babylonjs/XR/webXREnterExitUI" {
  54001. import { Nullable } from "babylonjs/types";
  54002. import { Observable } from "babylonjs/Misc/observable";
  54003. import { IDisposable, Scene } from "babylonjs/scene";
  54004. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54005. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54006. /**
  54007. * Button which can be used to enter a different mode of XR
  54008. */
  54009. export class WebXREnterExitUIButton {
  54010. /** button element */
  54011. element: HTMLElement;
  54012. /** XR initialization options for the button */
  54013. sessionMode: XRSessionMode;
  54014. /** Reference space type */
  54015. referenceSpaceType: XRReferenceSpaceType;
  54016. /**
  54017. * Creates a WebXREnterExitUIButton
  54018. * @param element button element
  54019. * @param sessionMode XR initialization session mode
  54020. * @param referenceSpaceType the type of reference space to be used
  54021. */
  54022. constructor(
  54023. /** button element */
  54024. element: HTMLElement,
  54025. /** XR initialization options for the button */
  54026. sessionMode: XRSessionMode,
  54027. /** Reference space type */
  54028. referenceSpaceType: XRReferenceSpaceType);
  54029. /**
  54030. * Extendable function which can be used to update the button's visuals when the state changes
  54031. * @param activeButton the current active button in the UI
  54032. */
  54033. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54034. }
  54035. /**
  54036. * Options to create the webXR UI
  54037. */
  54038. export class WebXREnterExitUIOptions {
  54039. /**
  54040. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54041. */
  54042. customButtons?: Array<WebXREnterExitUIButton>;
  54043. /**
  54044. * A reference space type to use when creating the default button.
  54045. * Default is local-floor
  54046. */
  54047. referenceSpaceType?: XRReferenceSpaceType;
  54048. /**
  54049. * Context to enter xr with
  54050. */
  54051. renderTarget?: Nullable<WebXRRenderTarget>;
  54052. /**
  54053. * A session mode to use when creating the default button.
  54054. * Default is immersive-vr
  54055. */
  54056. sessionMode?: XRSessionMode;
  54057. /**
  54058. * A list of optional features to init the session with
  54059. */
  54060. optionalFeatures?: string[];
  54061. /**
  54062. * A list of optional features to init the session with
  54063. */
  54064. requiredFeatures?: string[];
  54065. }
  54066. /**
  54067. * UI to allow the user to enter/exit XR mode
  54068. */
  54069. export class WebXREnterExitUI implements IDisposable {
  54070. private scene;
  54071. /** version of the options passed to this UI */
  54072. options: WebXREnterExitUIOptions;
  54073. private _activeButton;
  54074. private _buttons;
  54075. /**
  54076. * The HTML Div Element to which buttons are added.
  54077. */
  54078. readonly overlay: HTMLDivElement;
  54079. /**
  54080. * Fired every time the active button is changed.
  54081. *
  54082. * When xr is entered via a button that launches xr that button will be the callback parameter
  54083. *
  54084. * When exiting xr the callback parameter will be null)
  54085. */
  54086. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54087. /**
  54088. *
  54089. * @param scene babylon scene object to use
  54090. * @param options (read-only) version of the options passed to this UI
  54091. */
  54092. private constructor();
  54093. /**
  54094. * Creates UI to allow the user to enter/exit XR mode
  54095. * @param scene the scene to add the ui to
  54096. * @param helper the xr experience helper to enter/exit xr with
  54097. * @param options options to configure the UI
  54098. * @returns the created ui
  54099. */
  54100. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54101. /**
  54102. * Disposes of the XR UI component
  54103. */
  54104. dispose(): void;
  54105. private _updateButtons;
  54106. }
  54107. }
  54108. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54109. import { Vector3 } from "babylonjs/Maths/math.vector";
  54110. import { Color4 } from "babylonjs/Maths/math.color";
  54111. import { Nullable } from "babylonjs/types";
  54112. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54113. import { Scene } from "babylonjs/scene";
  54114. /**
  54115. * Class containing static functions to help procedurally build meshes
  54116. */
  54117. export class LinesBuilder {
  54118. /**
  54119. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54120. * * 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
  54121. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54122. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54123. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54124. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54125. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54126. * * 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
  54127. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54130. * @param name defines the name of the new line system
  54131. * @param options defines the options used to create the line system
  54132. * @param scene defines the hosting scene
  54133. * @returns a new line system mesh
  54134. */
  54135. static CreateLineSystem(name: string, options: {
  54136. lines: Vector3[][];
  54137. updatable?: boolean;
  54138. instance?: Nullable<LinesMesh>;
  54139. colors?: Nullable<Color4[][]>;
  54140. useVertexAlpha?: boolean;
  54141. }, scene: Nullable<Scene>): LinesMesh;
  54142. /**
  54143. * Creates a line mesh
  54144. * 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
  54145. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54146. * * The parameter `points` is an array successive Vector3
  54147. * * 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
  54148. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54149. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54150. * * When updating an instance, remember that only point positions can change, not the number of points
  54151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54152. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54153. * @param name defines the name of the new line system
  54154. * @param options defines the options used to create the line system
  54155. * @param scene defines the hosting scene
  54156. * @returns a new line mesh
  54157. */
  54158. static CreateLines(name: string, options: {
  54159. points: Vector3[];
  54160. updatable?: boolean;
  54161. instance?: Nullable<LinesMesh>;
  54162. colors?: Color4[];
  54163. useVertexAlpha?: boolean;
  54164. }, scene?: Nullable<Scene>): LinesMesh;
  54165. /**
  54166. * Creates a dashed line mesh
  54167. * * 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
  54168. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54169. * * The parameter `points` is an array successive Vector3
  54170. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54171. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54172. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54173. * * 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
  54174. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54175. * * When updating an instance, remember that only point positions can change, not the number of points
  54176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54177. * @param name defines the name of the mesh
  54178. * @param options defines the options used to create the mesh
  54179. * @param scene defines the hosting scene
  54180. * @returns the dashed line mesh
  54181. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54182. */
  54183. static CreateDashedLines(name: string, options: {
  54184. points: Vector3[];
  54185. dashSize?: number;
  54186. gapSize?: number;
  54187. dashNb?: number;
  54188. updatable?: boolean;
  54189. instance?: LinesMesh;
  54190. useVertexAlpha?: boolean;
  54191. }, scene?: Nullable<Scene>): LinesMesh;
  54192. }
  54193. }
  54194. declare module "babylonjs/Misc/timer" {
  54195. import { Observable, Observer } from "babylonjs/Misc/observable";
  54196. import { Nullable } from "babylonjs/types";
  54197. import { IDisposable } from "babylonjs/scene";
  54198. /**
  54199. * Construction options for a timer
  54200. */
  54201. export interface ITimerOptions<T> {
  54202. /**
  54203. * Time-to-end
  54204. */
  54205. timeout: number;
  54206. /**
  54207. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  54208. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  54209. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  54210. */
  54211. contextObservable: Observable<T>;
  54212. /**
  54213. * Optional parameters when adding an observer to the observable
  54214. */
  54215. observableParameters?: {
  54216. mask?: number;
  54217. insertFirst?: boolean;
  54218. scope?: any;
  54219. };
  54220. /**
  54221. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  54222. */
  54223. breakCondition?: (data?: ITimerData<T>) => boolean;
  54224. /**
  54225. * Will be triggered when the time condition has met
  54226. */
  54227. onEnded?: (data: ITimerData<any>) => void;
  54228. /**
  54229. * Will be triggered when the break condition has met (prematurely ended)
  54230. */
  54231. onAborted?: (data: ITimerData<any>) => void;
  54232. /**
  54233. * Optional function to execute on each tick (or count)
  54234. */
  54235. onTick?: (data: ITimerData<any>) => void;
  54236. }
  54237. /**
  54238. * An interface defining the data sent by the timer
  54239. */
  54240. export interface ITimerData<T> {
  54241. /**
  54242. * When did it start
  54243. */
  54244. startTime: number;
  54245. /**
  54246. * Time now
  54247. */
  54248. currentTime: number;
  54249. /**
  54250. * Time passed since started
  54251. */
  54252. deltaTime: number;
  54253. /**
  54254. * How much is completed, in [0.0...1.0].
  54255. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  54256. */
  54257. completeRate: number;
  54258. /**
  54259. * What the registered observable sent in the last count
  54260. */
  54261. payload: T;
  54262. }
  54263. /**
  54264. * The current state of the timer
  54265. */
  54266. export enum TimerState {
  54267. /**
  54268. * Timer initialized, not yet started
  54269. */
  54270. INIT = 0,
  54271. /**
  54272. * Timer started and counting
  54273. */
  54274. STARTED = 1,
  54275. /**
  54276. * Timer ended (whether aborted or time reached)
  54277. */
  54278. ENDED = 2
  54279. }
  54280. /**
  54281. * A simple version of the timer. Will take options and start the timer immediately after calling it
  54282. *
  54283. * @param options options with which to initialize this timer
  54284. */
  54285. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  54286. /**
  54287. * An advanced implementation of a timer class
  54288. */
  54289. export class AdvancedTimer<T = any> implements IDisposable {
  54290. /**
  54291. * Will notify each time the timer calculates the remaining time
  54292. */
  54293. onEachCountObservable: Observable<ITimerData<T>>;
  54294. /**
  54295. * Will trigger when the timer was aborted due to the break condition
  54296. */
  54297. onTimerAbortedObservable: Observable<ITimerData<T>>;
  54298. /**
  54299. * Will trigger when the timer ended successfully
  54300. */
  54301. onTimerEndedObservable: Observable<ITimerData<T>>;
  54302. /**
  54303. * Will trigger when the timer state has changed
  54304. */
  54305. onStateChangedObservable: Observable<TimerState>;
  54306. private _observer;
  54307. private _contextObservable;
  54308. private _observableParameters;
  54309. private _startTime;
  54310. private _timer;
  54311. private _state;
  54312. private _breakCondition;
  54313. private _timeToEnd;
  54314. private _breakOnNextTick;
  54315. /**
  54316. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  54317. * @param options construction options for this advanced timer
  54318. */
  54319. constructor(options: ITimerOptions<T>);
  54320. /**
  54321. * set a breaking condition for this timer. Default is to never break during count
  54322. * @param predicate the new break condition. Returns true to break, false otherwise
  54323. */
  54324. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  54325. /**
  54326. * Reset ALL associated observables in this advanced timer
  54327. */
  54328. clearObservables(): void;
  54329. /**
  54330. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  54331. *
  54332. * @param timeToEnd how much time to measure until timer ended
  54333. */
  54334. start(timeToEnd?: number): void;
  54335. /**
  54336. * Will force a stop on the next tick.
  54337. */
  54338. stop(): void;
  54339. /**
  54340. * Dispose this timer, clearing all resources
  54341. */
  54342. dispose(): void;
  54343. private _setState;
  54344. private _tick;
  54345. private _stop;
  54346. }
  54347. }
  54348. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  54349. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54350. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54351. import { Nullable } from "babylonjs/types";
  54352. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54354. import { Vector3 } from "babylonjs/Maths/math.vector";
  54355. import { Material } from "babylonjs/Materials/material";
  54356. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54357. import { Scene } from "babylonjs/scene";
  54358. /**
  54359. * The options container for the teleportation module
  54360. */
  54361. export interface IWebXRTeleportationOptions {
  54362. /**
  54363. * if provided, this scene will be used to render meshes.
  54364. */
  54365. customUtilityLayerScene?: Scene;
  54366. /**
  54367. * Values to configure the default target mesh
  54368. */
  54369. defaultTargetMeshOptions?: {
  54370. /**
  54371. * Fill color of the teleportation area
  54372. */
  54373. teleportationFillColor?: string;
  54374. /**
  54375. * Border color for the teleportation area
  54376. */
  54377. teleportationBorderColor?: string;
  54378. /**
  54379. * Disable the mesh's animation sequence
  54380. */
  54381. disableAnimation?: boolean;
  54382. /**
  54383. * Disable lighting on the material or the ring and arrow
  54384. */
  54385. disableLighting?: boolean;
  54386. /**
  54387. * Override the default material of the torus and arrow
  54388. */
  54389. torusArrowMaterial?: Material;
  54390. };
  54391. /**
  54392. * A list of meshes to use as floor meshes.
  54393. * Meshes can be added and removed after initializing the feature using the
  54394. * addFloorMesh and removeFloorMesh functions
  54395. * If empty, rotation will still work
  54396. */
  54397. floorMeshes?: AbstractMesh[];
  54398. /**
  54399. * use this rendering group id for the meshes (optional)
  54400. */
  54401. renderingGroupId?: number;
  54402. /**
  54403. * Should teleportation move only to snap points
  54404. */
  54405. snapPointsOnly?: boolean;
  54406. /**
  54407. * An array of points to which the teleportation will snap to.
  54408. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  54409. */
  54410. snapPositions?: Vector3[];
  54411. /**
  54412. * How close should the teleportation ray be in order to snap to position.
  54413. * Default to 0.8 units (meters)
  54414. */
  54415. snapToPositionRadius?: number;
  54416. /**
  54417. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  54418. * If you want to support rotation, make sure your mesh has a direction indicator.
  54419. *
  54420. * When left untouched, the default mesh will be initialized.
  54421. */
  54422. teleportationTargetMesh?: AbstractMesh;
  54423. /**
  54424. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  54425. */
  54426. timeToTeleport?: number;
  54427. /**
  54428. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  54429. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  54430. */
  54431. useMainComponentOnly?: boolean;
  54432. /**
  54433. * Should meshes created here be added to a utility layer or the main scene
  54434. */
  54435. useUtilityLayer?: boolean;
  54436. /**
  54437. * Babylon XR Input class for controller
  54438. */
  54439. xrInput: WebXRInput;
  54440. /**
  54441. * Meshes that the teleportation ray cannot go through
  54442. */
  54443. pickBlockerMeshes?: AbstractMesh[];
  54444. }
  54445. /**
  54446. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  54447. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  54448. * the input of the attached controllers.
  54449. */
  54450. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  54451. private _options;
  54452. private _controllers;
  54453. private _currentTeleportationControllerId;
  54454. private _floorMeshes;
  54455. private _quadraticBezierCurve;
  54456. private _selectionFeature;
  54457. private _snapToPositions;
  54458. private _snappedToPoint;
  54459. private _teleportationRingMaterial?;
  54460. private _tmpRay;
  54461. private _tmpVector;
  54462. private _tmpQuaternion;
  54463. /**
  54464. * The module's name
  54465. */
  54466. static readonly Name: string;
  54467. /**
  54468. * The (Babylon) version of this module.
  54469. * This is an integer representing the implementation version.
  54470. * This number does not correspond to the webxr specs version
  54471. */
  54472. static readonly Version: number;
  54473. /**
  54474. * Is movement backwards enabled
  54475. */
  54476. backwardsMovementEnabled: boolean;
  54477. /**
  54478. * Distance to travel when moving backwards
  54479. */
  54480. backwardsTeleportationDistance: number;
  54481. /**
  54482. * The distance from the user to the inspection point in the direction of the controller
  54483. * A higher number will allow the user to move further
  54484. * defaults to 5 (meters, in xr units)
  54485. */
  54486. parabolicCheckRadius: number;
  54487. /**
  54488. * Should the module support parabolic ray on top of direct ray
  54489. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  54490. * Very helpful when moving between floors / different heights
  54491. */
  54492. parabolicRayEnabled: boolean;
  54493. /**
  54494. * How much rotation should be applied when rotating right and left
  54495. */
  54496. rotationAngle: number;
  54497. /**
  54498. * Is rotation enabled when moving forward?
  54499. * Disabling this feature will prevent the user from deciding the direction when teleporting
  54500. */
  54501. rotationEnabled: boolean;
  54502. /**
  54503. * constructs a new anchor system
  54504. * @param _xrSessionManager an instance of WebXRSessionManager
  54505. * @param _options configuration object for this feature
  54506. */
  54507. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  54508. /**
  54509. * Get the snapPointsOnly flag
  54510. */
  54511. get snapPointsOnly(): boolean;
  54512. /**
  54513. * Sets the snapPointsOnly flag
  54514. * @param snapToPoints should teleportation be exclusively to snap points
  54515. */
  54516. set snapPointsOnly(snapToPoints: boolean);
  54517. /**
  54518. * Add a new mesh to the floor meshes array
  54519. * @param mesh the mesh to use as floor mesh
  54520. */
  54521. addFloorMesh(mesh: AbstractMesh): void;
  54522. /**
  54523. * Add a new snap-to point to fix teleportation to this position
  54524. * @param newSnapPoint The new Snap-To point
  54525. */
  54526. addSnapPoint(newSnapPoint: Vector3): void;
  54527. attach(): boolean;
  54528. detach(): boolean;
  54529. dispose(): void;
  54530. /**
  54531. * Remove a mesh from the floor meshes array
  54532. * @param mesh the mesh to remove
  54533. */
  54534. removeFloorMesh(mesh: AbstractMesh): void;
  54535. /**
  54536. * Remove a mesh from the floor meshes array using its name
  54537. * @param name the mesh name to remove
  54538. */
  54539. removeFloorMeshByName(name: string): void;
  54540. /**
  54541. * 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
  54542. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  54543. * @returns was the point found and removed or not
  54544. */
  54545. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  54546. /**
  54547. * This function sets a selection feature that will be disabled when
  54548. * the forward ray is shown and will be reattached when hidden.
  54549. * This is used to remove the selection rays when moving.
  54550. * @param selectionFeature the feature to disable when forward movement is enabled
  54551. */
  54552. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  54553. protected _onXRFrame(_xrFrame: XRFrame): void;
  54554. private _attachController;
  54555. private _createDefaultTargetMesh;
  54556. private _detachController;
  54557. private _findClosestSnapPointWithRadius;
  54558. private _setTargetMeshPosition;
  54559. private _setTargetMeshVisibility;
  54560. private _showParabolicPath;
  54561. private _teleportForward;
  54562. }
  54563. }
  54564. declare module "babylonjs/XR/webXRDefaultExperience" {
  54565. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54566. import { Scene } from "babylonjs/scene";
  54567. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  54568. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  54569. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54570. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  54571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54572. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  54573. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  54574. /**
  54575. * Options for the default xr helper
  54576. */
  54577. export class WebXRDefaultExperienceOptions {
  54578. /**
  54579. * Enable or disable default UI to enter XR
  54580. */
  54581. disableDefaultUI?: boolean;
  54582. /**
  54583. * Should teleportation not initialize. defaults to false.
  54584. */
  54585. disableTeleportation?: boolean;
  54586. /**
  54587. * Floor meshes that will be used for teleport
  54588. */
  54589. floorMeshes?: Array<AbstractMesh>;
  54590. /**
  54591. * If set to true, the first frame will not be used to reset position
  54592. * The first frame is mainly used when copying transformation from the old camera
  54593. * Mainly used in AR
  54594. */
  54595. ignoreNativeCameraTransformation?: boolean;
  54596. /**
  54597. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  54598. */
  54599. inputOptions?: IWebXRInputOptions;
  54600. /**
  54601. * optional configuration for the output canvas
  54602. */
  54603. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  54604. /**
  54605. * optional UI options. This can be used among other to change session mode and reference space type
  54606. */
  54607. uiOptions?: WebXREnterExitUIOptions;
  54608. /**
  54609. * When loading teleportation and pointer select, use stable versions instead of latest.
  54610. */
  54611. useStablePlugins?: boolean;
  54612. /**
  54613. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  54614. */
  54615. renderingGroupId?: number;
  54616. /**
  54617. * A list of optional features to init the session with
  54618. * If set to true, all features we support will be added
  54619. */
  54620. optionalFeatures?: boolean | string[];
  54621. }
  54622. /**
  54623. * Default experience which provides a similar setup to the previous webVRExperience
  54624. */
  54625. export class WebXRDefaultExperience {
  54626. /**
  54627. * Base experience
  54628. */
  54629. baseExperience: WebXRExperienceHelper;
  54630. /**
  54631. * Enables ui for entering/exiting xr
  54632. */
  54633. enterExitUI: WebXREnterExitUI;
  54634. /**
  54635. * Input experience extension
  54636. */
  54637. input: WebXRInput;
  54638. /**
  54639. * Enables laser pointer and selection
  54640. */
  54641. pointerSelection: WebXRControllerPointerSelection;
  54642. /**
  54643. * Default target xr should render to
  54644. */
  54645. renderTarget: WebXRRenderTarget;
  54646. /**
  54647. * Enables teleportation
  54648. */
  54649. teleportation: WebXRMotionControllerTeleportation;
  54650. private constructor();
  54651. /**
  54652. * Creates the default xr experience
  54653. * @param scene scene
  54654. * @param options options for basic configuration
  54655. * @returns resulting WebXRDefaultExperience
  54656. */
  54657. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54658. /**
  54659. * DIsposes of the experience helper
  54660. */
  54661. dispose(): void;
  54662. }
  54663. }
  54664. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  54665. import { Observable } from "babylonjs/Misc/observable";
  54666. import { Nullable } from "babylonjs/types";
  54667. import { Camera } from "babylonjs/Cameras/camera";
  54668. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  54669. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  54670. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  54671. import { Scene } from "babylonjs/scene";
  54672. import { Vector3 } from "babylonjs/Maths/math.vector";
  54673. import { Color3 } from "babylonjs/Maths/math.color";
  54674. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54676. import { Mesh } from "babylonjs/Meshes/mesh";
  54677. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  54678. import { EasingFunction } from "babylonjs/Animations/easing";
  54679. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  54680. import "babylonjs/Meshes/Builders/groundBuilder";
  54681. import "babylonjs/Meshes/Builders/torusBuilder";
  54682. import "babylonjs/Meshes/Builders/cylinderBuilder";
  54683. import "babylonjs/Gamepads/gamepadSceneComponent";
  54684. import "babylonjs/Animations/animatable";
  54685. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  54686. /**
  54687. * Options to modify the vr teleportation behavior.
  54688. */
  54689. export interface VRTeleportationOptions {
  54690. /**
  54691. * The name of the mesh which should be used as the teleportation floor. (default: null)
  54692. */
  54693. floorMeshName?: string;
  54694. /**
  54695. * A list of meshes to be used as the teleportation floor. (default: empty)
  54696. */
  54697. floorMeshes?: Mesh[];
  54698. /**
  54699. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  54700. */
  54701. teleportationMode?: number;
  54702. /**
  54703. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  54704. */
  54705. teleportationTime?: number;
  54706. /**
  54707. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  54708. */
  54709. teleportationSpeed?: number;
  54710. /**
  54711. * The easing function used in the animation or null for Linear. (default CircleEase)
  54712. */
  54713. easingFunction?: EasingFunction;
  54714. }
  54715. /**
  54716. * Options to modify the vr experience helper's behavior.
  54717. */
  54718. export interface VRExperienceHelperOptions extends WebVROptions {
  54719. /**
  54720. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  54721. */
  54722. createDeviceOrientationCamera?: boolean;
  54723. /**
  54724. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  54725. */
  54726. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  54727. /**
  54728. * Uses the main button on the controller to toggle the laser casted. (default: true)
  54729. */
  54730. laserToggle?: boolean;
  54731. /**
  54732. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  54733. */
  54734. floorMeshes?: Mesh[];
  54735. /**
  54736. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  54737. */
  54738. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  54739. /**
  54740. * Defines if WebXR should be used instead of WebVR (if available)
  54741. */
  54742. useXR?: boolean;
  54743. }
  54744. /**
  54745. * Event containing information after VR has been entered
  54746. */
  54747. export class OnAfterEnteringVRObservableEvent {
  54748. /**
  54749. * If entering vr was successful
  54750. */
  54751. success: boolean;
  54752. }
  54753. /**
  54754. * Helps to quickly add VR support to an existing scene.
  54755. * See https://doc.babylonjs.com/how_to/webvr_helper
  54756. */
  54757. export class VRExperienceHelper {
  54758. /** Options to modify the vr experience helper's behavior. */
  54759. webVROptions: VRExperienceHelperOptions;
  54760. private _scene;
  54761. private _position;
  54762. private _btnVR;
  54763. private _btnVRDisplayed;
  54764. private _webVRsupported;
  54765. private _webVRready;
  54766. private _webVRrequesting;
  54767. private _webVRpresenting;
  54768. private _hasEnteredVR;
  54769. private _fullscreenVRpresenting;
  54770. private _inputElement;
  54771. private _webVRCamera;
  54772. private _vrDeviceOrientationCamera;
  54773. private _deviceOrientationCamera;
  54774. private _existingCamera;
  54775. private _onKeyDown;
  54776. private _onVrDisplayPresentChange;
  54777. private _onVRDisplayChanged;
  54778. private _onVRRequestPresentStart;
  54779. private _onVRRequestPresentComplete;
  54780. /**
  54781. * 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)
  54782. */
  54783. enableGazeEvenWhenNoPointerLock: boolean;
  54784. /**
  54785. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  54786. */
  54787. exitVROnDoubleTap: boolean;
  54788. /**
  54789. * Observable raised right before entering VR.
  54790. */
  54791. onEnteringVRObservable: Observable<VRExperienceHelper>;
  54792. /**
  54793. * Observable raised when entering VR has completed.
  54794. */
  54795. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  54796. /**
  54797. * Observable raised when exiting VR.
  54798. */
  54799. onExitingVRObservable: Observable<VRExperienceHelper>;
  54800. /**
  54801. * Observable raised when controller mesh is loaded.
  54802. */
  54803. onControllerMeshLoadedObservable: Observable<WebVRController>;
  54804. /** Return this.onEnteringVRObservable
  54805. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  54806. */
  54807. get onEnteringVR(): Observable<VRExperienceHelper>;
  54808. /** Return this.onExitingVRObservable
  54809. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  54810. */
  54811. get onExitingVR(): Observable<VRExperienceHelper>;
  54812. /** Return this.onControllerMeshLoadedObservable
  54813. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  54814. */
  54815. get onControllerMeshLoaded(): Observable<WebVRController>;
  54816. private _rayLength;
  54817. private _useCustomVRButton;
  54818. private _teleportationRequested;
  54819. private _teleportActive;
  54820. private _floorMeshName;
  54821. private _floorMeshesCollection;
  54822. private _teleportationMode;
  54823. private _teleportationTime;
  54824. private _teleportationSpeed;
  54825. private _teleportationEasing;
  54826. private _rotationAllowed;
  54827. private _teleportBackwardsVector;
  54828. private _teleportationTarget;
  54829. private _isDefaultTeleportationTarget;
  54830. private _postProcessMove;
  54831. private _teleportationFillColor;
  54832. private _teleportationBorderColor;
  54833. private _rotationAngle;
  54834. private _haloCenter;
  54835. private _cameraGazer;
  54836. private _padSensibilityUp;
  54837. private _padSensibilityDown;
  54838. private _leftController;
  54839. private _rightController;
  54840. private _gazeColor;
  54841. private _laserColor;
  54842. private _pickedLaserColor;
  54843. private _pickedGazeColor;
  54844. /**
  54845. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  54846. */
  54847. onNewMeshSelected: Observable<AbstractMesh>;
  54848. /**
  54849. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  54850. * This observable will provide the mesh and the controller used to select the mesh
  54851. */
  54852. onMeshSelectedWithController: Observable<{
  54853. mesh: AbstractMesh;
  54854. controller: WebVRController;
  54855. }>;
  54856. /**
  54857. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  54858. */
  54859. onNewMeshPicked: Observable<PickingInfo>;
  54860. private _circleEase;
  54861. /**
  54862. * Observable raised before camera teleportation
  54863. */
  54864. onBeforeCameraTeleport: Observable<Vector3>;
  54865. /**
  54866. * Observable raised after camera teleportation
  54867. */
  54868. onAfterCameraTeleport: Observable<Vector3>;
  54869. /**
  54870. * Observable raised when current selected mesh gets unselected
  54871. */
  54872. onSelectedMeshUnselected: Observable<AbstractMesh>;
  54873. private _raySelectionPredicate;
  54874. /**
  54875. * To be optionaly changed by user to define custom ray selection
  54876. */
  54877. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54878. /**
  54879. * To be optionaly changed by user to define custom selection logic (after ray selection)
  54880. */
  54881. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54882. /**
  54883. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  54884. */
  54885. teleportationEnabled: boolean;
  54886. private _defaultHeight;
  54887. private _teleportationInitialized;
  54888. private _interactionsEnabled;
  54889. private _interactionsRequested;
  54890. private _displayGaze;
  54891. private _displayLaserPointer;
  54892. /**
  54893. * The mesh used to display where the user is going to teleport.
  54894. */
  54895. get teleportationTarget(): Mesh;
  54896. /**
  54897. * Sets the mesh to be used to display where the user is going to teleport.
  54898. */
  54899. set teleportationTarget(value: Mesh);
  54900. /**
  54901. * 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
  54902. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  54903. * See https://doc.babylonjs.com/resources/baking_transformations
  54904. */
  54905. get gazeTrackerMesh(): Mesh;
  54906. set gazeTrackerMesh(value: Mesh);
  54907. /**
  54908. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  54909. */
  54910. updateGazeTrackerScale: boolean;
  54911. /**
  54912. * If the gaze trackers color should be updated when selecting meshes
  54913. */
  54914. updateGazeTrackerColor: boolean;
  54915. /**
  54916. * If the controller laser color should be updated when selecting meshes
  54917. */
  54918. updateControllerLaserColor: boolean;
  54919. /**
  54920. * The gaze tracking mesh corresponding to the left controller
  54921. */
  54922. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  54923. /**
  54924. * The gaze tracking mesh corresponding to the right controller
  54925. */
  54926. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  54927. /**
  54928. * If the ray of the gaze should be displayed.
  54929. */
  54930. get displayGaze(): boolean;
  54931. /**
  54932. * Sets if the ray of the gaze should be displayed.
  54933. */
  54934. set displayGaze(value: boolean);
  54935. /**
  54936. * If the ray of the LaserPointer should be displayed.
  54937. */
  54938. get displayLaserPointer(): boolean;
  54939. /**
  54940. * Sets if the ray of the LaserPointer should be displayed.
  54941. */
  54942. set displayLaserPointer(value: boolean);
  54943. /**
  54944. * The deviceOrientationCamera used as the camera when not in VR.
  54945. */
  54946. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  54947. /**
  54948. * Based on the current WebVR support, returns the current VR camera used.
  54949. */
  54950. get currentVRCamera(): Nullable<Camera>;
  54951. /**
  54952. * The webVRCamera which is used when in VR.
  54953. */
  54954. get webVRCamera(): WebVRFreeCamera;
  54955. /**
  54956. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  54957. */
  54958. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  54959. /**
  54960. * The html button that is used to trigger entering into VR.
  54961. */
  54962. get vrButton(): Nullable<HTMLButtonElement>;
  54963. private get _teleportationRequestInitiated();
  54964. /**
  54965. * Defines whether or not Pointer lock should be requested when switching to
  54966. * full screen.
  54967. */
  54968. requestPointerLockOnFullScreen: boolean;
  54969. /**
  54970. * If asking to force XR, this will be populated with the default xr experience
  54971. */
  54972. xr: WebXRDefaultExperience;
  54973. /**
  54974. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  54975. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  54976. */
  54977. xrTestDone: boolean;
  54978. /**
  54979. * Instantiates a VRExperienceHelper.
  54980. * Helps to quickly add VR support to an existing scene.
  54981. * @param scene The scene the VRExperienceHelper belongs to.
  54982. * @param webVROptions Options to modify the vr experience helper's behavior.
  54983. */
  54984. constructor(scene: Scene,
  54985. /** Options to modify the vr experience helper's behavior. */
  54986. webVROptions?: VRExperienceHelperOptions);
  54987. private completeVRInit;
  54988. private _onDefaultMeshLoaded;
  54989. private _onResize;
  54990. private _onFullscreenChange;
  54991. /**
  54992. * Gets a value indicating if we are currently in VR mode.
  54993. */
  54994. get isInVRMode(): boolean;
  54995. private onVrDisplayPresentChange;
  54996. private onVRDisplayChanged;
  54997. private moveButtonToBottomRight;
  54998. private displayVRButton;
  54999. private updateButtonVisibility;
  55000. private _cachedAngularSensibility;
  55001. /**
  55002. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55003. * Otherwise, will use the fullscreen API.
  55004. */
  55005. enterVR(): void;
  55006. /**
  55007. * Attempt to exit VR, or fullscreen.
  55008. */
  55009. exitVR(): void;
  55010. /**
  55011. * The position of the vr experience helper.
  55012. */
  55013. get position(): Vector3;
  55014. /**
  55015. * Sets the position of the vr experience helper.
  55016. */
  55017. set position(value: Vector3);
  55018. /**
  55019. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55020. */
  55021. enableInteractions(): void;
  55022. private get _noControllerIsActive();
  55023. private beforeRender;
  55024. private _isTeleportationFloor;
  55025. /**
  55026. * Adds a floor mesh to be used for teleportation.
  55027. * @param floorMesh the mesh to be used for teleportation.
  55028. */
  55029. addFloorMesh(floorMesh: Mesh): void;
  55030. /**
  55031. * Removes a floor mesh from being used for teleportation.
  55032. * @param floorMesh the mesh to be removed.
  55033. */
  55034. removeFloorMesh(floorMesh: Mesh): void;
  55035. /**
  55036. * Enables interactions and teleportation using the VR controllers and gaze.
  55037. * @param vrTeleportationOptions options to modify teleportation behavior.
  55038. */
  55039. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55040. private _onNewGamepadConnected;
  55041. private _tryEnableInteractionOnController;
  55042. private _onNewGamepadDisconnected;
  55043. private _enableInteractionOnController;
  55044. private _checkTeleportWithRay;
  55045. private _checkRotate;
  55046. private _checkTeleportBackwards;
  55047. private _enableTeleportationOnController;
  55048. private _createTeleportationCircles;
  55049. private _displayTeleportationTarget;
  55050. private _hideTeleportationTarget;
  55051. private _rotateCamera;
  55052. private _moveTeleportationSelectorTo;
  55053. private _workingVector;
  55054. private _workingQuaternion;
  55055. private _workingMatrix;
  55056. /**
  55057. * Time Constant Teleportation Mode
  55058. */
  55059. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55060. /**
  55061. * Speed Constant Teleportation Mode
  55062. */
  55063. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55064. /**
  55065. * Teleports the users feet to the desired location
  55066. * @param location The location where the user's feet should be placed
  55067. */
  55068. teleportCamera(location: Vector3): void;
  55069. private _convertNormalToDirectionOfRay;
  55070. private _castRayAndSelectObject;
  55071. private _notifySelectedMeshUnselected;
  55072. /**
  55073. * Permanently set new colors for the laser pointer
  55074. * @param color the new laser color
  55075. * @param pickedColor the new laser color when picked mesh detected
  55076. */
  55077. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55078. /**
  55079. * Set lighting enabled / disabled on the laser pointer of both controllers
  55080. * @param enabled should the lighting be enabled on the laser pointer
  55081. */
  55082. setLaserLightingState(enabled?: boolean): void;
  55083. /**
  55084. * Permanently set new colors for the gaze pointer
  55085. * @param color the new gaze color
  55086. * @param pickedColor the new gaze color when picked mesh detected
  55087. */
  55088. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55089. /**
  55090. * Sets the color of the laser ray from the vr controllers.
  55091. * @param color new color for the ray.
  55092. */
  55093. changeLaserColor(color: Color3): void;
  55094. /**
  55095. * Sets the color of the ray from the vr headsets gaze.
  55096. * @param color new color for the ray.
  55097. */
  55098. changeGazeColor(color: Color3): void;
  55099. /**
  55100. * Exits VR and disposes of the vr experience helper
  55101. */
  55102. dispose(): void;
  55103. /**
  55104. * Gets the name of the VRExperienceHelper class
  55105. * @returns "VRExperienceHelper"
  55106. */
  55107. getClassName(): string;
  55108. }
  55109. }
  55110. declare module "babylonjs/Cameras/VR/index" {
  55111. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55112. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55113. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55114. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55115. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55116. export * from "babylonjs/Cameras/VR/webVRCamera";
  55117. }
  55118. declare module "babylonjs/Cameras/RigModes/index" {
  55119. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55120. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55121. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55122. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55123. }
  55124. declare module "babylonjs/Cameras/index" {
  55125. export * from "babylonjs/Cameras/Inputs/index";
  55126. export * from "babylonjs/Cameras/cameraInputsManager";
  55127. export * from "babylonjs/Cameras/camera";
  55128. export * from "babylonjs/Cameras/targetCamera";
  55129. export * from "babylonjs/Cameras/freeCamera";
  55130. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55131. export * from "babylonjs/Cameras/touchCamera";
  55132. export * from "babylonjs/Cameras/arcRotateCamera";
  55133. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55134. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55135. export * from "babylonjs/Cameras/flyCamera";
  55136. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55137. export * from "babylonjs/Cameras/followCamera";
  55138. export * from "babylonjs/Cameras/followCameraInputsManager";
  55139. export * from "babylonjs/Cameras/gamepadCamera";
  55140. export * from "babylonjs/Cameras/Stereoscopic/index";
  55141. export * from "babylonjs/Cameras/universalCamera";
  55142. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55143. export * from "babylonjs/Cameras/VR/index";
  55144. export * from "babylonjs/Cameras/RigModes/index";
  55145. }
  55146. declare module "babylonjs/Collisions/index" {
  55147. export * from "babylonjs/Collisions/collider";
  55148. export * from "babylonjs/Collisions/collisionCoordinator";
  55149. export * from "babylonjs/Collisions/pickingInfo";
  55150. export * from "babylonjs/Collisions/intersectionInfo";
  55151. export * from "babylonjs/Collisions/meshCollisionData";
  55152. }
  55153. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55154. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55155. import { Vector3 } from "babylonjs/Maths/math.vector";
  55156. import { Ray } from "babylonjs/Culling/ray";
  55157. import { Plane } from "babylonjs/Maths/math.plane";
  55158. /**
  55159. * Contains an array of blocks representing the octree
  55160. */
  55161. export interface IOctreeContainer<T> {
  55162. /**
  55163. * Blocks within the octree
  55164. */
  55165. blocks: Array<OctreeBlock<T>>;
  55166. }
  55167. /**
  55168. * Class used to store a cell in an octree
  55169. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55170. */
  55171. export class OctreeBlock<T> {
  55172. /**
  55173. * Gets the content of the current block
  55174. */
  55175. entries: T[];
  55176. /**
  55177. * Gets the list of block children
  55178. */
  55179. blocks: Array<OctreeBlock<T>>;
  55180. private _depth;
  55181. private _maxDepth;
  55182. private _capacity;
  55183. private _minPoint;
  55184. private _maxPoint;
  55185. private _boundingVectors;
  55186. private _creationFunc;
  55187. /**
  55188. * Creates a new block
  55189. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  55190. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  55191. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55192. * @param depth defines the current depth of this block in the octree
  55193. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  55194. * @param creationFunc defines a callback to call when an element is added to the block
  55195. */
  55196. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  55197. /**
  55198. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55199. */
  55200. get capacity(): number;
  55201. /**
  55202. * Gets the minimum vector (in world space) of the block's bounding box
  55203. */
  55204. get minPoint(): Vector3;
  55205. /**
  55206. * Gets the maximum vector (in world space) of the block's bounding box
  55207. */
  55208. get maxPoint(): Vector3;
  55209. /**
  55210. * Add a new element to this block
  55211. * @param entry defines the element to add
  55212. */
  55213. addEntry(entry: T): void;
  55214. /**
  55215. * Remove an element from this block
  55216. * @param entry defines the element to remove
  55217. */
  55218. removeEntry(entry: T): void;
  55219. /**
  55220. * Add an array of elements to this block
  55221. * @param entries defines the array of elements to add
  55222. */
  55223. addEntries(entries: T[]): void;
  55224. /**
  55225. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  55226. * @param frustumPlanes defines the frustum planes to test
  55227. * @param selection defines the array to store current content if selection is positive
  55228. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55229. */
  55230. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55231. /**
  55232. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  55233. * @param sphereCenter defines the bounding sphere center
  55234. * @param sphereRadius defines the bounding sphere radius
  55235. * @param selection defines the array to store current content if selection is positive
  55236. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55237. */
  55238. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55239. /**
  55240. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  55241. * @param ray defines the ray to test with
  55242. * @param selection defines the array to store current content if selection is positive
  55243. */
  55244. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  55245. /**
  55246. * Subdivide the content into child blocks (this block will then be empty)
  55247. */
  55248. createInnerBlocks(): void;
  55249. /**
  55250. * @hidden
  55251. */
  55252. 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;
  55253. }
  55254. }
  55255. declare module "babylonjs/Culling/Octrees/octree" {
  55256. import { SmartArray } from "babylonjs/Misc/smartArray";
  55257. import { Vector3 } from "babylonjs/Maths/math.vector";
  55258. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55260. import { Ray } from "babylonjs/Culling/ray";
  55261. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  55262. import { Plane } from "babylonjs/Maths/math.plane";
  55263. /**
  55264. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  55265. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55266. */
  55267. export class Octree<T> {
  55268. /** 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.) */
  55269. maxDepth: number;
  55270. /**
  55271. * Blocks within the octree containing objects
  55272. */
  55273. blocks: Array<OctreeBlock<T>>;
  55274. /**
  55275. * Content stored in the octree
  55276. */
  55277. dynamicContent: T[];
  55278. private _maxBlockCapacity;
  55279. private _selectionContent;
  55280. private _creationFunc;
  55281. /**
  55282. * Creates a octree
  55283. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55284. * @param creationFunc function to be used to instatiate the octree
  55285. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  55286. * @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.)
  55287. */
  55288. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  55289. /** 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.) */
  55290. maxDepth?: number);
  55291. /**
  55292. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  55293. * @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);
  55294. * @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);
  55295. * @param entries meshes to be added to the octree blocks
  55296. */
  55297. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  55298. /**
  55299. * Adds a mesh to the octree
  55300. * @param entry Mesh to add to the octree
  55301. */
  55302. addMesh(entry: T): void;
  55303. /**
  55304. * Remove an element from the octree
  55305. * @param entry defines the element to remove
  55306. */
  55307. removeMesh(entry: T): void;
  55308. /**
  55309. * Selects an array of meshes within the frustum
  55310. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  55311. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  55312. * @returns array of meshes within the frustum
  55313. */
  55314. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  55315. /**
  55316. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  55317. * @param sphereCenter defines the bounding sphere center
  55318. * @param sphereRadius defines the bounding sphere radius
  55319. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55320. * @returns an array of objects that intersect the sphere
  55321. */
  55322. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  55323. /**
  55324. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  55325. * @param ray defines the ray to test with
  55326. * @returns array of intersected objects
  55327. */
  55328. intersectsRay(ray: Ray): SmartArray<T>;
  55329. /**
  55330. * Adds a mesh into the octree block if it intersects the block
  55331. */
  55332. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  55333. /**
  55334. * Adds a submesh into the octree block if it intersects the block
  55335. */
  55336. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  55337. }
  55338. }
  55339. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  55340. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  55341. import { Scene } from "babylonjs/scene";
  55342. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55344. import { Ray } from "babylonjs/Culling/ray";
  55345. import { Octree } from "babylonjs/Culling/Octrees/octree";
  55346. import { Collider } from "babylonjs/Collisions/collider";
  55347. module "babylonjs/scene" {
  55348. interface Scene {
  55349. /**
  55350. * @hidden
  55351. * Backing Filed
  55352. */
  55353. _selectionOctree: Octree<AbstractMesh>;
  55354. /**
  55355. * Gets the octree used to boost mesh selection (picking)
  55356. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55357. */
  55358. selectionOctree: Octree<AbstractMesh>;
  55359. /**
  55360. * Creates or updates the octree used to boost selection (picking)
  55361. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55362. * @param maxCapacity defines the maximum capacity per leaf
  55363. * @param maxDepth defines the maximum depth of the octree
  55364. * @returns an octree of AbstractMesh
  55365. */
  55366. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  55367. }
  55368. }
  55369. module "babylonjs/Meshes/abstractMesh" {
  55370. interface AbstractMesh {
  55371. /**
  55372. * @hidden
  55373. * Backing Field
  55374. */
  55375. _submeshesOctree: Octree<SubMesh>;
  55376. /**
  55377. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  55378. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  55379. * @param maxCapacity defines the maximum size of each block (64 by default)
  55380. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  55381. * @returns the new octree
  55382. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  55383. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55384. */
  55385. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  55386. }
  55387. }
  55388. /**
  55389. * Defines the octree scene component responsible to manage any octrees
  55390. * in a given scene.
  55391. */
  55392. export class OctreeSceneComponent {
  55393. /**
  55394. * The component name help to identify the component in the list of scene components.
  55395. */
  55396. readonly name: string;
  55397. /**
  55398. * The scene the component belongs to.
  55399. */
  55400. scene: Scene;
  55401. /**
  55402. * Indicates if the meshes have been checked to make sure they are isEnabled()
  55403. */
  55404. readonly checksIsEnabled: boolean;
  55405. /**
  55406. * Creates a new instance of the component for the given scene
  55407. * @param scene Defines the scene to register the component in
  55408. */
  55409. constructor(scene: Scene);
  55410. /**
  55411. * Registers the component in a given scene
  55412. */
  55413. register(): void;
  55414. /**
  55415. * Return the list of active meshes
  55416. * @returns the list of active meshes
  55417. */
  55418. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  55419. /**
  55420. * Return the list of active sub meshes
  55421. * @param mesh The mesh to get the candidates sub meshes from
  55422. * @returns the list of active sub meshes
  55423. */
  55424. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  55425. private _tempRay;
  55426. /**
  55427. * Return the list of sub meshes intersecting with a given local ray
  55428. * @param mesh defines the mesh to find the submesh for
  55429. * @param localRay defines the ray in local space
  55430. * @returns the list of intersecting sub meshes
  55431. */
  55432. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  55433. /**
  55434. * Return the list of sub meshes colliding with a collider
  55435. * @param mesh defines the mesh to find the submesh for
  55436. * @param collider defines the collider to evaluate the collision against
  55437. * @returns the list of colliding sub meshes
  55438. */
  55439. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  55440. /**
  55441. * Rebuilds the elements related to this component in case of
  55442. * context lost for instance.
  55443. */
  55444. rebuild(): void;
  55445. /**
  55446. * Disposes the component and the associated ressources.
  55447. */
  55448. dispose(): void;
  55449. }
  55450. }
  55451. declare module "babylonjs/Culling/Octrees/index" {
  55452. export * from "babylonjs/Culling/Octrees/octree";
  55453. export * from "babylonjs/Culling/Octrees/octreeBlock";
  55454. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  55455. }
  55456. declare module "babylonjs/Culling/index" {
  55457. export * from "babylonjs/Culling/boundingBox";
  55458. export * from "babylonjs/Culling/boundingInfo";
  55459. export * from "babylonjs/Culling/boundingSphere";
  55460. export * from "babylonjs/Culling/Octrees/index";
  55461. export * from "babylonjs/Culling/ray";
  55462. }
  55463. declare module "babylonjs/Gizmos/gizmo" {
  55464. import { Nullable } from "babylonjs/types";
  55465. import { IDisposable } from "babylonjs/scene";
  55466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55467. import { Mesh } from "babylonjs/Meshes/mesh";
  55468. import { Node } from "babylonjs/node";
  55469. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55470. /**
  55471. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  55472. */
  55473. export class Gizmo implements IDisposable {
  55474. /** The utility layer the gizmo will be added to */
  55475. gizmoLayer: UtilityLayerRenderer;
  55476. /**
  55477. * The root mesh of the gizmo
  55478. */
  55479. _rootMesh: Mesh;
  55480. private _attachedMesh;
  55481. private _attachedNode;
  55482. /**
  55483. * Ratio for the scale of the gizmo (Default: 1)
  55484. */
  55485. protected _scaleRatio: number;
  55486. /**
  55487. * boolean updated by pointermove when a gizmo mesh is hovered
  55488. */
  55489. protected _isHovered: boolean;
  55490. /**
  55491. * Ratio for the scale of the gizmo (Default: 1)
  55492. */
  55493. set scaleRatio(value: number);
  55494. get scaleRatio(): number;
  55495. /**
  55496. * True when the mouse pointer is hovered a gizmo mesh
  55497. */
  55498. get isHovered(): boolean;
  55499. /**
  55500. * If a custom mesh has been set (Default: false)
  55501. */
  55502. protected _customMeshSet: boolean;
  55503. /**
  55504. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  55505. * * When set, interactions will be enabled
  55506. */
  55507. get attachedMesh(): Nullable<AbstractMesh>;
  55508. set attachedMesh(value: Nullable<AbstractMesh>);
  55509. /**
  55510. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  55511. * * When set, interactions will be enabled
  55512. */
  55513. get attachedNode(): Nullable<Node>;
  55514. set attachedNode(value: Nullable<Node>);
  55515. /**
  55516. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55517. * @param mesh The mesh to replace the default mesh of the gizmo
  55518. */
  55519. setCustomMesh(mesh: Mesh): void;
  55520. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  55521. /**
  55522. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  55523. */
  55524. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55525. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55526. /**
  55527. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  55528. */
  55529. updateGizmoPositionToMatchAttachedMesh: boolean;
  55530. /**
  55531. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  55532. */
  55533. updateScale: boolean;
  55534. protected _interactionsEnabled: boolean;
  55535. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55536. private _beforeRenderObserver;
  55537. private _tempQuaternion;
  55538. private _tempVector;
  55539. private _tempVector2;
  55540. private _tempMatrix1;
  55541. private _tempMatrix2;
  55542. private _rightHandtoLeftHandMatrix;
  55543. /**
  55544. * Creates a gizmo
  55545. * @param gizmoLayer The utility layer the gizmo will be added to
  55546. */
  55547. constructor(
  55548. /** The utility layer the gizmo will be added to */
  55549. gizmoLayer?: UtilityLayerRenderer);
  55550. /**
  55551. * Updates the gizmo to match the attached mesh's position/rotation
  55552. */
  55553. protected _update(): void;
  55554. /**
  55555. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  55556. * @param value Node, TransformNode or mesh
  55557. */
  55558. protected _matrixChanged(): void;
  55559. /**
  55560. * Disposes of the gizmo
  55561. */
  55562. dispose(): void;
  55563. }
  55564. }
  55565. declare module "babylonjs/Gizmos/planeDragGizmo" {
  55566. import { Observable } from "babylonjs/Misc/observable";
  55567. import { Nullable } from "babylonjs/types";
  55568. import { Vector3 } from "babylonjs/Maths/math.vector";
  55569. import { Color3 } from "babylonjs/Maths/math.color";
  55570. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55571. import { Node } from "babylonjs/node";
  55572. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55573. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55574. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55575. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55576. import { Scene } from "babylonjs/scene";
  55577. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55578. /**
  55579. * Single plane drag gizmo
  55580. */
  55581. export class PlaneDragGizmo extends Gizmo {
  55582. /**
  55583. * Drag behavior responsible for the gizmos dragging interactions
  55584. */
  55585. dragBehavior: PointerDragBehavior;
  55586. private _pointerObserver;
  55587. /**
  55588. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55589. */
  55590. snapDistance: number;
  55591. /**
  55592. * Event that fires each time the gizmo snaps to a new location.
  55593. * * snapDistance is the the change in distance
  55594. */
  55595. onSnapObservable: Observable<{
  55596. snapDistance: number;
  55597. }>;
  55598. private _plane;
  55599. private _coloredMaterial;
  55600. private _hoverMaterial;
  55601. private _isEnabled;
  55602. private _parent;
  55603. /** @hidden */
  55604. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  55605. /** @hidden */
  55606. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55607. /**
  55608. * Creates a PlaneDragGizmo
  55609. * @param gizmoLayer The utility layer the gizmo will be added to
  55610. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  55611. * @param color The color of the gizmo
  55612. */
  55613. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  55614. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55615. /**
  55616. * If the gizmo is enabled
  55617. */
  55618. set isEnabled(value: boolean);
  55619. get isEnabled(): boolean;
  55620. /**
  55621. * Disposes of the gizmo
  55622. */
  55623. dispose(): void;
  55624. }
  55625. }
  55626. declare module "babylonjs/Gizmos/positionGizmo" {
  55627. import { Observable } from "babylonjs/Misc/observable";
  55628. import { Nullable } from "babylonjs/types";
  55629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55630. import { Node } from "babylonjs/node";
  55631. import { Mesh } from "babylonjs/Meshes/mesh";
  55632. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55633. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  55634. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  55635. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55636. /**
  55637. * Gizmo that enables dragging a mesh along 3 axis
  55638. */
  55639. export class PositionGizmo extends Gizmo {
  55640. /**
  55641. * Internal gizmo used for interactions on the x axis
  55642. */
  55643. xGizmo: AxisDragGizmo;
  55644. /**
  55645. * Internal gizmo used for interactions on the y axis
  55646. */
  55647. yGizmo: AxisDragGizmo;
  55648. /**
  55649. * Internal gizmo used for interactions on the z axis
  55650. */
  55651. zGizmo: AxisDragGizmo;
  55652. /**
  55653. * Internal gizmo used for interactions on the yz plane
  55654. */
  55655. xPlaneGizmo: PlaneDragGizmo;
  55656. /**
  55657. * Internal gizmo used for interactions on the xz plane
  55658. */
  55659. yPlaneGizmo: PlaneDragGizmo;
  55660. /**
  55661. * Internal gizmo used for interactions on the xy plane
  55662. */
  55663. zPlaneGizmo: PlaneDragGizmo;
  55664. /**
  55665. * private variables
  55666. */
  55667. private _meshAttached;
  55668. private _nodeAttached;
  55669. private _snapDistance;
  55670. /** Fires an event when any of it's sub gizmos are dragged */
  55671. onDragStartObservable: Observable<unknown>;
  55672. /** Fires an event when any of it's sub gizmos are released from dragging */
  55673. onDragEndObservable: Observable<unknown>;
  55674. /**
  55675. * If set to true, planar drag is enabled
  55676. */
  55677. private _planarGizmoEnabled;
  55678. get attachedMesh(): Nullable<AbstractMesh>;
  55679. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55680. get attachedNode(): Nullable<Node>;
  55681. set attachedNode(node: Nullable<Node>);
  55682. /**
  55683. * True when the mouse pointer is hovering a gizmo mesh
  55684. */
  55685. get isHovered(): boolean;
  55686. /**
  55687. * Creates a PositionGizmo
  55688. * @param gizmoLayer The utility layer the gizmo will be added to
  55689. @param thickness display gizmo axis thickness
  55690. */
  55691. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55692. /**
  55693. * If the planar drag gizmo is enabled
  55694. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  55695. */
  55696. set planarGizmoEnabled(value: boolean);
  55697. get planarGizmoEnabled(): boolean;
  55698. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55699. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55700. /**
  55701. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55702. */
  55703. set snapDistance(value: number);
  55704. get snapDistance(): number;
  55705. /**
  55706. * Ratio for the scale of the gizmo (Default: 1)
  55707. */
  55708. set scaleRatio(value: number);
  55709. get scaleRatio(): number;
  55710. /**
  55711. * Disposes of the gizmo
  55712. */
  55713. dispose(): void;
  55714. /**
  55715. * CustomMeshes are not supported by this gizmo
  55716. * @param mesh The mesh to replace the default mesh of the gizmo
  55717. */
  55718. setCustomMesh(mesh: Mesh): void;
  55719. }
  55720. }
  55721. declare module "babylonjs/Gizmos/axisDragGizmo" {
  55722. import { Observable } from "babylonjs/Misc/observable";
  55723. import { Nullable } from "babylonjs/types";
  55724. import { Vector3 } from "babylonjs/Maths/math.vector";
  55725. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55726. import { Node } from "babylonjs/node";
  55727. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55728. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55729. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55730. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55731. import { Scene } from "babylonjs/scene";
  55732. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55733. import { Color3 } from "babylonjs/Maths/math.color";
  55734. /**
  55735. * Single axis drag gizmo
  55736. */
  55737. export class AxisDragGizmo extends Gizmo {
  55738. /**
  55739. * Drag behavior responsible for the gizmos dragging interactions
  55740. */
  55741. dragBehavior: PointerDragBehavior;
  55742. private _pointerObserver;
  55743. /**
  55744. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55745. */
  55746. snapDistance: number;
  55747. /**
  55748. * Event that fires each time the gizmo snaps to a new location.
  55749. * * snapDistance is the the change in distance
  55750. */
  55751. onSnapObservable: Observable<{
  55752. snapDistance: number;
  55753. }>;
  55754. private _isEnabled;
  55755. private _parent;
  55756. private _arrow;
  55757. private _coloredMaterial;
  55758. private _hoverMaterial;
  55759. /** @hidden */
  55760. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  55761. /** @hidden */
  55762. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55763. /**
  55764. * Creates an AxisDragGizmo
  55765. * @param gizmoLayer The utility layer the gizmo will be added to
  55766. * @param dragAxis The axis which the gizmo will be able to drag on
  55767. * @param color The color of the gizmo
  55768. * @param thickness display gizmo axis thickness
  55769. */
  55770. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  55771. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55772. /**
  55773. * If the gizmo is enabled
  55774. */
  55775. set isEnabled(value: boolean);
  55776. get isEnabled(): boolean;
  55777. /**
  55778. * Disposes of the gizmo
  55779. */
  55780. dispose(): void;
  55781. }
  55782. }
  55783. declare module "babylonjs/Debug/axesViewer" {
  55784. import { Vector3 } from "babylonjs/Maths/math.vector";
  55785. import { Nullable } from "babylonjs/types";
  55786. import { Scene } from "babylonjs/scene";
  55787. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55788. /**
  55789. * The Axes viewer will show 3 axes in a specific point in space
  55790. */
  55791. export class AxesViewer {
  55792. private _xAxis;
  55793. private _yAxis;
  55794. private _zAxis;
  55795. private _scaleLinesFactor;
  55796. private _instanced;
  55797. /**
  55798. * Gets the hosting scene
  55799. */
  55800. scene: Nullable<Scene>;
  55801. /**
  55802. * Gets or sets a number used to scale line length
  55803. */
  55804. scaleLines: number;
  55805. /** Gets the node hierarchy used to render x-axis */
  55806. get xAxis(): TransformNode;
  55807. /** Gets the node hierarchy used to render y-axis */
  55808. get yAxis(): TransformNode;
  55809. /** Gets the node hierarchy used to render z-axis */
  55810. get zAxis(): TransformNode;
  55811. /**
  55812. * Creates a new AxesViewer
  55813. * @param scene defines the hosting scene
  55814. * @param scaleLines defines a number used to scale line length (1 by default)
  55815. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  55816. * @param xAxis defines the node hierarchy used to render the x-axis
  55817. * @param yAxis defines the node hierarchy used to render the y-axis
  55818. * @param zAxis defines the node hierarchy used to render the z-axis
  55819. */
  55820. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  55821. /**
  55822. * Force the viewer to update
  55823. * @param position defines the position of the viewer
  55824. * @param xaxis defines the x axis of the viewer
  55825. * @param yaxis defines the y axis of the viewer
  55826. * @param zaxis defines the z axis of the viewer
  55827. */
  55828. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  55829. /**
  55830. * Creates an instance of this axes viewer.
  55831. * @returns a new axes viewer with instanced meshes
  55832. */
  55833. createInstance(): AxesViewer;
  55834. /** Releases resources */
  55835. dispose(): void;
  55836. private static _SetRenderingGroupId;
  55837. }
  55838. }
  55839. declare module "babylonjs/Debug/boneAxesViewer" {
  55840. import { Nullable } from "babylonjs/types";
  55841. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  55842. import { Vector3 } from "babylonjs/Maths/math.vector";
  55843. import { Mesh } from "babylonjs/Meshes/mesh";
  55844. import { Bone } from "babylonjs/Bones/bone";
  55845. import { Scene } from "babylonjs/scene";
  55846. /**
  55847. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  55848. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  55849. */
  55850. export class BoneAxesViewer extends AxesViewer {
  55851. /**
  55852. * Gets or sets the target mesh where to display the axes viewer
  55853. */
  55854. mesh: Nullable<Mesh>;
  55855. /**
  55856. * Gets or sets the target bone where to display the axes viewer
  55857. */
  55858. bone: Nullable<Bone>;
  55859. /** Gets current position */
  55860. pos: Vector3;
  55861. /** Gets direction of X axis */
  55862. xaxis: Vector3;
  55863. /** Gets direction of Y axis */
  55864. yaxis: Vector3;
  55865. /** Gets direction of Z axis */
  55866. zaxis: Vector3;
  55867. /**
  55868. * Creates a new BoneAxesViewer
  55869. * @param scene defines the hosting scene
  55870. * @param bone defines the target bone
  55871. * @param mesh defines the target mesh
  55872. * @param scaleLines defines a scaling factor for line length (1 by default)
  55873. */
  55874. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  55875. /**
  55876. * Force the viewer to update
  55877. */
  55878. update(): void;
  55879. /** Releases resources */
  55880. dispose(): void;
  55881. }
  55882. }
  55883. declare module "babylonjs/Debug/debugLayer" {
  55884. import { Scene } from "babylonjs/scene";
  55885. /**
  55886. * Interface used to define scene explorer extensibility option
  55887. */
  55888. export interface IExplorerExtensibilityOption {
  55889. /**
  55890. * Define the option label
  55891. */
  55892. label: string;
  55893. /**
  55894. * Defines the action to execute on click
  55895. */
  55896. action: (entity: any) => void;
  55897. }
  55898. /**
  55899. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  55900. */
  55901. export interface IExplorerExtensibilityGroup {
  55902. /**
  55903. * Defines a predicate to test if a given type mut be extended
  55904. */
  55905. predicate: (entity: any) => boolean;
  55906. /**
  55907. * Gets the list of options added to a type
  55908. */
  55909. entries: IExplorerExtensibilityOption[];
  55910. }
  55911. /**
  55912. * Interface used to define the options to use to create the Inspector
  55913. */
  55914. export interface IInspectorOptions {
  55915. /**
  55916. * Display in overlay mode (default: false)
  55917. */
  55918. overlay?: boolean;
  55919. /**
  55920. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  55921. */
  55922. globalRoot?: HTMLElement;
  55923. /**
  55924. * Display the Scene explorer
  55925. */
  55926. showExplorer?: boolean;
  55927. /**
  55928. * Display the property inspector
  55929. */
  55930. showInspector?: boolean;
  55931. /**
  55932. * Display in embed mode (both panes on the right)
  55933. */
  55934. embedMode?: boolean;
  55935. /**
  55936. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  55937. */
  55938. handleResize?: boolean;
  55939. /**
  55940. * Allow the panes to popup (default: true)
  55941. */
  55942. enablePopup?: boolean;
  55943. /**
  55944. * Allow the panes to be closed by users (default: true)
  55945. */
  55946. enableClose?: boolean;
  55947. /**
  55948. * Optional list of extensibility entries
  55949. */
  55950. explorerExtensibility?: IExplorerExtensibilityGroup[];
  55951. /**
  55952. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  55953. */
  55954. inspectorURL?: string;
  55955. /**
  55956. * Optional initial tab (default to DebugLayerTab.Properties)
  55957. */
  55958. initialTab?: DebugLayerTab;
  55959. }
  55960. module "babylonjs/scene" {
  55961. interface Scene {
  55962. /**
  55963. * @hidden
  55964. * Backing field
  55965. */
  55966. _debugLayer: DebugLayer;
  55967. /**
  55968. * Gets the debug layer (aka Inspector) associated with the scene
  55969. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55970. */
  55971. debugLayer: DebugLayer;
  55972. }
  55973. }
  55974. /**
  55975. * Enum of inspector action tab
  55976. */
  55977. export enum DebugLayerTab {
  55978. /**
  55979. * Properties tag (default)
  55980. */
  55981. Properties = 0,
  55982. /**
  55983. * Debug tab
  55984. */
  55985. Debug = 1,
  55986. /**
  55987. * Statistics tab
  55988. */
  55989. Statistics = 2,
  55990. /**
  55991. * Tools tab
  55992. */
  55993. Tools = 3,
  55994. /**
  55995. * Settings tab
  55996. */
  55997. Settings = 4
  55998. }
  55999. /**
  56000. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56001. * what is happening in your scene
  56002. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56003. */
  56004. export class DebugLayer {
  56005. /**
  56006. * Define the url to get the inspector script from.
  56007. * By default it uses the babylonjs CDN.
  56008. * @ignoreNaming
  56009. */
  56010. static InspectorURL: string;
  56011. private _scene;
  56012. private BJSINSPECTOR;
  56013. private _onPropertyChangedObservable?;
  56014. /**
  56015. * Observable triggered when a property is changed through the inspector.
  56016. */
  56017. get onPropertyChangedObservable(): any;
  56018. /**
  56019. * Instantiates a new debug layer.
  56020. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56021. * what is happening in your scene
  56022. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56023. * @param scene Defines the scene to inspect
  56024. */
  56025. constructor(scene: Scene);
  56026. /** Creates the inspector window. */
  56027. private _createInspector;
  56028. /**
  56029. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  56030. * @param entity defines the entity to select
  56031. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  56032. */
  56033. select(entity: any, lineContainerTitles?: string | string[]): void;
  56034. /** Get the inspector from bundle or global */
  56035. private _getGlobalInspector;
  56036. /**
  56037. * Get if the inspector is visible or not.
  56038. * @returns true if visible otherwise, false
  56039. */
  56040. isVisible(): boolean;
  56041. /**
  56042. * Hide the inspector and close its window.
  56043. */
  56044. hide(): void;
  56045. /**
  56046. * Update the scene in the inspector
  56047. */
  56048. setAsActiveScene(): void;
  56049. /**
  56050. * Launch the debugLayer.
  56051. * @param config Define the configuration of the inspector
  56052. * @return a promise fulfilled when the debug layer is visible
  56053. */
  56054. show(config?: IInspectorOptions): Promise<DebugLayer>;
  56055. }
  56056. }
  56057. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56058. import { Nullable } from "babylonjs/types";
  56059. import { Scene } from "babylonjs/scene";
  56060. import { Vector4 } from "babylonjs/Maths/math.vector";
  56061. import { Color4 } from "babylonjs/Maths/math.color";
  56062. import { Mesh } from "babylonjs/Meshes/mesh";
  56063. /**
  56064. * Class containing static functions to help procedurally build meshes
  56065. */
  56066. export class BoxBuilder {
  56067. /**
  56068. * Creates a box mesh
  56069. * * The parameter `size` sets the size (float) of each box side (default 1)
  56070. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56071. * * 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)
  56072. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56074. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56076. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56077. * @param name defines the name of the mesh
  56078. * @param options defines the options used to create the mesh
  56079. * @param scene defines the hosting scene
  56080. * @returns the box mesh
  56081. */
  56082. static CreateBox(name: string, options: {
  56083. size?: number;
  56084. width?: number;
  56085. height?: number;
  56086. depth?: number;
  56087. faceUV?: Vector4[];
  56088. faceColors?: Color4[];
  56089. sideOrientation?: number;
  56090. frontUVs?: Vector4;
  56091. backUVs?: Vector4;
  56092. wrap?: boolean;
  56093. topBaseAt?: number;
  56094. bottomBaseAt?: number;
  56095. updatable?: boolean;
  56096. }, scene?: Nullable<Scene>): Mesh;
  56097. }
  56098. }
  56099. declare module "babylonjs/Debug/physicsViewer" {
  56100. import { Nullable } from "babylonjs/types";
  56101. import { Scene } from "babylonjs/scene";
  56102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56103. import { Mesh } from "babylonjs/Meshes/mesh";
  56104. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56105. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56106. /**
  56107. * Used to show the physics impostor around the specific mesh
  56108. */
  56109. export class PhysicsViewer {
  56110. /** @hidden */
  56111. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  56112. /** @hidden */
  56113. protected _meshes: Array<Nullable<AbstractMesh>>;
  56114. /** @hidden */
  56115. protected _scene: Nullable<Scene>;
  56116. /** @hidden */
  56117. protected _numMeshes: number;
  56118. /** @hidden */
  56119. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  56120. private _renderFunction;
  56121. private _utilityLayer;
  56122. private _debugBoxMesh;
  56123. private _debugSphereMesh;
  56124. private _debugCylinderMesh;
  56125. private _debugMaterial;
  56126. private _debugMeshMeshes;
  56127. /**
  56128. * Creates a new PhysicsViewer
  56129. * @param scene defines the hosting scene
  56130. */
  56131. constructor(scene: Scene);
  56132. /** @hidden */
  56133. protected _updateDebugMeshes(): void;
  56134. /**
  56135. * Renders a specified physic impostor
  56136. * @param impostor defines the impostor to render
  56137. * @param targetMesh defines the mesh represented by the impostor
  56138. * @returns the new debug mesh used to render the impostor
  56139. */
  56140. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  56141. /**
  56142. * Hides a specified physic impostor
  56143. * @param impostor defines the impostor to hide
  56144. */
  56145. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  56146. private _getDebugMaterial;
  56147. private _getDebugBoxMesh;
  56148. private _getDebugSphereMesh;
  56149. private _getDebugCylinderMesh;
  56150. private _getDebugMeshMesh;
  56151. private _getDebugMesh;
  56152. /** Releases all resources */
  56153. dispose(): void;
  56154. }
  56155. }
  56156. declare module "babylonjs/Debug/rayHelper" {
  56157. import { Nullable } from "babylonjs/types";
  56158. import { Ray } from "babylonjs/Culling/ray";
  56159. import { Vector3 } from "babylonjs/Maths/math.vector";
  56160. import { Color3 } from "babylonjs/Maths/math.color";
  56161. import { Scene } from "babylonjs/scene";
  56162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56163. import "babylonjs/Meshes/Builders/linesBuilder";
  56164. /**
  56165. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56166. * in order to better appreciate the issue one might have.
  56167. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56168. */
  56169. export class RayHelper {
  56170. /**
  56171. * Defines the ray we are currently tryin to visualize.
  56172. */
  56173. ray: Nullable<Ray>;
  56174. private _renderPoints;
  56175. private _renderLine;
  56176. private _renderFunction;
  56177. private _scene;
  56178. private _onAfterRenderObserver;
  56179. private _onAfterStepObserver;
  56180. private _attachedToMesh;
  56181. private _meshSpaceDirection;
  56182. private _meshSpaceOrigin;
  56183. /**
  56184. * Helper function to create a colored helper in a scene in one line.
  56185. * @param ray Defines the ray we are currently tryin to visualize
  56186. * @param scene Defines the scene the ray is used in
  56187. * @param color Defines the color we want to see the ray in
  56188. * @returns The newly created ray helper.
  56189. */
  56190. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  56191. /**
  56192. * Instantiate a new ray helper.
  56193. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56194. * in order to better appreciate the issue one might have.
  56195. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56196. * @param ray Defines the ray we are currently tryin to visualize
  56197. */
  56198. constructor(ray: Ray);
  56199. /**
  56200. * Shows the ray we are willing to debug.
  56201. * @param scene Defines the scene the ray needs to be rendered in
  56202. * @param color Defines the color the ray needs to be rendered in
  56203. */
  56204. show(scene: Scene, color?: Color3): void;
  56205. /**
  56206. * Hides the ray we are debugging.
  56207. */
  56208. hide(): void;
  56209. private _render;
  56210. /**
  56211. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  56212. * @param mesh Defines the mesh we want the helper attached to
  56213. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  56214. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  56215. * @param length Defines the length of the ray
  56216. */
  56217. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  56218. /**
  56219. * Detach the ray helper from the mesh it has previously been attached to.
  56220. */
  56221. detachFromMesh(): void;
  56222. private _updateToMesh;
  56223. /**
  56224. * Dispose the helper and release its associated resources.
  56225. */
  56226. dispose(): void;
  56227. }
  56228. }
  56229. declare module "babylonjs/Debug/ISkeletonViewer" {
  56230. import { Skeleton } from "babylonjs/Bones/skeleton";
  56231. import { Color3 } from "babylonjs/Maths/math.color";
  56232. /**
  56233. * Defines the options associated with the creation of a SkeletonViewer.
  56234. */
  56235. export interface ISkeletonViewerOptions {
  56236. /** Should the system pause animations before building the Viewer? */
  56237. pauseAnimations: boolean;
  56238. /** Should the system return the skeleton to rest before building? */
  56239. returnToRest: boolean;
  56240. /** public Display Mode of the Viewer */
  56241. displayMode: number;
  56242. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56243. displayOptions: ISkeletonViewerDisplayOptions;
  56244. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56245. computeBonesUsingShaders: boolean;
  56246. /** Flag ignore non weighted bones */
  56247. useAllBones: boolean;
  56248. }
  56249. /**
  56250. * Defines how to display the various bone meshes for the viewer.
  56251. */
  56252. export interface ISkeletonViewerDisplayOptions {
  56253. /** How far down to start tapering the bone spurs */
  56254. midStep?: number;
  56255. /** How big is the midStep? */
  56256. midStepFactor?: number;
  56257. /** Base for the Sphere Size */
  56258. sphereBaseSize?: number;
  56259. /** The ratio of the sphere to the longest bone in units */
  56260. sphereScaleUnit?: number;
  56261. /** Ratio for the Sphere Size */
  56262. sphereFactor?: number;
  56263. /** Whether a spur should attach its far end to the child bone position */
  56264. spurFollowsChild?: boolean;
  56265. /** Whether to show local axes or not */
  56266. showLocalAxes?: boolean;
  56267. /** Length of each local axis */
  56268. localAxesSize?: number;
  56269. }
  56270. /**
  56271. * Defines the constructor options for the BoneWeight Shader.
  56272. */
  56273. export interface IBoneWeightShaderOptions {
  56274. /** Skeleton to Map */
  56275. skeleton: Skeleton;
  56276. /** Colors for Uninfluenced bones */
  56277. colorBase?: Color3;
  56278. /** Colors for 0.0-0.25 Weight bones */
  56279. colorZero?: Color3;
  56280. /** Color for 0.25-0.5 Weight Influence */
  56281. colorQuarter?: Color3;
  56282. /** Color for 0.5-0.75 Weight Influence */
  56283. colorHalf?: Color3;
  56284. /** Color for 0.75-1 Weight Influence */
  56285. colorFull?: Color3;
  56286. /** Color for Zero Weight Influence */
  56287. targetBoneIndex?: number;
  56288. }
  56289. /**
  56290. * Simple structure of the gradient steps for the Color Map.
  56291. */
  56292. export interface ISkeletonMapShaderColorMapKnot {
  56293. /** Color of the Knot */
  56294. color: Color3;
  56295. /** Location of the Knot */
  56296. location: number;
  56297. }
  56298. /**
  56299. * Defines the constructor options for the SkeletonMap Shader.
  56300. */
  56301. export interface ISkeletonMapShaderOptions {
  56302. /** Skeleton to Map */
  56303. skeleton: Skeleton;
  56304. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  56305. colorMap?: ISkeletonMapShaderColorMapKnot[];
  56306. }
  56307. }
  56308. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  56309. import { Nullable } from "babylonjs/types";
  56310. import { Scene } from "babylonjs/scene";
  56311. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  56312. import { Color4 } from "babylonjs/Maths/math.color";
  56313. import { Mesh } from "babylonjs/Meshes/mesh";
  56314. /**
  56315. * Class containing static functions to help procedurally build meshes
  56316. */
  56317. export class RibbonBuilder {
  56318. /**
  56319. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56320. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56321. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56322. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56323. * * 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
  56324. * * 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
  56325. * * 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
  56326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56327. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56328. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56329. * * 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
  56330. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56331. * * 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
  56332. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56334. * @param name defines the name of the mesh
  56335. * @param options defines the options used to create the mesh
  56336. * @param scene defines the hosting scene
  56337. * @returns the ribbon mesh
  56338. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56339. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56340. */
  56341. static CreateRibbon(name: string, options: {
  56342. pathArray: Vector3[][];
  56343. closeArray?: boolean;
  56344. closePath?: boolean;
  56345. offset?: number;
  56346. updatable?: boolean;
  56347. sideOrientation?: number;
  56348. frontUVs?: Vector4;
  56349. backUVs?: Vector4;
  56350. instance?: Mesh;
  56351. invertUV?: boolean;
  56352. uvs?: Vector2[];
  56353. colors?: Color4[];
  56354. }, scene?: Nullable<Scene>): Mesh;
  56355. }
  56356. }
  56357. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  56358. import { Nullable } from "babylonjs/types";
  56359. import { Scene } from "babylonjs/scene";
  56360. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56361. import { Mesh } from "babylonjs/Meshes/mesh";
  56362. /**
  56363. * Class containing static functions to help procedurally build meshes
  56364. */
  56365. export class ShapeBuilder {
  56366. /**
  56367. * 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.
  56368. * * 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.
  56369. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56370. * * 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.
  56371. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56372. * * 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
  56373. * * 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
  56374. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56376. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56377. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56379. * @param name defines the name of the mesh
  56380. * @param options defines the options used to create the mesh
  56381. * @param scene defines the hosting scene
  56382. * @returns the extruded shape mesh
  56383. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56384. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56385. */
  56386. static ExtrudeShape(name: string, options: {
  56387. shape: Vector3[];
  56388. path: Vector3[];
  56389. scale?: number;
  56390. rotation?: number;
  56391. cap?: number;
  56392. updatable?: boolean;
  56393. sideOrientation?: number;
  56394. frontUVs?: Vector4;
  56395. backUVs?: Vector4;
  56396. instance?: Mesh;
  56397. invertUV?: boolean;
  56398. }, scene?: Nullable<Scene>): Mesh;
  56399. /**
  56400. * Creates an custom extruded shape mesh.
  56401. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56402. * * 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.
  56403. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56404. * * 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
  56405. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56406. * * 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
  56407. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56408. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56409. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56410. * * 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
  56411. * * 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
  56412. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56415. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56417. * @param name defines the name of the mesh
  56418. * @param options defines the options used to create the mesh
  56419. * @param scene defines the hosting scene
  56420. * @returns the custom extruded shape mesh
  56421. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56422. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56424. */
  56425. static ExtrudeShapeCustom(name: string, options: {
  56426. shape: Vector3[];
  56427. path: Vector3[];
  56428. scaleFunction?: any;
  56429. rotationFunction?: any;
  56430. ribbonCloseArray?: boolean;
  56431. ribbonClosePath?: boolean;
  56432. cap?: number;
  56433. updatable?: boolean;
  56434. sideOrientation?: number;
  56435. frontUVs?: Vector4;
  56436. backUVs?: Vector4;
  56437. instance?: Mesh;
  56438. invertUV?: boolean;
  56439. }, scene?: Nullable<Scene>): Mesh;
  56440. private static _ExtrudeShapeGeneric;
  56441. }
  56442. }
  56443. declare module "babylonjs/Debug/skeletonViewer" {
  56444. import { Color3 } from "babylonjs/Maths/math.color";
  56445. import { Scene } from "babylonjs/scene";
  56446. import { Nullable } from "babylonjs/types";
  56447. import { Skeleton } from "babylonjs/Bones/skeleton";
  56448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56449. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56450. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56451. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  56452. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  56453. /**
  56454. * Class used to render a debug view of a given skeleton
  56455. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  56456. */
  56457. export class SkeletonViewer {
  56458. /** defines the skeleton to render */
  56459. skeleton: Skeleton;
  56460. /** defines the mesh attached to the skeleton */
  56461. mesh: AbstractMesh;
  56462. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56463. autoUpdateBonesMatrices: boolean;
  56464. /** defines the rendering group id to use with the viewer */
  56465. renderingGroupId: number;
  56466. /** is the options for the viewer */
  56467. options: Partial<ISkeletonViewerOptions>;
  56468. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  56469. static readonly DISPLAY_LINES: number;
  56470. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  56471. static readonly DISPLAY_SPHERES: number;
  56472. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  56473. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  56474. /** public static method to create a BoneWeight Shader
  56475. * @param options The constructor options
  56476. * @param scene The scene that the shader is scoped to
  56477. * @returns The created ShaderMaterial
  56478. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  56479. */
  56480. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  56481. /** public static method to create a BoneWeight Shader
  56482. * @param options The constructor options
  56483. * @param scene The scene that the shader is scoped to
  56484. * @returns The created ShaderMaterial
  56485. */
  56486. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  56487. /** private static method to create a BoneWeight Shader
  56488. * @param size The size of the buffer to create (usually the bone count)
  56489. * @param colorMap The gradient data to generate
  56490. * @param scene The scene that the shader is scoped to
  56491. * @returns an Array of floats from the color gradient values
  56492. */
  56493. private static _CreateBoneMapColorBuffer;
  56494. /** If SkeletonViewer scene scope. */
  56495. private _scene;
  56496. /** Gets or sets the color used to render the skeleton */
  56497. color: Color3;
  56498. /** Array of the points of the skeleton fo the line view. */
  56499. private _debugLines;
  56500. /** The SkeletonViewers Mesh. */
  56501. private _debugMesh;
  56502. /** The local axes Meshes. */
  56503. private _localAxes;
  56504. /** If SkeletonViewer is enabled. */
  56505. private _isEnabled;
  56506. /** If SkeletonViewer is ready. */
  56507. private _ready;
  56508. /** SkeletonViewer render observable. */
  56509. private _obs;
  56510. /** The Utility Layer to render the gizmos in. */
  56511. private _utilityLayer;
  56512. private _boneIndices;
  56513. /** Gets the Scene. */
  56514. get scene(): Scene;
  56515. /** Gets the utilityLayer. */
  56516. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  56517. /** Checks Ready Status. */
  56518. get isReady(): Boolean;
  56519. /** Sets Ready Status. */
  56520. set ready(value: boolean);
  56521. /** Gets the debugMesh */
  56522. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  56523. /** Sets the debugMesh */
  56524. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  56525. /** Gets the displayMode */
  56526. get displayMode(): number;
  56527. /** Sets the displayMode */
  56528. set displayMode(value: number);
  56529. /**
  56530. * Creates a new SkeletonViewer
  56531. * @param skeleton defines the skeleton to render
  56532. * @param mesh defines the mesh attached to the skeleton
  56533. * @param scene defines the hosting scene
  56534. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  56535. * @param renderingGroupId defines the rendering group id to use with the viewer
  56536. * @param options All of the extra constructor options for the SkeletonViewer
  56537. */
  56538. constructor(
  56539. /** defines the skeleton to render */
  56540. skeleton: Skeleton,
  56541. /** defines the mesh attached to the skeleton */
  56542. mesh: AbstractMesh,
  56543. /** The Scene scope*/
  56544. scene: Scene,
  56545. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56546. autoUpdateBonesMatrices?: boolean,
  56547. /** defines the rendering group id to use with the viewer */
  56548. renderingGroupId?: number,
  56549. /** is the options for the viewer */
  56550. options?: Partial<ISkeletonViewerOptions>);
  56551. /** The Dynamic bindings for the update functions */
  56552. private _bindObs;
  56553. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  56554. update(): void;
  56555. /** Gets or sets a boolean indicating if the viewer is enabled */
  56556. set isEnabled(value: boolean);
  56557. get isEnabled(): boolean;
  56558. private _getBonePosition;
  56559. private _getLinesForBonesWithLength;
  56560. private _getLinesForBonesNoLength;
  56561. /** function to revert the mesh and scene back to the initial state. */
  56562. private _revert;
  56563. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  56564. private _getAbsoluteBindPoseToRef;
  56565. /** function to build and bind sphere joint points and spur bone representations. */
  56566. private _buildSpheresAndSpurs;
  56567. private _buildLocalAxes;
  56568. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  56569. private _displayLinesUpdate;
  56570. /** Changes the displayMode of the skeleton viewer
  56571. * @param mode The displayMode numerical value
  56572. */
  56573. changeDisplayMode(mode: number): void;
  56574. /** Sets a display option of the skeleton viewer
  56575. *
  56576. * | Option | Type | Default | Description |
  56577. * | ---------------- | ------- | ------- | ----------- |
  56578. * | 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`. |
  56579. * | 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`. |
  56580. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56581. * | 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`. |
  56582. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  56583. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  56584. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  56585. *
  56586. * @param option String of the option name
  56587. * @param value The numerical option value
  56588. */
  56589. changeDisplayOptions(option: string, value: number): void;
  56590. /** Release associated resources */
  56591. dispose(): void;
  56592. }
  56593. }
  56594. declare module "babylonjs/Debug/index" {
  56595. export * from "babylonjs/Debug/axesViewer";
  56596. export * from "babylonjs/Debug/boneAxesViewer";
  56597. export * from "babylonjs/Debug/debugLayer";
  56598. export * from "babylonjs/Debug/physicsViewer";
  56599. export * from "babylonjs/Debug/rayHelper";
  56600. export * from "babylonjs/Debug/skeletonViewer";
  56601. export * from "babylonjs/Debug/ISkeletonViewer";
  56602. }
  56603. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  56604. /**
  56605. * Enum for Device Types
  56606. */
  56607. export enum DeviceType {
  56608. /** Generic */
  56609. Generic = 0,
  56610. /** Keyboard */
  56611. Keyboard = 1,
  56612. /** Mouse */
  56613. Mouse = 2,
  56614. /** Touch Pointers */
  56615. Touch = 3,
  56616. /** PS4 Dual Shock */
  56617. DualShock = 4,
  56618. /** Xbox */
  56619. Xbox = 5,
  56620. /** Switch Controller */
  56621. Switch = 6
  56622. }
  56623. /**
  56624. * Enum for All Pointers (Touch/Mouse)
  56625. */
  56626. export enum PointerInput {
  56627. /** Horizontal Axis */
  56628. Horizontal = 0,
  56629. /** Vertical Axis */
  56630. Vertical = 1,
  56631. /** Left Click or Touch */
  56632. LeftClick = 2,
  56633. /** Middle Click */
  56634. MiddleClick = 3,
  56635. /** Right Click */
  56636. RightClick = 4,
  56637. /** Browser Back */
  56638. BrowserBack = 5,
  56639. /** Browser Forward */
  56640. BrowserForward = 6
  56641. }
  56642. /**
  56643. * Enum for Dual Shock Gamepad
  56644. */
  56645. export enum DualShockInput {
  56646. /** Cross */
  56647. Cross = 0,
  56648. /** Circle */
  56649. Circle = 1,
  56650. /** Square */
  56651. Square = 2,
  56652. /** Triangle */
  56653. Triangle = 3,
  56654. /** L1 */
  56655. L1 = 4,
  56656. /** R1 */
  56657. R1 = 5,
  56658. /** L2 */
  56659. L2 = 6,
  56660. /** R2 */
  56661. R2 = 7,
  56662. /** Share */
  56663. Share = 8,
  56664. /** Options */
  56665. Options = 9,
  56666. /** L3 */
  56667. L3 = 10,
  56668. /** R3 */
  56669. R3 = 11,
  56670. /** DPadUp */
  56671. DPadUp = 12,
  56672. /** DPadDown */
  56673. DPadDown = 13,
  56674. /** DPadLeft */
  56675. DPadLeft = 14,
  56676. /** DRight */
  56677. DPadRight = 15,
  56678. /** Home */
  56679. Home = 16,
  56680. /** TouchPad */
  56681. TouchPad = 17,
  56682. /** LStickXAxis */
  56683. LStickXAxis = 18,
  56684. /** LStickYAxis */
  56685. LStickYAxis = 19,
  56686. /** RStickXAxis */
  56687. RStickXAxis = 20,
  56688. /** RStickYAxis */
  56689. RStickYAxis = 21
  56690. }
  56691. /**
  56692. * Enum for Xbox Gamepad
  56693. */
  56694. export enum XboxInput {
  56695. /** A */
  56696. A = 0,
  56697. /** B */
  56698. B = 1,
  56699. /** X */
  56700. X = 2,
  56701. /** Y */
  56702. Y = 3,
  56703. /** LB */
  56704. LB = 4,
  56705. /** RB */
  56706. RB = 5,
  56707. /** LT */
  56708. LT = 6,
  56709. /** RT */
  56710. RT = 7,
  56711. /** Back */
  56712. Back = 8,
  56713. /** Start */
  56714. Start = 9,
  56715. /** LS */
  56716. LS = 10,
  56717. /** RS */
  56718. RS = 11,
  56719. /** DPadUp */
  56720. DPadUp = 12,
  56721. /** DPadDown */
  56722. DPadDown = 13,
  56723. /** DPadLeft */
  56724. DPadLeft = 14,
  56725. /** DRight */
  56726. DPadRight = 15,
  56727. /** Home */
  56728. Home = 16,
  56729. /** LStickXAxis */
  56730. LStickXAxis = 17,
  56731. /** LStickYAxis */
  56732. LStickYAxis = 18,
  56733. /** RStickXAxis */
  56734. RStickXAxis = 19,
  56735. /** RStickYAxis */
  56736. RStickYAxis = 20
  56737. }
  56738. /**
  56739. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  56740. */
  56741. export enum SwitchInput {
  56742. /** B */
  56743. B = 0,
  56744. /** A */
  56745. A = 1,
  56746. /** Y */
  56747. Y = 2,
  56748. /** X */
  56749. X = 3,
  56750. /** L */
  56751. L = 4,
  56752. /** R */
  56753. R = 5,
  56754. /** ZL */
  56755. ZL = 6,
  56756. /** ZR */
  56757. ZR = 7,
  56758. /** Minus */
  56759. Minus = 8,
  56760. /** Plus */
  56761. Plus = 9,
  56762. /** LS */
  56763. LS = 10,
  56764. /** RS */
  56765. RS = 11,
  56766. /** DPadUp */
  56767. DPadUp = 12,
  56768. /** DPadDown */
  56769. DPadDown = 13,
  56770. /** DPadLeft */
  56771. DPadLeft = 14,
  56772. /** DRight */
  56773. DPadRight = 15,
  56774. /** Home */
  56775. Home = 16,
  56776. /** Capture */
  56777. Capture = 17,
  56778. /** LStickXAxis */
  56779. LStickXAxis = 18,
  56780. /** LStickYAxis */
  56781. LStickYAxis = 19,
  56782. /** RStickXAxis */
  56783. RStickXAxis = 20,
  56784. /** RStickYAxis */
  56785. RStickYAxis = 21
  56786. }
  56787. }
  56788. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  56789. import { Engine } from "babylonjs/Engines/engine";
  56790. import { IDisposable } from "babylonjs/scene";
  56791. import { Nullable } from "babylonjs/types";
  56792. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56793. /**
  56794. * This class will take all inputs from Keyboard, Pointer, and
  56795. * any Gamepads and provide a polling system that all devices
  56796. * will use. This class assumes that there will only be one
  56797. * pointer device and one keyboard.
  56798. */
  56799. export class DeviceInputSystem implements IDisposable {
  56800. /**
  56801. * Callback to be triggered when a device is connected
  56802. */
  56803. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56804. /**
  56805. * Callback to be triggered when a device is disconnected
  56806. */
  56807. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56808. /**
  56809. * Callback to be triggered when event driven input is updated
  56810. */
  56811. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  56812. private _inputs;
  56813. private _gamepads;
  56814. private _keyboardActive;
  56815. private _pointerActive;
  56816. private _elementToAttachTo;
  56817. private _keyboardDownEvent;
  56818. private _keyboardUpEvent;
  56819. private _pointerMoveEvent;
  56820. private _pointerDownEvent;
  56821. private _pointerUpEvent;
  56822. private _gamepadConnectedEvent;
  56823. private _gamepadDisconnectedEvent;
  56824. private static _MAX_KEYCODES;
  56825. private static _MAX_POINTER_INPUTS;
  56826. private constructor();
  56827. /**
  56828. * Creates a new DeviceInputSystem instance
  56829. * @param engine Engine to pull input element from
  56830. * @returns The new instance
  56831. */
  56832. static Create(engine: Engine): DeviceInputSystem;
  56833. /**
  56834. * Checks for current device input value, given an id and input index
  56835. * @param deviceName Id of connected device
  56836. * @param inputIndex Index of device input
  56837. * @returns Current value of input
  56838. */
  56839. /**
  56840. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  56841. * @param deviceType Enum specifiying device type
  56842. * @param deviceSlot "Slot" or index that device is referenced in
  56843. * @param inputIndex Id of input to be checked
  56844. * @returns Current value of input
  56845. */
  56846. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  56847. /**
  56848. * Dispose of all the eventlisteners
  56849. */
  56850. dispose(): void;
  56851. /**
  56852. * Add device and inputs to device array
  56853. * @param deviceType Enum specifiying device type
  56854. * @param deviceSlot "Slot" or index that device is referenced in
  56855. * @param numberOfInputs Number of input entries to create for given device
  56856. */
  56857. private _registerDevice;
  56858. /**
  56859. * Given a specific device name, remove that device from the device map
  56860. * @param deviceType Enum specifiying device type
  56861. * @param deviceSlot "Slot" or index that device is referenced in
  56862. */
  56863. private _unregisterDevice;
  56864. /**
  56865. * Handle all actions that come from keyboard interaction
  56866. */
  56867. private _handleKeyActions;
  56868. /**
  56869. * Handle all actions that come from pointer interaction
  56870. */
  56871. private _handlePointerActions;
  56872. /**
  56873. * Handle all actions that come from gamepad interaction
  56874. */
  56875. private _handleGamepadActions;
  56876. /**
  56877. * Update all non-event based devices with each frame
  56878. * @param deviceType Enum specifiying device type
  56879. * @param deviceSlot "Slot" or index that device is referenced in
  56880. * @param inputIndex Id of input to be checked
  56881. */
  56882. private _updateDevice;
  56883. /**
  56884. * Gets DeviceType from the device name
  56885. * @param deviceName Name of Device from DeviceInputSystem
  56886. * @returns DeviceType enum value
  56887. */
  56888. private _getGamepadDeviceType;
  56889. }
  56890. }
  56891. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  56892. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56893. /**
  56894. * Type to handle enforcement of inputs
  56895. */
  56896. 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;
  56897. }
  56898. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  56899. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  56900. import { Engine } from "babylonjs/Engines/engine";
  56901. import { IDisposable } from "babylonjs/scene";
  56902. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56903. import { Nullable } from "babylonjs/types";
  56904. import { Observable } from "babylonjs/Misc/observable";
  56905. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  56906. /**
  56907. * Class that handles all input for a specific device
  56908. */
  56909. export class DeviceSource<T extends DeviceType> {
  56910. /** Type of device */
  56911. readonly deviceType: DeviceType;
  56912. /** "Slot" or index that device is referenced in */
  56913. readonly deviceSlot: number;
  56914. /**
  56915. * Observable to handle device input changes per device
  56916. */
  56917. readonly onInputChangedObservable: Observable<{
  56918. inputIndex: DeviceInput<T>;
  56919. previousState: Nullable<number>;
  56920. currentState: Nullable<number>;
  56921. }>;
  56922. private readonly _deviceInputSystem;
  56923. /**
  56924. * Default Constructor
  56925. * @param deviceInputSystem Reference to DeviceInputSystem
  56926. * @param deviceType Type of device
  56927. * @param deviceSlot "Slot" or index that device is referenced in
  56928. */
  56929. constructor(deviceInputSystem: DeviceInputSystem,
  56930. /** Type of device */
  56931. deviceType: DeviceType,
  56932. /** "Slot" or index that device is referenced in */
  56933. deviceSlot?: number);
  56934. /**
  56935. * Get input for specific input
  56936. * @param inputIndex index of specific input on device
  56937. * @returns Input value from DeviceInputSystem
  56938. */
  56939. getInput(inputIndex: DeviceInput<T>): number;
  56940. }
  56941. /**
  56942. * Class to keep track of devices
  56943. */
  56944. export class DeviceSourceManager implements IDisposable {
  56945. /**
  56946. * Observable to be triggered when before a device is connected
  56947. */
  56948. readonly onBeforeDeviceConnectedObservable: Observable<{
  56949. deviceType: DeviceType;
  56950. deviceSlot: number;
  56951. }>;
  56952. /**
  56953. * Observable to be triggered when before a device is disconnected
  56954. */
  56955. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  56956. deviceType: DeviceType;
  56957. deviceSlot: number;
  56958. }>;
  56959. /**
  56960. * Observable to be triggered when after a device is connected
  56961. */
  56962. readonly onAfterDeviceConnectedObservable: Observable<{
  56963. deviceType: DeviceType;
  56964. deviceSlot: number;
  56965. }>;
  56966. /**
  56967. * Observable to be triggered when after a device is disconnected
  56968. */
  56969. readonly onAfterDeviceDisconnectedObservable: Observable<{
  56970. deviceType: DeviceType;
  56971. deviceSlot: number;
  56972. }>;
  56973. private readonly _devices;
  56974. private readonly _firstDevice;
  56975. private readonly _deviceInputSystem;
  56976. /**
  56977. * Default Constructor
  56978. * @param engine engine to pull input element from
  56979. */
  56980. constructor(engine: Engine);
  56981. /**
  56982. * Gets a DeviceSource, given a type and slot
  56983. * @param deviceType Enum specifying device type
  56984. * @param deviceSlot "Slot" or index that device is referenced in
  56985. * @returns DeviceSource object
  56986. */
  56987. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  56988. /**
  56989. * Gets an array of DeviceSource objects for a given device type
  56990. * @param deviceType Enum specifying device type
  56991. * @returns Array of DeviceSource objects
  56992. */
  56993. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  56994. /**
  56995. * Dispose of DeviceInputSystem and other parts
  56996. */
  56997. dispose(): void;
  56998. /**
  56999. * Function to add device name to device list
  57000. * @param deviceType Enum specifying device type
  57001. * @param deviceSlot "Slot" or index that device is referenced in
  57002. */
  57003. private _addDevice;
  57004. /**
  57005. * Function to remove device name to device list
  57006. * @param deviceType Enum specifying device type
  57007. * @param deviceSlot "Slot" or index that device is referenced in
  57008. */
  57009. private _removeDevice;
  57010. /**
  57011. * Updates array storing first connected device of each type
  57012. * @param type Type of Device
  57013. */
  57014. private _updateFirstDevices;
  57015. }
  57016. }
  57017. declare module "babylonjs/DeviceInput/index" {
  57018. export * from "babylonjs/DeviceInput/deviceInputSystem";
  57019. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57020. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57021. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57022. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57023. }
  57024. declare module "babylonjs/Engines/nullEngine" {
  57025. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  57026. import { Engine } from "babylonjs/Engines/engine";
  57027. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  57028. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  57029. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57030. import { Effect } from "babylonjs/Materials/effect";
  57031. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  57032. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57033. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  57034. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  57035. /**
  57036. * Options to create the null engine
  57037. */
  57038. export class NullEngineOptions {
  57039. /**
  57040. * Render width (Default: 512)
  57041. */
  57042. renderWidth: number;
  57043. /**
  57044. * Render height (Default: 256)
  57045. */
  57046. renderHeight: number;
  57047. /**
  57048. * Texture size (Default: 512)
  57049. */
  57050. textureSize: number;
  57051. /**
  57052. * If delta time between frames should be constant
  57053. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57054. */
  57055. deterministicLockstep: boolean;
  57056. /**
  57057. * Maximum about of steps between frames (Default: 4)
  57058. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57059. */
  57060. lockstepMaxSteps: number;
  57061. /**
  57062. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  57063. */
  57064. useHighPrecisionMatrix?: boolean;
  57065. }
  57066. /**
  57067. * The null engine class provides support for headless version of babylon.js.
  57068. * This can be used in server side scenario or for testing purposes
  57069. */
  57070. export class NullEngine extends Engine {
  57071. private _options;
  57072. /**
  57073. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  57074. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57075. * @returns true if engine is in deterministic lock step mode
  57076. */
  57077. isDeterministicLockStep(): boolean;
  57078. /**
  57079. * Gets the max steps when engine is running in deterministic lock step
  57080. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57081. * @returns the max steps
  57082. */
  57083. getLockstepMaxSteps(): number;
  57084. /**
  57085. * Gets the current hardware scaling level.
  57086. * By default the hardware scaling level is computed from the window device ratio.
  57087. * 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.
  57088. * @returns a number indicating the current hardware scaling level
  57089. */
  57090. getHardwareScalingLevel(): number;
  57091. constructor(options?: NullEngineOptions);
  57092. /**
  57093. * Creates a vertex buffer
  57094. * @param vertices the data for the vertex buffer
  57095. * @returns the new WebGL static buffer
  57096. */
  57097. createVertexBuffer(vertices: FloatArray): DataBuffer;
  57098. /**
  57099. * Creates a new index buffer
  57100. * @param indices defines the content of the index buffer
  57101. * @param updatable defines if the index buffer must be updatable
  57102. * @returns a new webGL buffer
  57103. */
  57104. createIndexBuffer(indices: IndicesArray): DataBuffer;
  57105. /**
  57106. * Clear the current render buffer or the current render target (if any is set up)
  57107. * @param color defines the color to use
  57108. * @param backBuffer defines if the back buffer must be cleared
  57109. * @param depth defines if the depth buffer must be cleared
  57110. * @param stencil defines if the stencil buffer must be cleared
  57111. */
  57112. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57113. /**
  57114. * Gets the current render width
  57115. * @param useScreen defines if screen size must be used (or the current render target if any)
  57116. * @returns a number defining the current render width
  57117. */
  57118. getRenderWidth(useScreen?: boolean): number;
  57119. /**
  57120. * Gets the current render height
  57121. * @param useScreen defines if screen size must be used (or the current render target if any)
  57122. * @returns a number defining the current render height
  57123. */
  57124. getRenderHeight(useScreen?: boolean): number;
  57125. /**
  57126. * Set the WebGL's viewport
  57127. * @param viewport defines the viewport element to be used
  57128. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  57129. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  57130. */
  57131. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  57132. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  57133. /**
  57134. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  57135. * @param pipelineContext defines the pipeline context to use
  57136. * @param uniformsNames defines the list of uniform names
  57137. * @returns an array of webGL uniform locations
  57138. */
  57139. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  57140. /**
  57141. * Gets the lsit of active attributes for a given webGL program
  57142. * @param pipelineContext defines the pipeline context to use
  57143. * @param attributesNames defines the list of attribute names to get
  57144. * @returns an array of indices indicating the offset of each attribute
  57145. */
  57146. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57147. /**
  57148. * Binds an effect to the webGL context
  57149. * @param effect defines the effect to bind
  57150. */
  57151. bindSamplers(effect: Effect): void;
  57152. /**
  57153. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  57154. * @param effect defines the effect to activate
  57155. */
  57156. enableEffect(effect: Effect): void;
  57157. /**
  57158. * Set various states to the webGL context
  57159. * @param culling defines backface culling state
  57160. * @param zOffset defines the value to apply to zOffset (0 by default)
  57161. * @param force defines if states must be applied even if cache is up to date
  57162. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  57163. */
  57164. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57165. /**
  57166. * Set the value of an uniform to an array of int32
  57167. * @param uniform defines the webGL uniform location where to store the value
  57168. * @param array defines the array of int32 to store
  57169. * @returns true if value was set
  57170. */
  57171. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57172. /**
  57173. * Set the value of an uniform to an array of int32 (stored as vec2)
  57174. * @param uniform defines the webGL uniform location where to store the value
  57175. * @param array defines the array of int32 to store
  57176. * @returns true if value was set
  57177. */
  57178. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57179. /**
  57180. * Set the value of an uniform to an array of int32 (stored as vec3)
  57181. * @param uniform defines the webGL uniform location where to store the value
  57182. * @param array defines the array of int32 to store
  57183. * @returns true if value was set
  57184. */
  57185. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57186. /**
  57187. * Set the value of an uniform to an array of int32 (stored as vec4)
  57188. * @param uniform defines the webGL uniform location where to store the value
  57189. * @param array defines the array of int32 to store
  57190. * @returns true if value was set
  57191. */
  57192. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57193. /**
  57194. * Set the value of an uniform to an array of float32
  57195. * @param uniform defines the webGL uniform location where to store the value
  57196. * @param array defines the array of float32 to store
  57197. * @returns true if value was set
  57198. */
  57199. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57200. /**
  57201. * Set the value of an uniform to an array of float32 (stored as vec2)
  57202. * @param uniform defines the webGL uniform location where to store the value
  57203. * @param array defines the array of float32 to store
  57204. * @returns true if value was set
  57205. */
  57206. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57207. /**
  57208. * Set the value of an uniform to an array of float32 (stored as vec3)
  57209. * @param uniform defines the webGL uniform location where to store the value
  57210. * @param array defines the array of float32 to store
  57211. * @returns true if value was set
  57212. */
  57213. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57214. /**
  57215. * Set the value of an uniform to an array of float32 (stored as vec4)
  57216. * @param uniform defines the webGL uniform location where to store the value
  57217. * @param array defines the array of float32 to store
  57218. * @returns true if value was set
  57219. */
  57220. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57221. /**
  57222. * Set the value of an uniform to an array of number
  57223. * @param uniform defines the webGL uniform location where to store the value
  57224. * @param array defines the array of number to store
  57225. * @returns true if value was set
  57226. */
  57227. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57228. /**
  57229. * Set the value of an uniform to an array of number (stored as vec2)
  57230. * @param uniform defines the webGL uniform location where to store the value
  57231. * @param array defines the array of number to store
  57232. * @returns true if value was set
  57233. */
  57234. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57235. /**
  57236. * Set the value of an uniform to an array of number (stored as vec3)
  57237. * @param uniform defines the webGL uniform location where to store the value
  57238. * @param array defines the array of number to store
  57239. * @returns true if value was set
  57240. */
  57241. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57242. /**
  57243. * Set the value of an uniform to an array of number (stored as vec4)
  57244. * @param uniform defines the webGL uniform location where to store the value
  57245. * @param array defines the array of number to store
  57246. * @returns true if value was set
  57247. */
  57248. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57249. /**
  57250. * Set the value of an uniform to an array of float32 (stored as matrices)
  57251. * @param uniform defines the webGL uniform location where to store the value
  57252. * @param matrices defines the array of float32 to store
  57253. * @returns true if value was set
  57254. */
  57255. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57256. /**
  57257. * Set the value of an uniform to a matrix (3x3)
  57258. * @param uniform defines the webGL uniform location where to store the value
  57259. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  57260. * @returns true if value was set
  57261. */
  57262. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57263. /**
  57264. * Set the value of an uniform to a matrix (2x2)
  57265. * @param uniform defines the webGL uniform location where to store the value
  57266. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  57267. * @returns true if value was set
  57268. */
  57269. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57270. /**
  57271. * Set the value of an uniform to a number (float)
  57272. * @param uniform defines the webGL uniform location where to store the value
  57273. * @param value defines the float number to store
  57274. * @returns true if value was set
  57275. */
  57276. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57277. /**
  57278. * Set the value of an uniform to a vec2
  57279. * @param uniform defines the webGL uniform location where to store the value
  57280. * @param x defines the 1st component of the value
  57281. * @param y defines the 2nd component of the value
  57282. * @returns true if value was set
  57283. */
  57284. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57285. /**
  57286. * Set the value of an uniform to a vec3
  57287. * @param uniform defines the webGL uniform location where to store the value
  57288. * @param x defines the 1st component of the value
  57289. * @param y defines the 2nd component of the value
  57290. * @param z defines the 3rd component of the value
  57291. * @returns true if value was set
  57292. */
  57293. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57294. /**
  57295. * Set the value of an uniform to a boolean
  57296. * @param uniform defines the webGL uniform location where to store the value
  57297. * @param bool defines the boolean to store
  57298. * @returns true if value was set
  57299. */
  57300. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  57301. /**
  57302. * Set the value of an uniform to a vec4
  57303. * @param uniform defines the webGL uniform location where to store the value
  57304. * @param x defines the 1st component of the value
  57305. * @param y defines the 2nd component of the value
  57306. * @param z defines the 3rd component of the value
  57307. * @param w defines the 4th component of the value
  57308. * @returns true if value was set
  57309. */
  57310. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57311. /**
  57312. * Sets the current alpha mode
  57313. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  57314. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57315. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57316. */
  57317. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57318. /**
  57319. * Bind webGl buffers directly to the webGL context
  57320. * @param vertexBuffers defines the vertex buffer to bind
  57321. * @param indexBuffer defines the index buffer to bind
  57322. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  57323. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  57324. * @param effect defines the effect associated with the vertex buffer
  57325. */
  57326. bindBuffers(vertexBuffers: {
  57327. [key: string]: VertexBuffer;
  57328. }, indexBuffer: DataBuffer, effect: Effect): void;
  57329. /**
  57330. * Force the entire cache to be cleared
  57331. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  57332. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  57333. */
  57334. wipeCaches(bruteForce?: boolean): void;
  57335. /**
  57336. * Send a draw order
  57337. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  57338. * @param indexStart defines the starting index
  57339. * @param indexCount defines the number of index to draw
  57340. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57341. */
  57342. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  57343. /**
  57344. * Draw a list of indexed primitives
  57345. * @param fillMode defines the primitive to use
  57346. * @param indexStart defines the starting index
  57347. * @param indexCount defines the number of index to draw
  57348. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57349. */
  57350. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57351. /**
  57352. * Draw a list of unindexed primitives
  57353. * @param fillMode defines the primitive to use
  57354. * @param verticesStart defines the index of first vertex to draw
  57355. * @param verticesCount defines the count of vertices to draw
  57356. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57357. */
  57358. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57359. /** @hidden */
  57360. _createTexture(): WebGLTexture;
  57361. /** @hidden */
  57362. _releaseTexture(texture: InternalTexture): void;
  57363. /**
  57364. * Usually called from Texture.ts.
  57365. * Passed information to create a WebGLTexture
  57366. * @param urlArg defines a value which contains one of the following:
  57367. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57368. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57369. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57370. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57371. * @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)
  57372. * @param scene needed for loading to the correct scene
  57373. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57374. * @param onLoad optional callback to be called upon successful completion
  57375. * @param onError optional callback to be called upon failure
  57376. * @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
  57377. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57378. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57379. * @param forcedExtension defines the extension to use to pick the right loader
  57380. * @param mimeType defines an optional mime type
  57381. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57382. */
  57383. 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;
  57384. /**
  57385. * Creates a new render target texture
  57386. * @param size defines the size of the texture
  57387. * @param options defines the options used to create the texture
  57388. * @returns a new render target texture stored in an InternalTexture
  57389. */
  57390. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  57391. /**
  57392. * Update the sampling mode of a given texture
  57393. * @param samplingMode defines the required sampling mode
  57394. * @param texture defines the texture to update
  57395. */
  57396. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57397. /**
  57398. * Binds the frame buffer to the specified texture.
  57399. * @param texture The texture to render to or null for the default canvas
  57400. * @param faceIndex The face of the texture to render to in case of cube texture
  57401. * @param requiredWidth The width of the target to render to
  57402. * @param requiredHeight The height of the target to render to
  57403. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  57404. * @param lodLevel defines le lod level to bind to the frame buffer
  57405. */
  57406. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57407. /**
  57408. * Unbind the current render target texture from the webGL context
  57409. * @param texture defines the render target texture to unbind
  57410. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  57411. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  57412. */
  57413. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57414. /**
  57415. * Creates a dynamic vertex buffer
  57416. * @param vertices the data for the dynamic vertex buffer
  57417. * @returns the new WebGL dynamic buffer
  57418. */
  57419. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  57420. /**
  57421. * Update the content of a dynamic texture
  57422. * @param texture defines the texture to update
  57423. * @param canvas defines the canvas containing the source
  57424. * @param invertY defines if data must be stored with Y axis inverted
  57425. * @param premulAlpha defines if alpha is stored as premultiplied
  57426. * @param format defines the format of the data
  57427. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57428. */
  57429. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57430. /**
  57431. * Gets a boolean indicating if all created effects are ready
  57432. * @returns true if all effects are ready
  57433. */
  57434. areAllEffectsReady(): boolean;
  57435. /**
  57436. * @hidden
  57437. * Get the current error code of the webGL context
  57438. * @returns the error code
  57439. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  57440. */
  57441. getError(): number;
  57442. /** @hidden */
  57443. _getUnpackAlignement(): number;
  57444. /** @hidden */
  57445. _unpackFlipY(value: boolean): void;
  57446. /**
  57447. * Update a dynamic index buffer
  57448. * @param indexBuffer defines the target index buffer
  57449. * @param indices defines the data to update
  57450. * @param offset defines the offset in the target index buffer where update should start
  57451. */
  57452. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  57453. /**
  57454. * Updates a dynamic vertex buffer.
  57455. * @param vertexBuffer the vertex buffer to update
  57456. * @param vertices the data used to update the vertex buffer
  57457. * @param byteOffset the byte offset of the data (optional)
  57458. * @param byteLength the byte length of the data (optional)
  57459. */
  57460. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  57461. /** @hidden */
  57462. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  57463. /** @hidden */
  57464. _bindTexture(channel: number, texture: InternalTexture): void;
  57465. protected _deleteBuffer(buffer: WebGLBuffer): void;
  57466. /**
  57467. * 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
  57468. */
  57469. releaseEffects(): void;
  57470. displayLoadingUI(): void;
  57471. hideLoadingUI(): void;
  57472. /** @hidden */
  57473. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57474. /** @hidden */
  57475. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57476. /** @hidden */
  57477. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57478. /** @hidden */
  57479. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57480. }
  57481. }
  57482. declare module "babylonjs/Instrumentation/timeToken" {
  57483. import { Nullable } from "babylonjs/types";
  57484. /**
  57485. * @hidden
  57486. **/
  57487. export class _TimeToken {
  57488. _startTimeQuery: Nullable<WebGLQuery>;
  57489. _endTimeQuery: Nullable<WebGLQuery>;
  57490. _timeElapsedQuery: Nullable<WebGLQuery>;
  57491. _timeElapsedQueryEnded: boolean;
  57492. }
  57493. }
  57494. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  57495. import { Nullable, int } from "babylonjs/types";
  57496. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  57497. /** @hidden */
  57498. export class _OcclusionDataStorage {
  57499. /** @hidden */
  57500. occlusionInternalRetryCounter: number;
  57501. /** @hidden */
  57502. isOcclusionQueryInProgress: boolean;
  57503. /** @hidden */
  57504. isOccluded: boolean;
  57505. /** @hidden */
  57506. occlusionRetryCount: number;
  57507. /** @hidden */
  57508. occlusionType: number;
  57509. /** @hidden */
  57510. occlusionQueryAlgorithmType: number;
  57511. }
  57512. module "babylonjs/Engines/engine" {
  57513. interface Engine {
  57514. /**
  57515. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  57516. * @return the new query
  57517. */
  57518. createQuery(): WebGLQuery;
  57519. /**
  57520. * Delete and release a webGL query
  57521. * @param query defines the query to delete
  57522. * @return the current engine
  57523. */
  57524. deleteQuery(query: WebGLQuery): Engine;
  57525. /**
  57526. * Check if a given query has resolved and got its value
  57527. * @param query defines the query to check
  57528. * @returns true if the query got its value
  57529. */
  57530. isQueryResultAvailable(query: WebGLQuery): boolean;
  57531. /**
  57532. * Gets the value of a given query
  57533. * @param query defines the query to check
  57534. * @returns the value of the query
  57535. */
  57536. getQueryResult(query: WebGLQuery): number;
  57537. /**
  57538. * Initiates an occlusion query
  57539. * @param algorithmType defines the algorithm to use
  57540. * @param query defines the query to use
  57541. * @returns the current engine
  57542. * @see https://doc.babylonjs.com/features/occlusionquery
  57543. */
  57544. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  57545. /**
  57546. * Ends an occlusion query
  57547. * @see https://doc.babylonjs.com/features/occlusionquery
  57548. * @param algorithmType defines the algorithm to use
  57549. * @returns the current engine
  57550. */
  57551. endOcclusionQuery(algorithmType: number): Engine;
  57552. /**
  57553. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  57554. * Please note that only one query can be issued at a time
  57555. * @returns a time token used to track the time span
  57556. */
  57557. startTimeQuery(): Nullable<_TimeToken>;
  57558. /**
  57559. * Ends a time query
  57560. * @param token defines the token used to measure the time span
  57561. * @returns the time spent (in ns)
  57562. */
  57563. endTimeQuery(token: _TimeToken): int;
  57564. /** @hidden */
  57565. _currentNonTimestampToken: Nullable<_TimeToken>;
  57566. /** @hidden */
  57567. _createTimeQuery(): WebGLQuery;
  57568. /** @hidden */
  57569. _deleteTimeQuery(query: WebGLQuery): void;
  57570. /** @hidden */
  57571. _getGlAlgorithmType(algorithmType: number): number;
  57572. /** @hidden */
  57573. _getTimeQueryResult(query: WebGLQuery): any;
  57574. /** @hidden */
  57575. _getTimeQueryAvailability(query: WebGLQuery): any;
  57576. }
  57577. }
  57578. module "babylonjs/Meshes/abstractMesh" {
  57579. interface AbstractMesh {
  57580. /**
  57581. * Backing filed
  57582. * @hidden
  57583. */
  57584. __occlusionDataStorage: _OcclusionDataStorage;
  57585. /**
  57586. * Access property
  57587. * @hidden
  57588. */
  57589. _occlusionDataStorage: _OcclusionDataStorage;
  57590. /**
  57591. * 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.
  57592. * The default value is -1 which means don't break the query and wait till the result
  57593. * @see https://doc.babylonjs.com/features/occlusionquery
  57594. */
  57595. occlusionRetryCount: number;
  57596. /**
  57597. * 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:
  57598. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  57599. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  57600. * * 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.
  57601. * @see https://doc.babylonjs.com/features/occlusionquery
  57602. */
  57603. occlusionType: number;
  57604. /**
  57605. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  57606. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  57607. * * 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.
  57608. * @see https://doc.babylonjs.com/features/occlusionquery
  57609. */
  57610. occlusionQueryAlgorithmType: number;
  57611. /**
  57612. * 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
  57613. * @see https://doc.babylonjs.com/features/occlusionquery
  57614. */
  57615. isOccluded: boolean;
  57616. /**
  57617. * Flag to check the progress status of the query
  57618. * @see https://doc.babylonjs.com/features/occlusionquery
  57619. */
  57620. isOcclusionQueryInProgress: boolean;
  57621. }
  57622. }
  57623. }
  57624. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  57625. import { Nullable } from "babylonjs/types";
  57626. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57627. /** @hidden */
  57628. export var _forceTransformFeedbackToBundle: boolean;
  57629. module "babylonjs/Engines/engine" {
  57630. interface Engine {
  57631. /**
  57632. * Creates a webGL transform feedback object
  57633. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  57634. * @returns the webGL transform feedback object
  57635. */
  57636. createTransformFeedback(): WebGLTransformFeedback;
  57637. /**
  57638. * Delete a webGL transform feedback object
  57639. * @param value defines the webGL transform feedback object to delete
  57640. */
  57641. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  57642. /**
  57643. * Bind a webGL transform feedback object to the webgl context
  57644. * @param value defines the webGL transform feedback object to bind
  57645. */
  57646. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  57647. /**
  57648. * Begins a transform feedback operation
  57649. * @param usePoints defines if points or triangles must be used
  57650. */
  57651. beginTransformFeedback(usePoints: boolean): void;
  57652. /**
  57653. * Ends a transform feedback operation
  57654. */
  57655. endTransformFeedback(): void;
  57656. /**
  57657. * Specify the varyings to use with transform feedback
  57658. * @param program defines the associated webGL program
  57659. * @param value defines the list of strings representing the varying names
  57660. */
  57661. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  57662. /**
  57663. * Bind a webGL buffer for a transform feedback operation
  57664. * @param value defines the webGL buffer to bind
  57665. */
  57666. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  57667. }
  57668. }
  57669. }
  57670. declare module "babylonjs/Engines/Extensions/engine.views" {
  57671. import { Camera } from "babylonjs/Cameras/camera";
  57672. import { Nullable } from "babylonjs/types";
  57673. /**
  57674. * Class used to define an additional view for the engine
  57675. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57676. */
  57677. export class EngineView {
  57678. /** Defines the canvas where to render the view */
  57679. target: HTMLCanvasElement;
  57680. /** Defines an optional camera used to render the view (will use active camera else) */
  57681. camera?: Camera;
  57682. }
  57683. module "babylonjs/Engines/engine" {
  57684. interface Engine {
  57685. /**
  57686. * Gets or sets the HTML element to use for attaching events
  57687. */
  57688. inputElement: Nullable<HTMLElement>;
  57689. /**
  57690. * Gets the current engine view
  57691. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57692. */
  57693. activeView: Nullable<EngineView>;
  57694. /** Gets or sets the list of views */
  57695. views: EngineView[];
  57696. /**
  57697. * Register a new child canvas
  57698. * @param canvas defines the canvas to register
  57699. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  57700. * @returns the associated view
  57701. */
  57702. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  57703. /**
  57704. * Remove a registered child canvas
  57705. * @param canvas defines the canvas to remove
  57706. * @returns the current engine
  57707. */
  57708. unRegisterView(canvas: HTMLCanvasElement): Engine;
  57709. }
  57710. }
  57711. }
  57712. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  57713. import { Nullable } from "babylonjs/types";
  57714. module "babylonjs/Engines/engine" {
  57715. interface Engine {
  57716. /** @hidden */
  57717. _excludedCompressedTextures: string[];
  57718. /** @hidden */
  57719. _textureFormatInUse: string;
  57720. /**
  57721. * Gets the list of texture formats supported
  57722. */
  57723. readonly texturesSupported: Array<string>;
  57724. /**
  57725. * Gets the texture format in use
  57726. */
  57727. readonly textureFormatInUse: Nullable<string>;
  57728. /**
  57729. * Set the compressed texture extensions or file names to skip.
  57730. *
  57731. * @param skippedFiles defines the list of those texture files you want to skip
  57732. * Example: [".dds", ".env", "myfile.png"]
  57733. */
  57734. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  57735. /**
  57736. * Set the compressed texture format to use, based on the formats you have, and the formats
  57737. * supported by the hardware / browser.
  57738. *
  57739. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  57740. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  57741. * to API arguments needed to compressed textures. This puts the burden on the container
  57742. * generator to house the arcane code for determining these for current & future formats.
  57743. *
  57744. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57745. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57746. *
  57747. * Note: The result of this call is not taken into account when a texture is base64.
  57748. *
  57749. * @param formatsAvailable defines the list of those format families you have created
  57750. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  57751. *
  57752. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  57753. * @returns The extension selected.
  57754. */
  57755. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  57756. }
  57757. }
  57758. }
  57759. declare module "babylonjs/Engines/Extensions/index" {
  57760. export * from "babylonjs/Engines/Extensions/engine.alpha";
  57761. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  57762. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  57763. export * from "babylonjs/Engines/Extensions/engine.multiview";
  57764. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  57765. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  57766. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  57767. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  57768. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  57769. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  57770. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57771. export * from "babylonjs/Engines/Extensions/engine.webVR";
  57772. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  57773. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  57774. export * from "babylonjs/Engines/Extensions/engine.views";
  57775. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  57776. import "babylonjs/Engines/Extensions/engine.textureSelector";
  57777. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  57778. }
  57779. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  57780. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57781. /** @hidden */
  57782. export var rgbdEncodePixelShader: {
  57783. name: string;
  57784. shader: string;
  57785. };
  57786. }
  57787. declare module "babylonjs/Misc/environmentTextureTools" {
  57788. import { Nullable } from "babylonjs/types";
  57789. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57790. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57791. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57792. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57793. import "babylonjs/Engines/Extensions/engine.readTexture";
  57794. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57795. import "babylonjs/Shaders/rgbdEncode.fragment";
  57796. import "babylonjs/Shaders/rgbdDecode.fragment";
  57797. /**
  57798. * Raw texture data and descriptor sufficient for WebGL texture upload
  57799. */
  57800. export interface EnvironmentTextureInfo {
  57801. /**
  57802. * Version of the environment map
  57803. */
  57804. version: number;
  57805. /**
  57806. * Width of image
  57807. */
  57808. width: number;
  57809. /**
  57810. * Irradiance information stored in the file.
  57811. */
  57812. irradiance: any;
  57813. /**
  57814. * Specular information stored in the file.
  57815. */
  57816. specular: any;
  57817. }
  57818. /**
  57819. * Defines One Image in the file. It requires only the position in the file
  57820. * as well as the length.
  57821. */
  57822. interface BufferImageData {
  57823. /**
  57824. * Length of the image data.
  57825. */
  57826. length: number;
  57827. /**
  57828. * Position of the data from the null terminator delimiting the end of the JSON.
  57829. */
  57830. position: number;
  57831. }
  57832. /**
  57833. * Defines the specular data enclosed in the file.
  57834. * This corresponds to the version 1 of the data.
  57835. */
  57836. export interface EnvironmentTextureSpecularInfoV1 {
  57837. /**
  57838. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  57839. */
  57840. specularDataPosition?: number;
  57841. /**
  57842. * This contains all the images data needed to reconstruct the cubemap.
  57843. */
  57844. mipmaps: Array<BufferImageData>;
  57845. /**
  57846. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  57847. */
  57848. lodGenerationScale: number;
  57849. }
  57850. /**
  57851. * Sets of helpers addressing the serialization and deserialization of environment texture
  57852. * stored in a BabylonJS env file.
  57853. * Those files are usually stored as .env files.
  57854. */
  57855. export class EnvironmentTextureTools {
  57856. /**
  57857. * Magic number identifying the env file.
  57858. */
  57859. private static _MagicBytes;
  57860. /**
  57861. * Gets the environment info from an env file.
  57862. * @param data The array buffer containing the .env bytes.
  57863. * @returns the environment file info (the json header) if successfully parsed.
  57864. */
  57865. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  57866. /**
  57867. * Creates an environment texture from a loaded cube texture.
  57868. * @param texture defines the cube texture to convert in env file
  57869. * @return a promise containing the environment data if succesfull.
  57870. */
  57871. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  57872. /**
  57873. * Creates a JSON representation of the spherical data.
  57874. * @param texture defines the texture containing the polynomials
  57875. * @return the JSON representation of the spherical info
  57876. */
  57877. private static _CreateEnvTextureIrradiance;
  57878. /**
  57879. * Creates the ArrayBufferViews used for initializing environment texture image data.
  57880. * @param data the image data
  57881. * @param info parameters that determine what views will be created for accessing the underlying buffer
  57882. * @return the views described by info providing access to the underlying buffer
  57883. */
  57884. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  57885. /**
  57886. * Uploads the texture info contained in the env file to the GPU.
  57887. * @param texture defines the internal texture to upload to
  57888. * @param data defines the data to load
  57889. * @param info defines the texture info retrieved through the GetEnvInfo method
  57890. * @returns a promise
  57891. */
  57892. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  57893. private static _OnImageReadyAsync;
  57894. /**
  57895. * Uploads the levels of image data to the GPU.
  57896. * @param texture defines the internal texture to upload to
  57897. * @param imageData defines the array buffer views of image data [mipmap][face]
  57898. * @returns a promise
  57899. */
  57900. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  57901. /**
  57902. * Uploads spherical polynomials information to the texture.
  57903. * @param texture defines the texture we are trying to upload the information to
  57904. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  57905. */
  57906. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  57907. /** @hidden */
  57908. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57909. }
  57910. }
  57911. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  57912. /**
  57913. * Class used to inline functions in shader code
  57914. */
  57915. export class ShaderCodeInliner {
  57916. private static readonly _RegexpFindFunctionNameAndType;
  57917. private _sourceCode;
  57918. private _functionDescr;
  57919. private _numMaxIterations;
  57920. /** Gets or sets the token used to mark the functions to inline */
  57921. inlineToken: string;
  57922. /** Gets or sets the debug mode */
  57923. debug: boolean;
  57924. /** Gets the code after the inlining process */
  57925. get code(): string;
  57926. /**
  57927. * Initializes the inliner
  57928. * @param sourceCode shader code source to inline
  57929. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  57930. */
  57931. constructor(sourceCode: string, numMaxIterations?: number);
  57932. /**
  57933. * Start the processing of the shader code
  57934. */
  57935. processCode(): void;
  57936. private _collectFunctions;
  57937. private _processInlining;
  57938. private _extractBetweenMarkers;
  57939. private _skipWhitespaces;
  57940. private _removeComments;
  57941. private _replaceFunctionCallsByCode;
  57942. private _findBackward;
  57943. private _escapeRegExp;
  57944. private _replaceNames;
  57945. }
  57946. }
  57947. declare module "babylonjs/Engines/nativeEngine" {
  57948. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  57949. import { Engine } from "babylonjs/Engines/engine";
  57950. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  57951. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57952. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57953. import { Effect } from "babylonjs/Materials/effect";
  57954. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57955. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  57956. import { IColor4Like } from "babylonjs/Maths/math.like";
  57957. import { Scene } from "babylonjs/scene";
  57958. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  57959. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  57960. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  57961. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  57962. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  57963. /**
  57964. * Container for accessors for natively-stored mesh data buffers.
  57965. */
  57966. class NativeDataBuffer extends DataBuffer {
  57967. /**
  57968. * Accessor value used to identify/retrieve a natively-stored index buffer.
  57969. */
  57970. nativeIndexBuffer?: any;
  57971. /**
  57972. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  57973. */
  57974. nativeVertexBuffer?: any;
  57975. }
  57976. /** @hidden */
  57977. class NativeTexture extends InternalTexture {
  57978. getInternalTexture(): InternalTexture;
  57979. getViewCount(): number;
  57980. }
  57981. /** @hidden */
  57982. export class NativeEngine extends Engine {
  57983. private readonly _native;
  57984. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  57985. private readonly INVALID_HANDLE;
  57986. private _boundBuffersVertexArray;
  57987. private _currentDepthTest;
  57988. getHardwareScalingLevel(): number;
  57989. constructor();
  57990. dispose(): void;
  57991. /**
  57992. * Can be used to override the current requestAnimationFrame requester.
  57993. * @hidden
  57994. */
  57995. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  57996. /**
  57997. * Override default engine behavior.
  57998. * @param color
  57999. * @param backBuffer
  58000. * @param depth
  58001. * @param stencil
  58002. */
  58003. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  58004. /**
  58005. * Gets host document
  58006. * @returns the host document object
  58007. */
  58008. getHostDocument(): Nullable<Document>;
  58009. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58010. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  58011. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  58012. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  58013. [key: string]: VertexBuffer;
  58014. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58015. bindBuffers(vertexBuffers: {
  58016. [key: string]: VertexBuffer;
  58017. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58018. recordVertexArrayObject(vertexBuffers: {
  58019. [key: string]: VertexBuffer;
  58020. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  58021. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58022. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58023. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58024. /**
  58025. * Draw a list of indexed primitives
  58026. * @param fillMode defines the primitive to use
  58027. * @param indexStart defines the starting index
  58028. * @param indexCount defines the number of index to draw
  58029. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58030. */
  58031. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58032. /**
  58033. * Draw a list of unindexed primitives
  58034. * @param fillMode defines the primitive to use
  58035. * @param verticesStart defines the index of first vertex to draw
  58036. * @param verticesCount defines the count of vertices to draw
  58037. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58038. */
  58039. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58040. createPipelineContext(): IPipelineContext;
  58041. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  58042. /** @hidden */
  58043. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  58044. /** @hidden */
  58045. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  58046. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58047. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58048. protected _setProgram(program: WebGLProgram): void;
  58049. _releaseEffect(effect: Effect): void;
  58050. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  58051. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  58052. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  58053. bindSamplers(effect: Effect): void;
  58054. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  58055. getRenderWidth(useScreen?: boolean): number;
  58056. getRenderHeight(useScreen?: boolean): number;
  58057. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  58058. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58059. /**
  58060. * Set the z offset to apply to current rendering
  58061. * @param value defines the offset to apply
  58062. */
  58063. setZOffset(value: number): void;
  58064. /**
  58065. * Gets the current value of the zOffset
  58066. * @returns the current zOffset state
  58067. */
  58068. getZOffset(): number;
  58069. /**
  58070. * Enable or disable depth buffering
  58071. * @param enable defines the state to set
  58072. */
  58073. setDepthBuffer(enable: boolean): void;
  58074. /**
  58075. * Gets a boolean indicating if depth writing is enabled
  58076. * @returns the current depth writing state
  58077. */
  58078. getDepthWrite(): boolean;
  58079. setDepthFunctionToGreater(): void;
  58080. setDepthFunctionToGreaterOrEqual(): void;
  58081. setDepthFunctionToLess(): void;
  58082. setDepthFunctionToLessOrEqual(): void;
  58083. /**
  58084. * Enable or disable depth writing
  58085. * @param enable defines the state to set
  58086. */
  58087. setDepthWrite(enable: boolean): void;
  58088. /**
  58089. * Enable or disable color writing
  58090. * @param enable defines the state to set
  58091. */
  58092. setColorWrite(enable: boolean): void;
  58093. /**
  58094. * Gets a boolean indicating if color writing is enabled
  58095. * @returns the current color writing state
  58096. */
  58097. getColorWrite(): boolean;
  58098. /**
  58099. * Sets alpha constants used by some alpha blending modes
  58100. * @param r defines the red component
  58101. * @param g defines the green component
  58102. * @param b defines the blue component
  58103. * @param a defines the alpha component
  58104. */
  58105. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  58106. /**
  58107. * Sets the current alpha mode
  58108. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  58109. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58110. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58111. */
  58112. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58113. /**
  58114. * Gets the current alpha mode
  58115. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58116. * @returns the current alpha mode
  58117. */
  58118. getAlphaMode(): number;
  58119. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  58120. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58121. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58122. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58123. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58124. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58125. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58126. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58127. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58128. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58129. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58130. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58131. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58132. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58133. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58134. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58135. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58136. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58137. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58138. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58139. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  58140. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  58141. wipeCaches(bruteForce?: boolean): void;
  58142. _createTexture(): WebGLTexture;
  58143. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  58144. /**
  58145. * Update the content of a dynamic texture
  58146. * @param texture defines the texture to update
  58147. * @param canvas defines the canvas containing the source
  58148. * @param invertY defines if data must be stored with Y axis inverted
  58149. * @param premulAlpha defines if alpha is stored as premultiplied
  58150. * @param format defines the format of the data
  58151. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58152. */
  58153. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58154. /**
  58155. * Usually called from Texture.ts.
  58156. * Passed information to create a WebGLTexture
  58157. * @param url defines a value which contains one of the following:
  58158. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58159. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58160. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58161. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58162. * @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)
  58163. * @param scene needed for loading to the correct scene
  58164. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58165. * @param onLoad optional callback to be called upon successful completion
  58166. * @param onError optional callback to be called upon failure
  58167. * @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
  58168. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58169. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58170. * @param forcedExtension defines the extension to use to pick the right loader
  58171. * @param mimeType defines an optional mime type
  58172. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58173. */
  58174. 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;
  58175. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  58176. _releaseFramebufferObjects(texture: InternalTexture): void;
  58177. /**
  58178. * Creates a cube texture
  58179. * @param rootUrl defines the url where the files to load is located
  58180. * @param scene defines the current scene
  58181. * @param files defines the list of files to load (1 per face)
  58182. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  58183. * @param onLoad defines an optional callback raised when the texture is loaded
  58184. * @param onError defines an optional callback raised if there is an issue to load the texture
  58185. * @param format defines the format of the data
  58186. * @param forcedExtension defines the extension to use to pick the right loader
  58187. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  58188. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58189. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58190. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  58191. * @returns the cube texture as an InternalTexture
  58192. */
  58193. 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;
  58194. createRenderTargetTexture(size: number | {
  58195. width: number;
  58196. height: number;
  58197. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  58198. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58199. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58200. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58201. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  58202. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  58203. /**
  58204. * Updates a dynamic vertex buffer.
  58205. * @param vertexBuffer the vertex buffer to update
  58206. * @param data the data used to update the vertex buffer
  58207. * @param byteOffset the byte offset of the data (optional)
  58208. * @param byteLength the byte length of the data (optional)
  58209. */
  58210. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  58211. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  58212. private _updateAnisotropicLevel;
  58213. private _getAddressMode;
  58214. /** @hidden */
  58215. _bindTexture(channel: number, texture: InternalTexture): void;
  58216. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  58217. releaseEffects(): void;
  58218. /** @hidden */
  58219. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58220. /** @hidden */
  58221. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58222. /** @hidden */
  58223. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58224. /** @hidden */
  58225. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  58226. private _getNativeSamplingMode;
  58227. private _getNativeTextureFormat;
  58228. private _getNativeAlphaMode;
  58229. private _getNativeAttribType;
  58230. }
  58231. }
  58232. declare module "babylonjs/Engines/index" {
  58233. export * from "babylonjs/Engines/constants";
  58234. export * from "babylonjs/Engines/engineCapabilities";
  58235. export * from "babylonjs/Engines/instancingAttributeInfo";
  58236. export * from "babylonjs/Engines/thinEngine";
  58237. export * from "babylonjs/Engines/engine";
  58238. export * from "babylonjs/Engines/engineStore";
  58239. export * from "babylonjs/Engines/nullEngine";
  58240. export * from "babylonjs/Engines/Extensions/index";
  58241. export * from "babylonjs/Engines/IPipelineContext";
  58242. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  58243. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  58244. export * from "babylonjs/Engines/nativeEngine";
  58245. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  58246. export * from "babylonjs/Engines/performanceConfigurator";
  58247. }
  58248. declare module "babylonjs/Events/clipboardEvents" {
  58249. /**
  58250. * Gather the list of clipboard event types as constants.
  58251. */
  58252. export class ClipboardEventTypes {
  58253. /**
  58254. * The clipboard event is fired when a copy command is active (pressed).
  58255. */
  58256. static readonly COPY: number;
  58257. /**
  58258. * The clipboard event is fired when a cut command is active (pressed).
  58259. */
  58260. static readonly CUT: number;
  58261. /**
  58262. * The clipboard event is fired when a paste command is active (pressed).
  58263. */
  58264. static readonly PASTE: number;
  58265. }
  58266. /**
  58267. * This class is used to store clipboard related info for the onClipboardObservable event.
  58268. */
  58269. export class ClipboardInfo {
  58270. /**
  58271. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58272. */
  58273. type: number;
  58274. /**
  58275. * Defines the related dom event
  58276. */
  58277. event: ClipboardEvent;
  58278. /**
  58279. *Creates an instance of ClipboardInfo.
  58280. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  58281. * @param event Defines the related dom event
  58282. */
  58283. constructor(
  58284. /**
  58285. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58286. */
  58287. type: number,
  58288. /**
  58289. * Defines the related dom event
  58290. */
  58291. event: ClipboardEvent);
  58292. /**
  58293. * Get the clipboard event's type from the keycode.
  58294. * @param keyCode Defines the keyCode for the current keyboard event.
  58295. * @return {number}
  58296. */
  58297. static GetTypeFromCharacter(keyCode: number): number;
  58298. }
  58299. }
  58300. declare module "babylonjs/Events/index" {
  58301. export * from "babylonjs/Events/keyboardEvents";
  58302. export * from "babylonjs/Events/pointerEvents";
  58303. export * from "babylonjs/Events/clipboardEvents";
  58304. }
  58305. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  58306. import { Scene } from "babylonjs/scene";
  58307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58308. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58309. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58310. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58311. /**
  58312. * Google Daydream controller
  58313. */
  58314. export class DaydreamController extends WebVRController {
  58315. /**
  58316. * Base Url for the controller model.
  58317. */
  58318. static MODEL_BASE_URL: string;
  58319. /**
  58320. * File name for the controller model.
  58321. */
  58322. static MODEL_FILENAME: string;
  58323. /**
  58324. * Gamepad Id prefix used to identify Daydream Controller.
  58325. */
  58326. static readonly GAMEPAD_ID_PREFIX: string;
  58327. /**
  58328. * Creates a new DaydreamController from a gamepad
  58329. * @param vrGamepad the gamepad that the controller should be created from
  58330. */
  58331. constructor(vrGamepad: any);
  58332. /**
  58333. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58334. * @param scene scene in which to add meshes
  58335. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58336. */
  58337. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58338. /**
  58339. * Called once for each button that changed state since the last frame
  58340. * @param buttonIdx Which button index changed
  58341. * @param state New state of the button
  58342. * @param changes Which properties on the state changed since last frame
  58343. */
  58344. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58345. }
  58346. }
  58347. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  58348. import { Scene } from "babylonjs/scene";
  58349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58350. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58351. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58352. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58353. /**
  58354. * Gear VR Controller
  58355. */
  58356. export class GearVRController extends WebVRController {
  58357. /**
  58358. * Base Url for the controller model.
  58359. */
  58360. static MODEL_BASE_URL: string;
  58361. /**
  58362. * File name for the controller model.
  58363. */
  58364. static MODEL_FILENAME: string;
  58365. /**
  58366. * Gamepad Id prefix used to identify this controller.
  58367. */
  58368. static readonly GAMEPAD_ID_PREFIX: string;
  58369. private readonly _buttonIndexToObservableNameMap;
  58370. /**
  58371. * Creates a new GearVRController from a gamepad
  58372. * @param vrGamepad the gamepad that the controller should be created from
  58373. */
  58374. constructor(vrGamepad: any);
  58375. /**
  58376. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58377. * @param scene scene in which to add meshes
  58378. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58379. */
  58380. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58381. /**
  58382. * Called once for each button that changed state since the last frame
  58383. * @param buttonIdx Which button index changed
  58384. * @param state New state of the button
  58385. * @param changes Which properties on the state changed since last frame
  58386. */
  58387. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58388. }
  58389. }
  58390. declare module "babylonjs/Gamepads/Controllers/genericController" {
  58391. import { Scene } from "babylonjs/scene";
  58392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58393. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58394. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58395. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58396. /**
  58397. * Generic Controller
  58398. */
  58399. export class GenericController extends WebVRController {
  58400. /**
  58401. * Base Url for the controller model.
  58402. */
  58403. static readonly MODEL_BASE_URL: string;
  58404. /**
  58405. * File name for the controller model.
  58406. */
  58407. static readonly MODEL_FILENAME: string;
  58408. /**
  58409. * Creates a new GenericController from a gamepad
  58410. * @param vrGamepad the gamepad that the controller should be created from
  58411. */
  58412. constructor(vrGamepad: any);
  58413. /**
  58414. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58415. * @param scene scene in which to add meshes
  58416. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58417. */
  58418. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58419. /**
  58420. * Called once for each button that changed state since the last frame
  58421. * @param buttonIdx Which button index changed
  58422. * @param state New state of the button
  58423. * @param changes Which properties on the state changed since last frame
  58424. */
  58425. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58426. }
  58427. }
  58428. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  58429. import { Observable } from "babylonjs/Misc/observable";
  58430. import { Scene } from "babylonjs/scene";
  58431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58432. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58433. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58434. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58435. /**
  58436. * Oculus Touch Controller
  58437. */
  58438. export class OculusTouchController extends WebVRController {
  58439. /**
  58440. * Base Url for the controller model.
  58441. */
  58442. static MODEL_BASE_URL: string;
  58443. /**
  58444. * File name for the left controller model.
  58445. */
  58446. static MODEL_LEFT_FILENAME: string;
  58447. /**
  58448. * File name for the right controller model.
  58449. */
  58450. static MODEL_RIGHT_FILENAME: string;
  58451. /**
  58452. * Base Url for the Quest controller model.
  58453. */
  58454. static QUEST_MODEL_BASE_URL: string;
  58455. /**
  58456. * @hidden
  58457. * If the controllers are running on a device that needs the updated Quest controller models
  58458. */
  58459. static _IsQuest: boolean;
  58460. /**
  58461. * Fired when the secondary trigger on this controller is modified
  58462. */
  58463. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  58464. /**
  58465. * Fired when the thumb rest on this controller is modified
  58466. */
  58467. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  58468. /**
  58469. * Creates a new OculusTouchController from a gamepad
  58470. * @param vrGamepad the gamepad that the controller should be created from
  58471. */
  58472. constructor(vrGamepad: any);
  58473. /**
  58474. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58475. * @param scene scene in which to add meshes
  58476. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58477. */
  58478. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58479. /**
  58480. * Fired when the A button on this controller is modified
  58481. */
  58482. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58483. /**
  58484. * Fired when the B button on this controller is modified
  58485. */
  58486. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58487. /**
  58488. * Fired when the X button on this controller is modified
  58489. */
  58490. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58491. /**
  58492. * Fired when the Y button on this controller is modified
  58493. */
  58494. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58495. /**
  58496. * Called once for each button that changed state since the last frame
  58497. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  58498. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  58499. * 2) secondary trigger (same)
  58500. * 3) A (right) X (left), touch, pressed = value
  58501. * 4) B / Y
  58502. * 5) thumb rest
  58503. * @param buttonIdx Which button index changed
  58504. * @param state New state of the button
  58505. * @param changes Which properties on the state changed since last frame
  58506. */
  58507. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58508. }
  58509. }
  58510. declare module "babylonjs/Gamepads/Controllers/viveController" {
  58511. import { Scene } from "babylonjs/scene";
  58512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58513. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58514. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58515. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58516. import { Observable } from "babylonjs/Misc/observable";
  58517. /**
  58518. * Vive Controller
  58519. */
  58520. export class ViveController extends WebVRController {
  58521. /**
  58522. * Base Url for the controller model.
  58523. */
  58524. static MODEL_BASE_URL: string;
  58525. /**
  58526. * File name for the controller model.
  58527. */
  58528. static MODEL_FILENAME: string;
  58529. /**
  58530. * Creates a new ViveController from a gamepad
  58531. * @param vrGamepad the gamepad that the controller should be created from
  58532. */
  58533. constructor(vrGamepad: any);
  58534. /**
  58535. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58536. * @param scene scene in which to add meshes
  58537. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58538. */
  58539. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58540. /**
  58541. * Fired when the left button on this controller is modified
  58542. */
  58543. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58544. /**
  58545. * Fired when the right button on this controller is modified
  58546. */
  58547. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58548. /**
  58549. * Fired when the menu button on this controller is modified
  58550. */
  58551. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58552. /**
  58553. * Called once for each button that changed state since the last frame
  58554. * Vive mapping:
  58555. * 0: touchpad
  58556. * 1: trigger
  58557. * 2: left AND right buttons
  58558. * 3: menu button
  58559. * @param buttonIdx Which button index changed
  58560. * @param state New state of the button
  58561. * @param changes Which properties on the state changed since last frame
  58562. */
  58563. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58564. }
  58565. }
  58566. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  58567. import { Observable } from "babylonjs/Misc/observable";
  58568. import { Scene } from "babylonjs/scene";
  58569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58570. import { Ray } from "babylonjs/Culling/ray";
  58571. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58572. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58573. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58574. /**
  58575. * Defines the WindowsMotionController object that the state of the windows motion controller
  58576. */
  58577. export class WindowsMotionController extends WebVRController {
  58578. /**
  58579. * The base url used to load the left and right controller models
  58580. */
  58581. static MODEL_BASE_URL: string;
  58582. /**
  58583. * The name of the left controller model file
  58584. */
  58585. static MODEL_LEFT_FILENAME: string;
  58586. /**
  58587. * The name of the right controller model file
  58588. */
  58589. static MODEL_RIGHT_FILENAME: string;
  58590. /**
  58591. * The controller name prefix for this controller type
  58592. */
  58593. static readonly GAMEPAD_ID_PREFIX: string;
  58594. /**
  58595. * The controller id pattern for this controller type
  58596. */
  58597. private static readonly GAMEPAD_ID_PATTERN;
  58598. private _loadedMeshInfo;
  58599. protected readonly _mapping: {
  58600. buttons: string[];
  58601. buttonMeshNames: {
  58602. trigger: string;
  58603. menu: string;
  58604. grip: string;
  58605. thumbstick: string;
  58606. trackpad: string;
  58607. };
  58608. buttonObservableNames: {
  58609. trigger: string;
  58610. menu: string;
  58611. grip: string;
  58612. thumbstick: string;
  58613. trackpad: string;
  58614. };
  58615. axisMeshNames: string[];
  58616. pointingPoseMeshName: string;
  58617. };
  58618. /**
  58619. * Fired when the trackpad on this controller is clicked
  58620. */
  58621. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58622. /**
  58623. * Fired when the trackpad on this controller is modified
  58624. */
  58625. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58626. /**
  58627. * The current x and y values of this controller's trackpad
  58628. */
  58629. trackpad: StickValues;
  58630. /**
  58631. * Creates a new WindowsMotionController from a gamepad
  58632. * @param vrGamepad the gamepad that the controller should be created from
  58633. */
  58634. constructor(vrGamepad: any);
  58635. /**
  58636. * Fired when the trigger on this controller is modified
  58637. */
  58638. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58639. /**
  58640. * Fired when the menu button on this controller is modified
  58641. */
  58642. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58643. /**
  58644. * Fired when the grip button on this controller is modified
  58645. */
  58646. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58647. /**
  58648. * Fired when the thumbstick button on this controller is modified
  58649. */
  58650. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58651. /**
  58652. * Fired when the touchpad button on this controller is modified
  58653. */
  58654. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58655. /**
  58656. * Fired when the touchpad values on this controller are modified
  58657. */
  58658. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  58659. protected _updateTrackpad(): void;
  58660. /**
  58661. * Called once per frame by the engine.
  58662. */
  58663. update(): void;
  58664. /**
  58665. * Called once for each button that changed state since the last frame
  58666. * @param buttonIdx Which button index changed
  58667. * @param state New state of the button
  58668. * @param changes Which properties on the state changed since last frame
  58669. */
  58670. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58671. /**
  58672. * Moves the buttons on the controller mesh based on their current state
  58673. * @param buttonName the name of the button to move
  58674. * @param buttonValue the value of the button which determines the buttons new position
  58675. */
  58676. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  58677. /**
  58678. * Moves the axis on the controller mesh based on its current state
  58679. * @param axis the index of the axis
  58680. * @param axisValue the value of the axis which determines the meshes new position
  58681. * @hidden
  58682. */
  58683. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  58684. /**
  58685. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58686. * @param scene scene in which to add meshes
  58687. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58688. */
  58689. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  58690. /**
  58691. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  58692. * can be transformed by button presses and axes values, based on this._mapping.
  58693. *
  58694. * @param scene scene in which the meshes exist
  58695. * @param meshes list of meshes that make up the controller model to process
  58696. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  58697. */
  58698. private processModel;
  58699. private createMeshInfo;
  58700. /**
  58701. * Gets the ray of the controller in the direction the controller is pointing
  58702. * @param length the length the resulting ray should be
  58703. * @returns a ray in the direction the controller is pointing
  58704. */
  58705. getForwardRay(length?: number): Ray;
  58706. /**
  58707. * Disposes of the controller
  58708. */
  58709. dispose(): void;
  58710. }
  58711. /**
  58712. * This class represents a new windows motion controller in XR.
  58713. */
  58714. export class XRWindowsMotionController extends WindowsMotionController {
  58715. /**
  58716. * Changing the original WIndowsMotionController mapping to fir the new mapping
  58717. */
  58718. protected readonly _mapping: {
  58719. buttons: string[];
  58720. buttonMeshNames: {
  58721. trigger: string;
  58722. menu: string;
  58723. grip: string;
  58724. thumbstick: string;
  58725. trackpad: string;
  58726. };
  58727. buttonObservableNames: {
  58728. trigger: string;
  58729. menu: string;
  58730. grip: string;
  58731. thumbstick: string;
  58732. trackpad: string;
  58733. };
  58734. axisMeshNames: string[];
  58735. pointingPoseMeshName: string;
  58736. };
  58737. /**
  58738. * Construct a new XR-Based windows motion controller
  58739. *
  58740. * @param gamepadInfo the gamepad object from the browser
  58741. */
  58742. constructor(gamepadInfo: any);
  58743. /**
  58744. * holds the thumbstick values (X,Y)
  58745. */
  58746. thumbstickValues: StickValues;
  58747. /**
  58748. * Fired when the thumbstick on this controller is clicked
  58749. */
  58750. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  58751. /**
  58752. * Fired when the thumbstick on this controller is modified
  58753. */
  58754. onThumbstickValuesChangedObservable: Observable<StickValues>;
  58755. /**
  58756. * Fired when the touchpad button on this controller is modified
  58757. */
  58758. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58759. /**
  58760. * Fired when the touchpad values on this controller are modified
  58761. */
  58762. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58763. /**
  58764. * Fired when the thumbstick button on this controller is modified
  58765. * here to prevent breaking changes
  58766. */
  58767. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58768. /**
  58769. * updating the thumbstick(!) and not the trackpad.
  58770. * This is named this way due to the difference between WebVR and XR and to avoid
  58771. * changing the parent class.
  58772. */
  58773. protected _updateTrackpad(): void;
  58774. /**
  58775. * Disposes the class with joy
  58776. */
  58777. dispose(): void;
  58778. }
  58779. }
  58780. declare module "babylonjs/Gamepads/Controllers/index" {
  58781. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  58782. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  58783. export * from "babylonjs/Gamepads/Controllers/genericController";
  58784. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  58785. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58786. export * from "babylonjs/Gamepads/Controllers/viveController";
  58787. export * from "babylonjs/Gamepads/Controllers/webVRController";
  58788. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  58789. }
  58790. declare module "babylonjs/Gamepads/index" {
  58791. export * from "babylonjs/Gamepads/Controllers/index";
  58792. export * from "babylonjs/Gamepads/gamepad";
  58793. export * from "babylonjs/Gamepads/gamepadManager";
  58794. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  58795. export * from "babylonjs/Gamepads/xboxGamepad";
  58796. export * from "babylonjs/Gamepads/dualShockGamepad";
  58797. }
  58798. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  58799. import { Scene } from "babylonjs/scene";
  58800. import { Vector4 } from "babylonjs/Maths/math.vector";
  58801. import { Color4 } from "babylonjs/Maths/math.color";
  58802. import { Mesh } from "babylonjs/Meshes/mesh";
  58803. import { Nullable } from "babylonjs/types";
  58804. /**
  58805. * Class containing static functions to help procedurally build meshes
  58806. */
  58807. export class PolyhedronBuilder {
  58808. /**
  58809. * Creates a polyhedron mesh
  58810. * * 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
  58811. * * The parameter `size` (positive float, default 1) sets the polygon size
  58812. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58813. * * 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`
  58814. * * 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
  58815. * * 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)`)
  58816. * * 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
  58817. * * 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
  58818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58819. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58821. * @param name defines the name of the mesh
  58822. * @param options defines the options used to create the mesh
  58823. * @param scene defines the hosting scene
  58824. * @returns the polyhedron mesh
  58825. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58826. */
  58827. static CreatePolyhedron(name: string, options: {
  58828. type?: number;
  58829. size?: number;
  58830. sizeX?: number;
  58831. sizeY?: number;
  58832. sizeZ?: number;
  58833. custom?: any;
  58834. faceUV?: Vector4[];
  58835. faceColors?: Color4[];
  58836. flat?: boolean;
  58837. updatable?: boolean;
  58838. sideOrientation?: number;
  58839. frontUVs?: Vector4;
  58840. backUVs?: Vector4;
  58841. }, scene?: Nullable<Scene>): Mesh;
  58842. }
  58843. }
  58844. declare module "babylonjs/Gizmos/scaleGizmo" {
  58845. import { Observable } from "babylonjs/Misc/observable";
  58846. import { Nullable } from "babylonjs/types";
  58847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58848. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  58849. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  58850. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  58851. import { Node } from "babylonjs/node";
  58852. /**
  58853. * Gizmo that enables scaling a mesh along 3 axis
  58854. */
  58855. export class ScaleGizmo extends Gizmo {
  58856. /**
  58857. * Internal gizmo used for interactions on the x axis
  58858. */
  58859. xGizmo: AxisScaleGizmo;
  58860. /**
  58861. * Internal gizmo used for interactions on the y axis
  58862. */
  58863. yGizmo: AxisScaleGizmo;
  58864. /**
  58865. * Internal gizmo used for interactions on the z axis
  58866. */
  58867. zGizmo: AxisScaleGizmo;
  58868. /**
  58869. * Internal gizmo used to scale all axis equally
  58870. */
  58871. uniformScaleGizmo: AxisScaleGizmo;
  58872. private _meshAttached;
  58873. private _nodeAttached;
  58874. private _snapDistance;
  58875. private _uniformScalingMesh;
  58876. private _octahedron;
  58877. private _sensitivity;
  58878. /** Fires an event when any of it's sub gizmos are dragged */
  58879. onDragStartObservable: Observable<unknown>;
  58880. /** Fires an event when any of it's sub gizmos are released from dragging */
  58881. onDragEndObservable: Observable<unknown>;
  58882. get attachedMesh(): Nullable<AbstractMesh>;
  58883. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58884. get attachedNode(): Nullable<Node>;
  58885. set attachedNode(node: Nullable<Node>);
  58886. /**
  58887. * True when the mouse pointer is hovering a gizmo mesh
  58888. */
  58889. get isHovered(): boolean;
  58890. /**
  58891. * Creates a ScaleGizmo
  58892. * @param gizmoLayer The utility layer the gizmo will be added to
  58893. * @param thickness display gizmo axis thickness
  58894. */
  58895. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  58896. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58897. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58898. /**
  58899. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58900. */
  58901. set snapDistance(value: number);
  58902. get snapDistance(): number;
  58903. /**
  58904. * Ratio for the scale of the gizmo (Default: 1)
  58905. */
  58906. set scaleRatio(value: number);
  58907. get scaleRatio(): number;
  58908. /**
  58909. * Sensitivity factor for dragging (Default: 1)
  58910. */
  58911. set sensitivity(value: number);
  58912. get sensitivity(): number;
  58913. /**
  58914. * Disposes of the gizmo
  58915. */
  58916. dispose(): void;
  58917. }
  58918. }
  58919. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  58920. import { Observable } from "babylonjs/Misc/observable";
  58921. import { Nullable } from "babylonjs/types";
  58922. import { Vector3 } from "babylonjs/Maths/math.vector";
  58923. import { Node } from "babylonjs/node";
  58924. import { Mesh } from "babylonjs/Meshes/mesh";
  58925. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  58926. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  58927. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  58928. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  58929. import { Color3 } from "babylonjs/Maths/math.color";
  58930. /**
  58931. * Single axis scale gizmo
  58932. */
  58933. export class AxisScaleGizmo extends Gizmo {
  58934. /**
  58935. * Drag behavior responsible for the gizmos dragging interactions
  58936. */
  58937. dragBehavior: PointerDragBehavior;
  58938. private _pointerObserver;
  58939. /**
  58940. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58941. */
  58942. snapDistance: number;
  58943. /**
  58944. * Event that fires each time the gizmo snaps to a new location.
  58945. * * snapDistance is the the change in distance
  58946. */
  58947. onSnapObservable: Observable<{
  58948. snapDistance: number;
  58949. }>;
  58950. /**
  58951. * If the scaling operation should be done on all axis (default: false)
  58952. */
  58953. uniformScaling: boolean;
  58954. /**
  58955. * Custom sensitivity value for the drag strength
  58956. */
  58957. sensitivity: number;
  58958. private _isEnabled;
  58959. private _parent;
  58960. private _arrow;
  58961. private _coloredMaterial;
  58962. private _hoverMaterial;
  58963. /**
  58964. * Creates an AxisScaleGizmo
  58965. * @param gizmoLayer The utility layer the gizmo will be added to
  58966. * @param dragAxis The axis which the gizmo will be able to scale on
  58967. * @param color The color of the gizmo
  58968. * @param thickness display gizmo axis thickness
  58969. */
  58970. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  58971. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58972. /**
  58973. * If the gizmo is enabled
  58974. */
  58975. set isEnabled(value: boolean);
  58976. get isEnabled(): boolean;
  58977. /**
  58978. * Disposes of the gizmo
  58979. */
  58980. dispose(): void;
  58981. /**
  58982. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  58983. * @param mesh The mesh to replace the default mesh of the gizmo
  58984. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  58985. */
  58986. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  58987. }
  58988. }
  58989. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  58990. import { Observable } from "babylonjs/Misc/observable";
  58991. import { Nullable } from "babylonjs/types";
  58992. import { Vector3 } from "babylonjs/Maths/math.vector";
  58993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58994. import { Mesh } from "babylonjs/Meshes/mesh";
  58995. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  58996. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  58997. import { Color3 } from "babylonjs/Maths/math.color";
  58998. import "babylonjs/Meshes/Builders/boxBuilder";
  58999. /**
  59000. * Bounding box gizmo
  59001. */
  59002. export class BoundingBoxGizmo extends Gizmo {
  59003. private _lineBoundingBox;
  59004. private _rotateSpheresParent;
  59005. private _scaleBoxesParent;
  59006. private _boundingDimensions;
  59007. private _renderObserver;
  59008. private _pointerObserver;
  59009. private _scaleDragSpeed;
  59010. private _tmpQuaternion;
  59011. private _tmpVector;
  59012. private _tmpRotationMatrix;
  59013. /**
  59014. * 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)
  59015. */
  59016. ignoreChildren: boolean;
  59017. /**
  59018. * 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)
  59019. */
  59020. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  59021. /**
  59022. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  59023. */
  59024. rotationSphereSize: number;
  59025. /**
  59026. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  59027. */
  59028. scaleBoxSize: number;
  59029. /**
  59030. * 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)
  59031. */
  59032. fixedDragMeshScreenSize: boolean;
  59033. /**
  59034. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  59035. */
  59036. fixedDragMeshScreenSizeDistanceFactor: number;
  59037. /**
  59038. * Fired when a rotation sphere or scale box is dragged
  59039. */
  59040. onDragStartObservable: Observable<{}>;
  59041. /**
  59042. * Fired when a scale box is dragged
  59043. */
  59044. onScaleBoxDragObservable: Observable<{}>;
  59045. /**
  59046. * Fired when a scale box drag is ended
  59047. */
  59048. onScaleBoxDragEndObservable: Observable<{}>;
  59049. /**
  59050. * Fired when a rotation sphere is dragged
  59051. */
  59052. onRotationSphereDragObservable: Observable<{}>;
  59053. /**
  59054. * Fired when a rotation sphere drag is ended
  59055. */
  59056. onRotationSphereDragEndObservable: Observable<{}>;
  59057. /**
  59058. * 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)
  59059. */
  59060. scalePivot: Nullable<Vector3>;
  59061. /**
  59062. * Mesh used as a pivot to rotate the attached node
  59063. */
  59064. private _anchorMesh;
  59065. private _existingMeshScale;
  59066. private _dragMesh;
  59067. private pointerDragBehavior;
  59068. private coloredMaterial;
  59069. private hoverColoredMaterial;
  59070. /**
  59071. * Sets the color of the bounding box gizmo
  59072. * @param color the color to set
  59073. */
  59074. setColor(color: Color3): void;
  59075. /**
  59076. * Creates an BoundingBoxGizmo
  59077. * @param gizmoLayer The utility layer the gizmo will be added to
  59078. * @param color The color of the gizmo
  59079. */
  59080. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  59081. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  59082. private _selectNode;
  59083. /**
  59084. * Updates the bounding box information for the Gizmo
  59085. */
  59086. updateBoundingBox(): void;
  59087. private _updateRotationSpheres;
  59088. private _updateScaleBoxes;
  59089. /**
  59090. * Enables rotation on the specified axis and disables rotation on the others
  59091. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  59092. */
  59093. setEnabledRotationAxis(axis: string): void;
  59094. /**
  59095. * Enables/disables scaling
  59096. * @param enable if scaling should be enabled
  59097. * @param homogeneousScaling defines if scaling should only be homogeneous
  59098. */
  59099. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  59100. private _updateDummy;
  59101. /**
  59102. * Enables a pointer drag behavior on the bounding box of the gizmo
  59103. */
  59104. enableDragBehavior(): void;
  59105. /**
  59106. * Disposes of the gizmo
  59107. */
  59108. dispose(): void;
  59109. /**
  59110. * 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)
  59111. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  59112. * @returns the bounding box mesh with the passed in mesh as a child
  59113. */
  59114. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  59115. /**
  59116. * CustomMeshes are not supported by this gizmo
  59117. * @param mesh The mesh to replace the default mesh of the gizmo
  59118. */
  59119. setCustomMesh(mesh: Mesh): void;
  59120. }
  59121. }
  59122. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  59123. import { Observable } from "babylonjs/Misc/observable";
  59124. import { Nullable } from "babylonjs/types";
  59125. import { Vector3 } from "babylonjs/Maths/math.vector";
  59126. import { Color3 } from "babylonjs/Maths/math.color";
  59127. import { Node } from "babylonjs/node";
  59128. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59129. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59130. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59131. import "babylonjs/Meshes/Builders/linesBuilder";
  59132. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59133. /**
  59134. * Single plane rotation gizmo
  59135. */
  59136. export class PlaneRotationGizmo extends Gizmo {
  59137. /**
  59138. * Drag behavior responsible for the gizmos dragging interactions
  59139. */
  59140. dragBehavior: PointerDragBehavior;
  59141. private _pointerObserver;
  59142. /**
  59143. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59144. */
  59145. snapDistance: number;
  59146. /**
  59147. * Event that fires each time the gizmo snaps to a new location.
  59148. * * snapDistance is the the change in distance
  59149. */
  59150. onSnapObservable: Observable<{
  59151. snapDistance: number;
  59152. }>;
  59153. private _isEnabled;
  59154. private _parent;
  59155. /**
  59156. * Creates a PlaneRotationGizmo
  59157. * @param gizmoLayer The utility layer the gizmo will be added to
  59158. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  59159. * @param color The color of the gizmo
  59160. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59161. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59162. * @param thickness display gizmo axis thickness
  59163. */
  59164. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  59165. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59166. /**
  59167. * If the gizmo is enabled
  59168. */
  59169. set isEnabled(value: boolean);
  59170. get isEnabled(): boolean;
  59171. /**
  59172. * Disposes of the gizmo
  59173. */
  59174. dispose(): void;
  59175. }
  59176. }
  59177. declare module "babylonjs/Gizmos/rotationGizmo" {
  59178. import { Observable } from "babylonjs/Misc/observable";
  59179. import { Nullable } from "babylonjs/types";
  59180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59181. import { Mesh } from "babylonjs/Meshes/mesh";
  59182. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59183. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  59184. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59185. import { Node } from "babylonjs/node";
  59186. /**
  59187. * Gizmo that enables rotating a mesh along 3 axis
  59188. */
  59189. export class RotationGizmo extends Gizmo {
  59190. /**
  59191. * Internal gizmo used for interactions on the x axis
  59192. */
  59193. xGizmo: PlaneRotationGizmo;
  59194. /**
  59195. * Internal gizmo used for interactions on the y axis
  59196. */
  59197. yGizmo: PlaneRotationGizmo;
  59198. /**
  59199. * Internal gizmo used for interactions on the z axis
  59200. */
  59201. zGizmo: PlaneRotationGizmo;
  59202. /** Fires an event when any of it's sub gizmos are dragged */
  59203. onDragStartObservable: Observable<unknown>;
  59204. /** Fires an event when any of it's sub gizmos are released from dragging */
  59205. onDragEndObservable: Observable<unknown>;
  59206. private _meshAttached;
  59207. private _nodeAttached;
  59208. get attachedMesh(): Nullable<AbstractMesh>;
  59209. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59210. get attachedNode(): Nullable<Node>;
  59211. set attachedNode(node: Nullable<Node>);
  59212. /**
  59213. * True when the mouse pointer is hovering a gizmo mesh
  59214. */
  59215. get isHovered(): boolean;
  59216. /**
  59217. * Creates a RotationGizmo
  59218. * @param gizmoLayer The utility layer the gizmo will be added to
  59219. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59220. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59221. * @param thickness display gizmo axis thickness
  59222. */
  59223. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  59224. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59225. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59226. /**
  59227. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59228. */
  59229. set snapDistance(value: number);
  59230. get snapDistance(): number;
  59231. /**
  59232. * Ratio for the scale of the gizmo (Default: 1)
  59233. */
  59234. set scaleRatio(value: number);
  59235. get scaleRatio(): number;
  59236. /**
  59237. * Disposes of the gizmo
  59238. */
  59239. dispose(): void;
  59240. /**
  59241. * CustomMeshes are not supported by this gizmo
  59242. * @param mesh The mesh to replace the default mesh of the gizmo
  59243. */
  59244. setCustomMesh(mesh: Mesh): void;
  59245. }
  59246. }
  59247. declare module "babylonjs/Gizmos/gizmoManager" {
  59248. import { Observable } from "babylonjs/Misc/observable";
  59249. import { Nullable } from "babylonjs/types";
  59250. import { Scene, IDisposable } from "babylonjs/scene";
  59251. import { Node } from "babylonjs/node";
  59252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59253. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59254. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  59255. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59256. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59257. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59258. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  59259. /**
  59260. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  59261. */
  59262. export class GizmoManager implements IDisposable {
  59263. private scene;
  59264. /**
  59265. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  59266. */
  59267. gizmos: {
  59268. positionGizmo: Nullable<PositionGizmo>;
  59269. rotationGizmo: Nullable<RotationGizmo>;
  59270. scaleGizmo: Nullable<ScaleGizmo>;
  59271. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  59272. };
  59273. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  59274. clearGizmoOnEmptyPointerEvent: boolean;
  59275. /** Fires an event when the manager is attached to a mesh */
  59276. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  59277. /** Fires an event when the manager is attached to a node */
  59278. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  59279. private _gizmosEnabled;
  59280. private _pointerObserver;
  59281. private _attachedMesh;
  59282. private _attachedNode;
  59283. private _boundingBoxColor;
  59284. private _defaultUtilityLayer;
  59285. private _defaultKeepDepthUtilityLayer;
  59286. private _thickness;
  59287. /**
  59288. * When bounding box gizmo is enabled, this can be used to track drag/end events
  59289. */
  59290. boundingBoxDragBehavior: SixDofDragBehavior;
  59291. /**
  59292. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  59293. */
  59294. attachableMeshes: Nullable<Array<AbstractMesh>>;
  59295. /**
  59296. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  59297. */
  59298. attachableNodes: Nullable<Array<Node>>;
  59299. /**
  59300. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  59301. */
  59302. usePointerToAttachGizmos: boolean;
  59303. /**
  59304. * Utility layer that the bounding box gizmo belongs to
  59305. */
  59306. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  59307. /**
  59308. * Utility layer that all gizmos besides bounding box belong to
  59309. */
  59310. get utilityLayer(): UtilityLayerRenderer;
  59311. /**
  59312. * True when the mouse pointer is hovering a gizmo mesh
  59313. */
  59314. get isHovered(): boolean;
  59315. /**
  59316. * Instatiates a gizmo manager
  59317. * @param scene the scene to overlay the gizmos on top of
  59318. * @param thickness display gizmo axis thickness
  59319. */
  59320. constructor(scene: Scene, thickness?: number);
  59321. /**
  59322. * Attaches a set of gizmos to the specified mesh
  59323. * @param mesh The mesh the gizmo's should be attached to
  59324. */
  59325. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59326. /**
  59327. * Attaches a set of gizmos to the specified node
  59328. * @param node The node the gizmo's should be attached to
  59329. */
  59330. attachToNode(node: Nullable<Node>): void;
  59331. /**
  59332. * If the position gizmo is enabled
  59333. */
  59334. set positionGizmoEnabled(value: boolean);
  59335. get positionGizmoEnabled(): boolean;
  59336. /**
  59337. * If the rotation gizmo is enabled
  59338. */
  59339. set rotationGizmoEnabled(value: boolean);
  59340. get rotationGizmoEnabled(): boolean;
  59341. /**
  59342. * If the scale gizmo is enabled
  59343. */
  59344. set scaleGizmoEnabled(value: boolean);
  59345. get scaleGizmoEnabled(): boolean;
  59346. /**
  59347. * If the boundingBox gizmo is enabled
  59348. */
  59349. set boundingBoxGizmoEnabled(value: boolean);
  59350. get boundingBoxGizmoEnabled(): boolean;
  59351. /**
  59352. * Disposes of the gizmo manager
  59353. */
  59354. dispose(): void;
  59355. }
  59356. }
  59357. declare module "babylonjs/Lights/directionalLight" {
  59358. import { Camera } from "babylonjs/Cameras/camera";
  59359. import { Scene } from "babylonjs/scene";
  59360. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59362. import { Light } from "babylonjs/Lights/light";
  59363. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59364. import { Effect } from "babylonjs/Materials/effect";
  59365. /**
  59366. * A directional light is defined by a direction (what a surprise!).
  59367. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  59368. * 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.
  59369. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59370. */
  59371. export class DirectionalLight extends ShadowLight {
  59372. private _shadowFrustumSize;
  59373. /**
  59374. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  59375. */
  59376. get shadowFrustumSize(): number;
  59377. /**
  59378. * Specifies a fix frustum size for the shadow generation.
  59379. */
  59380. set shadowFrustumSize(value: number);
  59381. private _shadowOrthoScale;
  59382. /**
  59383. * Gets the shadow projection scale against the optimal computed one.
  59384. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59385. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59386. */
  59387. get shadowOrthoScale(): number;
  59388. /**
  59389. * Sets the shadow projection scale against the optimal computed one.
  59390. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59391. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59392. */
  59393. set shadowOrthoScale(value: number);
  59394. /**
  59395. * Automatically compute the projection matrix to best fit (including all the casters)
  59396. * on each frame.
  59397. */
  59398. autoUpdateExtends: boolean;
  59399. /**
  59400. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  59401. * on each frame. autoUpdateExtends must be set to true for this to work
  59402. */
  59403. autoCalcShadowZBounds: boolean;
  59404. private _orthoLeft;
  59405. private _orthoRight;
  59406. private _orthoTop;
  59407. private _orthoBottom;
  59408. /**
  59409. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  59410. * The directional light is emitted from everywhere in the given direction.
  59411. * It can cast shadows.
  59412. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59413. * @param name The friendly name of the light
  59414. * @param direction The direction of the light
  59415. * @param scene The scene the light belongs to
  59416. */
  59417. constructor(name: string, direction: Vector3, scene: Scene);
  59418. /**
  59419. * Returns the string "DirectionalLight".
  59420. * @return The class name
  59421. */
  59422. getClassName(): string;
  59423. /**
  59424. * Returns the integer 1.
  59425. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59426. */
  59427. getTypeID(): number;
  59428. /**
  59429. * Sets the passed matrix "matrix" as 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 _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59433. /**
  59434. * Sets the passed matrix "matrix" as fixed frustum 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 _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  59438. /**
  59439. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  59440. * Returns the DirectionalLight Shadow projection matrix.
  59441. */
  59442. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59443. protected _buildUniformLayout(): void;
  59444. /**
  59445. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  59446. * @param effect The effect to update
  59447. * @param lightIndex The index of the light in the effect to update
  59448. * @returns The directional light
  59449. */
  59450. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  59451. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  59452. /**
  59453. * Gets the minZ used for shadow according to both the scene and the light.
  59454. *
  59455. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59456. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59457. * @param activeCamera The camera we are returning the min for
  59458. * @returns the depth min z
  59459. */
  59460. getDepthMinZ(activeCamera: Camera): number;
  59461. /**
  59462. * Gets the maxZ used for shadow according to both the scene and the light.
  59463. *
  59464. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59465. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59466. * @param activeCamera The camera we are returning the max for
  59467. * @returns the depth max z
  59468. */
  59469. getDepthMaxZ(activeCamera: Camera): number;
  59470. /**
  59471. * Prepares the list of defines specific to the light type.
  59472. * @param defines the list of defines
  59473. * @param lightIndex defines the index of the light for the effect
  59474. */
  59475. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59476. }
  59477. }
  59478. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  59479. import { Mesh } from "babylonjs/Meshes/mesh";
  59480. /**
  59481. * Class containing static functions to help procedurally build meshes
  59482. */
  59483. export class HemisphereBuilder {
  59484. /**
  59485. * Creates a hemisphere mesh
  59486. * @param name defines the name of the mesh
  59487. * @param options defines the options used to create the mesh
  59488. * @param scene defines the hosting scene
  59489. * @returns the hemisphere mesh
  59490. */
  59491. static CreateHemisphere(name: string, options: {
  59492. segments?: number;
  59493. diameter?: number;
  59494. sideOrientation?: number;
  59495. }, scene: any): Mesh;
  59496. }
  59497. }
  59498. declare module "babylonjs/Lights/spotLight" {
  59499. import { Nullable } from "babylonjs/types";
  59500. import { Scene } from "babylonjs/scene";
  59501. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59503. import { Effect } from "babylonjs/Materials/effect";
  59504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59505. import { Light } from "babylonjs/Lights/light";
  59506. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59507. /**
  59508. * A spot light is defined by a position, a direction, an angle, and an exponent.
  59509. * These values define a cone of light starting from the position, emitting toward the direction.
  59510. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  59511. * and the exponent defines the speed of the decay of the light with distance (reach).
  59512. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59513. */
  59514. export class SpotLight extends ShadowLight {
  59515. private _angle;
  59516. private _innerAngle;
  59517. private _cosHalfAngle;
  59518. private _lightAngleScale;
  59519. private _lightAngleOffset;
  59520. /**
  59521. * Gets the cone angle of the spot light in Radians.
  59522. */
  59523. get angle(): number;
  59524. /**
  59525. * Sets the cone angle of the spot light in Radians.
  59526. */
  59527. set angle(value: number);
  59528. /**
  59529. * Only used in gltf falloff mode, this defines the angle where
  59530. * the directional falloff will start before cutting at angle which could be seen
  59531. * as outer angle.
  59532. */
  59533. get innerAngle(): number;
  59534. /**
  59535. * Only used in gltf falloff mode, this defines the angle where
  59536. * the directional falloff will start before cutting at angle which could be seen
  59537. * as outer angle.
  59538. */
  59539. set innerAngle(value: number);
  59540. private _shadowAngleScale;
  59541. /**
  59542. * Allows scaling the angle of the light for shadow generation only.
  59543. */
  59544. get shadowAngleScale(): number;
  59545. /**
  59546. * Allows scaling the angle of the light for shadow generation only.
  59547. */
  59548. set shadowAngleScale(value: number);
  59549. /**
  59550. * The light decay speed with the distance from the emission spot.
  59551. */
  59552. exponent: number;
  59553. private _projectionTextureMatrix;
  59554. /**
  59555. * Allows reading the projecton texture
  59556. */
  59557. get projectionTextureMatrix(): Matrix;
  59558. protected _projectionTextureLightNear: number;
  59559. /**
  59560. * Gets the near clip of the Spotlight for texture projection.
  59561. */
  59562. get projectionTextureLightNear(): number;
  59563. /**
  59564. * Sets the near clip of the Spotlight for texture projection.
  59565. */
  59566. set projectionTextureLightNear(value: number);
  59567. protected _projectionTextureLightFar: number;
  59568. /**
  59569. * Gets the far clip of the Spotlight for texture projection.
  59570. */
  59571. get projectionTextureLightFar(): number;
  59572. /**
  59573. * Sets the far clip of the Spotlight for texture projection.
  59574. */
  59575. set projectionTextureLightFar(value: number);
  59576. protected _projectionTextureUpDirection: Vector3;
  59577. /**
  59578. * Gets the Up vector of the Spotlight for texture projection.
  59579. */
  59580. get projectionTextureUpDirection(): Vector3;
  59581. /**
  59582. * Sets the Up vector of the Spotlight for texture projection.
  59583. */
  59584. set projectionTextureUpDirection(value: Vector3);
  59585. private _projectionTexture;
  59586. /**
  59587. * Gets the projection texture of the light.
  59588. */
  59589. get projectionTexture(): Nullable<BaseTexture>;
  59590. /**
  59591. * Sets the projection texture of the light.
  59592. */
  59593. set projectionTexture(value: Nullable<BaseTexture>);
  59594. private _projectionTextureViewLightDirty;
  59595. private _projectionTextureProjectionLightDirty;
  59596. private _projectionTextureDirty;
  59597. private _projectionTextureViewTargetVector;
  59598. private _projectionTextureViewLightMatrix;
  59599. private _projectionTextureProjectionLightMatrix;
  59600. private _projectionTextureScalingMatrix;
  59601. /**
  59602. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  59603. * It can cast shadows.
  59604. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59605. * @param name The light friendly name
  59606. * @param position The position of the spot light in the scene
  59607. * @param direction The direction of the light in the scene
  59608. * @param angle The cone angle of the light in Radians
  59609. * @param exponent The light decay speed with the distance from the emission spot
  59610. * @param scene The scene the lights belongs to
  59611. */
  59612. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  59613. /**
  59614. * Returns the string "SpotLight".
  59615. * @returns the class name
  59616. */
  59617. getClassName(): string;
  59618. /**
  59619. * Returns the integer 2.
  59620. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59621. */
  59622. getTypeID(): number;
  59623. /**
  59624. * Overrides the direction setter to recompute the projection texture view light Matrix.
  59625. */
  59626. protected _setDirection(value: Vector3): void;
  59627. /**
  59628. * Overrides the position setter to recompute the projection texture view light Matrix.
  59629. */
  59630. protected _setPosition(value: Vector3): void;
  59631. /**
  59632. * 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.
  59633. * Returns the SpotLight.
  59634. */
  59635. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59636. protected _computeProjectionTextureViewLightMatrix(): void;
  59637. protected _computeProjectionTextureProjectionLightMatrix(): void;
  59638. /**
  59639. * Main function for light texture projection matrix computing.
  59640. */
  59641. protected _computeProjectionTextureMatrix(): void;
  59642. protected _buildUniformLayout(): void;
  59643. private _computeAngleValues;
  59644. /**
  59645. * Sets the passed Effect "effect" with the Light textures.
  59646. * @param effect The effect to update
  59647. * @param lightIndex The index of the light in the effect to update
  59648. * @returns The light
  59649. */
  59650. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  59651. /**
  59652. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  59653. * @param effect The effect to update
  59654. * @param lightIndex The index of the light in the effect to update
  59655. * @returns The spot light
  59656. */
  59657. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  59658. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59659. /**
  59660. * Disposes the light and the associated resources.
  59661. */
  59662. dispose(): void;
  59663. /**
  59664. * Prepares the list of defines specific to the light type.
  59665. * @param defines the list of defines
  59666. * @param lightIndex defines the index of the light for the effect
  59667. */
  59668. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59669. }
  59670. }
  59671. declare module "babylonjs/Gizmos/lightGizmo" {
  59672. import { Nullable } from "babylonjs/types";
  59673. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59674. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59675. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59676. import { Light } from "babylonjs/Lights/light";
  59677. import { Observable } from "babylonjs/Misc/observable";
  59678. /**
  59679. * Gizmo that enables viewing a light
  59680. */
  59681. export class LightGizmo extends Gizmo {
  59682. private _lightMesh;
  59683. private _material;
  59684. private _cachedPosition;
  59685. private _cachedForward;
  59686. private _attachedMeshParent;
  59687. private _pointerObserver;
  59688. /**
  59689. * Event that fires each time the gizmo is clicked
  59690. */
  59691. onClickedObservable: Observable<Light>;
  59692. /**
  59693. * Creates a LightGizmo
  59694. * @param gizmoLayer The utility layer the gizmo will be added to
  59695. */
  59696. constructor(gizmoLayer?: UtilityLayerRenderer);
  59697. private _light;
  59698. /**
  59699. * The light that the gizmo is attached to
  59700. */
  59701. set light(light: Nullable<Light>);
  59702. get light(): Nullable<Light>;
  59703. /**
  59704. * Gets the material used to render the light gizmo
  59705. */
  59706. get material(): StandardMaterial;
  59707. /**
  59708. * @hidden
  59709. * Updates the gizmo to match the attached mesh's position/rotation
  59710. */
  59711. protected _update(): void;
  59712. private static _Scale;
  59713. /**
  59714. * Creates the lines for a light mesh
  59715. */
  59716. private static _CreateLightLines;
  59717. /**
  59718. * Disposes of the light gizmo
  59719. */
  59720. dispose(): void;
  59721. private static _CreateHemisphericLightMesh;
  59722. private static _CreatePointLightMesh;
  59723. private static _CreateSpotLightMesh;
  59724. private static _CreateDirectionalLightMesh;
  59725. }
  59726. }
  59727. declare module "babylonjs/Gizmos/cameraGizmo" {
  59728. import { Nullable } from "babylonjs/types";
  59729. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59730. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59731. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59732. import { Camera } from "babylonjs/Cameras/camera";
  59733. import { Observable } from "babylonjs/Misc/observable";
  59734. /**
  59735. * Gizmo that enables viewing a camera
  59736. */
  59737. export class CameraGizmo extends Gizmo {
  59738. private _cameraMesh;
  59739. private _cameraLinesMesh;
  59740. private _material;
  59741. private _pointerObserver;
  59742. /**
  59743. * Event that fires each time the gizmo is clicked
  59744. */
  59745. onClickedObservable: Observable<Camera>;
  59746. /**
  59747. * Creates a CameraGizmo
  59748. * @param gizmoLayer The utility layer the gizmo will be added to
  59749. */
  59750. constructor(gizmoLayer?: UtilityLayerRenderer);
  59751. private _camera;
  59752. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  59753. get displayFrustum(): boolean;
  59754. set displayFrustum(value: boolean);
  59755. /**
  59756. * The camera that the gizmo is attached to
  59757. */
  59758. set camera(camera: Nullable<Camera>);
  59759. get camera(): Nullable<Camera>;
  59760. /**
  59761. * Gets the material used to render the camera gizmo
  59762. */
  59763. get material(): StandardMaterial;
  59764. /**
  59765. * @hidden
  59766. * Updates the gizmo to match the attached mesh's position/rotation
  59767. */
  59768. protected _update(): void;
  59769. private static _Scale;
  59770. private _invProjection;
  59771. /**
  59772. * Disposes of the camera gizmo
  59773. */
  59774. dispose(): void;
  59775. private static _CreateCameraMesh;
  59776. private static _CreateCameraFrustum;
  59777. }
  59778. }
  59779. declare module "babylonjs/Gizmos/index" {
  59780. export * from "babylonjs/Gizmos/axisDragGizmo";
  59781. export * from "babylonjs/Gizmos/axisScaleGizmo";
  59782. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  59783. export * from "babylonjs/Gizmos/gizmo";
  59784. export * from "babylonjs/Gizmos/gizmoManager";
  59785. export * from "babylonjs/Gizmos/planeRotationGizmo";
  59786. export * from "babylonjs/Gizmos/positionGizmo";
  59787. export * from "babylonjs/Gizmos/rotationGizmo";
  59788. export * from "babylonjs/Gizmos/scaleGizmo";
  59789. export * from "babylonjs/Gizmos/lightGizmo";
  59790. export * from "babylonjs/Gizmos/cameraGizmo";
  59791. export * from "babylonjs/Gizmos/planeDragGizmo";
  59792. }
  59793. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  59794. /** @hidden */
  59795. export var backgroundFragmentDeclaration: {
  59796. name: string;
  59797. shader: string;
  59798. };
  59799. }
  59800. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  59801. /** @hidden */
  59802. export var backgroundUboDeclaration: {
  59803. name: string;
  59804. shader: string;
  59805. };
  59806. }
  59807. declare module "babylonjs/Shaders/background.fragment" {
  59808. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  59809. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  59810. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59811. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59812. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59813. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59814. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59815. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  59816. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59817. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59818. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  59819. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59820. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59821. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59822. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  59823. /** @hidden */
  59824. export var backgroundPixelShader: {
  59825. name: string;
  59826. shader: string;
  59827. };
  59828. }
  59829. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  59830. /** @hidden */
  59831. export var backgroundVertexDeclaration: {
  59832. name: string;
  59833. shader: string;
  59834. };
  59835. }
  59836. declare module "babylonjs/Shaders/background.vertex" {
  59837. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  59838. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  59839. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59840. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59841. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59842. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  59843. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  59844. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59845. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59846. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59847. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59848. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59849. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  59850. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59851. /** @hidden */
  59852. export var backgroundVertexShader: {
  59853. name: string;
  59854. shader: string;
  59855. };
  59856. }
  59857. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  59858. import { Nullable, int, float } from "babylonjs/types";
  59859. import { Scene } from "babylonjs/scene";
  59860. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59861. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59863. import { Mesh } from "babylonjs/Meshes/mesh";
  59864. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59865. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59866. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59867. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59868. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  59869. import { Color3 } from "babylonjs/Maths/math.color";
  59870. import "babylonjs/Shaders/background.fragment";
  59871. import "babylonjs/Shaders/background.vertex";
  59872. /**
  59873. * Background material used to create an efficient environement around your scene.
  59874. */
  59875. export class BackgroundMaterial extends PushMaterial {
  59876. /**
  59877. * Standard reflectance value at parallel view angle.
  59878. */
  59879. static StandardReflectance0: number;
  59880. /**
  59881. * Standard reflectance value at grazing angle.
  59882. */
  59883. static StandardReflectance90: number;
  59884. protected _primaryColor: Color3;
  59885. /**
  59886. * Key light Color (multiply against the environement texture)
  59887. */
  59888. primaryColor: Color3;
  59889. protected __perceptualColor: Nullable<Color3>;
  59890. /**
  59891. * Experimental Internal Use Only.
  59892. *
  59893. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  59894. * This acts as a helper to set the primary color to a more "human friendly" value.
  59895. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  59896. * output color as close as possible from the chosen value.
  59897. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  59898. * part of lighting setup.)
  59899. */
  59900. get _perceptualColor(): Nullable<Color3>;
  59901. set _perceptualColor(value: Nullable<Color3>);
  59902. protected _primaryColorShadowLevel: float;
  59903. /**
  59904. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  59905. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  59906. */
  59907. get primaryColorShadowLevel(): float;
  59908. set primaryColorShadowLevel(value: float);
  59909. protected _primaryColorHighlightLevel: float;
  59910. /**
  59911. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  59912. * The primary color is used at the level chosen to define what the white area would look.
  59913. */
  59914. get primaryColorHighlightLevel(): float;
  59915. set primaryColorHighlightLevel(value: float);
  59916. protected _reflectionTexture: Nullable<BaseTexture>;
  59917. /**
  59918. * Reflection Texture used in the material.
  59919. * Should be author in a specific way for the best result (refer to the documentation).
  59920. */
  59921. reflectionTexture: Nullable<BaseTexture>;
  59922. protected _reflectionBlur: float;
  59923. /**
  59924. * Reflection Texture level of blur.
  59925. *
  59926. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  59927. * texture twice.
  59928. */
  59929. reflectionBlur: float;
  59930. protected _diffuseTexture: Nullable<BaseTexture>;
  59931. /**
  59932. * Diffuse Texture used in the material.
  59933. * Should be author in a specific way for the best result (refer to the documentation).
  59934. */
  59935. diffuseTexture: Nullable<BaseTexture>;
  59936. protected _shadowLights: Nullable<IShadowLight[]>;
  59937. /**
  59938. * Specify the list of lights casting shadow on the material.
  59939. * All scene shadow lights will be included if null.
  59940. */
  59941. shadowLights: Nullable<IShadowLight[]>;
  59942. protected _shadowLevel: float;
  59943. /**
  59944. * Helps adjusting the shadow to a softer level if required.
  59945. * 0 means black shadows and 1 means no shadows.
  59946. */
  59947. shadowLevel: float;
  59948. protected _sceneCenter: Vector3;
  59949. /**
  59950. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  59951. * It is usually zero but might be interesting to modify according to your setup.
  59952. */
  59953. sceneCenter: Vector3;
  59954. protected _opacityFresnel: boolean;
  59955. /**
  59956. * This helps specifying that the material is falling off to the sky box at grazing angle.
  59957. * This helps ensuring a nice transition when the camera goes under the ground.
  59958. */
  59959. opacityFresnel: boolean;
  59960. protected _reflectionFresnel: boolean;
  59961. /**
  59962. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  59963. * This helps adding a mirror texture on the ground.
  59964. */
  59965. reflectionFresnel: boolean;
  59966. protected _reflectionFalloffDistance: number;
  59967. /**
  59968. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  59969. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  59970. */
  59971. reflectionFalloffDistance: number;
  59972. protected _reflectionAmount: number;
  59973. /**
  59974. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  59975. */
  59976. reflectionAmount: number;
  59977. protected _reflectionReflectance0: number;
  59978. /**
  59979. * This specifies the weight of the reflection at grazing angle.
  59980. */
  59981. reflectionReflectance0: number;
  59982. protected _reflectionReflectance90: number;
  59983. /**
  59984. * This specifies the weight of the reflection at a perpendicular point of view.
  59985. */
  59986. reflectionReflectance90: number;
  59987. /**
  59988. * Sets the reflection reflectance fresnel values according to the default standard
  59989. * empirically know to work well :-)
  59990. */
  59991. set reflectionStandardFresnelWeight(value: number);
  59992. protected _useRGBColor: boolean;
  59993. /**
  59994. * Helps to directly use the maps channels instead of their level.
  59995. */
  59996. useRGBColor: boolean;
  59997. protected _enableNoise: boolean;
  59998. /**
  59999. * This helps reducing the banding effect that could occur on the background.
  60000. */
  60001. enableNoise: boolean;
  60002. /**
  60003. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60004. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60005. * Recommended to be keep at 1.0 except for special cases.
  60006. */
  60007. get fovMultiplier(): number;
  60008. set fovMultiplier(value: number);
  60009. private _fovMultiplier;
  60010. /**
  60011. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60012. */
  60013. useEquirectangularFOV: boolean;
  60014. private _maxSimultaneousLights;
  60015. /**
  60016. * Number of Simultaneous lights allowed on the material.
  60017. */
  60018. maxSimultaneousLights: int;
  60019. private _shadowOnly;
  60020. /**
  60021. * Make the material only render shadows
  60022. */
  60023. shadowOnly: boolean;
  60024. /**
  60025. * Default configuration related to image processing available in the Background Material.
  60026. */
  60027. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60028. /**
  60029. * Keep track of the image processing observer to allow dispose and replace.
  60030. */
  60031. private _imageProcessingObserver;
  60032. /**
  60033. * Attaches a new image processing configuration to the PBR Material.
  60034. * @param configuration (if null the scene configuration will be use)
  60035. */
  60036. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60037. /**
  60038. * Gets the image processing configuration used either in this material.
  60039. */
  60040. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  60041. /**
  60042. * Sets the Default image processing configuration used either in the this material.
  60043. *
  60044. * If sets to null, the scene one is in use.
  60045. */
  60046. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  60047. /**
  60048. * Gets wether the color curves effect is enabled.
  60049. */
  60050. get cameraColorCurvesEnabled(): boolean;
  60051. /**
  60052. * Sets wether the color curves effect is enabled.
  60053. */
  60054. set cameraColorCurvesEnabled(value: boolean);
  60055. /**
  60056. * Gets wether the color grading effect is enabled.
  60057. */
  60058. get cameraColorGradingEnabled(): boolean;
  60059. /**
  60060. * Gets wether the color grading effect is enabled.
  60061. */
  60062. set cameraColorGradingEnabled(value: boolean);
  60063. /**
  60064. * Gets wether tonemapping is enabled or not.
  60065. */
  60066. get cameraToneMappingEnabled(): boolean;
  60067. /**
  60068. * Sets wether tonemapping is enabled or not
  60069. */
  60070. set cameraToneMappingEnabled(value: boolean);
  60071. /**
  60072. * The camera exposure used on this material.
  60073. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60074. * This corresponds to a photographic exposure.
  60075. */
  60076. get cameraExposure(): float;
  60077. /**
  60078. * The camera exposure used on this material.
  60079. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60080. * This corresponds to a photographic exposure.
  60081. */
  60082. set cameraExposure(value: float);
  60083. /**
  60084. * Gets The camera contrast used on this material.
  60085. */
  60086. get cameraContrast(): float;
  60087. /**
  60088. * Sets The camera contrast used on this material.
  60089. */
  60090. set cameraContrast(value: float);
  60091. /**
  60092. * Gets the Color Grading 2D Lookup Texture.
  60093. */
  60094. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60095. /**
  60096. * Sets the Color Grading 2D Lookup Texture.
  60097. */
  60098. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60099. /**
  60100. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60101. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60102. * 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;
  60103. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60104. */
  60105. get cameraColorCurves(): Nullable<ColorCurves>;
  60106. /**
  60107. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60108. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60109. * 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;
  60110. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60111. */
  60112. set cameraColorCurves(value: Nullable<ColorCurves>);
  60113. /**
  60114. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  60115. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  60116. */
  60117. switchToBGR: boolean;
  60118. private _renderTargets;
  60119. private _reflectionControls;
  60120. private _white;
  60121. private _primaryShadowColor;
  60122. private _primaryHighlightColor;
  60123. /**
  60124. * Instantiates a Background Material in the given scene
  60125. * @param name The friendly name of the material
  60126. * @param scene The scene to add the material to
  60127. */
  60128. constructor(name: string, scene: Scene);
  60129. /**
  60130. * Gets a boolean indicating that current material needs to register RTT
  60131. */
  60132. get hasRenderTargetTextures(): boolean;
  60133. /**
  60134. * The entire material has been created in order to prevent overdraw.
  60135. * @returns false
  60136. */
  60137. needAlphaTesting(): boolean;
  60138. /**
  60139. * The entire material has been created in order to prevent overdraw.
  60140. * @returns true if blending is enable
  60141. */
  60142. needAlphaBlending(): boolean;
  60143. /**
  60144. * Checks wether the material is ready to be rendered for a given mesh.
  60145. * @param mesh The mesh to render
  60146. * @param subMesh The submesh to check against
  60147. * @param useInstances Specify wether or not the material is used with instances
  60148. * @returns true if all the dependencies are ready (Textures, Effects...)
  60149. */
  60150. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60151. /**
  60152. * Compute the primary color according to the chosen perceptual color.
  60153. */
  60154. private _computePrimaryColorFromPerceptualColor;
  60155. /**
  60156. * Compute the highlights and shadow colors according to their chosen levels.
  60157. */
  60158. private _computePrimaryColors;
  60159. /**
  60160. * Build the uniform buffer used in the material.
  60161. */
  60162. buildUniformLayout(): void;
  60163. /**
  60164. * Unbind the material.
  60165. */
  60166. unbind(): void;
  60167. /**
  60168. * Bind only the world matrix to the material.
  60169. * @param world The world matrix to bind.
  60170. */
  60171. bindOnlyWorldMatrix(world: Matrix): void;
  60172. /**
  60173. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  60174. * @param world The world matrix to bind.
  60175. * @param subMesh The submesh to bind for.
  60176. */
  60177. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60178. /**
  60179. * Checks to see if a texture is used in the material.
  60180. * @param texture - Base texture to use.
  60181. * @returns - Boolean specifying if a texture is used in the material.
  60182. */
  60183. hasTexture(texture: BaseTexture): boolean;
  60184. /**
  60185. * Dispose the material.
  60186. * @param forceDisposeEffect Force disposal of the associated effect.
  60187. * @param forceDisposeTextures Force disposal of the associated textures.
  60188. */
  60189. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  60190. /**
  60191. * Clones the material.
  60192. * @param name The cloned name.
  60193. * @returns The cloned material.
  60194. */
  60195. clone(name: string): BackgroundMaterial;
  60196. /**
  60197. * Serializes the current material to its JSON representation.
  60198. * @returns The JSON representation.
  60199. */
  60200. serialize(): any;
  60201. /**
  60202. * Gets the class name of the material
  60203. * @returns "BackgroundMaterial"
  60204. */
  60205. getClassName(): string;
  60206. /**
  60207. * Parse a JSON input to create back a background material.
  60208. * @param source The JSON data to parse
  60209. * @param scene The scene to create the parsed material in
  60210. * @param rootUrl The root url of the assets the material depends upon
  60211. * @returns the instantiated BackgroundMaterial.
  60212. */
  60213. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  60214. }
  60215. }
  60216. declare module "babylonjs/Helpers/environmentHelper" {
  60217. import { Observable } from "babylonjs/Misc/observable";
  60218. import { Nullable } from "babylonjs/types";
  60219. import { Scene } from "babylonjs/scene";
  60220. import { Vector3 } from "babylonjs/Maths/math.vector";
  60221. import { Color3 } from "babylonjs/Maths/math.color";
  60222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60223. import { Mesh } from "babylonjs/Meshes/mesh";
  60224. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60225. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  60226. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60227. import "babylonjs/Meshes/Builders/planeBuilder";
  60228. import "babylonjs/Meshes/Builders/boxBuilder";
  60229. /**
  60230. * Represents the different options available during the creation of
  60231. * a Environment helper.
  60232. *
  60233. * This can control the default ground, skybox and image processing setup of your scene.
  60234. */
  60235. export interface IEnvironmentHelperOptions {
  60236. /**
  60237. * Specifies whether or not to create a ground.
  60238. * True by default.
  60239. */
  60240. createGround: boolean;
  60241. /**
  60242. * Specifies the ground size.
  60243. * 15 by default.
  60244. */
  60245. groundSize: number;
  60246. /**
  60247. * The texture used on the ground for the main color.
  60248. * Comes from the BabylonJS CDN by default.
  60249. *
  60250. * Remarks: Can be either a texture or a url.
  60251. */
  60252. groundTexture: string | BaseTexture;
  60253. /**
  60254. * The color mixed in the ground texture by default.
  60255. * BabylonJS clearColor by default.
  60256. */
  60257. groundColor: Color3;
  60258. /**
  60259. * Specifies the ground opacity.
  60260. * 1 by default.
  60261. */
  60262. groundOpacity: number;
  60263. /**
  60264. * Enables the ground to receive shadows.
  60265. * True by default.
  60266. */
  60267. enableGroundShadow: boolean;
  60268. /**
  60269. * Helps preventing the shadow to be fully black on the ground.
  60270. * 0.5 by default.
  60271. */
  60272. groundShadowLevel: number;
  60273. /**
  60274. * Creates a mirror texture attach to the ground.
  60275. * false by default.
  60276. */
  60277. enableGroundMirror: boolean;
  60278. /**
  60279. * Specifies the ground mirror size ratio.
  60280. * 0.3 by default as the default kernel is 64.
  60281. */
  60282. groundMirrorSizeRatio: number;
  60283. /**
  60284. * Specifies the ground mirror blur kernel size.
  60285. * 64 by default.
  60286. */
  60287. groundMirrorBlurKernel: number;
  60288. /**
  60289. * Specifies the ground mirror visibility amount.
  60290. * 1 by default
  60291. */
  60292. groundMirrorAmount: number;
  60293. /**
  60294. * Specifies the ground mirror reflectance weight.
  60295. * This uses the standard weight of the background material to setup the fresnel effect
  60296. * of the mirror.
  60297. * 1 by default.
  60298. */
  60299. groundMirrorFresnelWeight: number;
  60300. /**
  60301. * Specifies the ground mirror Falloff distance.
  60302. * This can helps reducing the size of the reflection.
  60303. * 0 by Default.
  60304. */
  60305. groundMirrorFallOffDistance: number;
  60306. /**
  60307. * Specifies the ground mirror texture type.
  60308. * Unsigned Int by Default.
  60309. */
  60310. groundMirrorTextureType: number;
  60311. /**
  60312. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  60313. * the shown objects.
  60314. */
  60315. groundYBias: number;
  60316. /**
  60317. * Specifies whether or not to create a skybox.
  60318. * True by default.
  60319. */
  60320. createSkybox: boolean;
  60321. /**
  60322. * Specifies the skybox size.
  60323. * 20 by default.
  60324. */
  60325. skyboxSize: number;
  60326. /**
  60327. * The texture used on the skybox for the main color.
  60328. * Comes from the BabylonJS CDN by default.
  60329. *
  60330. * Remarks: Can be either a texture or a url.
  60331. */
  60332. skyboxTexture: string | BaseTexture;
  60333. /**
  60334. * The color mixed in the skybox texture by default.
  60335. * BabylonJS clearColor by default.
  60336. */
  60337. skyboxColor: Color3;
  60338. /**
  60339. * The background rotation around the Y axis of the scene.
  60340. * This helps aligning the key lights of your scene with the background.
  60341. * 0 by default.
  60342. */
  60343. backgroundYRotation: number;
  60344. /**
  60345. * Compute automatically the size of the elements to best fit with the scene.
  60346. */
  60347. sizeAuto: boolean;
  60348. /**
  60349. * Default position of the rootMesh if autoSize is not true.
  60350. */
  60351. rootPosition: Vector3;
  60352. /**
  60353. * Sets up the image processing in the scene.
  60354. * true by default.
  60355. */
  60356. setupImageProcessing: boolean;
  60357. /**
  60358. * The texture used as your environment texture in the scene.
  60359. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  60360. *
  60361. * Remarks: Can be either a texture or a url.
  60362. */
  60363. environmentTexture: string | BaseTexture;
  60364. /**
  60365. * The value of the exposure to apply to the scene.
  60366. * 0.6 by default if setupImageProcessing is true.
  60367. */
  60368. cameraExposure: number;
  60369. /**
  60370. * The value of the contrast to apply to the scene.
  60371. * 1.6 by default if setupImageProcessing is true.
  60372. */
  60373. cameraContrast: number;
  60374. /**
  60375. * Specifies whether or not tonemapping should be enabled in the scene.
  60376. * true by default if setupImageProcessing is true.
  60377. */
  60378. toneMappingEnabled: boolean;
  60379. }
  60380. /**
  60381. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  60382. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  60383. * It also helps with the default setup of your imageProcessing configuration.
  60384. */
  60385. export class EnvironmentHelper {
  60386. /**
  60387. * Default ground texture URL.
  60388. */
  60389. private static _groundTextureCDNUrl;
  60390. /**
  60391. * Default skybox texture URL.
  60392. */
  60393. private static _skyboxTextureCDNUrl;
  60394. /**
  60395. * Default environment texture URL.
  60396. */
  60397. private static _environmentTextureCDNUrl;
  60398. /**
  60399. * Creates the default options for the helper.
  60400. */
  60401. private static _getDefaultOptions;
  60402. private _rootMesh;
  60403. /**
  60404. * Gets the root mesh created by the helper.
  60405. */
  60406. get rootMesh(): Mesh;
  60407. private _skybox;
  60408. /**
  60409. * Gets the skybox created by the helper.
  60410. */
  60411. get skybox(): Nullable<Mesh>;
  60412. private _skyboxTexture;
  60413. /**
  60414. * Gets the skybox texture created by the helper.
  60415. */
  60416. get skyboxTexture(): Nullable<BaseTexture>;
  60417. private _skyboxMaterial;
  60418. /**
  60419. * Gets the skybox material created by the helper.
  60420. */
  60421. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  60422. private _ground;
  60423. /**
  60424. * Gets the ground mesh created by the helper.
  60425. */
  60426. get ground(): Nullable<Mesh>;
  60427. private _groundTexture;
  60428. /**
  60429. * Gets the ground texture created by the helper.
  60430. */
  60431. get groundTexture(): Nullable<BaseTexture>;
  60432. private _groundMirror;
  60433. /**
  60434. * Gets the ground mirror created by the helper.
  60435. */
  60436. get groundMirror(): Nullable<MirrorTexture>;
  60437. /**
  60438. * Gets the ground mirror render list to helps pushing the meshes
  60439. * you wish in the ground reflection.
  60440. */
  60441. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  60442. private _groundMaterial;
  60443. /**
  60444. * Gets the ground material created by the helper.
  60445. */
  60446. get groundMaterial(): Nullable<BackgroundMaterial>;
  60447. /**
  60448. * Stores the creation options.
  60449. */
  60450. private readonly _scene;
  60451. private _options;
  60452. /**
  60453. * This observable will be notified with any error during the creation of the environment,
  60454. * mainly texture creation errors.
  60455. */
  60456. onErrorObservable: Observable<{
  60457. message?: string;
  60458. exception?: any;
  60459. }>;
  60460. /**
  60461. * constructor
  60462. * @param options Defines the options we want to customize the helper
  60463. * @param scene The scene to add the material to
  60464. */
  60465. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  60466. /**
  60467. * Updates the background according to the new options
  60468. * @param options
  60469. */
  60470. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  60471. /**
  60472. * Sets the primary color of all the available elements.
  60473. * @param color the main color to affect to the ground and the background
  60474. */
  60475. setMainColor(color: Color3): void;
  60476. /**
  60477. * Setup the image processing according to the specified options.
  60478. */
  60479. private _setupImageProcessing;
  60480. /**
  60481. * Setup the environment texture according to the specified options.
  60482. */
  60483. private _setupEnvironmentTexture;
  60484. /**
  60485. * Setup the background according to the specified options.
  60486. */
  60487. private _setupBackground;
  60488. /**
  60489. * Get the scene sizes according to the setup.
  60490. */
  60491. private _getSceneSize;
  60492. /**
  60493. * Setup the ground according to the specified options.
  60494. */
  60495. private _setupGround;
  60496. /**
  60497. * Setup the ground material according to the specified options.
  60498. */
  60499. private _setupGroundMaterial;
  60500. /**
  60501. * Setup the ground diffuse texture according to the specified options.
  60502. */
  60503. private _setupGroundDiffuseTexture;
  60504. /**
  60505. * Setup the ground mirror texture according to the specified options.
  60506. */
  60507. private _setupGroundMirrorTexture;
  60508. /**
  60509. * Setup the ground to receive the mirror texture.
  60510. */
  60511. private _setupMirrorInGroundMaterial;
  60512. /**
  60513. * Setup the skybox according to the specified options.
  60514. */
  60515. private _setupSkybox;
  60516. /**
  60517. * Setup the skybox material according to the specified options.
  60518. */
  60519. private _setupSkyboxMaterial;
  60520. /**
  60521. * Setup the skybox reflection texture according to the specified options.
  60522. */
  60523. private _setupSkyboxReflectionTexture;
  60524. private _errorHandler;
  60525. /**
  60526. * Dispose all the elements created by the Helper.
  60527. */
  60528. dispose(): void;
  60529. }
  60530. }
  60531. declare module "babylonjs/Helpers/textureDome" {
  60532. import { Scene } from "babylonjs/scene";
  60533. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60534. import { Mesh } from "babylonjs/Meshes/mesh";
  60535. import { Texture } from "babylonjs/Materials/Textures/texture";
  60536. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60537. import "babylonjs/Meshes/Builders/sphereBuilder";
  60538. import { Nullable } from "babylonjs/types";
  60539. import { Observable } from "babylonjs/Misc/observable";
  60540. /**
  60541. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  60542. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  60543. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60544. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60545. */
  60546. export abstract class TextureDome<T extends Texture> extends TransformNode {
  60547. protected onError: Nullable<(message?: string, exception?: any) => void>;
  60548. /**
  60549. * Define the source as a Monoscopic panoramic 360/180.
  60550. */
  60551. static readonly MODE_MONOSCOPIC: number;
  60552. /**
  60553. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  60554. */
  60555. static readonly MODE_TOPBOTTOM: number;
  60556. /**
  60557. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  60558. */
  60559. static readonly MODE_SIDEBYSIDE: number;
  60560. private _halfDome;
  60561. protected _useDirectMapping: boolean;
  60562. /**
  60563. * The texture being displayed on the sphere
  60564. */
  60565. protected _texture: T;
  60566. /**
  60567. * Gets the texture being displayed on the sphere
  60568. */
  60569. get texture(): T;
  60570. /**
  60571. * Sets the texture being displayed on the sphere
  60572. */
  60573. set texture(newTexture: T);
  60574. /**
  60575. * The skybox material
  60576. */
  60577. protected _material: BackgroundMaterial;
  60578. /**
  60579. * The surface used for the dome
  60580. */
  60581. protected _mesh: Mesh;
  60582. /**
  60583. * Gets the mesh used for the dome.
  60584. */
  60585. get mesh(): Mesh;
  60586. /**
  60587. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  60588. */
  60589. private _halfDomeMask;
  60590. /**
  60591. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60592. * Also see the options.resolution property.
  60593. */
  60594. get fovMultiplier(): number;
  60595. set fovMultiplier(value: number);
  60596. protected _textureMode: number;
  60597. /**
  60598. * Gets or set the current texture mode for the texture. It can be:
  60599. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60600. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60601. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60602. */
  60603. get textureMode(): number;
  60604. /**
  60605. * Sets the current texture mode for the texture. It can be:
  60606. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60607. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60608. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60609. */
  60610. set textureMode(value: number);
  60611. /**
  60612. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  60613. */
  60614. get halfDome(): boolean;
  60615. /**
  60616. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  60617. */
  60618. set halfDome(enabled: boolean);
  60619. /**
  60620. * Oberserver used in Stereoscopic VR Mode.
  60621. */
  60622. private _onBeforeCameraRenderObserver;
  60623. /**
  60624. * Observable raised when an error occured while loading the 360 image
  60625. */
  60626. onLoadErrorObservable: Observable<string>;
  60627. /**
  60628. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  60629. * @param name Element's name, child elements will append suffixes for their own names.
  60630. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  60631. * @param options An object containing optional or exposed sub element properties
  60632. */
  60633. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  60634. resolution?: number;
  60635. clickToPlay?: boolean;
  60636. autoPlay?: boolean;
  60637. loop?: boolean;
  60638. size?: number;
  60639. poster?: string;
  60640. faceForward?: boolean;
  60641. useDirectMapping?: boolean;
  60642. halfDomeMode?: boolean;
  60643. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  60644. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  60645. protected _changeTextureMode(value: number): void;
  60646. /**
  60647. * Releases resources associated with this node.
  60648. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  60649. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  60650. */
  60651. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  60652. }
  60653. }
  60654. declare module "babylonjs/Helpers/photoDome" {
  60655. import { Scene } from "babylonjs/scene";
  60656. import { Texture } from "babylonjs/Materials/Textures/texture";
  60657. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60658. /**
  60659. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  60660. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  60661. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60662. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60663. */
  60664. export class PhotoDome extends TextureDome<Texture> {
  60665. /**
  60666. * Define the image as a Monoscopic panoramic 360 image.
  60667. */
  60668. static readonly MODE_MONOSCOPIC: number;
  60669. /**
  60670. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  60671. */
  60672. static readonly MODE_TOPBOTTOM: number;
  60673. /**
  60674. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  60675. */
  60676. static readonly MODE_SIDEBYSIDE: number;
  60677. /**
  60678. * Gets or sets the texture being displayed on the sphere
  60679. */
  60680. get photoTexture(): Texture;
  60681. /**
  60682. * sets the texture being displayed on the sphere
  60683. */
  60684. set photoTexture(value: Texture);
  60685. /**
  60686. * Gets the current video mode for the video. It can be:
  60687. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60688. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60689. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60690. */
  60691. get imageMode(): number;
  60692. /**
  60693. * Sets the current video mode for the video. It can be:
  60694. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60695. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60696. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60697. */
  60698. set imageMode(value: number);
  60699. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  60700. }
  60701. }
  60702. declare module "babylonjs/Misc/dds" {
  60703. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60704. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60705. import { Nullable } from "babylonjs/types";
  60706. import { Scene } from "babylonjs/scene";
  60707. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60708. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60709. /**
  60710. * Direct draw surface info
  60711. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60712. */
  60713. export interface DDSInfo {
  60714. /**
  60715. * Width of the texture
  60716. */
  60717. width: number;
  60718. /**
  60719. * Width of the texture
  60720. */
  60721. height: number;
  60722. /**
  60723. * Number of Mipmaps for the texture
  60724. * @see https://en.wikipedia.org/wiki/Mipmap
  60725. */
  60726. mipmapCount: number;
  60727. /**
  60728. * If the textures format is a known fourCC format
  60729. * @see https://www.fourcc.org/
  60730. */
  60731. isFourCC: boolean;
  60732. /**
  60733. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60734. */
  60735. isRGB: boolean;
  60736. /**
  60737. * If the texture is a lumincance format
  60738. */
  60739. isLuminance: boolean;
  60740. /**
  60741. * If this is a cube texture
  60742. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60743. */
  60744. isCube: boolean;
  60745. /**
  60746. * If the texture is a compressed format eg. FOURCC_DXT1
  60747. */
  60748. isCompressed: boolean;
  60749. /**
  60750. * The dxgiFormat of the texture
  60751. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60752. */
  60753. dxgiFormat: number;
  60754. /**
  60755. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60756. */
  60757. textureType: number;
  60758. /**
  60759. * Sphericle polynomial created for the dds texture
  60760. */
  60761. sphericalPolynomial?: SphericalPolynomial;
  60762. }
  60763. /**
  60764. * Class used to provide DDS decompression tools
  60765. */
  60766. export class DDSTools {
  60767. /**
  60768. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60769. */
  60770. static StoreLODInAlphaChannel: boolean;
  60771. /**
  60772. * Gets DDS information from an array buffer
  60773. * @param data defines the array buffer view to read data from
  60774. * @returns the DDS information
  60775. */
  60776. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60777. private static _FloatView;
  60778. private static _Int32View;
  60779. private static _ToHalfFloat;
  60780. private static _FromHalfFloat;
  60781. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60782. private static _GetHalfFloatRGBAArrayBuffer;
  60783. private static _GetFloatRGBAArrayBuffer;
  60784. private static _GetFloatAsUIntRGBAArrayBuffer;
  60785. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60786. private static _GetRGBAArrayBuffer;
  60787. private static _ExtractLongWordOrder;
  60788. private static _GetRGBArrayBuffer;
  60789. private static _GetLuminanceArrayBuffer;
  60790. /**
  60791. * Uploads DDS Levels to a Babylon Texture
  60792. * @hidden
  60793. */
  60794. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60795. }
  60796. module "babylonjs/Engines/thinEngine" {
  60797. interface ThinEngine {
  60798. /**
  60799. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60800. * @param rootUrl defines the url where the file to load is located
  60801. * @param scene defines the current scene
  60802. * @param lodScale defines scale to apply to the mip map selection
  60803. * @param lodOffset defines offset to apply to the mip map selection
  60804. * @param onLoad defines an optional callback raised when the texture is loaded
  60805. * @param onError defines an optional callback raised if there is an issue to load the texture
  60806. * @param format defines the format of the data
  60807. * @param forcedExtension defines the extension to use to pick the right loader
  60808. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60809. * @returns the cube texture as an InternalTexture
  60810. */
  60811. 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;
  60812. }
  60813. }
  60814. }
  60815. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60816. import { Nullable } from "babylonjs/types";
  60817. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60818. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60819. /**
  60820. * Implementation of the DDS Texture Loader.
  60821. * @hidden
  60822. */
  60823. export class _DDSTextureLoader implements IInternalTextureLoader {
  60824. /**
  60825. * Defines wether the loader supports cascade loading the different faces.
  60826. */
  60827. readonly supportCascades: boolean;
  60828. /**
  60829. * This returns if the loader support the current file information.
  60830. * @param extension defines the file extension of the file being loaded
  60831. * @returns true if the loader can load the specified file
  60832. */
  60833. canLoad(extension: string): boolean;
  60834. /**
  60835. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60836. * @param data contains the texture data
  60837. * @param texture defines the BabylonJS internal texture
  60838. * @param createPolynomials will be true if polynomials have been requested
  60839. * @param onLoad defines the callback to trigger once the texture is ready
  60840. * @param onError defines the callback to trigger in case of error
  60841. */
  60842. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60843. /**
  60844. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60845. * @param data contains the texture data
  60846. * @param texture defines the BabylonJS internal texture
  60847. * @param callback defines the method to call once ready to upload
  60848. */
  60849. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60850. }
  60851. }
  60852. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60853. import { Nullable } from "babylonjs/types";
  60854. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60855. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60856. /**
  60857. * Implementation of the ENV Texture Loader.
  60858. * @hidden
  60859. */
  60860. export class _ENVTextureLoader implements IInternalTextureLoader {
  60861. /**
  60862. * Defines wether the loader supports cascade loading the different faces.
  60863. */
  60864. readonly supportCascades: boolean;
  60865. /**
  60866. * This returns if the loader support the current file information.
  60867. * @param extension defines the file extension of the file being loaded
  60868. * @returns true if the loader can load the specified file
  60869. */
  60870. canLoad(extension: string): boolean;
  60871. /**
  60872. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60873. * @param data contains the texture data
  60874. * @param texture defines the BabylonJS internal texture
  60875. * @param createPolynomials will be true if polynomials have been requested
  60876. * @param onLoad defines the callback to trigger once the texture is ready
  60877. * @param onError defines the callback to trigger in case of error
  60878. */
  60879. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60880. /**
  60881. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60882. * @param data contains the texture data
  60883. * @param texture defines the BabylonJS internal texture
  60884. * @param callback defines the method to call once ready to upload
  60885. */
  60886. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60887. }
  60888. }
  60889. declare module "babylonjs/Misc/khronosTextureContainer" {
  60890. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60891. /**
  60892. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60893. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60894. */
  60895. export class KhronosTextureContainer {
  60896. /** contents of the KTX container file */
  60897. data: ArrayBufferView;
  60898. private static HEADER_LEN;
  60899. private static COMPRESSED_2D;
  60900. private static COMPRESSED_3D;
  60901. private static TEX_2D;
  60902. private static TEX_3D;
  60903. /**
  60904. * Gets the openGL type
  60905. */
  60906. glType: number;
  60907. /**
  60908. * Gets the openGL type size
  60909. */
  60910. glTypeSize: number;
  60911. /**
  60912. * Gets the openGL format
  60913. */
  60914. glFormat: number;
  60915. /**
  60916. * Gets the openGL internal format
  60917. */
  60918. glInternalFormat: number;
  60919. /**
  60920. * Gets the base internal format
  60921. */
  60922. glBaseInternalFormat: number;
  60923. /**
  60924. * Gets image width in pixel
  60925. */
  60926. pixelWidth: number;
  60927. /**
  60928. * Gets image height in pixel
  60929. */
  60930. pixelHeight: number;
  60931. /**
  60932. * Gets image depth in pixels
  60933. */
  60934. pixelDepth: number;
  60935. /**
  60936. * Gets the number of array elements
  60937. */
  60938. numberOfArrayElements: number;
  60939. /**
  60940. * Gets the number of faces
  60941. */
  60942. numberOfFaces: number;
  60943. /**
  60944. * Gets the number of mipmap levels
  60945. */
  60946. numberOfMipmapLevels: number;
  60947. /**
  60948. * Gets the bytes of key value data
  60949. */
  60950. bytesOfKeyValueData: number;
  60951. /**
  60952. * Gets the load type
  60953. */
  60954. loadType: number;
  60955. /**
  60956. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60957. */
  60958. isInvalid: boolean;
  60959. /**
  60960. * Creates a new KhronosTextureContainer
  60961. * @param data contents of the KTX container file
  60962. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60963. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60964. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60965. */
  60966. constructor(
  60967. /** contents of the KTX container file */
  60968. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60969. /**
  60970. * Uploads KTX content to a Babylon Texture.
  60971. * It is assumed that the texture has already been created & is currently bound
  60972. * @hidden
  60973. */
  60974. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60975. private _upload2DCompressedLevels;
  60976. /**
  60977. * Checks if the given data starts with a KTX file identifier.
  60978. * @param data the data to check
  60979. * @returns true if the data is a KTX file or false otherwise
  60980. */
  60981. static IsValid(data: ArrayBufferView): boolean;
  60982. }
  60983. }
  60984. declare module "babylonjs/Misc/workerPool" {
  60985. import { IDisposable } from "babylonjs/scene";
  60986. /**
  60987. * Helper class to push actions to a pool of workers.
  60988. */
  60989. export class WorkerPool implements IDisposable {
  60990. private _workerInfos;
  60991. private _pendingActions;
  60992. /**
  60993. * Constructor
  60994. * @param workers Array of workers to use for actions
  60995. */
  60996. constructor(workers: Array<Worker>);
  60997. /**
  60998. * Terminates all workers and clears any pending actions.
  60999. */
  61000. dispose(): void;
  61001. /**
  61002. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61003. * pended until a worker has completed its action.
  61004. * @param action The action to perform. Call onComplete when the action is complete.
  61005. */
  61006. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61007. private _execute;
  61008. }
  61009. }
  61010. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61011. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61012. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61013. /**
  61014. * Class for loading KTX2 files
  61015. */
  61016. export class KhronosTextureContainer2 {
  61017. private static _WorkerPoolPromise?;
  61018. private static _Initialized;
  61019. private static _Ktx2Decoder;
  61020. /**
  61021. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61022. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61023. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61024. * Urls you can change:
  61025. * URLConfig.jsDecoderModule
  61026. * URLConfig.wasmUASTCToASTC
  61027. * URLConfig.wasmUASTCToBC7
  61028. * URLConfig.jsMSCTranscoder
  61029. * URLConfig.wasmMSCTranscoder
  61030. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  61031. */
  61032. static URLConfig: {
  61033. jsDecoderModule: string;
  61034. wasmUASTCToASTC: null;
  61035. wasmUASTCToBC7: null;
  61036. jsMSCTranscoder: null;
  61037. wasmMSCTranscoder: null;
  61038. };
  61039. /**
  61040. * Default number of workers used to handle data decoding
  61041. */
  61042. static DefaultNumWorkers: number;
  61043. private static GetDefaultNumWorkers;
  61044. private _engine;
  61045. private static _CreateWorkerPool;
  61046. /**
  61047. * Constructor
  61048. * @param engine The engine to use
  61049. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61050. */
  61051. constructor(engine: ThinEngine, numWorkers?: number);
  61052. /** @hidden */
  61053. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  61054. /**
  61055. * Stop all async operations and release resources.
  61056. */
  61057. dispose(): void;
  61058. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  61059. /**
  61060. * Checks if the given data starts with a KTX2 file identifier.
  61061. * @param data the data to check
  61062. * @returns true if the data is a KTX2 file or false otherwise
  61063. */
  61064. static IsValid(data: ArrayBufferView): boolean;
  61065. }
  61066. }
  61067. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  61068. import { Nullable } from "babylonjs/types";
  61069. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61070. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61071. /**
  61072. * Implementation of the KTX Texture Loader.
  61073. * @hidden
  61074. */
  61075. export class _KTXTextureLoader implements IInternalTextureLoader {
  61076. /**
  61077. * Defines wether the loader supports cascade loading the different faces.
  61078. */
  61079. readonly supportCascades: boolean;
  61080. /**
  61081. * This returns if the loader support the current file information.
  61082. * @param extension defines the file extension of the file being loaded
  61083. * @param mimeType defines the optional mime type of the file being loaded
  61084. * @returns true if the loader can load the specified file
  61085. */
  61086. canLoad(extension: string, mimeType?: string): boolean;
  61087. /**
  61088. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61089. * @param data contains the texture data
  61090. * @param texture defines the BabylonJS internal texture
  61091. * @param createPolynomials will be true if polynomials have been requested
  61092. * @param onLoad defines the callback to trigger once the texture is ready
  61093. * @param onError defines the callback to trigger in case of error
  61094. */
  61095. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61096. /**
  61097. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61098. * @param data contains the texture data
  61099. * @param texture defines the BabylonJS internal texture
  61100. * @param callback defines the method to call once ready to upload
  61101. */
  61102. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  61103. }
  61104. }
  61105. declare module "babylonjs/Helpers/sceneHelpers" {
  61106. import { Nullable } from "babylonjs/types";
  61107. import { Mesh } from "babylonjs/Meshes/mesh";
  61108. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61109. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  61110. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  61111. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  61112. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  61113. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  61114. import "babylonjs/Meshes/Builders/boxBuilder";
  61115. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  61116. /** @hidden */
  61117. export var _forceSceneHelpersToBundle: boolean;
  61118. module "babylonjs/scene" {
  61119. interface Scene {
  61120. /**
  61121. * Creates a default light for the scene.
  61122. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  61123. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  61124. */
  61125. createDefaultLight(replace?: boolean): void;
  61126. /**
  61127. * Creates a default camera for the scene.
  61128. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  61129. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61130. * @param replace has default false, when true replaces the active camera in the scene
  61131. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  61132. */
  61133. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61134. /**
  61135. * Creates a default camera and a default light.
  61136. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  61137. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61138. * @param replace has the default false, when true replaces the active camera/light in the scene
  61139. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  61140. */
  61141. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61142. /**
  61143. * Creates a new sky box
  61144. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  61145. * @param environmentTexture defines the texture to use as environment texture
  61146. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  61147. * @param scale defines the overall scale of the skybox
  61148. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  61149. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  61150. * @returns a new mesh holding the sky box
  61151. */
  61152. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  61153. /**
  61154. * Creates a new environment
  61155. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  61156. * @param options defines the options you can use to configure the environment
  61157. * @returns the new EnvironmentHelper
  61158. */
  61159. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  61160. /**
  61161. * Creates a new VREXperienceHelper
  61162. * @see https://doc.babylonjs.com/how_to/webvr_helper
  61163. * @param webVROptions defines the options used to create the new VREXperienceHelper
  61164. * @returns a new VREXperienceHelper
  61165. */
  61166. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  61167. /**
  61168. * Creates a new WebXRDefaultExperience
  61169. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  61170. * @param options experience options
  61171. * @returns a promise for a new WebXRDefaultExperience
  61172. */
  61173. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  61174. }
  61175. }
  61176. }
  61177. declare module "babylonjs/Helpers/videoDome" {
  61178. import { Scene } from "babylonjs/scene";
  61179. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  61180. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61181. /**
  61182. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  61183. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  61184. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  61185. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61186. */
  61187. export class VideoDome extends TextureDome<VideoTexture> {
  61188. /**
  61189. * Define the video source as a Monoscopic panoramic 360 video.
  61190. */
  61191. static readonly MODE_MONOSCOPIC: number;
  61192. /**
  61193. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  61194. */
  61195. static readonly MODE_TOPBOTTOM: number;
  61196. /**
  61197. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  61198. */
  61199. static readonly MODE_SIDEBYSIDE: number;
  61200. /**
  61201. * Get the video texture associated with this video dome
  61202. */
  61203. get videoTexture(): VideoTexture;
  61204. /**
  61205. * Get the video mode of this dome
  61206. */
  61207. get videoMode(): number;
  61208. /**
  61209. * Set the video mode of this dome.
  61210. * @see textureMode
  61211. */
  61212. set videoMode(value: number);
  61213. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  61214. }
  61215. }
  61216. declare module "babylonjs/Helpers/index" {
  61217. export * from "babylonjs/Helpers/environmentHelper";
  61218. export * from "babylonjs/Helpers/photoDome";
  61219. export * from "babylonjs/Helpers/sceneHelpers";
  61220. export * from "babylonjs/Helpers/videoDome";
  61221. }
  61222. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  61223. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61224. import { IDisposable } from "babylonjs/scene";
  61225. import { Engine } from "babylonjs/Engines/engine";
  61226. /**
  61227. * This class can be used to get instrumentation data from a Babylon engine
  61228. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61229. */
  61230. export class EngineInstrumentation implements IDisposable {
  61231. /**
  61232. * Define the instrumented engine.
  61233. */
  61234. engine: Engine;
  61235. private _captureGPUFrameTime;
  61236. private _gpuFrameTimeToken;
  61237. private _gpuFrameTime;
  61238. private _captureShaderCompilationTime;
  61239. private _shaderCompilationTime;
  61240. private _onBeginFrameObserver;
  61241. private _onEndFrameObserver;
  61242. private _onBeforeShaderCompilationObserver;
  61243. private _onAfterShaderCompilationObserver;
  61244. /**
  61245. * Gets the perf counter used for GPU frame time
  61246. */
  61247. get gpuFrameTimeCounter(): PerfCounter;
  61248. /**
  61249. * Gets the GPU frame time capture status
  61250. */
  61251. get captureGPUFrameTime(): boolean;
  61252. /**
  61253. * Enable or disable the GPU frame time capture
  61254. */
  61255. set captureGPUFrameTime(value: boolean);
  61256. /**
  61257. * Gets the perf counter used for shader compilation time
  61258. */
  61259. get shaderCompilationTimeCounter(): PerfCounter;
  61260. /**
  61261. * Gets the shader compilation time capture status
  61262. */
  61263. get captureShaderCompilationTime(): boolean;
  61264. /**
  61265. * Enable or disable the shader compilation time capture
  61266. */
  61267. set captureShaderCompilationTime(value: boolean);
  61268. /**
  61269. * Instantiates a new engine instrumentation.
  61270. * This class can be used to get instrumentation data from a Babylon engine
  61271. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61272. * @param engine Defines the engine to instrument
  61273. */
  61274. constructor(
  61275. /**
  61276. * Define the instrumented engine.
  61277. */
  61278. engine: Engine);
  61279. /**
  61280. * Dispose and release associated resources.
  61281. */
  61282. dispose(): void;
  61283. }
  61284. }
  61285. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  61286. import { Scene, IDisposable } from "babylonjs/scene";
  61287. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61288. /**
  61289. * This class can be used to get instrumentation data from a Babylon engine
  61290. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61291. */
  61292. export class SceneInstrumentation implements IDisposable {
  61293. /**
  61294. * Defines the scene to instrument
  61295. */
  61296. scene: Scene;
  61297. private _captureActiveMeshesEvaluationTime;
  61298. private _activeMeshesEvaluationTime;
  61299. private _captureRenderTargetsRenderTime;
  61300. private _renderTargetsRenderTime;
  61301. private _captureFrameTime;
  61302. private _frameTime;
  61303. private _captureRenderTime;
  61304. private _renderTime;
  61305. private _captureInterFrameTime;
  61306. private _interFrameTime;
  61307. private _captureParticlesRenderTime;
  61308. private _particlesRenderTime;
  61309. private _captureSpritesRenderTime;
  61310. private _spritesRenderTime;
  61311. private _capturePhysicsTime;
  61312. private _physicsTime;
  61313. private _captureAnimationsTime;
  61314. private _animationsTime;
  61315. private _captureCameraRenderTime;
  61316. private _cameraRenderTime;
  61317. private _onBeforeActiveMeshesEvaluationObserver;
  61318. private _onAfterActiveMeshesEvaluationObserver;
  61319. private _onBeforeRenderTargetsRenderObserver;
  61320. private _onAfterRenderTargetsRenderObserver;
  61321. private _onAfterRenderObserver;
  61322. private _onBeforeDrawPhaseObserver;
  61323. private _onAfterDrawPhaseObserver;
  61324. private _onBeforeAnimationsObserver;
  61325. private _onBeforeParticlesRenderingObserver;
  61326. private _onAfterParticlesRenderingObserver;
  61327. private _onBeforeSpritesRenderingObserver;
  61328. private _onAfterSpritesRenderingObserver;
  61329. private _onBeforePhysicsObserver;
  61330. private _onAfterPhysicsObserver;
  61331. private _onAfterAnimationsObserver;
  61332. private _onBeforeCameraRenderObserver;
  61333. private _onAfterCameraRenderObserver;
  61334. /**
  61335. * Gets the perf counter used for active meshes evaluation time
  61336. */
  61337. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  61338. /**
  61339. * Gets the active meshes evaluation time capture status
  61340. */
  61341. get captureActiveMeshesEvaluationTime(): boolean;
  61342. /**
  61343. * Enable or disable the active meshes evaluation time capture
  61344. */
  61345. set captureActiveMeshesEvaluationTime(value: boolean);
  61346. /**
  61347. * Gets the perf counter used for render targets render time
  61348. */
  61349. get renderTargetsRenderTimeCounter(): PerfCounter;
  61350. /**
  61351. * Gets the render targets render time capture status
  61352. */
  61353. get captureRenderTargetsRenderTime(): boolean;
  61354. /**
  61355. * Enable or disable the render targets render time capture
  61356. */
  61357. set captureRenderTargetsRenderTime(value: boolean);
  61358. /**
  61359. * Gets the perf counter used for particles render time
  61360. */
  61361. get particlesRenderTimeCounter(): PerfCounter;
  61362. /**
  61363. * Gets the particles render time capture status
  61364. */
  61365. get captureParticlesRenderTime(): boolean;
  61366. /**
  61367. * Enable or disable the particles render time capture
  61368. */
  61369. set captureParticlesRenderTime(value: boolean);
  61370. /**
  61371. * Gets the perf counter used for sprites render time
  61372. */
  61373. get spritesRenderTimeCounter(): PerfCounter;
  61374. /**
  61375. * Gets the sprites render time capture status
  61376. */
  61377. get captureSpritesRenderTime(): boolean;
  61378. /**
  61379. * Enable or disable the sprites render time capture
  61380. */
  61381. set captureSpritesRenderTime(value: boolean);
  61382. /**
  61383. * Gets the perf counter used for physics time
  61384. */
  61385. get physicsTimeCounter(): PerfCounter;
  61386. /**
  61387. * Gets the physics time capture status
  61388. */
  61389. get capturePhysicsTime(): boolean;
  61390. /**
  61391. * Enable or disable the physics time capture
  61392. */
  61393. set capturePhysicsTime(value: boolean);
  61394. /**
  61395. * Gets the perf counter used for animations time
  61396. */
  61397. get animationsTimeCounter(): PerfCounter;
  61398. /**
  61399. * Gets the animations time capture status
  61400. */
  61401. get captureAnimationsTime(): boolean;
  61402. /**
  61403. * Enable or disable the animations time capture
  61404. */
  61405. set captureAnimationsTime(value: boolean);
  61406. /**
  61407. * Gets the perf counter used for frame time capture
  61408. */
  61409. get frameTimeCounter(): PerfCounter;
  61410. /**
  61411. * Gets the frame time capture status
  61412. */
  61413. get captureFrameTime(): boolean;
  61414. /**
  61415. * Enable or disable the frame time capture
  61416. */
  61417. set captureFrameTime(value: boolean);
  61418. /**
  61419. * Gets the perf counter used for inter-frames time capture
  61420. */
  61421. get interFrameTimeCounter(): PerfCounter;
  61422. /**
  61423. * Gets the inter-frames time capture status
  61424. */
  61425. get captureInterFrameTime(): boolean;
  61426. /**
  61427. * Enable or disable the inter-frames time capture
  61428. */
  61429. set captureInterFrameTime(value: boolean);
  61430. /**
  61431. * Gets the perf counter used for render time capture
  61432. */
  61433. get renderTimeCounter(): PerfCounter;
  61434. /**
  61435. * Gets the render time capture status
  61436. */
  61437. get captureRenderTime(): boolean;
  61438. /**
  61439. * Enable or disable the render time capture
  61440. */
  61441. set captureRenderTime(value: boolean);
  61442. /**
  61443. * Gets the perf counter used for camera render time capture
  61444. */
  61445. get cameraRenderTimeCounter(): PerfCounter;
  61446. /**
  61447. * Gets the camera render time capture status
  61448. */
  61449. get captureCameraRenderTime(): boolean;
  61450. /**
  61451. * Enable or disable the camera render time capture
  61452. */
  61453. set captureCameraRenderTime(value: boolean);
  61454. /**
  61455. * Gets the perf counter used for draw calls
  61456. */
  61457. get drawCallsCounter(): PerfCounter;
  61458. /**
  61459. * Instantiates a new scene instrumentation.
  61460. * This class can be used to get instrumentation data from a Babylon engine
  61461. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61462. * @param scene Defines the scene to instrument
  61463. */
  61464. constructor(
  61465. /**
  61466. * Defines the scene to instrument
  61467. */
  61468. scene: Scene);
  61469. /**
  61470. * Dispose and release associated resources.
  61471. */
  61472. dispose(): void;
  61473. }
  61474. }
  61475. declare module "babylonjs/Instrumentation/index" {
  61476. export * from "babylonjs/Instrumentation/engineInstrumentation";
  61477. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  61478. export * from "babylonjs/Instrumentation/timeToken";
  61479. }
  61480. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  61481. /** @hidden */
  61482. export var glowMapGenerationPixelShader: {
  61483. name: string;
  61484. shader: string;
  61485. };
  61486. }
  61487. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61488. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61489. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61490. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61491. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61492. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61493. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61494. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61495. /** @hidden */
  61496. export var glowMapGenerationVertexShader: {
  61497. name: string;
  61498. shader: string;
  61499. };
  61500. }
  61501. declare module "babylonjs/Layers/effectLayer" {
  61502. import { Observable } from "babylonjs/Misc/observable";
  61503. import { Nullable } from "babylonjs/types";
  61504. import { Camera } from "babylonjs/Cameras/camera";
  61505. import { Scene } from "babylonjs/scene";
  61506. import { ISize } from "babylonjs/Maths/math.size";
  61507. import { Color4 } from "babylonjs/Maths/math.color";
  61508. import { Engine } from "babylonjs/Engines/engine";
  61509. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61511. import { Mesh } from "babylonjs/Meshes/mesh";
  61512. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61513. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61514. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61515. import { Effect } from "babylonjs/Materials/effect";
  61516. import { Material } from "babylonjs/Materials/material";
  61517. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61518. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61519. /**
  61520. * Effect layer options. This helps customizing the behaviour
  61521. * of the effect layer.
  61522. */
  61523. export interface IEffectLayerOptions {
  61524. /**
  61525. * Multiplication factor apply to the canvas size to compute the render target size
  61526. * used to generated the objects (the smaller the faster).
  61527. */
  61528. mainTextureRatio: number;
  61529. /**
  61530. * Enforces a fixed size texture to ensure effect stability across devices.
  61531. */
  61532. mainTextureFixedSize?: number;
  61533. /**
  61534. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61535. */
  61536. alphaBlendingMode: number;
  61537. /**
  61538. * The camera attached to the layer.
  61539. */
  61540. camera: Nullable<Camera>;
  61541. /**
  61542. * The rendering group to draw the layer in.
  61543. */
  61544. renderingGroupId: number;
  61545. }
  61546. /**
  61547. * The effect layer Helps adding post process effect blended with the main pass.
  61548. *
  61549. * This can be for instance use to generate glow or higlight effects on the scene.
  61550. *
  61551. * The effect layer class can not be used directly and is intented to inherited from to be
  61552. * customized per effects.
  61553. */
  61554. export abstract class EffectLayer {
  61555. private _vertexBuffers;
  61556. private _indexBuffer;
  61557. private _cachedDefines;
  61558. private _effectLayerMapGenerationEffect;
  61559. private _effectLayerOptions;
  61560. private _mergeEffect;
  61561. protected _scene: Scene;
  61562. protected _engine: Engine;
  61563. protected _maxSize: number;
  61564. protected _mainTextureDesiredSize: ISize;
  61565. protected _mainTexture: RenderTargetTexture;
  61566. protected _shouldRender: boolean;
  61567. protected _postProcesses: PostProcess[];
  61568. protected _textures: BaseTexture[];
  61569. protected _emissiveTextureAndColor: {
  61570. texture: Nullable<BaseTexture>;
  61571. color: Color4;
  61572. };
  61573. /**
  61574. * The name of the layer
  61575. */
  61576. name: string;
  61577. /**
  61578. * The clear color of the texture used to generate the glow map.
  61579. */
  61580. neutralColor: Color4;
  61581. /**
  61582. * Specifies whether the highlight layer is enabled or not.
  61583. */
  61584. isEnabled: boolean;
  61585. /**
  61586. * Gets the camera attached to the layer.
  61587. */
  61588. get camera(): Nullable<Camera>;
  61589. /**
  61590. * Gets the rendering group id the layer should render in.
  61591. */
  61592. get renderingGroupId(): number;
  61593. set renderingGroupId(renderingGroupId: number);
  61594. /**
  61595. * An event triggered when the effect layer has been disposed.
  61596. */
  61597. onDisposeObservable: Observable<EffectLayer>;
  61598. /**
  61599. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61600. */
  61601. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61602. /**
  61603. * An event triggered when the generated texture is being merged in the scene.
  61604. */
  61605. onBeforeComposeObservable: Observable<EffectLayer>;
  61606. /**
  61607. * An event triggered when the mesh is rendered into the effect render target.
  61608. */
  61609. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61610. /**
  61611. * An event triggered after the mesh has been rendered into the effect render target.
  61612. */
  61613. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61614. /**
  61615. * An event triggered when the generated texture has been merged in the scene.
  61616. */
  61617. onAfterComposeObservable: Observable<EffectLayer>;
  61618. /**
  61619. * An event triggered when the efffect layer changes its size.
  61620. */
  61621. onSizeChangedObservable: Observable<EffectLayer>;
  61622. /** @hidden */
  61623. static _SceneComponentInitialization: (scene: Scene) => void;
  61624. /**
  61625. * Instantiates a new effect Layer and references it in the scene.
  61626. * @param name The name of the layer
  61627. * @param scene The scene to use the layer in
  61628. */
  61629. constructor(
  61630. /** The Friendly of the effect in the scene */
  61631. name: string, scene: Scene);
  61632. /**
  61633. * Get the effect name of the layer.
  61634. * @return The effect name
  61635. */
  61636. abstract getEffectName(): string;
  61637. /**
  61638. * Checks for the readiness of the element composing the layer.
  61639. * @param subMesh the mesh to check for
  61640. * @param useInstances specify whether or not to use instances to render the mesh
  61641. * @return true if ready otherwise, false
  61642. */
  61643. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61644. /**
  61645. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61646. * @returns true if the effect requires stencil during the main canvas render pass.
  61647. */
  61648. abstract needStencil(): boolean;
  61649. /**
  61650. * Create the merge effect. This is the shader use to blit the information back
  61651. * to the main canvas at the end of the scene rendering.
  61652. * @returns The effect containing the shader used to merge the effect on the main canvas
  61653. */
  61654. protected abstract _createMergeEffect(): Effect;
  61655. /**
  61656. * Creates the render target textures and post processes used in the effect layer.
  61657. */
  61658. protected abstract _createTextureAndPostProcesses(): void;
  61659. /**
  61660. * Implementation specific of rendering the generating effect on the main canvas.
  61661. * @param effect The effect used to render through
  61662. */
  61663. protected abstract _internalRender(effect: Effect): void;
  61664. /**
  61665. * Sets the required values for both the emissive texture and and the main color.
  61666. */
  61667. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61668. /**
  61669. * Free any resources and references associated to a mesh.
  61670. * Internal use
  61671. * @param mesh The mesh to free.
  61672. */
  61673. abstract _disposeMesh(mesh: Mesh): void;
  61674. /**
  61675. * Serializes this layer (Glow or Highlight for example)
  61676. * @returns a serialized layer object
  61677. */
  61678. abstract serialize?(): any;
  61679. /**
  61680. * Initializes the effect layer with the required options.
  61681. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61682. */
  61683. protected _init(options: Partial<IEffectLayerOptions>): void;
  61684. /**
  61685. * Generates the index buffer of the full screen quad blending to the main canvas.
  61686. */
  61687. private _generateIndexBuffer;
  61688. /**
  61689. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61690. */
  61691. private _generateVertexBuffer;
  61692. /**
  61693. * Sets the main texture desired size which is the closest power of two
  61694. * of the engine canvas size.
  61695. */
  61696. private _setMainTextureSize;
  61697. /**
  61698. * Creates the main texture for the effect layer.
  61699. */
  61700. protected _createMainTexture(): void;
  61701. /**
  61702. * Adds specific effects defines.
  61703. * @param defines The defines to add specifics to.
  61704. */
  61705. protected _addCustomEffectDefines(defines: string[]): void;
  61706. /**
  61707. * Checks for the readiness of the element composing the layer.
  61708. * @param subMesh the mesh to check for
  61709. * @param useInstances specify whether or not to use instances to render the mesh
  61710. * @param emissiveTexture the associated emissive texture used to generate the glow
  61711. * @return true if ready otherwise, false
  61712. */
  61713. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61714. /**
  61715. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61716. */
  61717. render(): void;
  61718. /**
  61719. * Determine if a given mesh will be used in the current effect.
  61720. * @param mesh mesh to test
  61721. * @returns true if the mesh will be used
  61722. */
  61723. hasMesh(mesh: AbstractMesh): boolean;
  61724. /**
  61725. * Returns true if the layer contains information to display, otherwise false.
  61726. * @returns true if the glow layer should be rendered
  61727. */
  61728. shouldRender(): boolean;
  61729. /**
  61730. * Returns true if the mesh should render, otherwise false.
  61731. * @param mesh The mesh to render
  61732. * @returns true if it should render otherwise false
  61733. */
  61734. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61735. /**
  61736. * Returns true if the mesh can be rendered, otherwise false.
  61737. * @param mesh The mesh to render
  61738. * @param material The material used on the mesh
  61739. * @returns true if it can be rendered otherwise false
  61740. */
  61741. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61742. /**
  61743. * Returns true if the mesh should render, otherwise false.
  61744. * @param mesh The mesh to render
  61745. * @returns true if it should render otherwise false
  61746. */
  61747. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61748. /**
  61749. * Renders the submesh passed in parameter to the generation map.
  61750. */
  61751. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61752. /**
  61753. * Defines whether the current material of the mesh should be use to render the effect.
  61754. * @param mesh defines the current mesh to render
  61755. */
  61756. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61757. /**
  61758. * Rebuild the required buffers.
  61759. * @hidden Internal use only.
  61760. */
  61761. _rebuild(): void;
  61762. /**
  61763. * Dispose only the render target textures and post process.
  61764. */
  61765. private _disposeTextureAndPostProcesses;
  61766. /**
  61767. * Dispose the highlight layer and free resources.
  61768. */
  61769. dispose(): void;
  61770. /**
  61771. * Gets the class name of the effect layer
  61772. * @returns the string with the class name of the effect layer
  61773. */
  61774. getClassName(): string;
  61775. /**
  61776. * Creates an effect layer from parsed effect layer data
  61777. * @param parsedEffectLayer defines effect layer data
  61778. * @param scene defines the current scene
  61779. * @param rootUrl defines the root URL containing the effect layer information
  61780. * @returns a parsed effect Layer
  61781. */
  61782. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61783. }
  61784. }
  61785. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61786. import { Scene } from "babylonjs/scene";
  61787. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61788. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61789. import { AbstractScene } from "babylonjs/abstractScene";
  61790. module "babylonjs/abstractScene" {
  61791. interface AbstractScene {
  61792. /**
  61793. * The list of effect layers (highlights/glow) added to the scene
  61794. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61795. * @see https://doc.babylonjs.com/how_to/glow_layer
  61796. */
  61797. effectLayers: Array<EffectLayer>;
  61798. /**
  61799. * Removes the given effect layer from this scene.
  61800. * @param toRemove defines the effect layer to remove
  61801. * @returns the index of the removed effect layer
  61802. */
  61803. removeEffectLayer(toRemove: EffectLayer): number;
  61804. /**
  61805. * Adds the given effect layer to this scene
  61806. * @param newEffectLayer defines the effect layer to add
  61807. */
  61808. addEffectLayer(newEffectLayer: EffectLayer): void;
  61809. }
  61810. }
  61811. /**
  61812. * Defines the layer scene component responsible to manage any effect layers
  61813. * in a given scene.
  61814. */
  61815. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61816. /**
  61817. * The component name helpfull to identify the component in the list of scene components.
  61818. */
  61819. readonly name: string;
  61820. /**
  61821. * The scene the component belongs to.
  61822. */
  61823. scene: Scene;
  61824. private _engine;
  61825. private _renderEffects;
  61826. private _needStencil;
  61827. private _previousStencilState;
  61828. /**
  61829. * Creates a new instance of the component for the given scene
  61830. * @param scene Defines the scene to register the component in
  61831. */
  61832. constructor(scene: Scene);
  61833. /**
  61834. * Registers the component in a given scene
  61835. */
  61836. register(): void;
  61837. /**
  61838. * Rebuilds the elements related to this component in case of
  61839. * context lost for instance.
  61840. */
  61841. rebuild(): void;
  61842. /**
  61843. * Serializes the component data to the specified json object
  61844. * @param serializationObject The object to serialize to
  61845. */
  61846. serialize(serializationObject: any): void;
  61847. /**
  61848. * Adds all the elements from the container to the scene
  61849. * @param container the container holding the elements
  61850. */
  61851. addFromContainer(container: AbstractScene): void;
  61852. /**
  61853. * Removes all the elements in the container from the scene
  61854. * @param container contains the elements to remove
  61855. * @param dispose if the removed element should be disposed (default: false)
  61856. */
  61857. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61858. /**
  61859. * Disposes the component and the associated ressources.
  61860. */
  61861. dispose(): void;
  61862. private _isReadyForMesh;
  61863. private _renderMainTexture;
  61864. private _setStencil;
  61865. private _setStencilBack;
  61866. private _draw;
  61867. private _drawCamera;
  61868. private _drawRenderingGroup;
  61869. }
  61870. }
  61871. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61872. /** @hidden */
  61873. export var glowMapMergePixelShader: {
  61874. name: string;
  61875. shader: string;
  61876. };
  61877. }
  61878. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61879. /** @hidden */
  61880. export var glowMapMergeVertexShader: {
  61881. name: string;
  61882. shader: string;
  61883. };
  61884. }
  61885. declare module "babylonjs/Layers/glowLayer" {
  61886. import { Nullable } from "babylonjs/types";
  61887. import { Camera } from "babylonjs/Cameras/camera";
  61888. import { Scene } from "babylonjs/scene";
  61889. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61891. import { Mesh } from "babylonjs/Meshes/mesh";
  61892. import { Texture } from "babylonjs/Materials/Textures/texture";
  61893. import { Effect } from "babylonjs/Materials/effect";
  61894. import { Material } from "babylonjs/Materials/material";
  61895. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61896. import { Color4 } from "babylonjs/Maths/math.color";
  61897. import "babylonjs/Shaders/glowMapMerge.fragment";
  61898. import "babylonjs/Shaders/glowMapMerge.vertex";
  61899. import "babylonjs/Layers/effectLayerSceneComponent";
  61900. module "babylonjs/abstractScene" {
  61901. interface AbstractScene {
  61902. /**
  61903. * Return a the first highlight layer of the scene with a given name.
  61904. * @param name The name of the highlight layer to look for.
  61905. * @return The highlight layer if found otherwise null.
  61906. */
  61907. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61908. }
  61909. }
  61910. /**
  61911. * Glow layer options. This helps customizing the behaviour
  61912. * of the glow layer.
  61913. */
  61914. export interface IGlowLayerOptions {
  61915. /**
  61916. * Multiplication factor apply to the canvas size to compute the render target size
  61917. * used to generated the glowing objects (the smaller the faster).
  61918. */
  61919. mainTextureRatio: number;
  61920. /**
  61921. * Enforces a fixed size texture to ensure resize independant blur.
  61922. */
  61923. mainTextureFixedSize?: number;
  61924. /**
  61925. * How big is the kernel of the blur texture.
  61926. */
  61927. blurKernelSize: number;
  61928. /**
  61929. * The camera attached to the layer.
  61930. */
  61931. camera: Nullable<Camera>;
  61932. /**
  61933. * Enable MSAA by chosing the number of samples.
  61934. */
  61935. mainTextureSamples?: number;
  61936. /**
  61937. * The rendering group to draw the layer in.
  61938. */
  61939. renderingGroupId: number;
  61940. }
  61941. /**
  61942. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61943. *
  61944. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61945. *
  61946. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61947. */
  61948. export class GlowLayer extends EffectLayer {
  61949. /**
  61950. * Effect Name of the layer.
  61951. */
  61952. static readonly EffectName: string;
  61953. /**
  61954. * The default blur kernel size used for the glow.
  61955. */
  61956. static DefaultBlurKernelSize: number;
  61957. /**
  61958. * The default texture size ratio used for the glow.
  61959. */
  61960. static DefaultTextureRatio: number;
  61961. /**
  61962. * Sets the kernel size of the blur.
  61963. */
  61964. set blurKernelSize(value: number);
  61965. /**
  61966. * Gets the kernel size of the blur.
  61967. */
  61968. get blurKernelSize(): number;
  61969. /**
  61970. * Sets the glow intensity.
  61971. */
  61972. set intensity(value: number);
  61973. /**
  61974. * Gets the glow intensity.
  61975. */
  61976. get intensity(): number;
  61977. private _options;
  61978. private _intensity;
  61979. private _horizontalBlurPostprocess1;
  61980. private _verticalBlurPostprocess1;
  61981. private _horizontalBlurPostprocess2;
  61982. private _verticalBlurPostprocess2;
  61983. private _blurTexture1;
  61984. private _blurTexture2;
  61985. private _postProcesses1;
  61986. private _postProcesses2;
  61987. private _includedOnlyMeshes;
  61988. private _excludedMeshes;
  61989. private _meshesUsingTheirOwnMaterials;
  61990. /**
  61991. * Callback used to let the user override the color selection on a per mesh basis
  61992. */
  61993. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61994. /**
  61995. * Callback used to let the user override the texture selection on a per mesh basis
  61996. */
  61997. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61998. /**
  61999. * Instantiates a new glow Layer and references it to the scene.
  62000. * @param name The name of the layer
  62001. * @param scene The scene to use the layer in
  62002. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62003. */
  62004. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62005. /**
  62006. * Get the effect name of the layer.
  62007. * @return The effect name
  62008. */
  62009. getEffectName(): string;
  62010. /**
  62011. * Create the merge effect. This is the shader use to blit the information back
  62012. * to the main canvas at the end of the scene rendering.
  62013. */
  62014. protected _createMergeEffect(): Effect;
  62015. /**
  62016. * Creates the render target textures and post processes used in the glow layer.
  62017. */
  62018. protected _createTextureAndPostProcesses(): void;
  62019. /**
  62020. * Checks for the readiness of the element composing the layer.
  62021. * @param subMesh the mesh to check for
  62022. * @param useInstances specify wether or not to use instances to render the mesh
  62023. * @param emissiveTexture the associated emissive texture used to generate the glow
  62024. * @return true if ready otherwise, false
  62025. */
  62026. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62027. /**
  62028. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62029. */
  62030. needStencil(): boolean;
  62031. /**
  62032. * Returns true if the mesh can be rendered, otherwise false.
  62033. * @param mesh The mesh to render
  62034. * @param material The material used on the mesh
  62035. * @returns true if it can be rendered otherwise false
  62036. */
  62037. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62038. /**
  62039. * Implementation specific of rendering the generating effect on the main canvas.
  62040. * @param effect The effect used to render through
  62041. */
  62042. protected _internalRender(effect: Effect): void;
  62043. /**
  62044. * Sets the required values for both the emissive texture and and the main color.
  62045. */
  62046. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62047. /**
  62048. * Returns true if the mesh should render, otherwise false.
  62049. * @param mesh The mesh to render
  62050. * @returns true if it should render otherwise false
  62051. */
  62052. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62053. /**
  62054. * Adds specific effects defines.
  62055. * @param defines The defines to add specifics to.
  62056. */
  62057. protected _addCustomEffectDefines(defines: string[]): void;
  62058. /**
  62059. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62060. * @param mesh The mesh to exclude from the glow layer
  62061. */
  62062. addExcludedMesh(mesh: Mesh): void;
  62063. /**
  62064. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62065. * @param mesh The mesh to remove
  62066. */
  62067. removeExcludedMesh(mesh: Mesh): void;
  62068. /**
  62069. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62070. * @param mesh The mesh to include in the glow layer
  62071. */
  62072. addIncludedOnlyMesh(mesh: Mesh): void;
  62073. /**
  62074. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  62075. * @param mesh The mesh to remove
  62076. */
  62077. removeIncludedOnlyMesh(mesh: Mesh): void;
  62078. /**
  62079. * Determine if a given mesh will be used in the glow layer
  62080. * @param mesh The mesh to test
  62081. * @returns true if the mesh will be highlighted by the current glow layer
  62082. */
  62083. hasMesh(mesh: AbstractMesh): boolean;
  62084. /**
  62085. * Defines whether the current material of the mesh should be use to render the effect.
  62086. * @param mesh defines the current mesh to render
  62087. */
  62088. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62089. /**
  62090. * Add a mesh to be rendered through its own material and not with emissive only.
  62091. * @param mesh The mesh for which we need to use its material
  62092. */
  62093. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  62094. /**
  62095. * Remove a mesh from being rendered through its own material and not with emissive only.
  62096. * @param mesh The mesh for which we need to not use its material
  62097. */
  62098. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  62099. /**
  62100. * Free any resources and references associated to a mesh.
  62101. * Internal use
  62102. * @param mesh The mesh to free.
  62103. * @hidden
  62104. */
  62105. _disposeMesh(mesh: Mesh): void;
  62106. /**
  62107. * Gets the class name of the effect layer
  62108. * @returns the string with the class name of the effect layer
  62109. */
  62110. getClassName(): string;
  62111. /**
  62112. * Serializes this glow layer
  62113. * @returns a serialized glow layer object
  62114. */
  62115. serialize(): any;
  62116. /**
  62117. * Creates a Glow Layer from parsed glow layer data
  62118. * @param parsedGlowLayer defines glow layer data
  62119. * @param scene defines the current scene
  62120. * @param rootUrl defines the root URL containing the glow layer information
  62121. * @returns a parsed Glow Layer
  62122. */
  62123. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  62124. }
  62125. }
  62126. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  62127. /** @hidden */
  62128. export var glowBlurPostProcessPixelShader: {
  62129. name: string;
  62130. shader: string;
  62131. };
  62132. }
  62133. declare module "babylonjs/Layers/highlightLayer" {
  62134. import { Observable } from "babylonjs/Misc/observable";
  62135. import { Nullable } from "babylonjs/types";
  62136. import { Camera } from "babylonjs/Cameras/camera";
  62137. import { Scene } from "babylonjs/scene";
  62138. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62140. import { Mesh } from "babylonjs/Meshes/mesh";
  62141. import { Effect } from "babylonjs/Materials/effect";
  62142. import { Material } from "babylonjs/Materials/material";
  62143. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62144. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62145. import "babylonjs/Shaders/glowMapMerge.fragment";
  62146. import "babylonjs/Shaders/glowMapMerge.vertex";
  62147. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  62148. module "babylonjs/abstractScene" {
  62149. interface AbstractScene {
  62150. /**
  62151. * Return a the first highlight layer of the scene with a given name.
  62152. * @param name The name of the highlight layer to look for.
  62153. * @return The highlight layer if found otherwise null.
  62154. */
  62155. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  62156. }
  62157. }
  62158. /**
  62159. * Highlight layer options. This helps customizing the behaviour
  62160. * of the highlight layer.
  62161. */
  62162. export interface IHighlightLayerOptions {
  62163. /**
  62164. * Multiplication factor apply to the canvas size to compute the render target size
  62165. * used to generated the glowing objects (the smaller the faster).
  62166. */
  62167. mainTextureRatio: number;
  62168. /**
  62169. * Enforces a fixed size texture to ensure resize independant blur.
  62170. */
  62171. mainTextureFixedSize?: number;
  62172. /**
  62173. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  62174. * of the picture to blur (the smaller the faster).
  62175. */
  62176. blurTextureSizeRatio: number;
  62177. /**
  62178. * How big in texel of the blur texture is the vertical blur.
  62179. */
  62180. blurVerticalSize: number;
  62181. /**
  62182. * How big in texel of the blur texture is the horizontal blur.
  62183. */
  62184. blurHorizontalSize: number;
  62185. /**
  62186. * Alpha blending mode used to apply the blur. Default is combine.
  62187. */
  62188. alphaBlendingMode: number;
  62189. /**
  62190. * The camera attached to the layer.
  62191. */
  62192. camera: Nullable<Camera>;
  62193. /**
  62194. * Should we display highlight as a solid stroke?
  62195. */
  62196. isStroke?: boolean;
  62197. /**
  62198. * The rendering group to draw the layer in.
  62199. */
  62200. renderingGroupId: number;
  62201. }
  62202. /**
  62203. * The highlight layer Helps adding a glow effect around a mesh.
  62204. *
  62205. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  62206. * glowy meshes to your scene.
  62207. *
  62208. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  62209. */
  62210. export class HighlightLayer extends EffectLayer {
  62211. name: string;
  62212. /**
  62213. * Effect Name of the highlight layer.
  62214. */
  62215. static readonly EffectName: string;
  62216. /**
  62217. * The neutral color used during the preparation of the glow effect.
  62218. * This is black by default as the blend operation is a blend operation.
  62219. */
  62220. static NeutralColor: Color4;
  62221. /**
  62222. * Stencil value used for glowing meshes.
  62223. */
  62224. static GlowingMeshStencilReference: number;
  62225. /**
  62226. * Stencil value used for the other meshes in the scene.
  62227. */
  62228. static NormalMeshStencilReference: number;
  62229. /**
  62230. * Specifies whether or not the inner glow is ACTIVE in the layer.
  62231. */
  62232. innerGlow: boolean;
  62233. /**
  62234. * Specifies whether or not the outer glow is ACTIVE in the layer.
  62235. */
  62236. outerGlow: boolean;
  62237. /**
  62238. * Specifies the horizontal size of the blur.
  62239. */
  62240. set blurHorizontalSize(value: number);
  62241. /**
  62242. * Specifies the vertical size of the blur.
  62243. */
  62244. set blurVerticalSize(value: number);
  62245. /**
  62246. * Gets the horizontal size of the blur.
  62247. */
  62248. get blurHorizontalSize(): number;
  62249. /**
  62250. * Gets the vertical size of the blur.
  62251. */
  62252. get blurVerticalSize(): number;
  62253. /**
  62254. * An event triggered when the highlight layer is being blurred.
  62255. */
  62256. onBeforeBlurObservable: Observable<HighlightLayer>;
  62257. /**
  62258. * An event triggered when the highlight layer has been blurred.
  62259. */
  62260. onAfterBlurObservable: Observable<HighlightLayer>;
  62261. private _instanceGlowingMeshStencilReference;
  62262. private _options;
  62263. private _downSamplePostprocess;
  62264. private _horizontalBlurPostprocess;
  62265. private _verticalBlurPostprocess;
  62266. private _blurTexture;
  62267. private _meshes;
  62268. private _excludedMeshes;
  62269. /**
  62270. * Instantiates a new highlight Layer and references it to the scene..
  62271. * @param name The name of the layer
  62272. * @param scene The scene to use the layer in
  62273. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  62274. */
  62275. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  62276. /**
  62277. * Get the effect name of the layer.
  62278. * @return The effect name
  62279. */
  62280. getEffectName(): string;
  62281. /**
  62282. * Create the merge effect. This is the shader use to blit the information back
  62283. * to the main canvas at the end of the scene rendering.
  62284. */
  62285. protected _createMergeEffect(): Effect;
  62286. /**
  62287. * Creates the render target textures and post processes used in the highlight layer.
  62288. */
  62289. protected _createTextureAndPostProcesses(): void;
  62290. /**
  62291. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  62292. */
  62293. needStencil(): boolean;
  62294. /**
  62295. * Checks for the readiness of the element composing the layer.
  62296. * @param subMesh the mesh to check for
  62297. * @param useInstances specify wether or not to use instances to render the mesh
  62298. * @param emissiveTexture the associated emissive texture used to generate the glow
  62299. * @return true if ready otherwise, false
  62300. */
  62301. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62302. /**
  62303. * Implementation specific of rendering the generating effect on the main canvas.
  62304. * @param effect The effect used to render through
  62305. */
  62306. protected _internalRender(effect: Effect): void;
  62307. /**
  62308. * Returns true if the layer contains information to display, otherwise false.
  62309. */
  62310. shouldRender(): boolean;
  62311. /**
  62312. * Returns true if the mesh should render, otherwise false.
  62313. * @param mesh The mesh to render
  62314. * @returns true if it should render otherwise false
  62315. */
  62316. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62317. /**
  62318. * Returns true if the mesh can be rendered, otherwise false.
  62319. * @param mesh The mesh to render
  62320. * @param material The material used on the mesh
  62321. * @returns true if it can be rendered otherwise false
  62322. */
  62323. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62324. /**
  62325. * Adds specific effects defines.
  62326. * @param defines The defines to add specifics to.
  62327. */
  62328. protected _addCustomEffectDefines(defines: string[]): void;
  62329. /**
  62330. * Sets the required values for both the emissive texture and and the main color.
  62331. */
  62332. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62333. /**
  62334. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  62335. * @param mesh The mesh to exclude from the highlight layer
  62336. */
  62337. addExcludedMesh(mesh: Mesh): void;
  62338. /**
  62339. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  62340. * @param mesh The mesh to highlight
  62341. */
  62342. removeExcludedMesh(mesh: Mesh): void;
  62343. /**
  62344. * Determine if a given mesh will be highlighted by the current HighlightLayer
  62345. * @param mesh mesh to test
  62346. * @returns true if the mesh will be highlighted by the current HighlightLayer
  62347. */
  62348. hasMesh(mesh: AbstractMesh): boolean;
  62349. /**
  62350. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  62351. * @param mesh The mesh to highlight
  62352. * @param color The color of the highlight
  62353. * @param glowEmissiveOnly Extract the glow from the emissive texture
  62354. */
  62355. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  62356. /**
  62357. * Remove a mesh from the highlight layer in order to make it stop glowing.
  62358. * @param mesh The mesh to highlight
  62359. */
  62360. removeMesh(mesh: Mesh): void;
  62361. /**
  62362. * Remove all the meshes currently referenced in the highlight layer
  62363. */
  62364. removeAllMeshes(): void;
  62365. /**
  62366. * Force the stencil to the normal expected value for none glowing parts
  62367. */
  62368. private _defaultStencilReference;
  62369. /**
  62370. * Free any resources and references associated to a mesh.
  62371. * Internal use
  62372. * @param mesh The mesh to free.
  62373. * @hidden
  62374. */
  62375. _disposeMesh(mesh: Mesh): void;
  62376. /**
  62377. * Dispose the highlight layer and free resources.
  62378. */
  62379. dispose(): void;
  62380. /**
  62381. * Gets the class name of the effect layer
  62382. * @returns the string with the class name of the effect layer
  62383. */
  62384. getClassName(): string;
  62385. /**
  62386. * Serializes this Highlight layer
  62387. * @returns a serialized Highlight layer object
  62388. */
  62389. serialize(): any;
  62390. /**
  62391. * Creates a Highlight layer from parsed Highlight layer data
  62392. * @param parsedHightlightLayer defines the Highlight layer data
  62393. * @param scene defines the current scene
  62394. * @param rootUrl defines the root URL containing the Highlight layer information
  62395. * @returns a parsed Highlight layer
  62396. */
  62397. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  62398. }
  62399. }
  62400. declare module "babylonjs/Layers/layerSceneComponent" {
  62401. import { Scene } from "babylonjs/scene";
  62402. import { ISceneComponent } from "babylonjs/sceneComponent";
  62403. import { Layer } from "babylonjs/Layers/layer";
  62404. import { AbstractScene } from "babylonjs/abstractScene";
  62405. module "babylonjs/abstractScene" {
  62406. interface AbstractScene {
  62407. /**
  62408. * The list of layers (background and foreground) of the scene
  62409. */
  62410. layers: Array<Layer>;
  62411. }
  62412. }
  62413. /**
  62414. * Defines the layer scene component responsible to manage any layers
  62415. * in a given scene.
  62416. */
  62417. export class LayerSceneComponent implements ISceneComponent {
  62418. /**
  62419. * The component name helpfull to identify the component in the list of scene components.
  62420. */
  62421. readonly name: string;
  62422. /**
  62423. * The scene the component belongs to.
  62424. */
  62425. scene: Scene;
  62426. private _engine;
  62427. /**
  62428. * Creates a new instance of the component for the given scene
  62429. * @param scene Defines the scene to register the component in
  62430. */
  62431. constructor(scene: Scene);
  62432. /**
  62433. * Registers the component in a given scene
  62434. */
  62435. register(): void;
  62436. /**
  62437. * Rebuilds the elements related to this component in case of
  62438. * context lost for instance.
  62439. */
  62440. rebuild(): void;
  62441. /**
  62442. * Disposes the component and the associated ressources.
  62443. */
  62444. dispose(): void;
  62445. private _draw;
  62446. private _drawCameraPredicate;
  62447. private _drawCameraBackground;
  62448. private _drawCameraForeground;
  62449. private _drawRenderTargetPredicate;
  62450. private _drawRenderTargetBackground;
  62451. private _drawRenderTargetForeground;
  62452. /**
  62453. * Adds all the elements from the container to the scene
  62454. * @param container the container holding the elements
  62455. */
  62456. addFromContainer(container: AbstractScene): void;
  62457. /**
  62458. * Removes all the elements in the container from the scene
  62459. * @param container contains the elements to remove
  62460. * @param dispose if the removed element should be disposed (default: false)
  62461. */
  62462. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62463. }
  62464. }
  62465. declare module "babylonjs/Shaders/layer.fragment" {
  62466. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62467. /** @hidden */
  62468. export var layerPixelShader: {
  62469. name: string;
  62470. shader: string;
  62471. };
  62472. }
  62473. declare module "babylonjs/Shaders/layer.vertex" {
  62474. /** @hidden */
  62475. export var layerVertexShader: {
  62476. name: string;
  62477. shader: string;
  62478. };
  62479. }
  62480. declare module "babylonjs/Layers/layer" {
  62481. import { Observable } from "babylonjs/Misc/observable";
  62482. import { Nullable } from "babylonjs/types";
  62483. import { Scene } from "babylonjs/scene";
  62484. import { Vector2 } from "babylonjs/Maths/math.vector";
  62485. import { Color4 } from "babylonjs/Maths/math.color";
  62486. import { Texture } from "babylonjs/Materials/Textures/texture";
  62487. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62488. import "babylonjs/Shaders/layer.fragment";
  62489. import "babylonjs/Shaders/layer.vertex";
  62490. /**
  62491. * This represents a full screen 2d layer.
  62492. * This can be useful to display a picture in the background of your scene for instance.
  62493. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62494. */
  62495. export class Layer {
  62496. /**
  62497. * Define the name of the layer.
  62498. */
  62499. name: string;
  62500. /**
  62501. * Define the texture the layer should display.
  62502. */
  62503. texture: Nullable<Texture>;
  62504. /**
  62505. * Is the layer in background or foreground.
  62506. */
  62507. isBackground: boolean;
  62508. /**
  62509. * Define the color of the layer (instead of texture).
  62510. */
  62511. color: Color4;
  62512. /**
  62513. * Define the scale of the layer in order to zoom in out of the texture.
  62514. */
  62515. scale: Vector2;
  62516. /**
  62517. * Define an offset for the layer in order to shift the texture.
  62518. */
  62519. offset: Vector2;
  62520. /**
  62521. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62522. */
  62523. alphaBlendingMode: number;
  62524. /**
  62525. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62526. * Alpha test will not mix with the background color in case of transparency.
  62527. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62528. */
  62529. alphaTest: boolean;
  62530. /**
  62531. * Define a mask to restrict the layer to only some of the scene cameras.
  62532. */
  62533. layerMask: number;
  62534. /**
  62535. * Define the list of render target the layer is visible into.
  62536. */
  62537. renderTargetTextures: RenderTargetTexture[];
  62538. /**
  62539. * Define if the layer is only used in renderTarget or if it also
  62540. * renders in the main frame buffer of the canvas.
  62541. */
  62542. renderOnlyInRenderTargetTextures: boolean;
  62543. private _scene;
  62544. private _vertexBuffers;
  62545. private _indexBuffer;
  62546. private _effect;
  62547. private _previousDefines;
  62548. /**
  62549. * An event triggered when the layer is disposed.
  62550. */
  62551. onDisposeObservable: Observable<Layer>;
  62552. private _onDisposeObserver;
  62553. /**
  62554. * Back compatibility with callback before the onDisposeObservable existed.
  62555. * The set callback will be triggered when the layer has been disposed.
  62556. */
  62557. set onDispose(callback: () => void);
  62558. /**
  62559. * An event triggered before rendering the scene
  62560. */
  62561. onBeforeRenderObservable: Observable<Layer>;
  62562. private _onBeforeRenderObserver;
  62563. /**
  62564. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62565. * The set callback will be triggered just before rendering the layer.
  62566. */
  62567. set onBeforeRender(callback: () => void);
  62568. /**
  62569. * An event triggered after rendering the scene
  62570. */
  62571. onAfterRenderObservable: Observable<Layer>;
  62572. private _onAfterRenderObserver;
  62573. /**
  62574. * Back compatibility with callback before the onAfterRenderObservable existed.
  62575. * The set callback will be triggered just after rendering the layer.
  62576. */
  62577. set onAfterRender(callback: () => void);
  62578. /**
  62579. * Instantiates a new layer.
  62580. * This represents a full screen 2d layer.
  62581. * This can be useful to display a picture in the background of your scene for instance.
  62582. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62583. * @param name Define the name of the layer in the scene
  62584. * @param imgUrl Define the url of the texture to display in the layer
  62585. * @param scene Define the scene the layer belongs to
  62586. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62587. * @param color Defines a color for the layer
  62588. */
  62589. constructor(
  62590. /**
  62591. * Define the name of the layer.
  62592. */
  62593. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62594. private _createIndexBuffer;
  62595. /** @hidden */
  62596. _rebuild(): void;
  62597. /**
  62598. * Renders the layer in the scene.
  62599. */
  62600. render(): void;
  62601. /**
  62602. * Disposes and releases the associated ressources.
  62603. */
  62604. dispose(): void;
  62605. }
  62606. }
  62607. declare module "babylonjs/Layers/index" {
  62608. export * from "babylonjs/Layers/effectLayer";
  62609. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62610. export * from "babylonjs/Layers/glowLayer";
  62611. export * from "babylonjs/Layers/highlightLayer";
  62612. export * from "babylonjs/Layers/layer";
  62613. export * from "babylonjs/Layers/layerSceneComponent";
  62614. }
  62615. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62616. /** @hidden */
  62617. export var lensFlarePixelShader: {
  62618. name: string;
  62619. shader: string;
  62620. };
  62621. }
  62622. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62623. /** @hidden */
  62624. export var lensFlareVertexShader: {
  62625. name: string;
  62626. shader: string;
  62627. };
  62628. }
  62629. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62630. import { Scene } from "babylonjs/scene";
  62631. import { Vector3 } from "babylonjs/Maths/math.vector";
  62632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62633. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62634. import "babylonjs/Shaders/lensFlare.fragment";
  62635. import "babylonjs/Shaders/lensFlare.vertex";
  62636. import { Viewport } from "babylonjs/Maths/math.viewport";
  62637. /**
  62638. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62639. * It is usually composed of several `lensFlare`.
  62640. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62641. */
  62642. export class LensFlareSystem {
  62643. /**
  62644. * Define the name of the lens flare system
  62645. */
  62646. name: string;
  62647. /**
  62648. * List of lens flares used in this system.
  62649. */
  62650. lensFlares: LensFlare[];
  62651. /**
  62652. * Define a limit from the border the lens flare can be visible.
  62653. */
  62654. borderLimit: number;
  62655. /**
  62656. * Define a viewport border we do not want to see the lens flare in.
  62657. */
  62658. viewportBorder: number;
  62659. /**
  62660. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62661. */
  62662. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62663. /**
  62664. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62665. */
  62666. layerMask: number;
  62667. /**
  62668. * Define the id of the lens flare system in the scene.
  62669. * (equal to name by default)
  62670. */
  62671. id: string;
  62672. private _scene;
  62673. private _emitter;
  62674. private _vertexBuffers;
  62675. private _indexBuffer;
  62676. private _effect;
  62677. private _positionX;
  62678. private _positionY;
  62679. private _isEnabled;
  62680. /** @hidden */
  62681. static _SceneComponentInitialization: (scene: Scene) => void;
  62682. /**
  62683. * Instantiates a lens flare system.
  62684. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62685. * It is usually composed of several `lensFlare`.
  62686. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62687. * @param name Define the name of the lens flare system in the scene
  62688. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62689. * @param scene Define the scene the lens flare system belongs to
  62690. */
  62691. constructor(
  62692. /**
  62693. * Define the name of the lens flare system
  62694. */
  62695. name: string, emitter: any, scene: Scene);
  62696. /**
  62697. * Define if the lens flare system is enabled.
  62698. */
  62699. get isEnabled(): boolean;
  62700. set isEnabled(value: boolean);
  62701. /**
  62702. * Get the scene the effects belongs to.
  62703. * @returns the scene holding the lens flare system
  62704. */
  62705. getScene(): Scene;
  62706. /**
  62707. * Get the emitter of the lens flare system.
  62708. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62709. * @returns the emitter of the lens flare system
  62710. */
  62711. getEmitter(): any;
  62712. /**
  62713. * Set the emitter of the lens flare system.
  62714. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62715. * @param newEmitter Define the new emitter of the system
  62716. */
  62717. setEmitter(newEmitter: any): void;
  62718. /**
  62719. * Get the lens flare system emitter position.
  62720. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62721. * @returns the position
  62722. */
  62723. getEmitterPosition(): Vector3;
  62724. /**
  62725. * @hidden
  62726. */
  62727. computeEffectivePosition(globalViewport: Viewport): boolean;
  62728. /** @hidden */
  62729. _isVisible(): boolean;
  62730. /**
  62731. * @hidden
  62732. */
  62733. render(): boolean;
  62734. /**
  62735. * Dispose and release the lens flare with its associated resources.
  62736. */
  62737. dispose(): void;
  62738. /**
  62739. * Parse a lens flare system from a JSON repressentation
  62740. * @param parsedLensFlareSystem Define the JSON to parse
  62741. * @param scene Define the scene the parsed system should be instantiated in
  62742. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62743. * @returns the parsed system
  62744. */
  62745. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62746. /**
  62747. * Serialize the current Lens Flare System into a JSON representation.
  62748. * @returns the serialized JSON
  62749. */
  62750. serialize(): any;
  62751. }
  62752. }
  62753. declare module "babylonjs/LensFlares/lensFlare" {
  62754. import { Nullable } from "babylonjs/types";
  62755. import { Color3 } from "babylonjs/Maths/math.color";
  62756. import { Texture } from "babylonjs/Materials/Textures/texture";
  62757. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62758. /**
  62759. * This represents one of the lens effect in a `lensFlareSystem`.
  62760. * It controls one of the indiviual texture used in the effect.
  62761. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62762. */
  62763. export class LensFlare {
  62764. /**
  62765. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62766. */
  62767. size: number;
  62768. /**
  62769. * 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.
  62770. */
  62771. position: number;
  62772. /**
  62773. * Define the lens color.
  62774. */
  62775. color: Color3;
  62776. /**
  62777. * Define the lens texture.
  62778. */
  62779. texture: Nullable<Texture>;
  62780. /**
  62781. * Define the alpha mode to render this particular lens.
  62782. */
  62783. alphaMode: number;
  62784. private _system;
  62785. /**
  62786. * Creates a new Lens Flare.
  62787. * This represents one of the lens effect in a `lensFlareSystem`.
  62788. * It controls one of the indiviual texture used in the effect.
  62789. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62790. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62791. * @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.
  62792. * @param color Define the lens color
  62793. * @param imgUrl Define the lens texture url
  62794. * @param system Define the `lensFlareSystem` this flare is part of
  62795. * @returns The newly created Lens Flare
  62796. */
  62797. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62798. /**
  62799. * Instantiates a new Lens Flare.
  62800. * This represents one of the lens effect in a `lensFlareSystem`.
  62801. * It controls one of the indiviual texture used in the effect.
  62802. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62803. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62804. * @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.
  62805. * @param color Define the lens color
  62806. * @param imgUrl Define the lens texture url
  62807. * @param system Define the `lensFlareSystem` this flare is part of
  62808. */
  62809. constructor(
  62810. /**
  62811. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62812. */
  62813. size: number,
  62814. /**
  62815. * 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.
  62816. */
  62817. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62818. /**
  62819. * Dispose and release the lens flare with its associated resources.
  62820. */
  62821. dispose(): void;
  62822. }
  62823. }
  62824. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62825. import { Nullable } from "babylonjs/types";
  62826. import { Scene } from "babylonjs/scene";
  62827. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62828. import { AbstractScene } from "babylonjs/abstractScene";
  62829. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62830. module "babylonjs/abstractScene" {
  62831. interface AbstractScene {
  62832. /**
  62833. * The list of lens flare system added to the scene
  62834. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62835. */
  62836. lensFlareSystems: Array<LensFlareSystem>;
  62837. /**
  62838. * Removes the given lens flare system from this scene.
  62839. * @param toRemove The lens flare system to remove
  62840. * @returns The index of the removed lens flare system
  62841. */
  62842. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62843. /**
  62844. * Adds the given lens flare system to this scene
  62845. * @param newLensFlareSystem The lens flare system to add
  62846. */
  62847. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62848. /**
  62849. * Gets a lens flare system using its name
  62850. * @param name defines the name to look for
  62851. * @returns the lens flare system or null if not found
  62852. */
  62853. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62854. /**
  62855. * Gets a lens flare system using its id
  62856. * @param id defines the id to look for
  62857. * @returns the lens flare system or null if not found
  62858. */
  62859. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62860. }
  62861. }
  62862. /**
  62863. * Defines the lens flare scene component responsible to manage any lens flares
  62864. * in a given scene.
  62865. */
  62866. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62867. /**
  62868. * The component name helpfull to identify the component in the list of scene components.
  62869. */
  62870. readonly name: string;
  62871. /**
  62872. * The scene the component belongs to.
  62873. */
  62874. scene: Scene;
  62875. /**
  62876. * Creates a new instance of the component for the given scene
  62877. * @param scene Defines the scene to register the component in
  62878. */
  62879. constructor(scene: Scene);
  62880. /**
  62881. * Registers the component in a given scene
  62882. */
  62883. register(): void;
  62884. /**
  62885. * Rebuilds the elements related to this component in case of
  62886. * context lost for instance.
  62887. */
  62888. rebuild(): void;
  62889. /**
  62890. * Adds all the elements from the container to the scene
  62891. * @param container the container holding the elements
  62892. */
  62893. addFromContainer(container: AbstractScene): void;
  62894. /**
  62895. * Removes all the elements in the container from the scene
  62896. * @param container contains the elements to remove
  62897. * @param dispose if the removed element should be disposed (default: false)
  62898. */
  62899. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62900. /**
  62901. * Serializes the component data to the specified json object
  62902. * @param serializationObject The object to serialize to
  62903. */
  62904. serialize(serializationObject: any): void;
  62905. /**
  62906. * Disposes the component and the associated ressources.
  62907. */
  62908. dispose(): void;
  62909. private _draw;
  62910. }
  62911. }
  62912. declare module "babylonjs/LensFlares/index" {
  62913. export * from "babylonjs/LensFlares/lensFlare";
  62914. export * from "babylonjs/LensFlares/lensFlareSystem";
  62915. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62916. }
  62917. declare module "babylonjs/Shaders/depth.fragment" {
  62918. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62919. /** @hidden */
  62920. export var depthPixelShader: {
  62921. name: string;
  62922. shader: string;
  62923. };
  62924. }
  62925. declare module "babylonjs/Shaders/depth.vertex" {
  62926. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62927. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62928. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62929. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62930. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62931. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62932. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62933. /** @hidden */
  62934. export var depthVertexShader: {
  62935. name: string;
  62936. shader: string;
  62937. };
  62938. }
  62939. declare module "babylonjs/Rendering/depthRenderer" {
  62940. import { Nullable } from "babylonjs/types";
  62941. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62942. import { Scene } from "babylonjs/scene";
  62943. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62944. import { Camera } from "babylonjs/Cameras/camera";
  62945. import "babylonjs/Shaders/depth.fragment";
  62946. import "babylonjs/Shaders/depth.vertex";
  62947. /**
  62948. * This represents a depth renderer in Babylon.
  62949. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62950. */
  62951. export class DepthRenderer {
  62952. private _scene;
  62953. private _depthMap;
  62954. private _effect;
  62955. private readonly _storeNonLinearDepth;
  62956. private readonly _clearColor;
  62957. /** Get if the depth renderer is using packed depth or not */
  62958. readonly isPacked: boolean;
  62959. private _cachedDefines;
  62960. private _camera;
  62961. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62962. enabled: boolean;
  62963. /**
  62964. * Specifiess that the depth renderer will only be used within
  62965. * the camera it is created for.
  62966. * This can help forcing its rendering during the camera processing.
  62967. */
  62968. useOnlyInActiveCamera: boolean;
  62969. /** @hidden */
  62970. static _SceneComponentInitialization: (scene: Scene) => void;
  62971. /**
  62972. * Instantiates a depth renderer
  62973. * @param scene The scene the renderer belongs to
  62974. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62975. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62976. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62977. */
  62978. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62979. /**
  62980. * Creates the depth rendering effect and checks if the effect is ready.
  62981. * @param subMesh The submesh to be used to render the depth map of
  62982. * @param useInstances If multiple world instances should be used
  62983. * @returns if the depth renderer is ready to render the depth map
  62984. */
  62985. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62986. /**
  62987. * Gets the texture which the depth map will be written to.
  62988. * @returns The depth map texture
  62989. */
  62990. getDepthMap(): RenderTargetTexture;
  62991. /**
  62992. * Disposes of the depth renderer.
  62993. */
  62994. dispose(): void;
  62995. }
  62996. }
  62997. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62998. /** @hidden */
  62999. export var minmaxReduxPixelShader: {
  63000. name: string;
  63001. shader: string;
  63002. };
  63003. }
  63004. declare module "babylonjs/Misc/minMaxReducer" {
  63005. import { Nullable } from "babylonjs/types";
  63006. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63007. import { Camera } from "babylonjs/Cameras/camera";
  63008. import { Observer } from "babylonjs/Misc/observable";
  63009. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63010. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63011. import { Observable } from "babylonjs/Misc/observable";
  63012. import "babylonjs/Shaders/minmaxRedux.fragment";
  63013. /**
  63014. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63015. * and maximum values from all values of the texture.
  63016. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63017. * The source values are read from the red channel of the texture.
  63018. */
  63019. export class MinMaxReducer {
  63020. /**
  63021. * Observable triggered when the computation has been performed
  63022. */
  63023. onAfterReductionPerformed: Observable<{
  63024. min: number;
  63025. max: number;
  63026. }>;
  63027. protected _camera: Camera;
  63028. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63029. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63030. protected _postProcessManager: PostProcessManager;
  63031. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63032. protected _forceFullscreenViewport: boolean;
  63033. /**
  63034. * Creates a min/max reducer
  63035. * @param camera The camera to use for the post processes
  63036. */
  63037. constructor(camera: Camera);
  63038. /**
  63039. * Gets the texture used to read the values from.
  63040. */
  63041. get sourceTexture(): Nullable<RenderTargetTexture>;
  63042. /**
  63043. * Sets the source texture to read the values from.
  63044. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63045. * because in such textures '1' value must not be taken into account to compute the maximum
  63046. * as this value is used to clear the texture.
  63047. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63048. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63049. * @param depthRedux Indicates if the texture is a depth texture or not
  63050. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63051. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63052. */
  63053. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63054. /**
  63055. * Defines the refresh rate of the computation.
  63056. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63057. */
  63058. get refreshRate(): number;
  63059. set refreshRate(value: number);
  63060. protected _activated: boolean;
  63061. /**
  63062. * Gets the activation status of the reducer
  63063. */
  63064. get activated(): boolean;
  63065. /**
  63066. * Activates the reduction computation.
  63067. * When activated, the observers registered in onAfterReductionPerformed are
  63068. * called after the compuation is performed
  63069. */
  63070. activate(): void;
  63071. /**
  63072. * Deactivates the reduction computation.
  63073. */
  63074. deactivate(): void;
  63075. /**
  63076. * Disposes the min/max reducer
  63077. * @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.
  63078. */
  63079. dispose(disposeAll?: boolean): void;
  63080. }
  63081. }
  63082. declare module "babylonjs/Misc/depthReducer" {
  63083. import { Nullable } from "babylonjs/types";
  63084. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63085. import { Camera } from "babylonjs/Cameras/camera";
  63086. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63087. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  63088. /**
  63089. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  63090. */
  63091. export class DepthReducer extends MinMaxReducer {
  63092. private _depthRenderer;
  63093. private _depthRendererId;
  63094. /**
  63095. * Gets the depth renderer used for the computation.
  63096. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  63097. */
  63098. get depthRenderer(): Nullable<DepthRenderer>;
  63099. /**
  63100. * Creates a depth reducer
  63101. * @param camera The camera used to render the depth texture
  63102. */
  63103. constructor(camera: Camera);
  63104. /**
  63105. * Sets the depth renderer to use to generate the depth map
  63106. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  63107. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  63108. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63109. */
  63110. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  63111. /** @hidden */
  63112. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63113. /**
  63114. * Activates the reduction computation.
  63115. * When activated, the observers registered in onAfterReductionPerformed are
  63116. * called after the compuation is performed
  63117. */
  63118. activate(): void;
  63119. /**
  63120. * Deactivates the reduction computation.
  63121. */
  63122. deactivate(): void;
  63123. /**
  63124. * Disposes the depth reducer
  63125. * @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.
  63126. */
  63127. dispose(disposeAll?: boolean): void;
  63128. }
  63129. }
  63130. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  63131. import { Nullable } from "babylonjs/types";
  63132. import { Scene } from "babylonjs/scene";
  63133. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63134. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63136. import { Effect } from "babylonjs/Materials/effect";
  63137. import "babylonjs/Shaders/shadowMap.fragment";
  63138. import "babylonjs/Shaders/shadowMap.vertex";
  63139. import "babylonjs/Shaders/depthBoxBlur.fragment";
  63140. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  63141. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63142. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63143. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63144. /**
  63145. * A CSM implementation allowing casting shadows on large scenes.
  63146. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63147. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  63148. */
  63149. export class CascadedShadowGenerator extends ShadowGenerator {
  63150. private static readonly frustumCornersNDCSpace;
  63151. /**
  63152. * Name of the CSM class
  63153. */
  63154. static CLASSNAME: string;
  63155. /**
  63156. * Defines the default number of cascades used by the CSM.
  63157. */
  63158. static readonly DEFAULT_CASCADES_COUNT: number;
  63159. /**
  63160. * Defines the minimum number of cascades used by the CSM.
  63161. */
  63162. static readonly MIN_CASCADES_COUNT: number;
  63163. /**
  63164. * Defines the maximum number of cascades used by the CSM.
  63165. */
  63166. static readonly MAX_CASCADES_COUNT: number;
  63167. protected _validateFilter(filter: number): number;
  63168. /**
  63169. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  63170. */
  63171. penumbraDarkness: number;
  63172. private _numCascades;
  63173. /**
  63174. * Gets or set the number of cascades used by the CSM.
  63175. */
  63176. get numCascades(): number;
  63177. set numCascades(value: number);
  63178. /**
  63179. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  63180. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  63181. */
  63182. stabilizeCascades: boolean;
  63183. private _freezeShadowCastersBoundingInfo;
  63184. private _freezeShadowCastersBoundingInfoObservable;
  63185. /**
  63186. * Enables or disables the shadow casters bounding info computation.
  63187. * If your shadow casters don't move, you can disable this feature.
  63188. * If it is enabled, the bounding box computation is done every frame.
  63189. */
  63190. get freezeShadowCastersBoundingInfo(): boolean;
  63191. set freezeShadowCastersBoundingInfo(freeze: boolean);
  63192. private _scbiMin;
  63193. private _scbiMax;
  63194. protected _computeShadowCastersBoundingInfo(): void;
  63195. protected _shadowCastersBoundingInfo: BoundingInfo;
  63196. /**
  63197. * Gets or sets the shadow casters bounding info.
  63198. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  63199. * so that the system won't overwrite the bounds you provide
  63200. */
  63201. get shadowCastersBoundingInfo(): BoundingInfo;
  63202. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  63203. protected _breaksAreDirty: boolean;
  63204. protected _minDistance: number;
  63205. protected _maxDistance: number;
  63206. /**
  63207. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  63208. *
  63209. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  63210. * If you don't know these values, simply leave them to their defaults and don't call this function.
  63211. * @param min minimal distance for the breaks (default to 0.)
  63212. * @param max maximal distance for the breaks (default to 1.)
  63213. */
  63214. setMinMaxDistance(min: number, max: number): void;
  63215. /** Gets the minimal distance used in the cascade break computation */
  63216. get minDistance(): number;
  63217. /** Gets the maximal distance used in the cascade break computation */
  63218. get maxDistance(): number;
  63219. /**
  63220. * Gets the class name of that object
  63221. * @returns "CascadedShadowGenerator"
  63222. */
  63223. getClassName(): string;
  63224. private _cascadeMinExtents;
  63225. private _cascadeMaxExtents;
  63226. /**
  63227. * Gets a cascade minimum extents
  63228. * @param cascadeIndex index of the cascade
  63229. * @returns the minimum cascade extents
  63230. */
  63231. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  63232. /**
  63233. * Gets a cascade maximum extents
  63234. * @param cascadeIndex index of the cascade
  63235. * @returns the maximum cascade extents
  63236. */
  63237. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  63238. private _cascades;
  63239. private _currentLayer;
  63240. private _viewSpaceFrustumsZ;
  63241. private _viewMatrices;
  63242. private _projectionMatrices;
  63243. private _transformMatrices;
  63244. private _transformMatricesAsArray;
  63245. private _frustumLengths;
  63246. private _lightSizeUVCorrection;
  63247. private _depthCorrection;
  63248. private _frustumCornersWorldSpace;
  63249. private _frustumCenter;
  63250. private _shadowCameraPos;
  63251. private _shadowMaxZ;
  63252. /**
  63253. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  63254. * It defaults to camera.maxZ
  63255. */
  63256. get shadowMaxZ(): number;
  63257. /**
  63258. * Sets the shadow max z distance.
  63259. */
  63260. set shadowMaxZ(value: number);
  63261. protected _debug: boolean;
  63262. /**
  63263. * Gets or sets the debug flag.
  63264. * When enabled, the cascades are materialized by different colors on the screen.
  63265. */
  63266. get debug(): boolean;
  63267. set debug(dbg: boolean);
  63268. private _depthClamp;
  63269. /**
  63270. * Gets or sets the depth clamping value.
  63271. *
  63272. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  63273. * to account for the shadow casters far away.
  63274. *
  63275. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  63276. */
  63277. get depthClamp(): boolean;
  63278. set depthClamp(value: boolean);
  63279. private _cascadeBlendPercentage;
  63280. /**
  63281. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  63282. * It defaults to 0.1 (10% blending).
  63283. */
  63284. get cascadeBlendPercentage(): number;
  63285. set cascadeBlendPercentage(value: number);
  63286. private _lambda;
  63287. /**
  63288. * Gets or set the lambda parameter.
  63289. * This parameter is used to split the camera frustum and create the cascades.
  63290. * 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.
  63291. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  63292. */
  63293. get lambda(): number;
  63294. set lambda(value: number);
  63295. /**
  63296. * Gets the view matrix corresponding to a given cascade
  63297. * @param cascadeNum cascade to retrieve the view matrix from
  63298. * @returns the cascade view matrix
  63299. */
  63300. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  63301. /**
  63302. * Gets the projection matrix corresponding to a given cascade
  63303. * @param cascadeNum cascade to retrieve the projection matrix from
  63304. * @returns the cascade projection matrix
  63305. */
  63306. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  63307. /**
  63308. * Gets the transformation matrix corresponding to a given cascade
  63309. * @param cascadeNum cascade to retrieve the transformation matrix from
  63310. * @returns the cascade transformation matrix
  63311. */
  63312. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  63313. private _depthRenderer;
  63314. /**
  63315. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  63316. *
  63317. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  63318. *
  63319. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  63320. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  63321. * @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
  63322. */
  63323. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  63324. private _depthReducer;
  63325. private _autoCalcDepthBounds;
  63326. /**
  63327. * Gets or sets the autoCalcDepthBounds property.
  63328. *
  63329. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  63330. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  63331. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  63332. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  63333. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  63334. */
  63335. get autoCalcDepthBounds(): boolean;
  63336. set autoCalcDepthBounds(value: boolean);
  63337. /**
  63338. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  63339. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63340. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  63341. * for setting the refresh rate on the renderer yourself!
  63342. */
  63343. get autoCalcDepthBoundsRefreshRate(): number;
  63344. set autoCalcDepthBoundsRefreshRate(value: number);
  63345. /**
  63346. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  63347. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  63348. * you change the camera near/far planes!
  63349. */
  63350. splitFrustum(): void;
  63351. private _splitFrustum;
  63352. private _computeMatrices;
  63353. private _computeFrustumInWorldSpace;
  63354. private _computeCascadeFrustum;
  63355. /**
  63356. * Support test.
  63357. */
  63358. static get IsSupported(): boolean;
  63359. /** @hidden */
  63360. static _SceneComponentInitialization: (scene: Scene) => void;
  63361. /**
  63362. * Creates a Cascaded Shadow Generator object.
  63363. * A ShadowGenerator is the required tool to use the shadows.
  63364. * Each directional light casting shadows needs to use its own ShadowGenerator.
  63365. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63366. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  63367. * @param light The directional light object generating the shadows.
  63368. * @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.
  63369. */
  63370. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  63371. protected _initializeGenerator(): void;
  63372. protected _createTargetRenderTexture(): void;
  63373. protected _initializeShadowMap(): void;
  63374. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  63375. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  63376. /**
  63377. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  63378. * @param defines Defines of the material we want to update
  63379. * @param lightIndex Index of the light in the enabled light list of the material
  63380. */
  63381. prepareDefines(defines: any, lightIndex: number): void;
  63382. /**
  63383. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  63384. * defined in the generator but impacting the effect).
  63385. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  63386. * @param effect The effect we are binfing the information for
  63387. */
  63388. bindShadowLight(lightIndex: string, effect: Effect): void;
  63389. /**
  63390. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  63391. * (eq to view projection * shadow projection matrices)
  63392. * @returns The transform matrix used to create the shadow map
  63393. */
  63394. getTransformMatrix(): Matrix;
  63395. /**
  63396. * Disposes the ShadowGenerator.
  63397. * Returns nothing.
  63398. */
  63399. dispose(): void;
  63400. /**
  63401. * Serializes the shadow generator setup to a json object.
  63402. * @returns The serialized JSON object
  63403. */
  63404. serialize(): any;
  63405. /**
  63406. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  63407. * @param parsedShadowGenerator The JSON object to parse
  63408. * @param scene The scene to create the shadow map for
  63409. * @returns The parsed shadow generator
  63410. */
  63411. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  63412. }
  63413. }
  63414. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  63415. import { Scene } from "babylonjs/scene";
  63416. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63417. import { AbstractScene } from "babylonjs/abstractScene";
  63418. /**
  63419. * Defines the shadow generator component responsible to manage any shadow generators
  63420. * in a given scene.
  63421. */
  63422. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  63423. /**
  63424. * The component name helpfull to identify the component in the list of scene components.
  63425. */
  63426. readonly name: string;
  63427. /**
  63428. * The scene the component belongs to.
  63429. */
  63430. scene: Scene;
  63431. /**
  63432. * Creates a new instance of the component for the given scene
  63433. * @param scene Defines the scene to register the component in
  63434. */
  63435. constructor(scene: Scene);
  63436. /**
  63437. * Registers the component in a given scene
  63438. */
  63439. register(): void;
  63440. /**
  63441. * Rebuilds the elements related to this component in case of
  63442. * context lost for instance.
  63443. */
  63444. rebuild(): void;
  63445. /**
  63446. * Serializes the component data to the specified json object
  63447. * @param serializationObject The object to serialize to
  63448. */
  63449. serialize(serializationObject: any): void;
  63450. /**
  63451. * Adds all the elements from the container to the scene
  63452. * @param container the container holding the elements
  63453. */
  63454. addFromContainer(container: AbstractScene): void;
  63455. /**
  63456. * Removes all the elements in the container from the scene
  63457. * @param container contains the elements to remove
  63458. * @param dispose if the removed element should be disposed (default: false)
  63459. */
  63460. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63461. /**
  63462. * Rebuilds the elements related to this component in case of
  63463. * context lost for instance.
  63464. */
  63465. dispose(): void;
  63466. private _gatherRenderTargets;
  63467. }
  63468. }
  63469. declare module "babylonjs/Lights/Shadows/index" {
  63470. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  63471. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  63472. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  63473. }
  63474. declare module "babylonjs/Lights/pointLight" {
  63475. import { Scene } from "babylonjs/scene";
  63476. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63478. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63479. import { Effect } from "babylonjs/Materials/effect";
  63480. /**
  63481. * A point light is a light defined by an unique point in world space.
  63482. * The light is emitted in every direction from this point.
  63483. * A good example of a point light is a standard light bulb.
  63484. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63485. */
  63486. export class PointLight extends ShadowLight {
  63487. private _shadowAngle;
  63488. /**
  63489. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63490. * This specifies what angle the shadow will use to be created.
  63491. *
  63492. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63493. */
  63494. get shadowAngle(): number;
  63495. /**
  63496. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63497. * This specifies what angle the shadow will use to be created.
  63498. *
  63499. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63500. */
  63501. set shadowAngle(value: number);
  63502. /**
  63503. * Gets the direction if it has been set.
  63504. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63505. */
  63506. get direction(): Vector3;
  63507. /**
  63508. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63509. */
  63510. set direction(value: Vector3);
  63511. /**
  63512. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63513. * A PointLight emits the light in every direction.
  63514. * It can cast shadows.
  63515. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63516. * ```javascript
  63517. * var pointLight = new PointLight("pl", camera.position, scene);
  63518. * ```
  63519. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63520. * @param name The light friendly name
  63521. * @param position The position of the point light in the scene
  63522. * @param scene The scene the lights belongs to
  63523. */
  63524. constructor(name: string, position: Vector3, scene: Scene);
  63525. /**
  63526. * Returns the string "PointLight"
  63527. * @returns the class name
  63528. */
  63529. getClassName(): string;
  63530. /**
  63531. * Returns the integer 0.
  63532. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63533. */
  63534. getTypeID(): number;
  63535. /**
  63536. * Specifies wether or not the shadowmap should be a cube texture.
  63537. * @returns true if the shadowmap needs to be a cube texture.
  63538. */
  63539. needCube(): boolean;
  63540. /**
  63541. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63542. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63543. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63544. */
  63545. getShadowDirection(faceIndex?: number): Vector3;
  63546. /**
  63547. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63548. * - fov = PI / 2
  63549. * - aspect ratio : 1.0
  63550. * - z-near and far equal to the active camera minZ and maxZ.
  63551. * Returns the PointLight.
  63552. */
  63553. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63554. protected _buildUniformLayout(): void;
  63555. /**
  63556. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63557. * @param effect The effect to update
  63558. * @param lightIndex The index of the light in the effect to update
  63559. * @returns The point light
  63560. */
  63561. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63562. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63563. /**
  63564. * Prepares the list of defines specific to the light type.
  63565. * @param defines the list of defines
  63566. * @param lightIndex defines the index of the light for the effect
  63567. */
  63568. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63569. }
  63570. }
  63571. declare module "babylonjs/Lights/index" {
  63572. export * from "babylonjs/Lights/light";
  63573. export * from "babylonjs/Lights/shadowLight";
  63574. export * from "babylonjs/Lights/Shadows/index";
  63575. export * from "babylonjs/Lights/directionalLight";
  63576. export * from "babylonjs/Lights/hemisphericLight";
  63577. export * from "babylonjs/Lights/pointLight";
  63578. export * from "babylonjs/Lights/spotLight";
  63579. }
  63580. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63581. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63582. /**
  63583. * Header information of HDR texture files.
  63584. */
  63585. export interface HDRInfo {
  63586. /**
  63587. * The height of the texture in pixels.
  63588. */
  63589. height: number;
  63590. /**
  63591. * The width of the texture in pixels.
  63592. */
  63593. width: number;
  63594. /**
  63595. * The index of the beginning of the data in the binary file.
  63596. */
  63597. dataPosition: number;
  63598. }
  63599. /**
  63600. * This groups tools to convert HDR texture to native colors array.
  63601. */
  63602. export class HDRTools {
  63603. private static Ldexp;
  63604. private static Rgbe2float;
  63605. private static readStringLine;
  63606. /**
  63607. * Reads header information from an RGBE texture stored in a native array.
  63608. * More information on this format are available here:
  63609. * https://en.wikipedia.org/wiki/RGBE_image_format
  63610. *
  63611. * @param uint8array The binary file stored in native array.
  63612. * @return The header information.
  63613. */
  63614. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63615. /**
  63616. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63617. * This RGBE texture needs to store the information as a panorama.
  63618. *
  63619. * More information on this format are available here:
  63620. * https://en.wikipedia.org/wiki/RGBE_image_format
  63621. *
  63622. * @param buffer The binary file stored in an array buffer.
  63623. * @param size The expected size of the extracted cubemap.
  63624. * @return The Cube Map information.
  63625. */
  63626. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63627. /**
  63628. * Returns the pixels data extracted from an RGBE texture.
  63629. * This pixels will be stored left to right up to down in the R G B order in one array.
  63630. *
  63631. * More information on this format are available here:
  63632. * https://en.wikipedia.org/wiki/RGBE_image_format
  63633. *
  63634. * @param uint8array The binary file stored in an array buffer.
  63635. * @param hdrInfo The header information of the file.
  63636. * @return The pixels data in RGB right to left up to down order.
  63637. */
  63638. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63639. private static RGBE_ReadPixels_RLE;
  63640. private static RGBE_ReadPixels_NOT_RLE;
  63641. }
  63642. }
  63643. declare module "babylonjs/Materials/effectRenderer" {
  63644. import { Nullable } from "babylonjs/types";
  63645. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63646. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63647. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63648. import { Viewport } from "babylonjs/Maths/math.viewport";
  63649. import { Observable } from "babylonjs/Misc/observable";
  63650. import { Effect } from "babylonjs/Materials/effect";
  63651. import "babylonjs/Shaders/postprocess.vertex";
  63652. /**
  63653. * Effect Render Options
  63654. */
  63655. export interface IEffectRendererOptions {
  63656. /**
  63657. * Defines the vertices positions.
  63658. */
  63659. positions?: number[];
  63660. /**
  63661. * Defines the indices.
  63662. */
  63663. indices?: number[];
  63664. }
  63665. /**
  63666. * Helper class to render one or more effects.
  63667. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63668. */
  63669. export class EffectRenderer {
  63670. private engine;
  63671. private static _DefaultOptions;
  63672. private _vertexBuffers;
  63673. private _indexBuffer;
  63674. private _fullscreenViewport;
  63675. /**
  63676. * Creates an effect renderer
  63677. * @param engine the engine to use for rendering
  63678. * @param options defines the options of the effect renderer
  63679. */
  63680. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63681. /**
  63682. * Sets the current viewport in normalized coordinates 0-1
  63683. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63684. */
  63685. setViewport(viewport?: Viewport): void;
  63686. /**
  63687. * Binds the embedded attributes buffer to the effect.
  63688. * @param effect Defines the effect to bind the attributes for
  63689. */
  63690. bindBuffers(effect: Effect): void;
  63691. /**
  63692. * Sets the current effect wrapper to use during draw.
  63693. * The effect needs to be ready before calling this api.
  63694. * This also sets the default full screen position attribute.
  63695. * @param effectWrapper Defines the effect to draw with
  63696. */
  63697. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63698. /**
  63699. * Restores engine states
  63700. */
  63701. restoreStates(): void;
  63702. /**
  63703. * Draws a full screen quad.
  63704. */
  63705. draw(): void;
  63706. private isRenderTargetTexture;
  63707. /**
  63708. * renders one or more effects to a specified texture
  63709. * @param effectWrapper the effect to renderer
  63710. * @param outputTexture texture to draw to, if null it will render to the screen.
  63711. */
  63712. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63713. /**
  63714. * Disposes of the effect renderer
  63715. */
  63716. dispose(): void;
  63717. }
  63718. /**
  63719. * Options to create an EffectWrapper
  63720. */
  63721. interface EffectWrapperCreationOptions {
  63722. /**
  63723. * Engine to use to create the effect
  63724. */
  63725. engine: ThinEngine;
  63726. /**
  63727. * Fragment shader for the effect
  63728. */
  63729. fragmentShader: string;
  63730. /**
  63731. * Use the shader store instead of direct source code
  63732. */
  63733. useShaderStore?: boolean;
  63734. /**
  63735. * Vertex shader for the effect
  63736. */
  63737. vertexShader?: string;
  63738. /**
  63739. * Attributes to use in the shader
  63740. */
  63741. attributeNames?: Array<string>;
  63742. /**
  63743. * Uniforms to use in the shader
  63744. */
  63745. uniformNames?: Array<string>;
  63746. /**
  63747. * Texture sampler names to use in the shader
  63748. */
  63749. samplerNames?: Array<string>;
  63750. /**
  63751. * Defines to use in the shader
  63752. */
  63753. defines?: Array<string>;
  63754. /**
  63755. * Callback when effect is compiled
  63756. */
  63757. onCompiled?: Nullable<(effect: Effect) => void>;
  63758. /**
  63759. * The friendly name of the effect displayed in Spector.
  63760. */
  63761. name?: string;
  63762. }
  63763. /**
  63764. * Wraps an effect to be used for rendering
  63765. */
  63766. export class EffectWrapper {
  63767. /**
  63768. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63769. */
  63770. onApplyObservable: Observable<{}>;
  63771. /**
  63772. * The underlying effect
  63773. */
  63774. effect: Effect;
  63775. /**
  63776. * Creates an effect to be renderer
  63777. * @param creationOptions options to create the effect
  63778. */
  63779. constructor(creationOptions: EffectWrapperCreationOptions);
  63780. /**
  63781. * Disposes of the effect wrapper
  63782. */
  63783. dispose(): void;
  63784. }
  63785. }
  63786. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63787. /** @hidden */
  63788. export var hdrFilteringVertexShader: {
  63789. name: string;
  63790. shader: string;
  63791. };
  63792. }
  63793. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63794. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63795. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63796. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63797. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63798. /** @hidden */
  63799. export var hdrFilteringPixelShader: {
  63800. name: string;
  63801. shader: string;
  63802. };
  63803. }
  63804. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63805. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63806. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63807. import { Nullable } from "babylonjs/types";
  63808. import "babylonjs/Shaders/hdrFiltering.vertex";
  63809. import "babylonjs/Shaders/hdrFiltering.fragment";
  63810. /**
  63811. * Options for texture filtering
  63812. */
  63813. interface IHDRFilteringOptions {
  63814. /**
  63815. * Scales pixel intensity for the input HDR map.
  63816. */
  63817. hdrScale?: number;
  63818. /**
  63819. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63820. */
  63821. quality?: number;
  63822. }
  63823. /**
  63824. * Filters HDR maps to get correct renderings of PBR reflections
  63825. */
  63826. export class HDRFiltering {
  63827. private _engine;
  63828. private _effectRenderer;
  63829. private _effectWrapper;
  63830. private _lodGenerationOffset;
  63831. private _lodGenerationScale;
  63832. /**
  63833. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63834. * you care about baking speed.
  63835. */
  63836. quality: number;
  63837. /**
  63838. * Scales pixel intensity for the input HDR map.
  63839. */
  63840. hdrScale: number;
  63841. /**
  63842. * Instantiates HDR filter for reflection maps
  63843. *
  63844. * @param engine Thin engine
  63845. * @param options Options
  63846. */
  63847. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63848. private _createRenderTarget;
  63849. private _prefilterInternal;
  63850. private _createEffect;
  63851. /**
  63852. * Get a value indicating if the filter is ready to be used
  63853. * @param texture Texture to filter
  63854. * @returns true if the filter is ready
  63855. */
  63856. isReady(texture: BaseTexture): boolean;
  63857. /**
  63858. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63859. * Prefiltering will be invoked at the end of next rendering pass.
  63860. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63861. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63862. * @param texture Texture to filter
  63863. * @param onFinished Callback when filtering is done
  63864. * @return Promise called when prefiltering is done
  63865. */
  63866. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63867. }
  63868. }
  63869. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63870. import { Nullable } from "babylonjs/types";
  63871. import { Scene } from "babylonjs/scene";
  63872. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63874. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63875. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63876. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63877. /**
  63878. * This represents a texture coming from an HDR input.
  63879. *
  63880. * The only supported format is currently panorama picture stored in RGBE format.
  63881. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63882. */
  63883. export class HDRCubeTexture extends BaseTexture {
  63884. private static _facesMapping;
  63885. private _generateHarmonics;
  63886. private _noMipmap;
  63887. private _prefilterOnLoad;
  63888. private _textureMatrix;
  63889. private _size;
  63890. private _onLoad;
  63891. private _onError;
  63892. /**
  63893. * The texture URL.
  63894. */
  63895. url: string;
  63896. protected _isBlocking: boolean;
  63897. /**
  63898. * Sets wether or not the texture is blocking during loading.
  63899. */
  63900. set isBlocking(value: boolean);
  63901. /**
  63902. * Gets wether or not the texture is blocking during loading.
  63903. */
  63904. get isBlocking(): boolean;
  63905. protected _rotationY: number;
  63906. /**
  63907. * Sets texture matrix rotation angle around Y axis in radians.
  63908. */
  63909. set rotationY(value: number);
  63910. /**
  63911. * Gets texture matrix rotation angle around Y axis radians.
  63912. */
  63913. get rotationY(): number;
  63914. /**
  63915. * Gets or sets the center of the bounding box associated with the cube texture
  63916. * It must define where the camera used to render the texture was set
  63917. */
  63918. boundingBoxPosition: Vector3;
  63919. private _boundingBoxSize;
  63920. /**
  63921. * Gets or sets the size of the bounding box associated with the cube texture
  63922. * When defined, the cubemap will switch to local mode
  63923. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63924. * @example https://www.babylonjs-playground.com/#RNASML
  63925. */
  63926. set boundingBoxSize(value: Vector3);
  63927. get boundingBoxSize(): Vector3;
  63928. /**
  63929. * Instantiates an HDRTexture from the following parameters.
  63930. *
  63931. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63932. * @param sceneOrEngine The scene or engine the texture will be used in
  63933. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63934. * @param noMipmap Forces to not generate the mipmap if true
  63935. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63936. * @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)
  63937. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63938. */
  63939. 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>);
  63940. /**
  63941. * Get the current class name of the texture useful for serialization or dynamic coding.
  63942. * @returns "HDRCubeTexture"
  63943. */
  63944. getClassName(): string;
  63945. /**
  63946. * Occurs when the file is raw .hdr file.
  63947. */
  63948. private loadTexture;
  63949. clone(): HDRCubeTexture;
  63950. delayLoad(): void;
  63951. /**
  63952. * Get the texture reflection matrix used to rotate/transform the reflection.
  63953. * @returns the reflection matrix
  63954. */
  63955. getReflectionTextureMatrix(): Matrix;
  63956. /**
  63957. * Set the texture reflection matrix used to rotate/transform the reflection.
  63958. * @param value Define the reflection matrix to set
  63959. */
  63960. setReflectionTextureMatrix(value: Matrix): void;
  63961. /**
  63962. * Parses a JSON representation of an HDR Texture in order to create the texture
  63963. * @param parsedTexture Define the JSON representation
  63964. * @param scene Define the scene the texture should be created in
  63965. * @param rootUrl Define the root url in case we need to load relative dependencies
  63966. * @returns the newly created texture after parsing
  63967. */
  63968. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63969. serialize(): any;
  63970. }
  63971. }
  63972. declare module "babylonjs/Physics/physicsEngine" {
  63973. import { Nullable } from "babylonjs/types";
  63974. import { Vector3 } from "babylonjs/Maths/math.vector";
  63975. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63976. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63977. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63978. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63979. /**
  63980. * Class used to control physics engine
  63981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63982. */
  63983. export class PhysicsEngine implements IPhysicsEngine {
  63984. private _physicsPlugin;
  63985. /**
  63986. * Global value used to control the smallest number supported by the simulation
  63987. */
  63988. static Epsilon: number;
  63989. private _impostors;
  63990. private _joints;
  63991. private _subTimeStep;
  63992. /**
  63993. * Gets the gravity vector used by the simulation
  63994. */
  63995. gravity: Vector3;
  63996. /**
  63997. * Factory used to create the default physics plugin.
  63998. * @returns The default physics plugin
  63999. */
  64000. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64001. /**
  64002. * Creates a new Physics Engine
  64003. * @param gravity defines the gravity vector used by the simulation
  64004. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64005. */
  64006. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64007. /**
  64008. * Sets the gravity vector used by the simulation
  64009. * @param gravity defines the gravity vector to use
  64010. */
  64011. setGravity(gravity: Vector3): void;
  64012. /**
  64013. * Set the time step of the physics engine.
  64014. * Default is 1/60.
  64015. * To slow it down, enter 1/600 for example.
  64016. * To speed it up, 1/30
  64017. * @param newTimeStep defines the new timestep to apply to this world.
  64018. */
  64019. setTimeStep(newTimeStep?: number): void;
  64020. /**
  64021. * Get the time step of the physics engine.
  64022. * @returns the current time step
  64023. */
  64024. getTimeStep(): number;
  64025. /**
  64026. * Set the sub time step of the physics engine.
  64027. * Default is 0 meaning there is no sub steps
  64028. * To increase physics resolution precision, set a small value (like 1 ms)
  64029. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64030. */
  64031. setSubTimeStep(subTimeStep?: number): void;
  64032. /**
  64033. * Get the sub time step of the physics engine.
  64034. * @returns the current sub time step
  64035. */
  64036. getSubTimeStep(): number;
  64037. /**
  64038. * Release all resources
  64039. */
  64040. dispose(): void;
  64041. /**
  64042. * Gets the name of the current physics plugin
  64043. * @returns the name of the plugin
  64044. */
  64045. getPhysicsPluginName(): string;
  64046. /**
  64047. * Adding a new impostor for the impostor tracking.
  64048. * This will be done by the impostor itself.
  64049. * @param impostor the impostor to add
  64050. */
  64051. addImpostor(impostor: PhysicsImpostor): void;
  64052. /**
  64053. * Remove an impostor from the engine.
  64054. * This impostor and its mesh will not longer be updated by the physics engine.
  64055. * @param impostor the impostor to remove
  64056. */
  64057. removeImpostor(impostor: PhysicsImpostor): void;
  64058. /**
  64059. * Add a joint to the physics engine
  64060. * @param mainImpostor defines the main impostor to which the joint is added.
  64061. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64062. * @param joint defines the joint that will connect both impostors.
  64063. */
  64064. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64065. /**
  64066. * Removes a joint from the simulation
  64067. * @param mainImpostor defines the impostor used with the joint
  64068. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64069. * @param joint defines the joint to remove
  64070. */
  64071. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64072. /**
  64073. * Called by the scene. No need to call it.
  64074. * @param delta defines the timespam between frames
  64075. */
  64076. _step(delta: number): void;
  64077. /**
  64078. * Gets the current plugin used to run the simulation
  64079. * @returns current plugin
  64080. */
  64081. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64082. /**
  64083. * Gets the list of physic impostors
  64084. * @returns an array of PhysicsImpostor
  64085. */
  64086. getImpostors(): Array<PhysicsImpostor>;
  64087. /**
  64088. * Gets the impostor for a physics enabled object
  64089. * @param object defines the object impersonated by the impostor
  64090. * @returns the PhysicsImpostor or null if not found
  64091. */
  64092. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64093. /**
  64094. * Gets the impostor for a physics body object
  64095. * @param body defines physics body used by the impostor
  64096. * @returns the PhysicsImpostor or null if not found
  64097. */
  64098. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64099. /**
  64100. * Does a raycast in the physics world
  64101. * @param from when should the ray start?
  64102. * @param to when should the ray end?
  64103. * @returns PhysicsRaycastResult
  64104. */
  64105. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64106. }
  64107. }
  64108. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  64109. import { Nullable } from "babylonjs/types";
  64110. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64112. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64113. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64114. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64115. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64116. /** @hidden */
  64117. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64118. private _useDeltaForWorldStep;
  64119. world: any;
  64120. name: string;
  64121. private _physicsMaterials;
  64122. private _fixedTimeStep;
  64123. private _cannonRaycastResult;
  64124. private _raycastResult;
  64125. private _physicsBodysToRemoveAfterStep;
  64126. private _firstFrame;
  64127. BJSCANNON: any;
  64128. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64129. setGravity(gravity: Vector3): void;
  64130. setTimeStep(timeStep: number): void;
  64131. getTimeStep(): number;
  64132. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64133. private _removeMarkedPhysicsBodiesFromWorld;
  64134. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64135. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64136. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64137. private _processChildMeshes;
  64138. removePhysicsBody(impostor: PhysicsImpostor): void;
  64139. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64140. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64141. private _addMaterial;
  64142. private _checkWithEpsilon;
  64143. private _createShape;
  64144. private _createHeightmap;
  64145. private _minus90X;
  64146. private _plus90X;
  64147. private _tmpPosition;
  64148. private _tmpDeltaPosition;
  64149. private _tmpUnityRotation;
  64150. private _updatePhysicsBodyTransformation;
  64151. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64152. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64153. isSupported(): boolean;
  64154. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64155. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64156. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64157. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64158. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64159. getBodyMass(impostor: PhysicsImpostor): number;
  64160. getBodyFriction(impostor: PhysicsImpostor): number;
  64161. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64162. getBodyRestitution(impostor: PhysicsImpostor): number;
  64163. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64164. sleepBody(impostor: PhysicsImpostor): void;
  64165. wakeUpBody(impostor: PhysicsImpostor): void;
  64166. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  64167. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64168. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64169. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64170. getRadius(impostor: PhysicsImpostor): number;
  64171. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64172. dispose(): void;
  64173. private _extendNamespace;
  64174. /**
  64175. * Does a raycast in the physics world
  64176. * @param from when should the ray start?
  64177. * @param to when should the ray end?
  64178. * @returns PhysicsRaycastResult
  64179. */
  64180. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64181. }
  64182. }
  64183. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  64184. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64185. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64186. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64188. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64189. import { Nullable } from "babylonjs/types";
  64190. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64191. /** @hidden */
  64192. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  64193. private _useDeltaForWorldStep;
  64194. world: any;
  64195. name: string;
  64196. BJSOIMO: any;
  64197. private _raycastResult;
  64198. private _fixedTimeStep;
  64199. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  64200. setGravity(gravity: Vector3): void;
  64201. setTimeStep(timeStep: number): void;
  64202. getTimeStep(): number;
  64203. private _tmpImpostorsArray;
  64204. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64205. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64206. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64207. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64208. private _tmpPositionVector;
  64209. removePhysicsBody(impostor: PhysicsImpostor): void;
  64210. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64211. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64212. isSupported(): boolean;
  64213. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64214. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64215. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64216. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64217. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64218. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64219. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64220. getBodyMass(impostor: PhysicsImpostor): number;
  64221. getBodyFriction(impostor: PhysicsImpostor): number;
  64222. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64223. getBodyRestitution(impostor: PhysicsImpostor): number;
  64224. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64225. sleepBody(impostor: PhysicsImpostor): void;
  64226. wakeUpBody(impostor: PhysicsImpostor): void;
  64227. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64228. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  64229. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  64230. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64231. getRadius(impostor: PhysicsImpostor): number;
  64232. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64233. dispose(): void;
  64234. /**
  64235. * Does a raycast in the physics world
  64236. * @param from when should the ray start?
  64237. * @param to when should the ray end?
  64238. * @returns PhysicsRaycastResult
  64239. */
  64240. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64241. }
  64242. }
  64243. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  64244. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  64245. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64246. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64247. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64248. import { Nullable } from "babylonjs/types";
  64249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64250. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64251. /**
  64252. * AmmoJS Physics plugin
  64253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64254. * @see https://github.com/kripken/ammo.js/
  64255. */
  64256. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  64257. private _useDeltaForWorldStep;
  64258. /**
  64259. * Reference to the Ammo library
  64260. */
  64261. bjsAMMO: any;
  64262. /**
  64263. * Created ammoJS world which physics bodies are added to
  64264. */
  64265. world: any;
  64266. /**
  64267. * Name of the plugin
  64268. */
  64269. name: string;
  64270. private _timeStep;
  64271. private _fixedTimeStep;
  64272. private _maxSteps;
  64273. private _tmpQuaternion;
  64274. private _tmpAmmoTransform;
  64275. private _tmpAmmoQuaternion;
  64276. private _tmpAmmoConcreteContactResultCallback;
  64277. private _collisionConfiguration;
  64278. private _dispatcher;
  64279. private _overlappingPairCache;
  64280. private _solver;
  64281. private _softBodySolver;
  64282. private _tmpAmmoVectorA;
  64283. private _tmpAmmoVectorB;
  64284. private _tmpAmmoVectorC;
  64285. private _tmpAmmoVectorD;
  64286. private _tmpContactCallbackResult;
  64287. private _tmpAmmoVectorRCA;
  64288. private _tmpAmmoVectorRCB;
  64289. private _raycastResult;
  64290. private static readonly DISABLE_COLLISION_FLAG;
  64291. private static readonly KINEMATIC_FLAG;
  64292. private static readonly DISABLE_DEACTIVATION_FLAG;
  64293. /**
  64294. * Initializes the ammoJS plugin
  64295. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  64296. * @param ammoInjection can be used to inject your own ammo reference
  64297. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  64298. */
  64299. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  64300. /**
  64301. * Sets the gravity of the physics world (m/(s^2))
  64302. * @param gravity Gravity to set
  64303. */
  64304. setGravity(gravity: Vector3): void;
  64305. /**
  64306. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  64307. * @param timeStep timestep to use in seconds
  64308. */
  64309. setTimeStep(timeStep: number): void;
  64310. /**
  64311. * 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)
  64312. * @param fixedTimeStep fixedTimeStep to use in seconds
  64313. */
  64314. setFixedTimeStep(fixedTimeStep: number): void;
  64315. /**
  64316. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  64317. * @param maxSteps the maximum number of steps by the physics engine per frame
  64318. */
  64319. setMaxSteps(maxSteps: number): void;
  64320. /**
  64321. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  64322. * @returns the current timestep in seconds
  64323. */
  64324. getTimeStep(): number;
  64325. /**
  64326. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  64327. */
  64328. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  64329. private _isImpostorInContact;
  64330. private _isImpostorPairInContact;
  64331. private _stepSimulation;
  64332. /**
  64333. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  64334. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  64335. * After the step the babylon meshes are set to the position of the physics imposters
  64336. * @param delta amount of time to step forward
  64337. * @param impostors array of imposters to update before/after the step
  64338. */
  64339. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64340. /**
  64341. * Update babylon mesh to match physics world object
  64342. * @param impostor imposter to match
  64343. */
  64344. private _afterSoftStep;
  64345. /**
  64346. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64347. * @param impostor imposter to match
  64348. */
  64349. private _ropeStep;
  64350. /**
  64351. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64352. * @param impostor imposter to match
  64353. */
  64354. private _softbodyOrClothStep;
  64355. private _tmpMatrix;
  64356. /**
  64357. * Applies an impulse on the imposter
  64358. * @param impostor imposter to apply impulse to
  64359. * @param force amount of force to be applied to the imposter
  64360. * @param contactPoint the location to apply the impulse on the imposter
  64361. */
  64362. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64363. /**
  64364. * Applies a force on the imposter
  64365. * @param impostor imposter to apply force
  64366. * @param force amount of force to be applied to the imposter
  64367. * @param contactPoint the location to apply the force on the imposter
  64368. */
  64369. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64370. /**
  64371. * Creates a physics body using the plugin
  64372. * @param impostor the imposter to create the physics body on
  64373. */
  64374. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64375. /**
  64376. * Removes the physics body from the imposter and disposes of the body's memory
  64377. * @param impostor imposter to remove the physics body from
  64378. */
  64379. removePhysicsBody(impostor: PhysicsImpostor): void;
  64380. /**
  64381. * Generates a joint
  64382. * @param impostorJoint the imposter joint to create the joint with
  64383. */
  64384. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64385. /**
  64386. * Removes a joint
  64387. * @param impostorJoint the imposter joint to remove the joint from
  64388. */
  64389. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64390. private _addMeshVerts;
  64391. /**
  64392. * Initialise the soft body vertices to match its object's (mesh) vertices
  64393. * Softbody vertices (nodes) are in world space and to match this
  64394. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  64395. * @param impostor to create the softbody for
  64396. */
  64397. private _softVertexData;
  64398. /**
  64399. * Create an impostor's soft body
  64400. * @param impostor to create the softbody for
  64401. */
  64402. private _createSoftbody;
  64403. /**
  64404. * Create cloth for an impostor
  64405. * @param impostor to create the softbody for
  64406. */
  64407. private _createCloth;
  64408. /**
  64409. * Create rope for an impostor
  64410. * @param impostor to create the softbody for
  64411. */
  64412. private _createRope;
  64413. /**
  64414. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  64415. * @param impostor to create the custom physics shape for
  64416. */
  64417. private _createCustom;
  64418. private _addHullVerts;
  64419. private _createShape;
  64420. /**
  64421. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  64422. * @param impostor imposter containing the physics body and babylon object
  64423. */
  64424. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64425. /**
  64426. * Sets the babylon object's position/rotation from the physics body's position/rotation
  64427. * @param impostor imposter containing the physics body and babylon object
  64428. * @param newPosition new position
  64429. * @param newRotation new rotation
  64430. */
  64431. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64432. /**
  64433. * If this plugin is supported
  64434. * @returns true if its supported
  64435. */
  64436. isSupported(): boolean;
  64437. /**
  64438. * Sets the linear velocity of the physics body
  64439. * @param impostor imposter to set the velocity on
  64440. * @param velocity velocity to set
  64441. */
  64442. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64443. /**
  64444. * Sets the angular velocity of the physics body
  64445. * @param impostor imposter to set the velocity on
  64446. * @param velocity velocity to set
  64447. */
  64448. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64449. /**
  64450. * gets the linear velocity
  64451. * @param impostor imposter to get linear velocity from
  64452. * @returns linear velocity
  64453. */
  64454. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64455. /**
  64456. * gets the angular velocity
  64457. * @param impostor imposter to get angular velocity from
  64458. * @returns angular velocity
  64459. */
  64460. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64461. /**
  64462. * Sets the mass of physics body
  64463. * @param impostor imposter to set the mass on
  64464. * @param mass mass to set
  64465. */
  64466. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64467. /**
  64468. * Gets the mass of the physics body
  64469. * @param impostor imposter to get the mass from
  64470. * @returns mass
  64471. */
  64472. getBodyMass(impostor: PhysicsImpostor): number;
  64473. /**
  64474. * Gets friction of the impostor
  64475. * @param impostor impostor to get friction from
  64476. * @returns friction value
  64477. */
  64478. getBodyFriction(impostor: PhysicsImpostor): number;
  64479. /**
  64480. * Sets friction of the impostor
  64481. * @param impostor impostor to set friction on
  64482. * @param friction friction value
  64483. */
  64484. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64485. /**
  64486. * Gets restitution of the impostor
  64487. * @param impostor impostor to get restitution from
  64488. * @returns restitution value
  64489. */
  64490. getBodyRestitution(impostor: PhysicsImpostor): number;
  64491. /**
  64492. * Sets resitution of the impostor
  64493. * @param impostor impostor to set resitution on
  64494. * @param restitution resitution value
  64495. */
  64496. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64497. /**
  64498. * Gets pressure inside the impostor
  64499. * @param impostor impostor to get pressure from
  64500. * @returns pressure value
  64501. */
  64502. getBodyPressure(impostor: PhysicsImpostor): number;
  64503. /**
  64504. * Sets pressure inside a soft body impostor
  64505. * Cloth and rope must remain 0 pressure
  64506. * @param impostor impostor to set pressure on
  64507. * @param pressure pressure value
  64508. */
  64509. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64510. /**
  64511. * Gets stiffness of the impostor
  64512. * @param impostor impostor to get stiffness from
  64513. * @returns pressure value
  64514. */
  64515. getBodyStiffness(impostor: PhysicsImpostor): number;
  64516. /**
  64517. * Sets stiffness of the impostor
  64518. * @param impostor impostor to set stiffness on
  64519. * @param stiffness stiffness value from 0 to 1
  64520. */
  64521. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64522. /**
  64523. * Gets velocityIterations of the impostor
  64524. * @param impostor impostor to get velocity iterations from
  64525. * @returns velocityIterations value
  64526. */
  64527. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64528. /**
  64529. * Sets velocityIterations of the impostor
  64530. * @param impostor impostor to set velocity iterations on
  64531. * @param velocityIterations velocityIterations value
  64532. */
  64533. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64534. /**
  64535. * Gets positionIterations of the impostor
  64536. * @param impostor impostor to get position iterations from
  64537. * @returns positionIterations value
  64538. */
  64539. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64540. /**
  64541. * Sets positionIterations of the impostor
  64542. * @param impostor impostor to set position on
  64543. * @param positionIterations positionIterations value
  64544. */
  64545. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64546. /**
  64547. * Append an anchor to a cloth object
  64548. * @param impostor is the cloth impostor to add anchor to
  64549. * @param otherImpostor is the rigid impostor to anchor to
  64550. * @param width ratio across width from 0 to 1
  64551. * @param height ratio up height from 0 to 1
  64552. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64553. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64554. */
  64555. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64556. /**
  64557. * Append an hook to a rope object
  64558. * @param impostor is the rope impostor to add hook to
  64559. * @param otherImpostor is the rigid impostor to hook to
  64560. * @param length ratio along the rope from 0 to 1
  64561. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64562. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64563. */
  64564. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64565. /**
  64566. * Sleeps the physics body and stops it from being active
  64567. * @param impostor impostor to sleep
  64568. */
  64569. sleepBody(impostor: PhysicsImpostor): void;
  64570. /**
  64571. * Activates the physics body
  64572. * @param impostor impostor to activate
  64573. */
  64574. wakeUpBody(impostor: PhysicsImpostor): void;
  64575. /**
  64576. * Updates the distance parameters of the joint
  64577. * @param joint joint to update
  64578. * @param maxDistance maximum distance of the joint
  64579. * @param minDistance minimum distance of the joint
  64580. */
  64581. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64582. /**
  64583. * Sets a motor on the joint
  64584. * @param joint joint to set motor on
  64585. * @param speed speed of the motor
  64586. * @param maxForce maximum force of the motor
  64587. * @param motorIndex index of the motor
  64588. */
  64589. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64590. /**
  64591. * Sets the motors limit
  64592. * @param joint joint to set limit on
  64593. * @param upperLimit upper limit
  64594. * @param lowerLimit lower limit
  64595. */
  64596. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64597. /**
  64598. * Syncs the position and rotation of a mesh with the impostor
  64599. * @param mesh mesh to sync
  64600. * @param impostor impostor to update the mesh with
  64601. */
  64602. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64603. /**
  64604. * Gets the radius of the impostor
  64605. * @param impostor impostor to get radius from
  64606. * @returns the radius
  64607. */
  64608. getRadius(impostor: PhysicsImpostor): number;
  64609. /**
  64610. * Gets the box size of the impostor
  64611. * @param impostor impostor to get box size from
  64612. * @param result the resulting box size
  64613. */
  64614. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64615. /**
  64616. * Disposes of the impostor
  64617. */
  64618. dispose(): void;
  64619. /**
  64620. * Does a raycast in the physics world
  64621. * @param from when should the ray start?
  64622. * @param to when should the ray end?
  64623. * @returns PhysicsRaycastResult
  64624. */
  64625. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64626. }
  64627. }
  64628. declare module "babylonjs/Probes/reflectionProbe" {
  64629. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64630. import { Vector3 } from "babylonjs/Maths/math.vector";
  64631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64632. import { Nullable } from "babylonjs/types";
  64633. import { Scene } from "babylonjs/scene";
  64634. module "babylonjs/abstractScene" {
  64635. interface AbstractScene {
  64636. /**
  64637. * The list of reflection probes added to the scene
  64638. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64639. */
  64640. reflectionProbes: Array<ReflectionProbe>;
  64641. /**
  64642. * Removes the given reflection probe from this scene.
  64643. * @param toRemove The reflection probe to remove
  64644. * @returns The index of the removed reflection probe
  64645. */
  64646. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64647. /**
  64648. * Adds the given reflection probe to this scene.
  64649. * @param newReflectionProbe The reflection probe to add
  64650. */
  64651. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64652. }
  64653. }
  64654. /**
  64655. * Class used to generate realtime reflection / refraction cube textures
  64656. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64657. */
  64658. export class ReflectionProbe {
  64659. /** defines the name of the probe */
  64660. name: string;
  64661. private _scene;
  64662. private _renderTargetTexture;
  64663. private _projectionMatrix;
  64664. private _viewMatrix;
  64665. private _target;
  64666. private _add;
  64667. private _attachedMesh;
  64668. private _invertYAxis;
  64669. /** Gets or sets probe position (center of the cube map) */
  64670. position: Vector3;
  64671. /**
  64672. * Creates a new reflection probe
  64673. * @param name defines the name of the probe
  64674. * @param size defines the texture resolution (for each face)
  64675. * @param scene defines the hosting scene
  64676. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64677. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64678. */
  64679. constructor(
  64680. /** defines the name of the probe */
  64681. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64682. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64683. get samples(): number;
  64684. set samples(value: number);
  64685. /** Gets or sets the refresh rate to use (on every frame by default) */
  64686. get refreshRate(): number;
  64687. set refreshRate(value: number);
  64688. /**
  64689. * Gets the hosting scene
  64690. * @returns a Scene
  64691. */
  64692. getScene(): Scene;
  64693. /** Gets the internal CubeTexture used to render to */
  64694. get cubeTexture(): RenderTargetTexture;
  64695. /** Gets the list of meshes to render */
  64696. get renderList(): Nullable<AbstractMesh[]>;
  64697. /**
  64698. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64699. * @param mesh defines the mesh to attach to
  64700. */
  64701. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64702. /**
  64703. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64704. * @param renderingGroupId The rendering group id corresponding to its index
  64705. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64706. */
  64707. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64708. /**
  64709. * Clean all associated resources
  64710. */
  64711. dispose(): void;
  64712. /**
  64713. * Converts the reflection probe information to a readable string for debug purpose.
  64714. * @param fullDetails Supports for multiple levels of logging within scene loading
  64715. * @returns the human readable reflection probe info
  64716. */
  64717. toString(fullDetails?: boolean): string;
  64718. /**
  64719. * Get the class name of the relfection probe.
  64720. * @returns "ReflectionProbe"
  64721. */
  64722. getClassName(): string;
  64723. /**
  64724. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64725. * @returns The JSON representation of the texture
  64726. */
  64727. serialize(): any;
  64728. /**
  64729. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64730. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64731. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64732. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64733. * @returns The parsed reflection probe if successful
  64734. */
  64735. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64736. }
  64737. }
  64738. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64739. /** @hidden */
  64740. export var _BabylonLoaderRegistered: boolean;
  64741. /**
  64742. * Helps setting up some configuration for the babylon file loader.
  64743. */
  64744. export class BabylonFileLoaderConfiguration {
  64745. /**
  64746. * The loader does not allow injecting custom physix engine into the plugins.
  64747. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64748. * So you could set this variable to your engine import to make it work.
  64749. */
  64750. static LoaderInjectedPhysicsEngine: any;
  64751. }
  64752. }
  64753. declare module "babylonjs/Loading/Plugins/index" {
  64754. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64755. }
  64756. declare module "babylonjs/Loading/index" {
  64757. export * from "babylonjs/Loading/loadingScreen";
  64758. export * from "babylonjs/Loading/Plugins/index";
  64759. export * from "babylonjs/Loading/sceneLoader";
  64760. export * from "babylonjs/Loading/sceneLoaderFlags";
  64761. }
  64762. declare module "babylonjs/Materials/Background/index" {
  64763. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64764. }
  64765. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64766. import { Scene } from "babylonjs/scene";
  64767. import { Color3 } from "babylonjs/Maths/math.color";
  64768. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64769. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64770. /**
  64771. * The Physically based simple base material of BJS.
  64772. *
  64773. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64774. * It is used as the base class for both the specGloss and metalRough conventions.
  64775. */
  64776. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64777. /**
  64778. * Number of Simultaneous lights allowed on the material.
  64779. */
  64780. maxSimultaneousLights: number;
  64781. /**
  64782. * If sets to true, disables all the lights affecting the material.
  64783. */
  64784. disableLighting: boolean;
  64785. /**
  64786. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64787. */
  64788. environmentTexture: BaseTexture;
  64789. /**
  64790. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64791. */
  64792. invertNormalMapX: boolean;
  64793. /**
  64794. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64795. */
  64796. invertNormalMapY: boolean;
  64797. /**
  64798. * Normal map used in the model.
  64799. */
  64800. normalTexture: BaseTexture;
  64801. /**
  64802. * Emissivie color used to self-illuminate the model.
  64803. */
  64804. emissiveColor: Color3;
  64805. /**
  64806. * Emissivie texture used to self-illuminate the model.
  64807. */
  64808. emissiveTexture: BaseTexture;
  64809. /**
  64810. * Occlusion Channel Strenght.
  64811. */
  64812. occlusionStrength: number;
  64813. /**
  64814. * Occlusion Texture of the material (adding extra occlusion effects).
  64815. */
  64816. occlusionTexture: BaseTexture;
  64817. /**
  64818. * Defines the alpha limits in alpha test mode.
  64819. */
  64820. alphaCutOff: number;
  64821. /**
  64822. * Gets the current double sided mode.
  64823. */
  64824. get doubleSided(): boolean;
  64825. /**
  64826. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64827. */
  64828. set doubleSided(value: boolean);
  64829. /**
  64830. * Stores the pre-calculated light information of a mesh in a texture.
  64831. */
  64832. lightmapTexture: BaseTexture;
  64833. /**
  64834. * If true, the light map contains occlusion information instead of lighting info.
  64835. */
  64836. useLightmapAsShadowmap: boolean;
  64837. /**
  64838. * Instantiates a new PBRMaterial instance.
  64839. *
  64840. * @param name The material name
  64841. * @param scene The scene the material will be use in.
  64842. */
  64843. constructor(name: string, scene: Scene);
  64844. getClassName(): string;
  64845. }
  64846. }
  64847. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64848. import { Scene } from "babylonjs/scene";
  64849. import { Color3 } from "babylonjs/Maths/math.color";
  64850. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64851. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64852. /**
  64853. * The PBR material of BJS following the metal roughness convention.
  64854. *
  64855. * This fits to the PBR convention in the GLTF definition:
  64856. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64857. */
  64858. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64859. /**
  64860. * The base color has two different interpretations depending on the value of metalness.
  64861. * When the material is a metal, the base color is the specific measured reflectance value
  64862. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64863. * of the material.
  64864. */
  64865. baseColor: Color3;
  64866. /**
  64867. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64868. * well as opacity information in the alpha channel.
  64869. */
  64870. baseTexture: BaseTexture;
  64871. /**
  64872. * Specifies the metallic scalar value of the material.
  64873. * Can also be used to scale the metalness values of the metallic texture.
  64874. */
  64875. metallic: number;
  64876. /**
  64877. * Specifies the roughness scalar value of the material.
  64878. * Can also be used to scale the roughness values of the metallic texture.
  64879. */
  64880. roughness: number;
  64881. /**
  64882. * Texture containing both the metallic value in the B channel and the
  64883. * roughness value in the G channel to keep better precision.
  64884. */
  64885. metallicRoughnessTexture: BaseTexture;
  64886. /**
  64887. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64888. *
  64889. * @param name The material name
  64890. * @param scene The scene the material will be use in.
  64891. */
  64892. constructor(name: string, scene: Scene);
  64893. /**
  64894. * Return the currrent class name of the material.
  64895. */
  64896. getClassName(): string;
  64897. /**
  64898. * Makes a duplicate of the current material.
  64899. * @param name - name to use for the new material.
  64900. */
  64901. clone(name: string): PBRMetallicRoughnessMaterial;
  64902. /**
  64903. * Serialize the material to a parsable JSON object.
  64904. */
  64905. serialize(): any;
  64906. /**
  64907. * Parses a JSON object correponding to the serialize function.
  64908. */
  64909. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64910. }
  64911. }
  64912. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64913. import { Scene } from "babylonjs/scene";
  64914. import { Color3 } from "babylonjs/Maths/math.color";
  64915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64916. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64917. /**
  64918. * The PBR material of BJS following the specular glossiness convention.
  64919. *
  64920. * This fits to the PBR convention in the GLTF definition:
  64921. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64922. */
  64923. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64924. /**
  64925. * Specifies the diffuse color of the material.
  64926. */
  64927. diffuseColor: Color3;
  64928. /**
  64929. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64930. * channel.
  64931. */
  64932. diffuseTexture: BaseTexture;
  64933. /**
  64934. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64935. */
  64936. specularColor: Color3;
  64937. /**
  64938. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64939. */
  64940. glossiness: number;
  64941. /**
  64942. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64943. */
  64944. specularGlossinessTexture: BaseTexture;
  64945. /**
  64946. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64947. *
  64948. * @param name The material name
  64949. * @param scene The scene the material will be use in.
  64950. */
  64951. constructor(name: string, scene: Scene);
  64952. /**
  64953. * Return the currrent class name of the material.
  64954. */
  64955. getClassName(): string;
  64956. /**
  64957. * Makes a duplicate of the current material.
  64958. * @param name - name to use for the new material.
  64959. */
  64960. clone(name: string): PBRSpecularGlossinessMaterial;
  64961. /**
  64962. * Serialize the material to a parsable JSON object.
  64963. */
  64964. serialize(): any;
  64965. /**
  64966. * Parses a JSON object correponding to the serialize function.
  64967. */
  64968. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64969. }
  64970. }
  64971. declare module "babylonjs/Materials/PBR/index" {
  64972. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64973. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64974. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64975. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64976. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64977. }
  64978. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64979. import { Nullable } from "babylonjs/types";
  64980. import { Scene } from "babylonjs/scene";
  64981. import { Matrix } from "babylonjs/Maths/math.vector";
  64982. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64983. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64984. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64985. /**
  64986. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64987. * It can help converting any input color in a desired output one. This can then be used to create effects
  64988. * from sepia, black and white to sixties or futuristic rendering...
  64989. *
  64990. * The only supported format is currently 3dl.
  64991. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64992. */
  64993. export class ColorGradingTexture extends BaseTexture {
  64994. /**
  64995. * The texture URL.
  64996. */
  64997. url: string;
  64998. /**
  64999. * Empty line regex stored for GC.
  65000. */
  65001. private static _noneEmptyLineRegex;
  65002. private _textureMatrix;
  65003. private _onLoad;
  65004. /**
  65005. * Instantiates a ColorGradingTexture from the following parameters.
  65006. *
  65007. * @param url The location of the color gradind data (currently only supporting 3dl)
  65008. * @param sceneOrEngine The scene or engine the texture will be used in
  65009. * @param onLoad defines a callback triggered when the texture has been loaded
  65010. */
  65011. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65012. /**
  65013. * Fires the onload event from the constructor if requested.
  65014. */
  65015. private _triggerOnLoad;
  65016. /**
  65017. * Returns the texture matrix used in most of the material.
  65018. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65019. */
  65020. getTextureMatrix(): Matrix;
  65021. /**
  65022. * Occurs when the file being loaded is a .3dl LUT file.
  65023. */
  65024. private load3dlTexture;
  65025. /**
  65026. * Starts the loading process of the texture.
  65027. */
  65028. private loadTexture;
  65029. /**
  65030. * Clones the color gradind texture.
  65031. */
  65032. clone(): ColorGradingTexture;
  65033. /**
  65034. * Called during delayed load for textures.
  65035. */
  65036. delayLoad(): void;
  65037. /**
  65038. * Parses a color grading texture serialized by Babylon.
  65039. * @param parsedTexture The texture information being parsedTexture
  65040. * @param scene The scene to load the texture in
  65041. * @param rootUrl The root url of the data assets to load
  65042. * @return A color gradind texture
  65043. */
  65044. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65045. /**
  65046. * Serializes the LUT texture to json format.
  65047. */
  65048. serialize(): any;
  65049. }
  65050. }
  65051. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  65052. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65053. import { Scene } from "babylonjs/scene";
  65054. import { Nullable } from "babylonjs/types";
  65055. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65056. /**
  65057. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65058. */
  65059. export class EquiRectangularCubeTexture extends BaseTexture {
  65060. /** The six faces of the cube. */
  65061. private static _FacesMapping;
  65062. private _noMipmap;
  65063. private _onLoad;
  65064. private _onError;
  65065. /** The size of the cubemap. */
  65066. private _size;
  65067. /** The buffer of the image. */
  65068. private _buffer;
  65069. /** The width of the input image. */
  65070. private _width;
  65071. /** The height of the input image. */
  65072. private _height;
  65073. /** The URL to the image. */
  65074. url: string;
  65075. /**
  65076. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65077. * @param url The location of the image
  65078. * @param scene The scene the texture will be used in
  65079. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65080. * @param noMipmap Forces to not generate the mipmap if true
  65081. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65082. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65083. * @param onLoad — defines a callback called when texture is loaded
  65084. * @param onError — defines a callback called if there is an error
  65085. */
  65086. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65087. /**
  65088. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65089. */
  65090. private loadImage;
  65091. /**
  65092. * Convert the image buffer into a cubemap and create a CubeTexture.
  65093. */
  65094. private loadTexture;
  65095. /**
  65096. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65097. * @param buffer The ArrayBuffer that should be converted.
  65098. * @returns The buffer as Float32Array.
  65099. */
  65100. private getFloat32ArrayFromArrayBuffer;
  65101. /**
  65102. * Get the current class name of the texture useful for serialization or dynamic coding.
  65103. * @returns "EquiRectangularCubeTexture"
  65104. */
  65105. getClassName(): string;
  65106. /**
  65107. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65108. * @returns A clone of the current EquiRectangularCubeTexture.
  65109. */
  65110. clone(): EquiRectangularCubeTexture;
  65111. }
  65112. }
  65113. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  65114. import { Nullable } from "babylonjs/types";
  65115. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65116. import { Matrix } from "babylonjs/Maths/math.vector";
  65117. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  65118. import "babylonjs/Engines/Extensions/engine.videoTexture";
  65119. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65120. import { Scene } from "babylonjs/scene";
  65121. /**
  65122. * Defines the options related to the creation of an HtmlElementTexture
  65123. */
  65124. export interface IHtmlElementTextureOptions {
  65125. /**
  65126. * Defines wether mip maps should be created or not.
  65127. */
  65128. generateMipMaps?: boolean;
  65129. /**
  65130. * Defines the sampling mode of the texture.
  65131. */
  65132. samplingMode?: number;
  65133. /**
  65134. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  65135. */
  65136. engine: Nullable<ThinEngine>;
  65137. /**
  65138. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  65139. */
  65140. scene: Nullable<Scene>;
  65141. }
  65142. /**
  65143. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  65144. * To be as efficient as possible depending on your constraints nothing aside the first upload
  65145. * is automatically managed.
  65146. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  65147. * in your application.
  65148. *
  65149. * As the update is not automatic, you need to call them manually.
  65150. */
  65151. export class HtmlElementTexture extends BaseTexture {
  65152. /**
  65153. * The texture URL.
  65154. */
  65155. element: HTMLVideoElement | HTMLCanvasElement;
  65156. private static readonly DefaultOptions;
  65157. private _textureMatrix;
  65158. private _isVideo;
  65159. private _generateMipMaps;
  65160. private _samplingMode;
  65161. /**
  65162. * Instantiates a HtmlElementTexture from the following parameters.
  65163. *
  65164. * @param name Defines the name of the texture
  65165. * @param element Defines the video or canvas the texture is filled with
  65166. * @param options Defines the other none mandatory texture creation options
  65167. */
  65168. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  65169. private _createInternalTexture;
  65170. /**
  65171. * Returns the texture matrix used in most of the material.
  65172. */
  65173. getTextureMatrix(): Matrix;
  65174. /**
  65175. * Updates the content of the texture.
  65176. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  65177. */
  65178. update(invertY?: Nullable<boolean>): void;
  65179. }
  65180. }
  65181. declare module "babylonjs/Misc/tga" {
  65182. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65183. /**
  65184. * Based on jsTGALoader - Javascript loader for TGA file
  65185. * By Vincent Thibault
  65186. * @see http://blog.robrowser.com/javascript-tga-loader.html
  65187. */
  65188. export class TGATools {
  65189. private static _TYPE_INDEXED;
  65190. private static _TYPE_RGB;
  65191. private static _TYPE_GREY;
  65192. private static _TYPE_RLE_INDEXED;
  65193. private static _TYPE_RLE_RGB;
  65194. private static _TYPE_RLE_GREY;
  65195. private static _ORIGIN_MASK;
  65196. private static _ORIGIN_SHIFT;
  65197. private static _ORIGIN_BL;
  65198. private static _ORIGIN_BR;
  65199. private static _ORIGIN_UL;
  65200. private static _ORIGIN_UR;
  65201. /**
  65202. * Gets the header of a TGA file
  65203. * @param data defines the TGA data
  65204. * @returns the header
  65205. */
  65206. static GetTGAHeader(data: Uint8Array): any;
  65207. /**
  65208. * Uploads TGA content to a Babylon Texture
  65209. * @hidden
  65210. */
  65211. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  65212. /** @hidden */
  65213. 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;
  65214. /** @hidden */
  65215. 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;
  65216. /** @hidden */
  65217. 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;
  65218. /** @hidden */
  65219. 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;
  65220. /** @hidden */
  65221. 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;
  65222. /** @hidden */
  65223. 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;
  65224. }
  65225. }
  65226. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  65227. import { Nullable } from "babylonjs/types";
  65228. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65229. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65230. /**
  65231. * Implementation of the TGA Texture Loader.
  65232. * @hidden
  65233. */
  65234. export class _TGATextureLoader implements IInternalTextureLoader {
  65235. /**
  65236. * Defines wether the loader supports cascade loading the different faces.
  65237. */
  65238. readonly supportCascades: boolean;
  65239. /**
  65240. * This returns if the loader support the current file information.
  65241. * @param extension defines the file extension of the file being loaded
  65242. * @returns true if the loader can load the specified file
  65243. */
  65244. canLoad(extension: string): boolean;
  65245. /**
  65246. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65247. * @param data contains the texture data
  65248. * @param texture defines the BabylonJS internal texture
  65249. * @param createPolynomials will be true if polynomials have been requested
  65250. * @param onLoad defines the callback to trigger once the texture is ready
  65251. * @param onError defines the callback to trigger in case of error
  65252. */
  65253. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65254. /**
  65255. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65256. * @param data contains the texture data
  65257. * @param texture defines the BabylonJS internal texture
  65258. * @param callback defines the method to call once ready to upload
  65259. */
  65260. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65261. }
  65262. }
  65263. declare module "babylonjs/Misc/basis" {
  65264. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65265. /**
  65266. * Info about the .basis files
  65267. */
  65268. class BasisFileInfo {
  65269. /**
  65270. * If the file has alpha
  65271. */
  65272. hasAlpha: boolean;
  65273. /**
  65274. * Info about each image of the basis file
  65275. */
  65276. images: Array<{
  65277. levels: Array<{
  65278. width: number;
  65279. height: number;
  65280. transcodedPixels: ArrayBufferView;
  65281. }>;
  65282. }>;
  65283. }
  65284. /**
  65285. * Result of transcoding a basis file
  65286. */
  65287. class TranscodeResult {
  65288. /**
  65289. * Info about the .basis file
  65290. */
  65291. fileInfo: BasisFileInfo;
  65292. /**
  65293. * Format to use when loading the file
  65294. */
  65295. format: number;
  65296. }
  65297. /**
  65298. * Configuration options for the Basis transcoder
  65299. */
  65300. export class BasisTranscodeConfiguration {
  65301. /**
  65302. * Supported compression formats used to determine the supported output format of the transcoder
  65303. */
  65304. supportedCompressionFormats?: {
  65305. /**
  65306. * etc1 compression format
  65307. */
  65308. etc1?: boolean;
  65309. /**
  65310. * s3tc compression format
  65311. */
  65312. s3tc?: boolean;
  65313. /**
  65314. * pvrtc compression format
  65315. */
  65316. pvrtc?: boolean;
  65317. /**
  65318. * etc2 compression format
  65319. */
  65320. etc2?: boolean;
  65321. };
  65322. /**
  65323. * If mipmap levels should be loaded for transcoded images (Default: true)
  65324. */
  65325. loadMipmapLevels?: boolean;
  65326. /**
  65327. * Index of a single image to load (Default: all images)
  65328. */
  65329. loadSingleImage?: number;
  65330. }
  65331. /**
  65332. * Used to load .Basis files
  65333. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65334. */
  65335. export class BasisTools {
  65336. private static _IgnoreSupportedFormats;
  65337. /**
  65338. * URL to use when loading the basis transcoder
  65339. */
  65340. static JSModuleURL: string;
  65341. /**
  65342. * URL to use when loading the wasm module for the transcoder
  65343. */
  65344. static WasmModuleURL: string;
  65345. /**
  65346. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  65347. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  65348. * @returns internal format corresponding to the Basis format
  65349. */
  65350. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  65351. private static _WorkerPromise;
  65352. private static _Worker;
  65353. private static _actionId;
  65354. private static _CreateWorkerAsync;
  65355. /**
  65356. * Transcodes a loaded image file to compressed pixel data
  65357. * @param data image data to transcode
  65358. * @param config configuration options for the transcoding
  65359. * @returns a promise resulting in the transcoded image
  65360. */
  65361. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  65362. /**
  65363. * Loads a texture from the transcode result
  65364. * @param texture texture load to
  65365. * @param transcodeResult the result of transcoding the basis file to load from
  65366. */
  65367. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  65368. }
  65369. }
  65370. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  65371. import { Nullable } from "babylonjs/types";
  65372. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65373. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65374. /**
  65375. * Loader for .basis file format
  65376. */
  65377. export class _BasisTextureLoader implements IInternalTextureLoader {
  65378. /**
  65379. * Defines whether the loader supports cascade loading the different faces.
  65380. */
  65381. readonly supportCascades: boolean;
  65382. /**
  65383. * This returns if the loader support the current file information.
  65384. * @param extension defines the file extension of the file being loaded
  65385. * @returns true if the loader can load the specified file
  65386. */
  65387. canLoad(extension: string): boolean;
  65388. /**
  65389. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65390. * @param data contains the texture data
  65391. * @param texture defines the BabylonJS internal texture
  65392. * @param createPolynomials will be true if polynomials have been requested
  65393. * @param onLoad defines the callback to trigger once the texture is ready
  65394. * @param onError defines the callback to trigger in case of error
  65395. */
  65396. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65397. /**
  65398. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65399. * @param data contains the texture data
  65400. * @param texture defines the BabylonJS internal texture
  65401. * @param callback defines the method to call once ready to upload
  65402. */
  65403. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65404. }
  65405. }
  65406. declare module "babylonjs/Materials/Textures/Loaders/index" {
  65407. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65408. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65409. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65410. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  65411. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  65412. }
  65413. declare module "babylonjs/Materials/Textures/Packer/frame" {
  65414. import { Vector2 } from "babylonjs/Maths/math.vector";
  65415. /**
  65416. * Defines the basic options interface of a TexturePacker Frame
  65417. */
  65418. export interface ITexturePackerFrame {
  65419. /**
  65420. * The frame ID
  65421. */
  65422. id: number;
  65423. /**
  65424. * The frames Scale
  65425. */
  65426. scale: Vector2;
  65427. /**
  65428. * The Frames offset
  65429. */
  65430. offset: Vector2;
  65431. }
  65432. /**
  65433. * This is a support class for frame Data on texture packer sets.
  65434. */
  65435. export class TexturePackerFrame implements ITexturePackerFrame {
  65436. /**
  65437. * The frame ID
  65438. */
  65439. id: number;
  65440. /**
  65441. * The frames Scale
  65442. */
  65443. scale: Vector2;
  65444. /**
  65445. * The Frames offset
  65446. */
  65447. offset: Vector2;
  65448. /**
  65449. * Initializes a texture package frame.
  65450. * @param id The numerical frame identifier
  65451. * @param scale Scalar Vector2 for UV frame
  65452. * @param offset Vector2 for the frame position in UV units.
  65453. * @returns TexturePackerFrame
  65454. */
  65455. constructor(id: number, scale: Vector2, offset: Vector2);
  65456. }
  65457. }
  65458. declare module "babylonjs/Materials/Textures/Packer/packer" {
  65459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65460. import { Scene } from "babylonjs/scene";
  65461. import { Nullable } from "babylonjs/types";
  65462. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  65463. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  65464. /**
  65465. * Defines the basic options interface of a TexturePacker
  65466. */
  65467. export interface ITexturePackerOptions {
  65468. /**
  65469. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  65470. */
  65471. map?: string[];
  65472. /**
  65473. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65474. */
  65475. uvsIn?: string;
  65476. /**
  65477. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65478. */
  65479. uvsOut?: string;
  65480. /**
  65481. * number representing the layout style. Defaults to LAYOUT_STRIP
  65482. */
  65483. layout?: number;
  65484. /**
  65485. * number of columns if using custom column count layout(2). This defaults to 4.
  65486. */
  65487. colnum?: number;
  65488. /**
  65489. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65490. */
  65491. updateInputMeshes?: boolean;
  65492. /**
  65493. * boolean flag to dispose all the source textures. Defaults to true.
  65494. */
  65495. disposeSources?: boolean;
  65496. /**
  65497. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65498. */
  65499. fillBlanks?: boolean;
  65500. /**
  65501. * string value representing the context fill style color. Defaults to 'black'.
  65502. */
  65503. customFillColor?: string;
  65504. /**
  65505. * Width and Height Value of each Frame in the TexturePacker Sets
  65506. */
  65507. frameSize?: number;
  65508. /**
  65509. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65510. */
  65511. paddingRatio?: number;
  65512. /**
  65513. * Number that declares the fill method for the padding gutter.
  65514. */
  65515. paddingMode?: number;
  65516. /**
  65517. * If in SUBUV_COLOR padding mode what color to use.
  65518. */
  65519. paddingColor?: Color3 | Color4;
  65520. }
  65521. /**
  65522. * Defines the basic interface of a TexturePacker JSON File
  65523. */
  65524. export interface ITexturePackerJSON {
  65525. /**
  65526. * The frame ID
  65527. */
  65528. name: string;
  65529. /**
  65530. * The base64 channel data
  65531. */
  65532. sets: any;
  65533. /**
  65534. * The options of the Packer
  65535. */
  65536. options: ITexturePackerOptions;
  65537. /**
  65538. * The frame data of the Packer
  65539. */
  65540. frames: Array<number>;
  65541. }
  65542. /**
  65543. * This is a support class that generates a series of packed texture sets.
  65544. * @see https://doc.babylonjs.com/babylon101/materials
  65545. */
  65546. export class TexturePacker {
  65547. /** Packer Layout Constant 0 */
  65548. static readonly LAYOUT_STRIP: number;
  65549. /** Packer Layout Constant 1 */
  65550. static readonly LAYOUT_POWER2: number;
  65551. /** Packer Layout Constant 2 */
  65552. static readonly LAYOUT_COLNUM: number;
  65553. /** Packer Layout Constant 0 */
  65554. static readonly SUBUV_WRAP: number;
  65555. /** Packer Layout Constant 1 */
  65556. static readonly SUBUV_EXTEND: number;
  65557. /** Packer Layout Constant 2 */
  65558. static readonly SUBUV_COLOR: number;
  65559. /** The Name of the Texture Package */
  65560. name: string;
  65561. /** The scene scope of the TexturePacker */
  65562. scene: Scene;
  65563. /** The Meshes to target */
  65564. meshes: AbstractMesh[];
  65565. /** Arguments passed with the Constructor */
  65566. options: ITexturePackerOptions;
  65567. /** The promise that is started upon initialization */
  65568. promise: Nullable<Promise<TexturePacker | string>>;
  65569. /** The Container object for the channel sets that are generated */
  65570. sets: object;
  65571. /** The Container array for the frames that are generated */
  65572. frames: TexturePackerFrame[];
  65573. /** The expected number of textures the system is parsing. */
  65574. private _expecting;
  65575. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65576. private _paddingValue;
  65577. /**
  65578. * Initializes a texture package series from an array of meshes or a single mesh.
  65579. * @param name The name of the package
  65580. * @param meshes The target meshes to compose the package from
  65581. * @param options The arguments that texture packer should follow while building.
  65582. * @param scene The scene which the textures are scoped to.
  65583. * @returns TexturePacker
  65584. */
  65585. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65586. /**
  65587. * Starts the package process
  65588. * @param resolve The promises resolution function
  65589. * @returns TexturePacker
  65590. */
  65591. private _createFrames;
  65592. /**
  65593. * Calculates the Size of the Channel Sets
  65594. * @returns Vector2
  65595. */
  65596. private _calculateSize;
  65597. /**
  65598. * Calculates the UV data for the frames.
  65599. * @param baseSize the base frameSize
  65600. * @param padding the base frame padding
  65601. * @param dtSize size of the Dynamic Texture for that channel
  65602. * @param dtUnits is 1/dtSize
  65603. * @param update flag to update the input meshes
  65604. */
  65605. private _calculateMeshUVFrames;
  65606. /**
  65607. * Calculates the frames Offset.
  65608. * @param index of the frame
  65609. * @returns Vector2
  65610. */
  65611. private _getFrameOffset;
  65612. /**
  65613. * Updates a Mesh to the frame data
  65614. * @param mesh that is the target
  65615. * @param frameID or the frame index
  65616. */
  65617. private _updateMeshUV;
  65618. /**
  65619. * Updates a Meshes materials to use the texture packer channels
  65620. * @param m is the mesh to target
  65621. * @param force all channels on the packer to be set.
  65622. */
  65623. private _updateTextureReferences;
  65624. /**
  65625. * Public method to set a Mesh to a frame
  65626. * @param m that is the target
  65627. * @param frameID or the frame index
  65628. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65629. */
  65630. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65631. /**
  65632. * Starts the async promise to compile the texture packer.
  65633. * @returns Promise<void>
  65634. */
  65635. processAsync(): Promise<void>;
  65636. /**
  65637. * Disposes all textures associated with this packer
  65638. */
  65639. dispose(): void;
  65640. /**
  65641. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65642. * @param imageType is the image type to use.
  65643. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65644. */
  65645. download(imageType?: string, quality?: number): void;
  65646. /**
  65647. * Public method to load a texturePacker JSON file.
  65648. * @param data of the JSON file in string format.
  65649. */
  65650. updateFromJSON(data: string): void;
  65651. }
  65652. }
  65653. declare module "babylonjs/Materials/Textures/Packer/index" {
  65654. export * from "babylonjs/Materials/Textures/Packer/packer";
  65655. export * from "babylonjs/Materials/Textures/Packer/frame";
  65656. }
  65657. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65658. import { Scene } from "babylonjs/scene";
  65659. import { Texture } from "babylonjs/Materials/Textures/texture";
  65660. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65661. /**
  65662. * 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.
  65663. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65664. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65665. */
  65666. export class CustomProceduralTexture extends ProceduralTexture {
  65667. private _animate;
  65668. private _time;
  65669. private _config;
  65670. private _texturePath;
  65671. /**
  65672. * Instantiates a new Custom Procedural Texture.
  65673. * 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.
  65674. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65675. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65676. * @param name Define the name of the texture
  65677. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65678. * @param size Define the size of the texture to create
  65679. * @param scene Define the scene the texture belongs to
  65680. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65681. * @param generateMipMaps Define if the texture should creates mip maps or not
  65682. */
  65683. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65684. private _loadJson;
  65685. /**
  65686. * Is the texture ready to be used ? (rendered at least once)
  65687. * @returns true if ready, otherwise, false.
  65688. */
  65689. isReady(): boolean;
  65690. /**
  65691. * Render the texture to its associated render target.
  65692. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65693. */
  65694. render(useCameraPostProcess?: boolean): void;
  65695. /**
  65696. * Update the list of dependant textures samplers in the shader.
  65697. */
  65698. updateTextures(): void;
  65699. /**
  65700. * Update the uniform values of the procedural texture in the shader.
  65701. */
  65702. updateShaderUniforms(): void;
  65703. /**
  65704. * Define if the texture animates or not.
  65705. */
  65706. get animate(): boolean;
  65707. set animate(value: boolean);
  65708. }
  65709. }
  65710. declare module "babylonjs/Shaders/noise.fragment" {
  65711. /** @hidden */
  65712. export var noisePixelShader: {
  65713. name: string;
  65714. shader: string;
  65715. };
  65716. }
  65717. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65718. import { Nullable } from "babylonjs/types";
  65719. import { Scene } from "babylonjs/scene";
  65720. import { Texture } from "babylonjs/Materials/Textures/texture";
  65721. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65722. import "babylonjs/Shaders/noise.fragment";
  65723. /**
  65724. * Class used to generate noise procedural textures
  65725. */
  65726. export class NoiseProceduralTexture extends ProceduralTexture {
  65727. /** Gets or sets the start time (default is 0) */
  65728. time: number;
  65729. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65730. brightness: number;
  65731. /** Defines the number of octaves to process */
  65732. octaves: number;
  65733. /** Defines the level of persistence (0.8 by default) */
  65734. persistence: number;
  65735. /** Gets or sets animation speed factor (default is 1) */
  65736. animationSpeedFactor: number;
  65737. /**
  65738. * Creates a new NoiseProceduralTexture
  65739. * @param name defines the name fo the texture
  65740. * @param size defines the size of the texture (default is 256)
  65741. * @param scene defines the hosting scene
  65742. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65743. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65744. */
  65745. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65746. private _updateShaderUniforms;
  65747. protected _getDefines(): string;
  65748. /** Generate the current state of the procedural texture */
  65749. render(useCameraPostProcess?: boolean): void;
  65750. /**
  65751. * Serializes this noise procedural texture
  65752. * @returns a serialized noise procedural texture object
  65753. */
  65754. serialize(): any;
  65755. /**
  65756. * Clone the texture.
  65757. * @returns the cloned texture
  65758. */
  65759. clone(): NoiseProceduralTexture;
  65760. /**
  65761. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65762. * @param parsedTexture defines parsed texture data
  65763. * @param scene defines the current scene
  65764. * @param rootUrl defines the root URL containing noise procedural texture information
  65765. * @returns a parsed NoiseProceduralTexture
  65766. */
  65767. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65768. }
  65769. }
  65770. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65771. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65772. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65773. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65774. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65775. }
  65776. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65777. import { Nullable } from "babylonjs/types";
  65778. import { Scene } from "babylonjs/scene";
  65779. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65780. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65781. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65782. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65783. /**
  65784. * Raw cube texture where the raw buffers are passed in
  65785. */
  65786. export class RawCubeTexture extends CubeTexture {
  65787. /**
  65788. * Creates a cube texture where the raw buffers are passed in.
  65789. * @param scene defines the scene the texture is attached to
  65790. * @param data defines the array of data to use to create each face
  65791. * @param size defines the size of the textures
  65792. * @param format defines the format of the data
  65793. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65794. * @param generateMipMaps defines if the engine should generate the mip levels
  65795. * @param invertY defines if data must be stored with Y axis inverted
  65796. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65797. * @param compression defines the compression used (null by default)
  65798. */
  65799. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65800. /**
  65801. * Updates the raw cube texture.
  65802. * @param data defines the data to store
  65803. * @param format defines the data format
  65804. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65805. * @param invertY defines if data must be stored with Y axis inverted
  65806. * @param compression defines the compression used (null by default)
  65807. * @param level defines which level of the texture to update
  65808. */
  65809. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65810. /**
  65811. * Updates a raw cube texture with RGBD encoded data.
  65812. * @param data defines the array of data [mipmap][face] to use to create each face
  65813. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65814. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65815. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65816. * @returns a promsie that resolves when the operation is complete
  65817. */
  65818. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65819. /**
  65820. * Clones the raw cube texture.
  65821. * @return a new cube texture
  65822. */
  65823. clone(): CubeTexture;
  65824. /** @hidden */
  65825. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65826. }
  65827. }
  65828. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65829. import { Scene } from "babylonjs/scene";
  65830. import { Texture } from "babylonjs/Materials/Textures/texture";
  65831. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65832. /**
  65833. * Class used to store 2D array textures containing user data
  65834. */
  65835. export class RawTexture2DArray extends Texture {
  65836. /** Gets or sets the texture format to use */
  65837. format: number;
  65838. /**
  65839. * Create a new RawTexture2DArray
  65840. * @param data defines the data of the texture
  65841. * @param width defines the width of the texture
  65842. * @param height defines the height of the texture
  65843. * @param depth defines the number of layers of the texture
  65844. * @param format defines the texture format to use
  65845. * @param scene defines the hosting scene
  65846. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65847. * @param invertY defines if texture must be stored with Y axis inverted
  65848. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65849. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65850. */
  65851. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65852. /** Gets or sets the texture format to use */
  65853. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65854. /**
  65855. * Update the texture with new data
  65856. * @param data defines the data to store in the texture
  65857. */
  65858. update(data: ArrayBufferView): void;
  65859. }
  65860. }
  65861. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65862. import { Scene } from "babylonjs/scene";
  65863. import { Texture } from "babylonjs/Materials/Textures/texture";
  65864. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65865. /**
  65866. * Class used to store 3D textures containing user data
  65867. */
  65868. export class RawTexture3D extends Texture {
  65869. /** Gets or sets the texture format to use */
  65870. format: number;
  65871. /**
  65872. * Create a new RawTexture3D
  65873. * @param data defines the data of the texture
  65874. * @param width defines the width of the texture
  65875. * @param height defines the height of the texture
  65876. * @param depth defines the depth of the texture
  65877. * @param format defines the texture format to use
  65878. * @param scene defines the hosting scene
  65879. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65880. * @param invertY defines if texture must be stored with Y axis inverted
  65881. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65882. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65883. */
  65884. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65885. /** Gets or sets the texture format to use */
  65886. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65887. /**
  65888. * Update the texture with new data
  65889. * @param data defines the data to store in the texture
  65890. */
  65891. update(data: ArrayBufferView): void;
  65892. }
  65893. }
  65894. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65895. import { Scene } from "babylonjs/scene";
  65896. import { Plane } from "babylonjs/Maths/math.plane";
  65897. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65898. /**
  65899. * Creates a refraction texture used by refraction channel of the standard material.
  65900. * It is like a mirror but to see through a material.
  65901. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65902. */
  65903. export class RefractionTexture extends RenderTargetTexture {
  65904. /**
  65905. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65906. * 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.
  65907. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65908. */
  65909. refractionPlane: Plane;
  65910. /**
  65911. * Define how deep under the surface we should see.
  65912. */
  65913. depth: number;
  65914. /**
  65915. * Creates a refraction texture used by refraction channel of the standard material.
  65916. * It is like a mirror but to see through a material.
  65917. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65918. * @param name Define the texture name
  65919. * @param size Define the size of the underlying texture
  65920. * @param scene Define the scene the refraction belongs to
  65921. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65922. */
  65923. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65924. /**
  65925. * Clone the refraction texture.
  65926. * @returns the cloned texture
  65927. */
  65928. clone(): RefractionTexture;
  65929. /**
  65930. * Serialize the texture to a JSON representation you could use in Parse later on
  65931. * @returns the serialized JSON representation
  65932. */
  65933. serialize(): any;
  65934. }
  65935. }
  65936. declare module "babylonjs/Materials/Textures/index" {
  65937. export * from "babylonjs/Materials/Textures/baseTexture";
  65938. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65939. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65940. export * from "babylonjs/Materials/Textures/cubeTexture";
  65941. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65942. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65943. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65944. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65945. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65946. export * from "babylonjs/Materials/Textures/internalTexture";
  65947. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65948. export * from "babylonjs/Materials/Textures/Loaders/index";
  65949. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65950. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65951. export * from "babylonjs/Materials/Textures/Packer/index";
  65952. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65953. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65954. export * from "babylonjs/Materials/Textures/rawTexture";
  65955. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65956. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65957. export * from "babylonjs/Materials/Textures/refractionTexture";
  65958. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65959. export * from "babylonjs/Materials/Textures/texture";
  65960. export * from "babylonjs/Materials/Textures/videoTexture";
  65961. }
  65962. declare module "babylonjs/Materials/Node/Enums/index" {
  65963. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65964. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65965. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65966. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65967. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65968. }
  65969. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65970. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65971. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65973. import { Mesh } from "babylonjs/Meshes/mesh";
  65974. import { Effect } from "babylonjs/Materials/effect";
  65975. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65976. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65977. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65978. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65979. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65980. /**
  65981. * Block used to add support for vertex skinning (bones)
  65982. */
  65983. export class BonesBlock extends NodeMaterialBlock {
  65984. /**
  65985. * Creates a new BonesBlock
  65986. * @param name defines the block name
  65987. */
  65988. constructor(name: string);
  65989. /**
  65990. * Initialize the block and prepare the context for build
  65991. * @param state defines the state that will be used for the build
  65992. */
  65993. initialize(state: NodeMaterialBuildState): void;
  65994. /**
  65995. * Gets the current class name
  65996. * @returns the class name
  65997. */
  65998. getClassName(): string;
  65999. /**
  66000. * Gets the matrix indices input component
  66001. */
  66002. get matricesIndices(): NodeMaterialConnectionPoint;
  66003. /**
  66004. * Gets the matrix weights input component
  66005. */
  66006. get matricesWeights(): NodeMaterialConnectionPoint;
  66007. /**
  66008. * Gets the extra matrix indices input component
  66009. */
  66010. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66011. /**
  66012. * Gets the extra matrix weights input component
  66013. */
  66014. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66015. /**
  66016. * Gets the world input component
  66017. */
  66018. get world(): NodeMaterialConnectionPoint;
  66019. /**
  66020. * Gets the output component
  66021. */
  66022. get output(): NodeMaterialConnectionPoint;
  66023. autoConfigure(material: NodeMaterial): void;
  66024. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66025. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66026. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66027. protected _buildBlock(state: NodeMaterialBuildState): this;
  66028. }
  66029. }
  66030. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  66031. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66032. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66033. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66035. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66036. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66037. /**
  66038. * Block used to add support for instances
  66039. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66040. */
  66041. export class InstancesBlock extends NodeMaterialBlock {
  66042. /**
  66043. * Creates a new InstancesBlock
  66044. * @param name defines the block name
  66045. */
  66046. constructor(name: string);
  66047. /**
  66048. * Gets the current class name
  66049. * @returns the class name
  66050. */
  66051. getClassName(): string;
  66052. /**
  66053. * Gets the first world row input component
  66054. */
  66055. get world0(): NodeMaterialConnectionPoint;
  66056. /**
  66057. * Gets the second world row input component
  66058. */
  66059. get world1(): NodeMaterialConnectionPoint;
  66060. /**
  66061. * Gets the third world row input component
  66062. */
  66063. get world2(): NodeMaterialConnectionPoint;
  66064. /**
  66065. * Gets the forth world row input component
  66066. */
  66067. get world3(): NodeMaterialConnectionPoint;
  66068. /**
  66069. * Gets the world input component
  66070. */
  66071. get world(): NodeMaterialConnectionPoint;
  66072. /**
  66073. * Gets the output component
  66074. */
  66075. get output(): NodeMaterialConnectionPoint;
  66076. /**
  66077. * Gets the isntanceID component
  66078. */
  66079. get instanceID(): NodeMaterialConnectionPoint;
  66080. autoConfigure(material: NodeMaterial): void;
  66081. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66082. protected _buildBlock(state: NodeMaterialBuildState): this;
  66083. }
  66084. }
  66085. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  66086. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66087. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66088. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66090. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66091. import { Effect } from "babylonjs/Materials/effect";
  66092. import { Mesh } from "babylonjs/Meshes/mesh";
  66093. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66094. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66095. /**
  66096. * Block used to add morph targets support to vertex shader
  66097. */
  66098. export class MorphTargetsBlock extends NodeMaterialBlock {
  66099. private _repeatableContentAnchor;
  66100. /**
  66101. * Create a new MorphTargetsBlock
  66102. * @param name defines the block name
  66103. */
  66104. constructor(name: string);
  66105. /**
  66106. * Gets the current class name
  66107. * @returns the class name
  66108. */
  66109. getClassName(): string;
  66110. /**
  66111. * Gets the position input component
  66112. */
  66113. get position(): NodeMaterialConnectionPoint;
  66114. /**
  66115. * Gets the normal input component
  66116. */
  66117. get normal(): NodeMaterialConnectionPoint;
  66118. /**
  66119. * Gets the tangent input component
  66120. */
  66121. get tangent(): NodeMaterialConnectionPoint;
  66122. /**
  66123. * Gets the tangent input component
  66124. */
  66125. get uv(): NodeMaterialConnectionPoint;
  66126. /**
  66127. * Gets the position output component
  66128. */
  66129. get positionOutput(): NodeMaterialConnectionPoint;
  66130. /**
  66131. * Gets the normal output component
  66132. */
  66133. get normalOutput(): NodeMaterialConnectionPoint;
  66134. /**
  66135. * Gets the tangent output component
  66136. */
  66137. get tangentOutput(): NodeMaterialConnectionPoint;
  66138. /**
  66139. * Gets the tangent output component
  66140. */
  66141. get uvOutput(): NodeMaterialConnectionPoint;
  66142. initialize(state: NodeMaterialBuildState): void;
  66143. autoConfigure(material: NodeMaterial): void;
  66144. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66145. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66146. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66147. protected _buildBlock(state: NodeMaterialBuildState): this;
  66148. }
  66149. }
  66150. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  66151. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66152. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66153. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66154. import { Nullable } from "babylonjs/types";
  66155. import { Scene } from "babylonjs/scene";
  66156. import { Effect } from "babylonjs/Materials/effect";
  66157. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66158. import { Mesh } from "babylonjs/Meshes/mesh";
  66159. import { Light } from "babylonjs/Lights/light";
  66160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66161. /**
  66162. * Block used to get data information from a light
  66163. */
  66164. export class LightInformationBlock extends NodeMaterialBlock {
  66165. private _lightDataUniformName;
  66166. private _lightColorUniformName;
  66167. private _lightTypeDefineName;
  66168. /**
  66169. * Gets or sets the light associated with this block
  66170. */
  66171. light: Nullable<Light>;
  66172. /**
  66173. * Creates a new LightInformationBlock
  66174. * @param name defines the block name
  66175. */
  66176. constructor(name: string);
  66177. /**
  66178. * Gets the current class name
  66179. * @returns the class name
  66180. */
  66181. getClassName(): string;
  66182. /**
  66183. * Gets the world position input component
  66184. */
  66185. get worldPosition(): NodeMaterialConnectionPoint;
  66186. /**
  66187. * Gets the direction output component
  66188. */
  66189. get direction(): NodeMaterialConnectionPoint;
  66190. /**
  66191. * Gets the direction output component
  66192. */
  66193. get color(): NodeMaterialConnectionPoint;
  66194. /**
  66195. * Gets the direction output component
  66196. */
  66197. get intensity(): NodeMaterialConnectionPoint;
  66198. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66199. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66200. protected _buildBlock(state: NodeMaterialBuildState): this;
  66201. serialize(): any;
  66202. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66203. }
  66204. }
  66205. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  66206. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  66207. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  66208. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  66209. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  66210. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  66211. }
  66212. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  66213. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66214. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66215. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66217. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66218. import { Effect } from "babylonjs/Materials/effect";
  66219. import { Mesh } from "babylonjs/Meshes/mesh";
  66220. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66221. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66222. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66223. /**
  66224. * Block used to add image processing support to fragment shader
  66225. */
  66226. export class ImageProcessingBlock extends NodeMaterialBlock {
  66227. /**
  66228. * Create a new ImageProcessingBlock
  66229. * @param name defines the block name
  66230. */
  66231. constructor(name: string);
  66232. /**
  66233. * Gets the current class name
  66234. * @returns the class name
  66235. */
  66236. getClassName(): string;
  66237. /**
  66238. * Gets the color input component
  66239. */
  66240. get color(): NodeMaterialConnectionPoint;
  66241. /**
  66242. * Gets the output component
  66243. */
  66244. get output(): NodeMaterialConnectionPoint;
  66245. /**
  66246. * Initialize the block and prepare the context for build
  66247. * @param state defines the state that will be used for the build
  66248. */
  66249. initialize(state: NodeMaterialBuildState): void;
  66250. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  66251. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66252. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66253. protected _buildBlock(state: NodeMaterialBuildState): this;
  66254. }
  66255. }
  66256. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  66257. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66258. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66259. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66260. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66262. import { Effect } from "babylonjs/Materials/effect";
  66263. import { Mesh } from "babylonjs/Meshes/mesh";
  66264. import { Scene } from "babylonjs/scene";
  66265. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  66266. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  66267. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  66268. /**
  66269. * Block used to pertub normals based on a normal map
  66270. */
  66271. export class PerturbNormalBlock extends NodeMaterialBlock {
  66272. private _tangentSpaceParameterName;
  66273. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66274. invertX: boolean;
  66275. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  66276. invertY: boolean;
  66277. /**
  66278. * Create a new PerturbNormalBlock
  66279. * @param name defines the block name
  66280. */
  66281. constructor(name: string);
  66282. /**
  66283. * Gets the current class name
  66284. * @returns the class name
  66285. */
  66286. getClassName(): string;
  66287. /**
  66288. * Gets the world position input component
  66289. */
  66290. get worldPosition(): NodeMaterialConnectionPoint;
  66291. /**
  66292. * Gets the world normal input component
  66293. */
  66294. get worldNormal(): NodeMaterialConnectionPoint;
  66295. /**
  66296. * Gets the world tangent input component
  66297. */
  66298. get worldTangent(): NodeMaterialConnectionPoint;
  66299. /**
  66300. * Gets the uv input component
  66301. */
  66302. get uv(): NodeMaterialConnectionPoint;
  66303. /**
  66304. * Gets the normal map color input component
  66305. */
  66306. get normalMapColor(): NodeMaterialConnectionPoint;
  66307. /**
  66308. * Gets the strength input component
  66309. */
  66310. get strength(): NodeMaterialConnectionPoint;
  66311. /**
  66312. * Gets the output component
  66313. */
  66314. get output(): NodeMaterialConnectionPoint;
  66315. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66316. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66317. autoConfigure(material: NodeMaterial): void;
  66318. protected _buildBlock(state: NodeMaterialBuildState): this;
  66319. protected _dumpPropertiesCode(): string;
  66320. serialize(): any;
  66321. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66322. }
  66323. }
  66324. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  66325. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66326. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66327. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66328. /**
  66329. * Block used to discard a pixel if a value is smaller than a cutoff
  66330. */
  66331. export class DiscardBlock extends NodeMaterialBlock {
  66332. /**
  66333. * Create a new DiscardBlock
  66334. * @param name defines the block name
  66335. */
  66336. constructor(name: string);
  66337. /**
  66338. * Gets the current class name
  66339. * @returns the class name
  66340. */
  66341. getClassName(): string;
  66342. /**
  66343. * Gets the color input component
  66344. */
  66345. get value(): NodeMaterialConnectionPoint;
  66346. /**
  66347. * Gets the cutoff input component
  66348. */
  66349. get cutoff(): NodeMaterialConnectionPoint;
  66350. protected _buildBlock(state: NodeMaterialBuildState): this;
  66351. }
  66352. }
  66353. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  66354. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66355. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66356. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66357. /**
  66358. * Block used to test if the fragment shader is front facing
  66359. */
  66360. export class FrontFacingBlock extends NodeMaterialBlock {
  66361. /**
  66362. * Creates a new FrontFacingBlock
  66363. * @param name defines the block name
  66364. */
  66365. constructor(name: string);
  66366. /**
  66367. * Gets the current class name
  66368. * @returns the class name
  66369. */
  66370. getClassName(): string;
  66371. /**
  66372. * Gets the output component
  66373. */
  66374. get output(): NodeMaterialConnectionPoint;
  66375. protected _buildBlock(state: NodeMaterialBuildState): this;
  66376. }
  66377. }
  66378. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  66379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66380. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66381. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66382. /**
  66383. * Block used to get the derivative value on x and y of a given input
  66384. */
  66385. export class DerivativeBlock extends NodeMaterialBlock {
  66386. /**
  66387. * Create a new DerivativeBlock
  66388. * @param name defines the block name
  66389. */
  66390. constructor(name: string);
  66391. /**
  66392. * Gets the current class name
  66393. * @returns the class name
  66394. */
  66395. getClassName(): string;
  66396. /**
  66397. * Gets the input component
  66398. */
  66399. get input(): NodeMaterialConnectionPoint;
  66400. /**
  66401. * Gets the derivative output on x
  66402. */
  66403. get dx(): NodeMaterialConnectionPoint;
  66404. /**
  66405. * Gets the derivative output on y
  66406. */
  66407. get dy(): NodeMaterialConnectionPoint;
  66408. protected _buildBlock(state: NodeMaterialBuildState): this;
  66409. }
  66410. }
  66411. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  66412. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66413. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66415. /**
  66416. * Block used to make gl_FragCoord available
  66417. */
  66418. export class FragCoordBlock extends NodeMaterialBlock {
  66419. /**
  66420. * Creates a new FragCoordBlock
  66421. * @param name defines the block name
  66422. */
  66423. constructor(name: string);
  66424. /**
  66425. * Gets the current class name
  66426. * @returns the class name
  66427. */
  66428. getClassName(): string;
  66429. /**
  66430. * Gets the xy component
  66431. */
  66432. get xy(): NodeMaterialConnectionPoint;
  66433. /**
  66434. * Gets the xyz component
  66435. */
  66436. get xyz(): NodeMaterialConnectionPoint;
  66437. /**
  66438. * Gets the xyzw component
  66439. */
  66440. get xyzw(): NodeMaterialConnectionPoint;
  66441. /**
  66442. * Gets the x component
  66443. */
  66444. get x(): NodeMaterialConnectionPoint;
  66445. /**
  66446. * Gets the y component
  66447. */
  66448. get y(): NodeMaterialConnectionPoint;
  66449. /**
  66450. * Gets the z component
  66451. */
  66452. get z(): NodeMaterialConnectionPoint;
  66453. /**
  66454. * Gets the w component
  66455. */
  66456. get output(): NodeMaterialConnectionPoint;
  66457. protected writeOutputs(state: NodeMaterialBuildState): string;
  66458. protected _buildBlock(state: NodeMaterialBuildState): this;
  66459. }
  66460. }
  66461. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  66462. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66463. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66464. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66465. import { Effect } from "babylonjs/Materials/effect";
  66466. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66467. import { Mesh } from "babylonjs/Meshes/mesh";
  66468. /**
  66469. * Block used to get the screen sizes
  66470. */
  66471. export class ScreenSizeBlock extends NodeMaterialBlock {
  66472. private _varName;
  66473. private _scene;
  66474. /**
  66475. * Creates a new ScreenSizeBlock
  66476. * @param name defines the block name
  66477. */
  66478. constructor(name: string);
  66479. /**
  66480. * Gets the current class name
  66481. * @returns the class name
  66482. */
  66483. getClassName(): string;
  66484. /**
  66485. * Gets the xy component
  66486. */
  66487. get xy(): NodeMaterialConnectionPoint;
  66488. /**
  66489. * Gets the x component
  66490. */
  66491. get x(): NodeMaterialConnectionPoint;
  66492. /**
  66493. * Gets the y component
  66494. */
  66495. get y(): NodeMaterialConnectionPoint;
  66496. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66497. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66498. protected _buildBlock(state: NodeMaterialBuildState): this;
  66499. }
  66500. }
  66501. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66502. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66503. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66504. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66505. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66506. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66507. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66508. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66509. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66510. }
  66511. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66512. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66513. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66514. import { Mesh } from "babylonjs/Meshes/mesh";
  66515. import { Effect } from "babylonjs/Materials/effect";
  66516. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66518. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66519. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66520. /**
  66521. * Block used to add support for scene fog
  66522. */
  66523. export class FogBlock extends NodeMaterialBlock {
  66524. private _fogDistanceName;
  66525. private _fogParameters;
  66526. /**
  66527. * Create a new FogBlock
  66528. * @param name defines the block name
  66529. */
  66530. constructor(name: string);
  66531. /**
  66532. * Gets the current class name
  66533. * @returns the class name
  66534. */
  66535. getClassName(): string;
  66536. /**
  66537. * Gets the world position input component
  66538. */
  66539. get worldPosition(): NodeMaterialConnectionPoint;
  66540. /**
  66541. * Gets the view input component
  66542. */
  66543. get view(): NodeMaterialConnectionPoint;
  66544. /**
  66545. * Gets the color input component
  66546. */
  66547. get input(): NodeMaterialConnectionPoint;
  66548. /**
  66549. * Gets the fog color input component
  66550. */
  66551. get fogColor(): NodeMaterialConnectionPoint;
  66552. /**
  66553. * Gets the output component
  66554. */
  66555. get output(): NodeMaterialConnectionPoint;
  66556. autoConfigure(material: NodeMaterial): void;
  66557. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66558. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66559. protected _buildBlock(state: NodeMaterialBuildState): this;
  66560. }
  66561. }
  66562. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66563. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66564. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66565. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66567. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66568. import { Effect } from "babylonjs/Materials/effect";
  66569. import { Mesh } from "babylonjs/Meshes/mesh";
  66570. import { Light } from "babylonjs/Lights/light";
  66571. import { Nullable } from "babylonjs/types";
  66572. import { Scene } from "babylonjs/scene";
  66573. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66574. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66575. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66576. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66577. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66578. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66579. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66580. /**
  66581. * Block used to add light in the fragment shader
  66582. */
  66583. export class LightBlock extends NodeMaterialBlock {
  66584. private _lightId;
  66585. /**
  66586. * Gets or sets the light associated with this block
  66587. */
  66588. light: Nullable<Light>;
  66589. /**
  66590. * Create a new LightBlock
  66591. * @param name defines the block name
  66592. */
  66593. constructor(name: string);
  66594. /**
  66595. * Gets the current class name
  66596. * @returns the class name
  66597. */
  66598. getClassName(): string;
  66599. /**
  66600. * Gets the world position input component
  66601. */
  66602. get worldPosition(): NodeMaterialConnectionPoint;
  66603. /**
  66604. * Gets the world normal input component
  66605. */
  66606. get worldNormal(): NodeMaterialConnectionPoint;
  66607. /**
  66608. * Gets the camera (or eye) position component
  66609. */
  66610. get cameraPosition(): NodeMaterialConnectionPoint;
  66611. /**
  66612. * Gets the glossiness component
  66613. */
  66614. get glossiness(): NodeMaterialConnectionPoint;
  66615. /**
  66616. * Gets the glossinness power component
  66617. */
  66618. get glossPower(): NodeMaterialConnectionPoint;
  66619. /**
  66620. * Gets the diffuse color component
  66621. */
  66622. get diffuseColor(): NodeMaterialConnectionPoint;
  66623. /**
  66624. * Gets the specular color component
  66625. */
  66626. get specularColor(): NodeMaterialConnectionPoint;
  66627. /**
  66628. * Gets the diffuse output component
  66629. */
  66630. get diffuseOutput(): NodeMaterialConnectionPoint;
  66631. /**
  66632. * Gets the specular output component
  66633. */
  66634. get specularOutput(): NodeMaterialConnectionPoint;
  66635. /**
  66636. * Gets the shadow output component
  66637. */
  66638. get shadow(): NodeMaterialConnectionPoint;
  66639. autoConfigure(material: NodeMaterial): void;
  66640. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66641. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66642. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66643. private _injectVertexCode;
  66644. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66645. serialize(): any;
  66646. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66647. }
  66648. }
  66649. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66650. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66652. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66653. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66654. /**
  66655. * Block used to read a reflection texture from a sampler
  66656. */
  66657. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66658. /**
  66659. * Create a new ReflectionTextureBlock
  66660. * @param name defines the block name
  66661. */
  66662. constructor(name: string);
  66663. /**
  66664. * Gets the current class name
  66665. * @returns the class name
  66666. */
  66667. getClassName(): string;
  66668. /**
  66669. * Gets the world position input component
  66670. */
  66671. get position(): NodeMaterialConnectionPoint;
  66672. /**
  66673. * Gets the world position input component
  66674. */
  66675. get worldPosition(): NodeMaterialConnectionPoint;
  66676. /**
  66677. * Gets the world normal input component
  66678. */
  66679. get worldNormal(): NodeMaterialConnectionPoint;
  66680. /**
  66681. * Gets the world input component
  66682. */
  66683. get world(): NodeMaterialConnectionPoint;
  66684. /**
  66685. * Gets the camera (or eye) position component
  66686. */
  66687. get cameraPosition(): NodeMaterialConnectionPoint;
  66688. /**
  66689. * Gets the view input component
  66690. */
  66691. get view(): NodeMaterialConnectionPoint;
  66692. /**
  66693. * Gets the rgb output component
  66694. */
  66695. get rgb(): NodeMaterialConnectionPoint;
  66696. /**
  66697. * Gets the rgba output component
  66698. */
  66699. get rgba(): NodeMaterialConnectionPoint;
  66700. /**
  66701. * Gets the r output component
  66702. */
  66703. get r(): NodeMaterialConnectionPoint;
  66704. /**
  66705. * Gets the g output component
  66706. */
  66707. get g(): NodeMaterialConnectionPoint;
  66708. /**
  66709. * Gets the b output component
  66710. */
  66711. get b(): NodeMaterialConnectionPoint;
  66712. /**
  66713. * Gets the a output component
  66714. */
  66715. get a(): NodeMaterialConnectionPoint;
  66716. autoConfigure(material: NodeMaterial): void;
  66717. protected _buildBlock(state: NodeMaterialBuildState): this;
  66718. }
  66719. }
  66720. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66721. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66722. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66723. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66724. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66725. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66726. }
  66727. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66728. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66729. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66730. }
  66731. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66732. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66733. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66735. /**
  66736. * Block used to add 2 vectors
  66737. */
  66738. export class AddBlock extends NodeMaterialBlock {
  66739. /**
  66740. * Creates a new AddBlock
  66741. * @param name defines the block name
  66742. */
  66743. constructor(name: string);
  66744. /**
  66745. * Gets the current class name
  66746. * @returns the class name
  66747. */
  66748. getClassName(): string;
  66749. /**
  66750. * Gets the left operand input component
  66751. */
  66752. get left(): NodeMaterialConnectionPoint;
  66753. /**
  66754. * Gets the right operand input component
  66755. */
  66756. get right(): NodeMaterialConnectionPoint;
  66757. /**
  66758. * Gets the output component
  66759. */
  66760. get output(): NodeMaterialConnectionPoint;
  66761. protected _buildBlock(state: NodeMaterialBuildState): this;
  66762. }
  66763. }
  66764. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66765. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66766. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66767. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66768. /**
  66769. * Block used to scale a vector by a float
  66770. */
  66771. export class ScaleBlock extends NodeMaterialBlock {
  66772. /**
  66773. * Creates a new ScaleBlock
  66774. * @param name defines the block name
  66775. */
  66776. constructor(name: string);
  66777. /**
  66778. * Gets the current class name
  66779. * @returns the class name
  66780. */
  66781. getClassName(): string;
  66782. /**
  66783. * Gets the input component
  66784. */
  66785. get input(): NodeMaterialConnectionPoint;
  66786. /**
  66787. * Gets the factor input component
  66788. */
  66789. get factor(): NodeMaterialConnectionPoint;
  66790. /**
  66791. * Gets the output component
  66792. */
  66793. get output(): NodeMaterialConnectionPoint;
  66794. protected _buildBlock(state: NodeMaterialBuildState): this;
  66795. }
  66796. }
  66797. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66800. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66801. import { Scene } from "babylonjs/scene";
  66802. /**
  66803. * Block used to clamp a float
  66804. */
  66805. export class ClampBlock extends NodeMaterialBlock {
  66806. /** Gets or sets the minimum range */
  66807. minimum: number;
  66808. /** Gets or sets the maximum range */
  66809. maximum: number;
  66810. /**
  66811. * Creates a new ClampBlock
  66812. * @param name defines the block name
  66813. */
  66814. constructor(name: string);
  66815. /**
  66816. * Gets the current class name
  66817. * @returns the class name
  66818. */
  66819. getClassName(): string;
  66820. /**
  66821. * Gets the value input component
  66822. */
  66823. get value(): NodeMaterialConnectionPoint;
  66824. /**
  66825. * Gets the output component
  66826. */
  66827. get output(): NodeMaterialConnectionPoint;
  66828. protected _buildBlock(state: NodeMaterialBuildState): this;
  66829. protected _dumpPropertiesCode(): string;
  66830. serialize(): any;
  66831. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66832. }
  66833. }
  66834. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66835. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66836. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66837. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66838. /**
  66839. * Block used to apply a cross product between 2 vectors
  66840. */
  66841. export class CrossBlock extends NodeMaterialBlock {
  66842. /**
  66843. * Creates a new CrossBlock
  66844. * @param name defines the block name
  66845. */
  66846. constructor(name: string);
  66847. /**
  66848. * Gets the current class name
  66849. * @returns the class name
  66850. */
  66851. getClassName(): string;
  66852. /**
  66853. * Gets the left operand input component
  66854. */
  66855. get left(): NodeMaterialConnectionPoint;
  66856. /**
  66857. * Gets the right operand input component
  66858. */
  66859. get right(): NodeMaterialConnectionPoint;
  66860. /**
  66861. * Gets the output component
  66862. */
  66863. get output(): NodeMaterialConnectionPoint;
  66864. protected _buildBlock(state: NodeMaterialBuildState): this;
  66865. }
  66866. }
  66867. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66868. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66869. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66870. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66871. /**
  66872. * Block used to apply a dot product between 2 vectors
  66873. */
  66874. export class DotBlock extends NodeMaterialBlock {
  66875. /**
  66876. * Creates a new DotBlock
  66877. * @param name defines the block name
  66878. */
  66879. constructor(name: string);
  66880. /**
  66881. * Gets the current class name
  66882. * @returns the class name
  66883. */
  66884. getClassName(): string;
  66885. /**
  66886. * Gets the left operand input component
  66887. */
  66888. get left(): NodeMaterialConnectionPoint;
  66889. /**
  66890. * Gets the right operand input component
  66891. */
  66892. get right(): NodeMaterialConnectionPoint;
  66893. /**
  66894. * Gets the output component
  66895. */
  66896. get output(): NodeMaterialConnectionPoint;
  66897. protected _buildBlock(state: NodeMaterialBuildState): this;
  66898. }
  66899. }
  66900. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66901. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66902. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66904. /**
  66905. * Block used to normalize a vector
  66906. */
  66907. export class NormalizeBlock extends NodeMaterialBlock {
  66908. /**
  66909. * Creates a new NormalizeBlock
  66910. * @param name defines the block name
  66911. */
  66912. constructor(name: string);
  66913. /**
  66914. * Gets the current class name
  66915. * @returns the class name
  66916. */
  66917. getClassName(): string;
  66918. /**
  66919. * Gets the input component
  66920. */
  66921. get input(): NodeMaterialConnectionPoint;
  66922. /**
  66923. * Gets the output component
  66924. */
  66925. get output(): NodeMaterialConnectionPoint;
  66926. protected _buildBlock(state: NodeMaterialBuildState): this;
  66927. }
  66928. }
  66929. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66930. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66931. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66932. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66933. /**
  66934. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66935. */
  66936. export class ColorMergerBlock extends NodeMaterialBlock {
  66937. /**
  66938. * Create a new ColorMergerBlock
  66939. * @param name defines the block name
  66940. */
  66941. constructor(name: string);
  66942. /**
  66943. * Gets the current class name
  66944. * @returns the class name
  66945. */
  66946. getClassName(): string;
  66947. /**
  66948. * Gets the rgb component (input)
  66949. */
  66950. get rgbIn(): NodeMaterialConnectionPoint;
  66951. /**
  66952. * Gets the r component (input)
  66953. */
  66954. get r(): NodeMaterialConnectionPoint;
  66955. /**
  66956. * Gets the g component (input)
  66957. */
  66958. get g(): NodeMaterialConnectionPoint;
  66959. /**
  66960. * Gets the b component (input)
  66961. */
  66962. get b(): NodeMaterialConnectionPoint;
  66963. /**
  66964. * Gets the a component (input)
  66965. */
  66966. get a(): NodeMaterialConnectionPoint;
  66967. /**
  66968. * Gets the rgba component (output)
  66969. */
  66970. get rgba(): NodeMaterialConnectionPoint;
  66971. /**
  66972. * Gets the rgb component (output)
  66973. */
  66974. get rgbOut(): NodeMaterialConnectionPoint;
  66975. /**
  66976. * Gets the rgb component (output)
  66977. * @deprecated Please use rgbOut instead.
  66978. */
  66979. get rgb(): NodeMaterialConnectionPoint;
  66980. protected _buildBlock(state: NodeMaterialBuildState): this;
  66981. }
  66982. }
  66983. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66984. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66985. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66986. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66987. /**
  66988. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66989. */
  66990. export class VectorSplitterBlock extends NodeMaterialBlock {
  66991. /**
  66992. * Create a new VectorSplitterBlock
  66993. * @param name defines the block name
  66994. */
  66995. constructor(name: string);
  66996. /**
  66997. * Gets the current class name
  66998. * @returns the class name
  66999. */
  67000. getClassName(): string;
  67001. /**
  67002. * Gets the xyzw component (input)
  67003. */
  67004. get xyzw(): NodeMaterialConnectionPoint;
  67005. /**
  67006. * Gets the xyz component (input)
  67007. */
  67008. get xyzIn(): NodeMaterialConnectionPoint;
  67009. /**
  67010. * Gets the xy component (input)
  67011. */
  67012. get xyIn(): NodeMaterialConnectionPoint;
  67013. /**
  67014. * Gets the xyz component (output)
  67015. */
  67016. get xyzOut(): NodeMaterialConnectionPoint;
  67017. /**
  67018. * Gets the xy component (output)
  67019. */
  67020. get xyOut(): NodeMaterialConnectionPoint;
  67021. /**
  67022. * Gets the x component (output)
  67023. */
  67024. get x(): NodeMaterialConnectionPoint;
  67025. /**
  67026. * Gets the y component (output)
  67027. */
  67028. get y(): NodeMaterialConnectionPoint;
  67029. /**
  67030. * Gets the z component (output)
  67031. */
  67032. get z(): NodeMaterialConnectionPoint;
  67033. /**
  67034. * Gets the w component (output)
  67035. */
  67036. get w(): NodeMaterialConnectionPoint;
  67037. protected _inputRename(name: string): string;
  67038. protected _outputRename(name: string): string;
  67039. protected _buildBlock(state: NodeMaterialBuildState): this;
  67040. }
  67041. }
  67042. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  67043. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67044. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67045. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67046. /**
  67047. * Block used to lerp between 2 values
  67048. */
  67049. export class LerpBlock extends NodeMaterialBlock {
  67050. /**
  67051. * Creates a new LerpBlock
  67052. * @param name defines the block name
  67053. */
  67054. constructor(name: string);
  67055. /**
  67056. * Gets the current class name
  67057. * @returns the class name
  67058. */
  67059. getClassName(): string;
  67060. /**
  67061. * Gets the left operand input component
  67062. */
  67063. get left(): NodeMaterialConnectionPoint;
  67064. /**
  67065. * Gets the right operand input component
  67066. */
  67067. get right(): NodeMaterialConnectionPoint;
  67068. /**
  67069. * Gets the gradient operand input component
  67070. */
  67071. get gradient(): NodeMaterialConnectionPoint;
  67072. /**
  67073. * Gets the output component
  67074. */
  67075. get output(): NodeMaterialConnectionPoint;
  67076. protected _buildBlock(state: NodeMaterialBuildState): this;
  67077. }
  67078. }
  67079. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  67080. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67081. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67082. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67083. /**
  67084. * Block used to divide 2 vectors
  67085. */
  67086. export class DivideBlock extends NodeMaterialBlock {
  67087. /**
  67088. * Creates a new DivideBlock
  67089. * @param name defines the block name
  67090. */
  67091. constructor(name: string);
  67092. /**
  67093. * Gets the current class name
  67094. * @returns the class name
  67095. */
  67096. getClassName(): string;
  67097. /**
  67098. * Gets the left operand input component
  67099. */
  67100. get left(): NodeMaterialConnectionPoint;
  67101. /**
  67102. * Gets the right operand input component
  67103. */
  67104. get right(): NodeMaterialConnectionPoint;
  67105. /**
  67106. * Gets the output component
  67107. */
  67108. get output(): NodeMaterialConnectionPoint;
  67109. protected _buildBlock(state: NodeMaterialBuildState): this;
  67110. }
  67111. }
  67112. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  67113. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67114. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67115. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67116. /**
  67117. * Block used to subtract 2 vectors
  67118. */
  67119. export class SubtractBlock extends NodeMaterialBlock {
  67120. /**
  67121. * Creates a new SubtractBlock
  67122. * @param name defines the block name
  67123. */
  67124. constructor(name: string);
  67125. /**
  67126. * Gets the current class name
  67127. * @returns the class name
  67128. */
  67129. getClassName(): string;
  67130. /**
  67131. * Gets the left operand input component
  67132. */
  67133. get left(): NodeMaterialConnectionPoint;
  67134. /**
  67135. * Gets the right operand input component
  67136. */
  67137. get right(): NodeMaterialConnectionPoint;
  67138. /**
  67139. * Gets the output component
  67140. */
  67141. get output(): NodeMaterialConnectionPoint;
  67142. protected _buildBlock(state: NodeMaterialBuildState): this;
  67143. }
  67144. }
  67145. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  67146. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67147. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67148. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67149. /**
  67150. * Block used to step a value
  67151. */
  67152. export class StepBlock extends NodeMaterialBlock {
  67153. /**
  67154. * Creates a new StepBlock
  67155. * @param name defines the block name
  67156. */
  67157. constructor(name: string);
  67158. /**
  67159. * Gets the current class name
  67160. * @returns the class name
  67161. */
  67162. getClassName(): string;
  67163. /**
  67164. * Gets the value operand input component
  67165. */
  67166. get value(): NodeMaterialConnectionPoint;
  67167. /**
  67168. * Gets the edge operand input component
  67169. */
  67170. get edge(): NodeMaterialConnectionPoint;
  67171. /**
  67172. * Gets the output component
  67173. */
  67174. get output(): NodeMaterialConnectionPoint;
  67175. protected _buildBlock(state: NodeMaterialBuildState): this;
  67176. }
  67177. }
  67178. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  67179. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67180. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67181. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67182. /**
  67183. * Block used to get the opposite (1 - x) of a value
  67184. */
  67185. export class OneMinusBlock extends NodeMaterialBlock {
  67186. /**
  67187. * Creates a new OneMinusBlock
  67188. * @param name defines the block name
  67189. */
  67190. constructor(name: string);
  67191. /**
  67192. * Gets the current class name
  67193. * @returns the class name
  67194. */
  67195. getClassName(): string;
  67196. /**
  67197. * Gets the input component
  67198. */
  67199. get input(): NodeMaterialConnectionPoint;
  67200. /**
  67201. * Gets the output component
  67202. */
  67203. get output(): NodeMaterialConnectionPoint;
  67204. protected _buildBlock(state: NodeMaterialBuildState): this;
  67205. }
  67206. }
  67207. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  67208. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67209. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67210. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67211. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67212. /**
  67213. * Block used to get the view direction
  67214. */
  67215. export class ViewDirectionBlock extends NodeMaterialBlock {
  67216. /**
  67217. * Creates a new ViewDirectionBlock
  67218. * @param name defines the block name
  67219. */
  67220. constructor(name: string);
  67221. /**
  67222. * Gets the current class name
  67223. * @returns the class name
  67224. */
  67225. getClassName(): string;
  67226. /**
  67227. * Gets the world position component
  67228. */
  67229. get worldPosition(): NodeMaterialConnectionPoint;
  67230. /**
  67231. * Gets the camera position component
  67232. */
  67233. get cameraPosition(): NodeMaterialConnectionPoint;
  67234. /**
  67235. * Gets the output component
  67236. */
  67237. get output(): NodeMaterialConnectionPoint;
  67238. autoConfigure(material: NodeMaterial): void;
  67239. protected _buildBlock(state: NodeMaterialBuildState): this;
  67240. }
  67241. }
  67242. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  67243. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67244. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67245. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67246. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67247. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  67248. /**
  67249. * Block used to compute fresnel value
  67250. */
  67251. export class FresnelBlock extends NodeMaterialBlock {
  67252. /**
  67253. * Create a new FresnelBlock
  67254. * @param name defines the block name
  67255. */
  67256. constructor(name: string);
  67257. /**
  67258. * Gets the current class name
  67259. * @returns the class name
  67260. */
  67261. getClassName(): string;
  67262. /**
  67263. * Gets the world normal input component
  67264. */
  67265. get worldNormal(): NodeMaterialConnectionPoint;
  67266. /**
  67267. * Gets the view direction input component
  67268. */
  67269. get viewDirection(): NodeMaterialConnectionPoint;
  67270. /**
  67271. * Gets the bias input component
  67272. */
  67273. get bias(): NodeMaterialConnectionPoint;
  67274. /**
  67275. * Gets the camera (or eye) position component
  67276. */
  67277. get power(): NodeMaterialConnectionPoint;
  67278. /**
  67279. * Gets the fresnel output component
  67280. */
  67281. get fresnel(): NodeMaterialConnectionPoint;
  67282. autoConfigure(material: NodeMaterial): void;
  67283. protected _buildBlock(state: NodeMaterialBuildState): this;
  67284. }
  67285. }
  67286. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  67287. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67288. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67289. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67290. /**
  67291. * Block used to get the max of 2 values
  67292. */
  67293. export class MaxBlock extends NodeMaterialBlock {
  67294. /**
  67295. * Creates a new MaxBlock
  67296. * @param name defines the block name
  67297. */
  67298. constructor(name: string);
  67299. /**
  67300. * Gets the current class name
  67301. * @returns the class name
  67302. */
  67303. getClassName(): string;
  67304. /**
  67305. * Gets the left operand input component
  67306. */
  67307. get left(): NodeMaterialConnectionPoint;
  67308. /**
  67309. * Gets the right operand input component
  67310. */
  67311. get right(): NodeMaterialConnectionPoint;
  67312. /**
  67313. * Gets the output component
  67314. */
  67315. get output(): NodeMaterialConnectionPoint;
  67316. protected _buildBlock(state: NodeMaterialBuildState): this;
  67317. }
  67318. }
  67319. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  67320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67323. /**
  67324. * Block used to get the min of 2 values
  67325. */
  67326. export class MinBlock extends NodeMaterialBlock {
  67327. /**
  67328. * Creates a new MinBlock
  67329. * @param name defines the block name
  67330. */
  67331. constructor(name: string);
  67332. /**
  67333. * Gets the current class name
  67334. * @returns the class name
  67335. */
  67336. getClassName(): string;
  67337. /**
  67338. * Gets the left operand input component
  67339. */
  67340. get left(): NodeMaterialConnectionPoint;
  67341. /**
  67342. * Gets the right operand input component
  67343. */
  67344. get right(): NodeMaterialConnectionPoint;
  67345. /**
  67346. * Gets the output component
  67347. */
  67348. get output(): NodeMaterialConnectionPoint;
  67349. protected _buildBlock(state: NodeMaterialBuildState): this;
  67350. }
  67351. }
  67352. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  67353. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67354. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67355. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67356. /**
  67357. * Block used to get the distance between 2 values
  67358. */
  67359. export class DistanceBlock extends NodeMaterialBlock {
  67360. /**
  67361. * Creates a new DistanceBlock
  67362. * @param name defines the block name
  67363. */
  67364. constructor(name: string);
  67365. /**
  67366. * Gets the current class name
  67367. * @returns the class name
  67368. */
  67369. getClassName(): string;
  67370. /**
  67371. * Gets the left operand input component
  67372. */
  67373. get left(): NodeMaterialConnectionPoint;
  67374. /**
  67375. * Gets the right operand input component
  67376. */
  67377. get right(): NodeMaterialConnectionPoint;
  67378. /**
  67379. * Gets the output component
  67380. */
  67381. get output(): NodeMaterialConnectionPoint;
  67382. protected _buildBlock(state: NodeMaterialBuildState): this;
  67383. }
  67384. }
  67385. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  67386. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67387. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67388. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67389. /**
  67390. * Block used to get the length of a vector
  67391. */
  67392. export class LengthBlock extends NodeMaterialBlock {
  67393. /**
  67394. * Creates a new LengthBlock
  67395. * @param name defines the block name
  67396. */
  67397. constructor(name: string);
  67398. /**
  67399. * Gets the current class name
  67400. * @returns the class name
  67401. */
  67402. getClassName(): string;
  67403. /**
  67404. * Gets the value input component
  67405. */
  67406. get value(): NodeMaterialConnectionPoint;
  67407. /**
  67408. * Gets the output component
  67409. */
  67410. get output(): NodeMaterialConnectionPoint;
  67411. protected _buildBlock(state: NodeMaterialBuildState): this;
  67412. }
  67413. }
  67414. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  67415. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67418. /**
  67419. * Block used to get negative version of a value (i.e. x * -1)
  67420. */
  67421. export class NegateBlock extends NodeMaterialBlock {
  67422. /**
  67423. * Creates a new NegateBlock
  67424. * @param name defines the block name
  67425. */
  67426. constructor(name: string);
  67427. /**
  67428. * Gets the current class name
  67429. * @returns the class name
  67430. */
  67431. getClassName(): string;
  67432. /**
  67433. * Gets the value input component
  67434. */
  67435. get value(): NodeMaterialConnectionPoint;
  67436. /**
  67437. * Gets the output component
  67438. */
  67439. get output(): NodeMaterialConnectionPoint;
  67440. protected _buildBlock(state: NodeMaterialBuildState): this;
  67441. }
  67442. }
  67443. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  67444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67445. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67447. /**
  67448. * Block used to get the value of the first parameter raised to the power of the second
  67449. */
  67450. export class PowBlock extends NodeMaterialBlock {
  67451. /**
  67452. * Creates a new PowBlock
  67453. * @param name defines the block name
  67454. */
  67455. constructor(name: string);
  67456. /**
  67457. * Gets the current class name
  67458. * @returns the class name
  67459. */
  67460. getClassName(): string;
  67461. /**
  67462. * Gets the value operand input component
  67463. */
  67464. get value(): NodeMaterialConnectionPoint;
  67465. /**
  67466. * Gets the power operand input component
  67467. */
  67468. get power(): NodeMaterialConnectionPoint;
  67469. /**
  67470. * Gets the output component
  67471. */
  67472. get output(): NodeMaterialConnectionPoint;
  67473. protected _buildBlock(state: NodeMaterialBuildState): this;
  67474. }
  67475. }
  67476. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  67477. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67478. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67479. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67480. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67481. /**
  67482. * Block used to get a random number
  67483. */
  67484. export class RandomNumberBlock extends NodeMaterialBlock {
  67485. /**
  67486. * Creates a new RandomNumberBlock
  67487. * @param name defines the block name
  67488. */
  67489. constructor(name: string);
  67490. /**
  67491. * Gets the current class name
  67492. * @returns the class name
  67493. */
  67494. getClassName(): string;
  67495. /**
  67496. * Gets the seed input component
  67497. */
  67498. get seed(): NodeMaterialConnectionPoint;
  67499. /**
  67500. * Gets the output component
  67501. */
  67502. get output(): NodeMaterialConnectionPoint;
  67503. protected _buildBlock(state: NodeMaterialBuildState): this;
  67504. }
  67505. }
  67506. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67507. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67508. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67509. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67510. /**
  67511. * Block used to compute arc tangent of 2 values
  67512. */
  67513. export class ArcTan2Block extends NodeMaterialBlock {
  67514. /**
  67515. * Creates a new ArcTan2Block
  67516. * @param name defines the block name
  67517. */
  67518. constructor(name: string);
  67519. /**
  67520. * Gets the current class name
  67521. * @returns the class name
  67522. */
  67523. getClassName(): string;
  67524. /**
  67525. * Gets the x operand input component
  67526. */
  67527. get x(): NodeMaterialConnectionPoint;
  67528. /**
  67529. * Gets the y operand input component
  67530. */
  67531. get y(): NodeMaterialConnectionPoint;
  67532. /**
  67533. * Gets the output component
  67534. */
  67535. get output(): NodeMaterialConnectionPoint;
  67536. protected _buildBlock(state: NodeMaterialBuildState): this;
  67537. }
  67538. }
  67539. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67540. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67541. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67542. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67543. /**
  67544. * Block used to smooth step a value
  67545. */
  67546. export class SmoothStepBlock extends NodeMaterialBlock {
  67547. /**
  67548. * Creates a new SmoothStepBlock
  67549. * @param name defines the block name
  67550. */
  67551. constructor(name: string);
  67552. /**
  67553. * Gets the current class name
  67554. * @returns the class name
  67555. */
  67556. getClassName(): string;
  67557. /**
  67558. * Gets the value operand input component
  67559. */
  67560. get value(): NodeMaterialConnectionPoint;
  67561. /**
  67562. * Gets the first edge operand input component
  67563. */
  67564. get edge0(): NodeMaterialConnectionPoint;
  67565. /**
  67566. * Gets the second edge operand input component
  67567. */
  67568. get edge1(): NodeMaterialConnectionPoint;
  67569. /**
  67570. * Gets the output component
  67571. */
  67572. get output(): NodeMaterialConnectionPoint;
  67573. protected _buildBlock(state: NodeMaterialBuildState): this;
  67574. }
  67575. }
  67576. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67577. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67578. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67579. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67580. /**
  67581. * Block used to get the reciprocal (1 / x) of a value
  67582. */
  67583. export class ReciprocalBlock extends NodeMaterialBlock {
  67584. /**
  67585. * Creates a new ReciprocalBlock
  67586. * @param name defines the block name
  67587. */
  67588. constructor(name: string);
  67589. /**
  67590. * Gets the current class name
  67591. * @returns the class name
  67592. */
  67593. getClassName(): string;
  67594. /**
  67595. * Gets the input component
  67596. */
  67597. get input(): NodeMaterialConnectionPoint;
  67598. /**
  67599. * Gets the output component
  67600. */
  67601. get output(): NodeMaterialConnectionPoint;
  67602. protected _buildBlock(state: NodeMaterialBuildState): this;
  67603. }
  67604. }
  67605. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67606. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67607. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67608. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67609. /**
  67610. * Block used to replace a color by another one
  67611. */
  67612. export class ReplaceColorBlock extends NodeMaterialBlock {
  67613. /**
  67614. * Creates a new ReplaceColorBlock
  67615. * @param name defines the block name
  67616. */
  67617. constructor(name: string);
  67618. /**
  67619. * Gets the current class name
  67620. * @returns the class name
  67621. */
  67622. getClassName(): string;
  67623. /**
  67624. * Gets the value input component
  67625. */
  67626. get value(): NodeMaterialConnectionPoint;
  67627. /**
  67628. * Gets the reference input component
  67629. */
  67630. get reference(): NodeMaterialConnectionPoint;
  67631. /**
  67632. * Gets the distance input component
  67633. */
  67634. get distance(): NodeMaterialConnectionPoint;
  67635. /**
  67636. * Gets the replacement input component
  67637. */
  67638. get replacement(): NodeMaterialConnectionPoint;
  67639. /**
  67640. * Gets the output component
  67641. */
  67642. get output(): NodeMaterialConnectionPoint;
  67643. protected _buildBlock(state: NodeMaterialBuildState): this;
  67644. }
  67645. }
  67646. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67647. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67648. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67649. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67650. /**
  67651. * Block used to posterize a value
  67652. * @see https://en.wikipedia.org/wiki/Posterization
  67653. */
  67654. export class PosterizeBlock extends NodeMaterialBlock {
  67655. /**
  67656. * Creates a new PosterizeBlock
  67657. * @param name defines the block name
  67658. */
  67659. constructor(name: string);
  67660. /**
  67661. * Gets the current class name
  67662. * @returns the class name
  67663. */
  67664. getClassName(): string;
  67665. /**
  67666. * Gets the value input component
  67667. */
  67668. get value(): NodeMaterialConnectionPoint;
  67669. /**
  67670. * Gets the steps input component
  67671. */
  67672. get steps(): NodeMaterialConnectionPoint;
  67673. /**
  67674. * Gets the output component
  67675. */
  67676. get output(): NodeMaterialConnectionPoint;
  67677. protected _buildBlock(state: NodeMaterialBuildState): this;
  67678. }
  67679. }
  67680. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67681. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67682. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67683. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67684. import { Scene } from "babylonjs/scene";
  67685. /**
  67686. * Operations supported by the Wave block
  67687. */
  67688. export enum WaveBlockKind {
  67689. /** SawTooth */
  67690. SawTooth = 0,
  67691. /** Square */
  67692. Square = 1,
  67693. /** Triangle */
  67694. Triangle = 2
  67695. }
  67696. /**
  67697. * Block used to apply wave operation to floats
  67698. */
  67699. export class WaveBlock extends NodeMaterialBlock {
  67700. /**
  67701. * Gets or sets the kibnd of wave to be applied by the block
  67702. */
  67703. kind: WaveBlockKind;
  67704. /**
  67705. * Creates a new WaveBlock
  67706. * @param name defines the block name
  67707. */
  67708. constructor(name: string);
  67709. /**
  67710. * Gets the current class name
  67711. * @returns the class name
  67712. */
  67713. getClassName(): string;
  67714. /**
  67715. * Gets the input component
  67716. */
  67717. get input(): NodeMaterialConnectionPoint;
  67718. /**
  67719. * Gets the output component
  67720. */
  67721. get output(): NodeMaterialConnectionPoint;
  67722. protected _buildBlock(state: NodeMaterialBuildState): this;
  67723. serialize(): any;
  67724. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67725. }
  67726. }
  67727. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67728. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67729. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67730. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67731. import { Color3 } from "babylonjs/Maths/math.color";
  67732. import { Scene } from "babylonjs/scene";
  67733. import { Observable } from "babylonjs/Misc/observable";
  67734. /**
  67735. * Class used to store a color step for the GradientBlock
  67736. */
  67737. export class GradientBlockColorStep {
  67738. private _step;
  67739. /**
  67740. * Gets value indicating which step this color is associated with (between 0 and 1)
  67741. */
  67742. get step(): number;
  67743. /**
  67744. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67745. */
  67746. set step(val: number);
  67747. private _color;
  67748. /**
  67749. * Gets the color associated with this step
  67750. */
  67751. get color(): Color3;
  67752. /**
  67753. * Sets the color associated with this step
  67754. */
  67755. set color(val: Color3);
  67756. /**
  67757. * Creates a new GradientBlockColorStep
  67758. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67759. * @param color defines the color associated with this step
  67760. */
  67761. constructor(step: number, color: Color3);
  67762. }
  67763. /**
  67764. * Block used to return a color from a gradient based on an input value between 0 and 1
  67765. */
  67766. export class GradientBlock extends NodeMaterialBlock {
  67767. /**
  67768. * Gets or sets the list of color steps
  67769. */
  67770. colorSteps: GradientBlockColorStep[];
  67771. /** Gets an observable raised when the value is changed */
  67772. onValueChangedObservable: Observable<GradientBlock>;
  67773. /** calls observable when the value is changed*/
  67774. colorStepsUpdated(): void;
  67775. /**
  67776. * Creates a new GradientBlock
  67777. * @param name defines the block name
  67778. */
  67779. constructor(name: string);
  67780. /**
  67781. * Gets the current class name
  67782. * @returns the class name
  67783. */
  67784. getClassName(): string;
  67785. /**
  67786. * Gets the gradient input component
  67787. */
  67788. get gradient(): NodeMaterialConnectionPoint;
  67789. /**
  67790. * Gets the output component
  67791. */
  67792. get output(): NodeMaterialConnectionPoint;
  67793. private _writeColorConstant;
  67794. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67795. serialize(): any;
  67796. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67797. protected _dumpPropertiesCode(): string;
  67798. }
  67799. }
  67800. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67802. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67804. /**
  67805. * Block used to normalize lerp between 2 values
  67806. */
  67807. export class NLerpBlock extends NodeMaterialBlock {
  67808. /**
  67809. * Creates a new NLerpBlock
  67810. * @param name defines the block name
  67811. */
  67812. constructor(name: string);
  67813. /**
  67814. * Gets the current class name
  67815. * @returns the class name
  67816. */
  67817. getClassName(): string;
  67818. /**
  67819. * Gets the left operand input component
  67820. */
  67821. get left(): NodeMaterialConnectionPoint;
  67822. /**
  67823. * Gets the right operand input component
  67824. */
  67825. get right(): NodeMaterialConnectionPoint;
  67826. /**
  67827. * Gets the gradient operand input component
  67828. */
  67829. get gradient(): NodeMaterialConnectionPoint;
  67830. /**
  67831. * Gets the output component
  67832. */
  67833. get output(): NodeMaterialConnectionPoint;
  67834. protected _buildBlock(state: NodeMaterialBuildState): this;
  67835. }
  67836. }
  67837. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67838. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67839. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67840. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67841. import { Scene } from "babylonjs/scene";
  67842. /**
  67843. * block used to Generate a Worley Noise 3D Noise Pattern
  67844. */
  67845. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67846. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67847. manhattanDistance: boolean;
  67848. /**
  67849. * Creates a new WorleyNoise3DBlock
  67850. * @param name defines the block name
  67851. */
  67852. constructor(name: string);
  67853. /**
  67854. * Gets the current class name
  67855. * @returns the class name
  67856. */
  67857. getClassName(): string;
  67858. /**
  67859. * Gets the seed input component
  67860. */
  67861. get seed(): NodeMaterialConnectionPoint;
  67862. /**
  67863. * Gets the jitter input component
  67864. */
  67865. get jitter(): NodeMaterialConnectionPoint;
  67866. /**
  67867. * Gets the output component
  67868. */
  67869. get output(): NodeMaterialConnectionPoint;
  67870. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67871. /**
  67872. * Exposes the properties to the UI?
  67873. */
  67874. protected _dumpPropertiesCode(): string;
  67875. /**
  67876. * Exposes the properties to the Seralize?
  67877. */
  67878. serialize(): any;
  67879. /**
  67880. * Exposes the properties to the deseralize?
  67881. */
  67882. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67883. }
  67884. }
  67885. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67886. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67887. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67888. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67889. /**
  67890. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67891. */
  67892. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67893. /**
  67894. * Creates a new SimplexPerlin3DBlock
  67895. * @param name defines the block name
  67896. */
  67897. constructor(name: string);
  67898. /**
  67899. * Gets the current class name
  67900. * @returns the class name
  67901. */
  67902. getClassName(): string;
  67903. /**
  67904. * Gets the seed operand input component
  67905. */
  67906. get seed(): NodeMaterialConnectionPoint;
  67907. /**
  67908. * Gets the output component
  67909. */
  67910. get output(): NodeMaterialConnectionPoint;
  67911. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67912. }
  67913. }
  67914. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67915. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67916. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67918. /**
  67919. * Block used to blend normals
  67920. */
  67921. export class NormalBlendBlock extends NodeMaterialBlock {
  67922. /**
  67923. * Creates a new NormalBlendBlock
  67924. * @param name defines the block name
  67925. */
  67926. constructor(name: string);
  67927. /**
  67928. * Gets the current class name
  67929. * @returns the class name
  67930. */
  67931. getClassName(): string;
  67932. /**
  67933. * Gets the first input component
  67934. */
  67935. get normalMap0(): NodeMaterialConnectionPoint;
  67936. /**
  67937. * Gets the second input component
  67938. */
  67939. get normalMap1(): NodeMaterialConnectionPoint;
  67940. /**
  67941. * Gets the output component
  67942. */
  67943. get output(): NodeMaterialConnectionPoint;
  67944. protected _buildBlock(state: NodeMaterialBuildState): this;
  67945. }
  67946. }
  67947. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67948. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67949. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67950. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67951. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67952. /**
  67953. * Block used to rotate a 2d vector by a given angle
  67954. */
  67955. export class Rotate2dBlock extends NodeMaterialBlock {
  67956. /**
  67957. * Creates a new Rotate2dBlock
  67958. * @param name defines the block name
  67959. */
  67960. constructor(name: string);
  67961. /**
  67962. * Gets the current class name
  67963. * @returns the class name
  67964. */
  67965. getClassName(): string;
  67966. /**
  67967. * Gets the input vector
  67968. */
  67969. get input(): NodeMaterialConnectionPoint;
  67970. /**
  67971. * Gets the input angle
  67972. */
  67973. get angle(): NodeMaterialConnectionPoint;
  67974. /**
  67975. * Gets the output component
  67976. */
  67977. get output(): NodeMaterialConnectionPoint;
  67978. autoConfigure(material: NodeMaterial): void;
  67979. protected _buildBlock(state: NodeMaterialBuildState): this;
  67980. }
  67981. }
  67982. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67983. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67984. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67985. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67986. /**
  67987. * Block used to get the reflected vector from a direction and a normal
  67988. */
  67989. export class ReflectBlock extends NodeMaterialBlock {
  67990. /**
  67991. * Creates a new ReflectBlock
  67992. * @param name defines the block name
  67993. */
  67994. constructor(name: string);
  67995. /**
  67996. * Gets the current class name
  67997. * @returns the class name
  67998. */
  67999. getClassName(): string;
  68000. /**
  68001. * Gets the incident component
  68002. */
  68003. get incident(): NodeMaterialConnectionPoint;
  68004. /**
  68005. * Gets the normal component
  68006. */
  68007. get normal(): NodeMaterialConnectionPoint;
  68008. /**
  68009. * Gets the output component
  68010. */
  68011. get output(): NodeMaterialConnectionPoint;
  68012. protected _buildBlock(state: NodeMaterialBuildState): this;
  68013. }
  68014. }
  68015. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  68016. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68017. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68018. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68019. /**
  68020. * Block used to get the refracted vector from a direction and a normal
  68021. */
  68022. export class RefractBlock extends NodeMaterialBlock {
  68023. /**
  68024. * Creates a new RefractBlock
  68025. * @param name defines the block name
  68026. */
  68027. constructor(name: string);
  68028. /**
  68029. * Gets the current class name
  68030. * @returns the class name
  68031. */
  68032. getClassName(): string;
  68033. /**
  68034. * Gets the incident component
  68035. */
  68036. get incident(): NodeMaterialConnectionPoint;
  68037. /**
  68038. * Gets the normal component
  68039. */
  68040. get normal(): NodeMaterialConnectionPoint;
  68041. /**
  68042. * Gets the index of refraction component
  68043. */
  68044. get ior(): NodeMaterialConnectionPoint;
  68045. /**
  68046. * Gets the output component
  68047. */
  68048. get output(): NodeMaterialConnectionPoint;
  68049. protected _buildBlock(state: NodeMaterialBuildState): this;
  68050. }
  68051. }
  68052. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  68053. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68054. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68055. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68056. /**
  68057. * Block used to desaturate a color
  68058. */
  68059. export class DesaturateBlock extends NodeMaterialBlock {
  68060. /**
  68061. * Creates a new DesaturateBlock
  68062. * @param name defines the block name
  68063. */
  68064. constructor(name: string);
  68065. /**
  68066. * Gets the current class name
  68067. * @returns the class name
  68068. */
  68069. getClassName(): string;
  68070. /**
  68071. * Gets the color operand input component
  68072. */
  68073. get color(): NodeMaterialConnectionPoint;
  68074. /**
  68075. * Gets the level operand input component
  68076. */
  68077. get level(): NodeMaterialConnectionPoint;
  68078. /**
  68079. * Gets the output component
  68080. */
  68081. get output(): NodeMaterialConnectionPoint;
  68082. protected _buildBlock(state: NodeMaterialBuildState): this;
  68083. }
  68084. }
  68085. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  68086. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68087. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68088. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68089. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68090. import { Nullable } from "babylonjs/types";
  68091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68092. import { Scene } from "babylonjs/scene";
  68093. /**
  68094. * Block used to implement the ambient occlusion module of the PBR material
  68095. */
  68096. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  68097. /**
  68098. * Create a new AmbientOcclusionBlock
  68099. * @param name defines the block name
  68100. */
  68101. constructor(name: string);
  68102. /**
  68103. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  68104. */
  68105. useAmbientInGrayScale: boolean;
  68106. /**
  68107. * Initialize the block and prepare the context for build
  68108. * @param state defines the state that will be used for the build
  68109. */
  68110. initialize(state: NodeMaterialBuildState): void;
  68111. /**
  68112. * Gets the current class name
  68113. * @returns the class name
  68114. */
  68115. getClassName(): string;
  68116. /**
  68117. * Gets the texture input component
  68118. */
  68119. get texture(): NodeMaterialConnectionPoint;
  68120. /**
  68121. * Gets the texture intensity component
  68122. */
  68123. get intensity(): NodeMaterialConnectionPoint;
  68124. /**
  68125. * Gets the direct light intensity input component
  68126. */
  68127. get directLightIntensity(): NodeMaterialConnectionPoint;
  68128. /**
  68129. * Gets the ambient occlusion object output component
  68130. */
  68131. get ambientOcc(): NodeMaterialConnectionPoint;
  68132. /**
  68133. * Gets the main code of the block (fragment side)
  68134. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  68135. * @returns the shader code
  68136. */
  68137. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  68138. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68139. protected _buildBlock(state: NodeMaterialBuildState): this;
  68140. protected _dumpPropertiesCode(): string;
  68141. serialize(): any;
  68142. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68143. }
  68144. }
  68145. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  68146. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68147. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68148. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68149. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  68150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68151. import { Nullable } from "babylonjs/types";
  68152. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68153. import { Mesh } from "babylonjs/Meshes/mesh";
  68154. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68155. import { Effect } from "babylonjs/Materials/effect";
  68156. import { Scene } from "babylonjs/scene";
  68157. /**
  68158. * Block used to implement the reflection module of the PBR material
  68159. */
  68160. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68161. /** @hidden */
  68162. _defineLODReflectionAlpha: string;
  68163. /** @hidden */
  68164. _defineLinearSpecularReflection: string;
  68165. private _vEnvironmentIrradianceName;
  68166. /** @hidden */
  68167. _vReflectionMicrosurfaceInfosName: string;
  68168. /** @hidden */
  68169. _vReflectionInfosName: string;
  68170. /** @hidden */
  68171. _vReflectionFilteringInfoName: string;
  68172. private _scene;
  68173. /**
  68174. * The three properties below are set by the main PBR block prior to calling methods of this class.
  68175. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68176. * It's less burden on the user side in the editor part.
  68177. */
  68178. /** @hidden */
  68179. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68180. /** @hidden */
  68181. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68182. /** @hidden */
  68183. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68184. /**
  68185. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68186. * diffuse part of the IBL.
  68187. */
  68188. useSphericalHarmonics: boolean;
  68189. /**
  68190. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68191. */
  68192. forceIrradianceInFragment: boolean;
  68193. /**
  68194. * Create a new ReflectionBlock
  68195. * @param name defines the block name
  68196. */
  68197. constructor(name: string);
  68198. /**
  68199. * Gets the current class name
  68200. * @returns the class name
  68201. */
  68202. getClassName(): string;
  68203. /**
  68204. * Gets the position input component
  68205. */
  68206. get position(): NodeMaterialConnectionPoint;
  68207. /**
  68208. * Gets the world position input component
  68209. */
  68210. get worldPosition(): NodeMaterialConnectionPoint;
  68211. /**
  68212. * Gets the world normal input component
  68213. */
  68214. get worldNormal(): NodeMaterialConnectionPoint;
  68215. /**
  68216. * Gets the world input component
  68217. */
  68218. get world(): NodeMaterialConnectionPoint;
  68219. /**
  68220. * Gets the camera (or eye) position component
  68221. */
  68222. get cameraPosition(): NodeMaterialConnectionPoint;
  68223. /**
  68224. * Gets the view input component
  68225. */
  68226. get view(): NodeMaterialConnectionPoint;
  68227. /**
  68228. * Gets the color input component
  68229. */
  68230. get color(): NodeMaterialConnectionPoint;
  68231. /**
  68232. * Gets the reflection object output component
  68233. */
  68234. get reflection(): NodeMaterialConnectionPoint;
  68235. /**
  68236. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68237. */
  68238. get hasTexture(): boolean;
  68239. /**
  68240. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68241. */
  68242. get reflectionColor(): string;
  68243. protected _getTexture(): Nullable<BaseTexture>;
  68244. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68245. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68246. /**
  68247. * Gets the code to inject in the vertex shader
  68248. * @param state current state of the node material building
  68249. * @returns the shader code
  68250. */
  68251. handleVertexSide(state: NodeMaterialBuildState): string;
  68252. /**
  68253. * Gets the main code of the block (fragment side)
  68254. * @param state current state of the node material building
  68255. * @param normalVarName name of the existing variable corresponding to the normal
  68256. * @returns the shader code
  68257. */
  68258. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68259. protected _buildBlock(state: NodeMaterialBuildState): this;
  68260. protected _dumpPropertiesCode(): string;
  68261. serialize(): any;
  68262. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68263. }
  68264. }
  68265. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  68266. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68267. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68268. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68269. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68271. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68272. import { Scene } from "babylonjs/scene";
  68273. import { Nullable } from "babylonjs/types";
  68274. /**
  68275. * Block used to implement the sheen module of the PBR material
  68276. */
  68277. export class SheenBlock extends NodeMaterialBlock {
  68278. /**
  68279. * Create a new SheenBlock
  68280. * @param name defines the block name
  68281. */
  68282. constructor(name: string);
  68283. /**
  68284. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68285. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68286. * making it easier to setup and tweak the effect
  68287. */
  68288. albedoScaling: boolean;
  68289. /**
  68290. * Defines if the sheen is linked to the sheen color.
  68291. */
  68292. linkSheenWithAlbedo: boolean;
  68293. /**
  68294. * Initialize the block and prepare the context for build
  68295. * @param state defines the state that will be used for the build
  68296. */
  68297. initialize(state: NodeMaterialBuildState): void;
  68298. /**
  68299. * Gets the current class name
  68300. * @returns the class name
  68301. */
  68302. getClassName(): string;
  68303. /**
  68304. * Gets the intensity input component
  68305. */
  68306. get intensity(): NodeMaterialConnectionPoint;
  68307. /**
  68308. * Gets the color input component
  68309. */
  68310. get color(): NodeMaterialConnectionPoint;
  68311. /**
  68312. * Gets the roughness input component
  68313. */
  68314. get roughness(): NodeMaterialConnectionPoint;
  68315. /**
  68316. * Gets the sheen object output component
  68317. */
  68318. get sheen(): NodeMaterialConnectionPoint;
  68319. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68320. /**
  68321. * Gets the main code of the block (fragment side)
  68322. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68323. * @returns the shader code
  68324. */
  68325. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68326. protected _buildBlock(state: NodeMaterialBuildState): this;
  68327. protected _dumpPropertiesCode(): string;
  68328. serialize(): any;
  68329. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68330. }
  68331. }
  68332. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  68333. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68334. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68338. import { Scene } from "babylonjs/scene";
  68339. import { Nullable } from "babylonjs/types";
  68340. import { Mesh } from "babylonjs/Meshes/mesh";
  68341. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68342. import { Effect } from "babylonjs/Materials/effect";
  68343. /**
  68344. * Block used to implement the reflectivity module of the PBR material
  68345. */
  68346. export class ReflectivityBlock extends NodeMaterialBlock {
  68347. private _metallicReflectanceColor;
  68348. private _metallicF0Factor;
  68349. /** @hidden */
  68350. _vMetallicReflectanceFactorsName: string;
  68351. /**
  68352. * The property below is set by the main PBR block prior to calling methods of this class.
  68353. */
  68354. /** @hidden */
  68355. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  68356. /**
  68357. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  68358. */
  68359. useAmbientOcclusionFromMetallicTextureRed: boolean;
  68360. /**
  68361. * Specifies if the metallic texture contains the metallness information in its blue channel.
  68362. */
  68363. useMetallnessFromMetallicTextureBlue: boolean;
  68364. /**
  68365. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  68366. */
  68367. useRoughnessFromMetallicTextureAlpha: boolean;
  68368. /**
  68369. * Specifies if the metallic texture contains the roughness information in its green channel.
  68370. */
  68371. useRoughnessFromMetallicTextureGreen: boolean;
  68372. /**
  68373. * Create a new ReflectivityBlock
  68374. * @param name defines the block name
  68375. */
  68376. constructor(name: string);
  68377. /**
  68378. * Initialize the block and prepare the context for build
  68379. * @param state defines the state that will be used for the build
  68380. */
  68381. initialize(state: NodeMaterialBuildState): void;
  68382. /**
  68383. * Gets the current class name
  68384. * @returns the class name
  68385. */
  68386. getClassName(): string;
  68387. /**
  68388. * Gets the metallic input component
  68389. */
  68390. get metallic(): NodeMaterialConnectionPoint;
  68391. /**
  68392. * Gets the roughness input component
  68393. */
  68394. get roughness(): NodeMaterialConnectionPoint;
  68395. /**
  68396. * Gets the texture input component
  68397. */
  68398. get texture(): NodeMaterialConnectionPoint;
  68399. /**
  68400. * Gets the reflectivity object output component
  68401. */
  68402. get reflectivity(): NodeMaterialConnectionPoint;
  68403. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68404. /**
  68405. * Gets the main code of the block (fragment side)
  68406. * @param state current state of the node material building
  68407. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  68408. * @returns the shader code
  68409. */
  68410. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  68411. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68412. protected _buildBlock(state: NodeMaterialBuildState): this;
  68413. protected _dumpPropertiesCode(): string;
  68414. serialize(): any;
  68415. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68416. }
  68417. }
  68418. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  68419. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68420. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68421. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68422. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68424. /**
  68425. * Block used to implement the anisotropy module of the PBR material
  68426. */
  68427. export class AnisotropyBlock extends NodeMaterialBlock {
  68428. /**
  68429. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68430. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68431. * It's less burden on the user side in the editor part.
  68432. */
  68433. /** @hidden */
  68434. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68435. /** @hidden */
  68436. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68437. /**
  68438. * Create a new AnisotropyBlock
  68439. * @param name defines the block name
  68440. */
  68441. constructor(name: string);
  68442. /**
  68443. * Initialize the block and prepare the context for build
  68444. * @param state defines the state that will be used for the build
  68445. */
  68446. initialize(state: NodeMaterialBuildState): void;
  68447. /**
  68448. * Gets the current class name
  68449. * @returns the class name
  68450. */
  68451. getClassName(): string;
  68452. /**
  68453. * Gets the intensity input component
  68454. */
  68455. get intensity(): NodeMaterialConnectionPoint;
  68456. /**
  68457. * Gets the direction input component
  68458. */
  68459. get direction(): NodeMaterialConnectionPoint;
  68460. /**
  68461. * Gets the texture input component
  68462. */
  68463. get texture(): NodeMaterialConnectionPoint;
  68464. /**
  68465. * Gets the uv input component
  68466. */
  68467. get uv(): NodeMaterialConnectionPoint;
  68468. /**
  68469. * Gets the worldTangent input component
  68470. */
  68471. get worldTangent(): NodeMaterialConnectionPoint;
  68472. /**
  68473. * Gets the anisotropy object output component
  68474. */
  68475. get anisotropy(): NodeMaterialConnectionPoint;
  68476. private _generateTBNSpace;
  68477. /**
  68478. * Gets the main code of the block (fragment side)
  68479. * @param state current state of the node material building
  68480. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68481. * @returns the shader code
  68482. */
  68483. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68484. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68485. protected _buildBlock(state: NodeMaterialBuildState): this;
  68486. }
  68487. }
  68488. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68489. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68490. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68491. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68492. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68494. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68495. import { Nullable } from "babylonjs/types";
  68496. import { Mesh } from "babylonjs/Meshes/mesh";
  68497. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68498. import { Effect } from "babylonjs/Materials/effect";
  68499. /**
  68500. * Block used to implement the clear coat module of the PBR material
  68501. */
  68502. export class ClearCoatBlock extends NodeMaterialBlock {
  68503. private _scene;
  68504. /**
  68505. * Create a new ClearCoatBlock
  68506. * @param name defines the block name
  68507. */
  68508. constructor(name: string);
  68509. /**
  68510. * Initialize the block and prepare the context for build
  68511. * @param state defines the state that will be used for the build
  68512. */
  68513. initialize(state: NodeMaterialBuildState): void;
  68514. /**
  68515. * Gets the current class name
  68516. * @returns the class name
  68517. */
  68518. getClassName(): string;
  68519. /**
  68520. * Gets the intensity input component
  68521. */
  68522. get intensity(): NodeMaterialConnectionPoint;
  68523. /**
  68524. * Gets the roughness input component
  68525. */
  68526. get roughness(): NodeMaterialConnectionPoint;
  68527. /**
  68528. * Gets the ior input component
  68529. */
  68530. get ior(): NodeMaterialConnectionPoint;
  68531. /**
  68532. * Gets the texture input component
  68533. */
  68534. get texture(): NodeMaterialConnectionPoint;
  68535. /**
  68536. * Gets the bump texture input component
  68537. */
  68538. get bumpTexture(): NodeMaterialConnectionPoint;
  68539. /**
  68540. * Gets the uv input component
  68541. */
  68542. get uv(): NodeMaterialConnectionPoint;
  68543. /**
  68544. * Gets the tint color input component
  68545. */
  68546. get tintColor(): NodeMaterialConnectionPoint;
  68547. /**
  68548. * Gets the tint "at distance" input component
  68549. */
  68550. get tintAtDistance(): NodeMaterialConnectionPoint;
  68551. /**
  68552. * Gets the tint thickness input component
  68553. */
  68554. get tintThickness(): NodeMaterialConnectionPoint;
  68555. /**
  68556. * Gets the world tangent input component
  68557. */
  68558. get worldTangent(): NodeMaterialConnectionPoint;
  68559. /**
  68560. * Gets the clear coat object output component
  68561. */
  68562. get clearcoat(): NodeMaterialConnectionPoint;
  68563. autoConfigure(material: NodeMaterial): void;
  68564. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68565. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68566. private _generateTBNSpace;
  68567. /**
  68568. * Gets the main code of the block (fragment side)
  68569. * @param state current state of the node material building
  68570. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68571. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68572. * @param worldPosVarName name of the variable holding the world position
  68573. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68574. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68575. * @param worldNormalVarName name of the variable holding the world normal
  68576. * @returns the shader code
  68577. */
  68578. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68579. protected _buildBlock(state: NodeMaterialBuildState): this;
  68580. }
  68581. }
  68582. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68583. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68584. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68585. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68586. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68588. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68589. import { Nullable } from "babylonjs/types";
  68590. /**
  68591. * Block used to implement the sub surface module of the PBR material
  68592. */
  68593. export class SubSurfaceBlock extends NodeMaterialBlock {
  68594. /**
  68595. * Create a new SubSurfaceBlock
  68596. * @param name defines the block name
  68597. */
  68598. constructor(name: string);
  68599. /**
  68600. * Stores the intensity of the different subsurface effects in the thickness texture.
  68601. * * the green channel is the translucency intensity.
  68602. * * the blue channel is the scattering intensity.
  68603. * * the alpha channel is the refraction intensity.
  68604. */
  68605. useMaskFromThicknessTexture: boolean;
  68606. /**
  68607. * Initialize the block and prepare the context for build
  68608. * @param state defines the state that will be used for the build
  68609. */
  68610. initialize(state: NodeMaterialBuildState): void;
  68611. /**
  68612. * Gets the current class name
  68613. * @returns the class name
  68614. */
  68615. getClassName(): string;
  68616. /**
  68617. * Gets the min thickness input component
  68618. */
  68619. get minThickness(): NodeMaterialConnectionPoint;
  68620. /**
  68621. * Gets the max thickness input component
  68622. */
  68623. get maxThickness(): NodeMaterialConnectionPoint;
  68624. /**
  68625. * Gets the thickness texture component
  68626. */
  68627. get thicknessTexture(): NodeMaterialConnectionPoint;
  68628. /**
  68629. * Gets the tint color input component
  68630. */
  68631. get tintColor(): NodeMaterialConnectionPoint;
  68632. /**
  68633. * Gets the translucency intensity input component
  68634. */
  68635. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68636. /**
  68637. * Gets the translucency diffusion distance input component
  68638. */
  68639. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68640. /**
  68641. * Gets the refraction object parameters
  68642. */
  68643. get refraction(): NodeMaterialConnectionPoint;
  68644. /**
  68645. * Gets the sub surface object output component
  68646. */
  68647. get subsurface(): NodeMaterialConnectionPoint;
  68648. autoConfigure(material: NodeMaterial): void;
  68649. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68650. /**
  68651. * Gets the main code of the block (fragment side)
  68652. * @param state current state of the node material building
  68653. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68654. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68655. * @param worldPosVarName name of the variable holding the world position
  68656. * @returns the shader code
  68657. */
  68658. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68659. protected _buildBlock(state: NodeMaterialBuildState): this;
  68660. }
  68661. }
  68662. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68663. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68664. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68665. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68666. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68667. import { Light } from "babylonjs/Lights/light";
  68668. import { Nullable } from "babylonjs/types";
  68669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68670. import { Effect } from "babylonjs/Materials/effect";
  68671. import { Mesh } from "babylonjs/Meshes/mesh";
  68672. import { Scene } from "babylonjs/scene";
  68673. /**
  68674. * Block used to implement the PBR metallic/roughness model
  68675. */
  68676. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68677. /**
  68678. * Gets or sets the light associated with this block
  68679. */
  68680. light: Nullable<Light>;
  68681. private _lightId;
  68682. private _scene;
  68683. private _environmentBRDFTexture;
  68684. private _environmentBrdfSamplerName;
  68685. private _vNormalWName;
  68686. private _invertNormalName;
  68687. /**
  68688. * Create a new ReflectionBlock
  68689. * @param name defines the block name
  68690. */
  68691. constructor(name: string);
  68692. /**
  68693. * Intensity of the direct lights e.g. the four lights available in your scene.
  68694. * This impacts both the direct diffuse and specular highlights.
  68695. */
  68696. directIntensity: number;
  68697. /**
  68698. * Intensity of the environment e.g. how much the environment will light the object
  68699. * either through harmonics for rough material or through the refelction for shiny ones.
  68700. */
  68701. environmentIntensity: number;
  68702. /**
  68703. * This is a special control allowing the reduction of the specular highlights coming from the
  68704. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68705. */
  68706. specularIntensity: number;
  68707. /**
  68708. * Defines the falloff type used in this material.
  68709. * It by default is Physical.
  68710. */
  68711. lightFalloff: number;
  68712. /**
  68713. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68714. */
  68715. useAlphaFromAlbedoTexture: boolean;
  68716. /**
  68717. * Specifies that alpha test should be used
  68718. */
  68719. useAlphaTest: boolean;
  68720. /**
  68721. * Defines the alpha limits in alpha test mode.
  68722. */
  68723. alphaTestCutoff: number;
  68724. /**
  68725. * Specifies that alpha blending should be used
  68726. */
  68727. useAlphaBlending: boolean;
  68728. /**
  68729. * Defines if the alpha value should be determined via the rgb values.
  68730. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68731. */
  68732. opacityRGB: boolean;
  68733. /**
  68734. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68735. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68736. */
  68737. useRadianceOverAlpha: boolean;
  68738. /**
  68739. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68740. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68741. */
  68742. useSpecularOverAlpha: boolean;
  68743. /**
  68744. * Enables specular anti aliasing in the PBR shader.
  68745. * It will both interacts on the Geometry for analytical and IBL lighting.
  68746. * It also prefilter the roughness map based on the bump values.
  68747. */
  68748. enableSpecularAntiAliasing: boolean;
  68749. /**
  68750. * Enables realtime filtering on the texture.
  68751. */
  68752. realTimeFiltering: boolean;
  68753. /**
  68754. * Quality switch for realtime filtering
  68755. */
  68756. realTimeFilteringQuality: number;
  68757. /**
  68758. * Defines if the material uses energy conservation.
  68759. */
  68760. useEnergyConservation: boolean;
  68761. /**
  68762. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68763. * too much the area relying on ambient texture to define their ambient occlusion.
  68764. */
  68765. useRadianceOcclusion: boolean;
  68766. /**
  68767. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68768. * makes the reflect vector face the model (under horizon).
  68769. */
  68770. useHorizonOcclusion: boolean;
  68771. /**
  68772. * If set to true, no lighting calculations will be applied.
  68773. */
  68774. unlit: boolean;
  68775. /**
  68776. * Force normal to face away from face.
  68777. */
  68778. forceNormalForward: boolean;
  68779. /**
  68780. * Defines the material debug mode.
  68781. * It helps seeing only some components of the material while troubleshooting.
  68782. */
  68783. debugMode: number;
  68784. /**
  68785. * Specify from where on screen the debug mode should start.
  68786. * The value goes from -1 (full screen) to 1 (not visible)
  68787. * It helps with side by side comparison against the final render
  68788. * This defaults to 0
  68789. */
  68790. debugLimit: number;
  68791. /**
  68792. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68793. * You can use the factor to better multiply the final value.
  68794. */
  68795. debugFactor: number;
  68796. /**
  68797. * Initialize the block and prepare the context for build
  68798. * @param state defines the state that will be used for the build
  68799. */
  68800. initialize(state: NodeMaterialBuildState): void;
  68801. /**
  68802. * Gets the current class name
  68803. * @returns the class name
  68804. */
  68805. getClassName(): string;
  68806. /**
  68807. * Gets the world position input component
  68808. */
  68809. get worldPosition(): NodeMaterialConnectionPoint;
  68810. /**
  68811. * Gets the world normal input component
  68812. */
  68813. get worldNormal(): NodeMaterialConnectionPoint;
  68814. /**
  68815. * Gets the perturbed normal input component
  68816. */
  68817. get perturbedNormal(): NodeMaterialConnectionPoint;
  68818. /**
  68819. * Gets the camera position input component
  68820. */
  68821. get cameraPosition(): NodeMaterialConnectionPoint;
  68822. /**
  68823. * Gets the base color input component
  68824. */
  68825. get baseColor(): NodeMaterialConnectionPoint;
  68826. /**
  68827. * Gets the opacity texture input component
  68828. */
  68829. get opacityTexture(): NodeMaterialConnectionPoint;
  68830. /**
  68831. * Gets the ambient color input component
  68832. */
  68833. get ambientColor(): NodeMaterialConnectionPoint;
  68834. /**
  68835. * Gets the reflectivity object parameters
  68836. */
  68837. get reflectivity(): NodeMaterialConnectionPoint;
  68838. /**
  68839. * Gets the ambient occlusion object parameters
  68840. */
  68841. get ambientOcc(): NodeMaterialConnectionPoint;
  68842. /**
  68843. * Gets the reflection object parameters
  68844. */
  68845. get reflection(): NodeMaterialConnectionPoint;
  68846. /**
  68847. * Gets the sheen object parameters
  68848. */
  68849. get sheen(): NodeMaterialConnectionPoint;
  68850. /**
  68851. * Gets the clear coat object parameters
  68852. */
  68853. get clearcoat(): NodeMaterialConnectionPoint;
  68854. /**
  68855. * Gets the sub surface object parameters
  68856. */
  68857. get subsurface(): NodeMaterialConnectionPoint;
  68858. /**
  68859. * Gets the anisotropy object parameters
  68860. */
  68861. get anisotropy(): NodeMaterialConnectionPoint;
  68862. /**
  68863. * Gets the ambient output component
  68864. */
  68865. get ambient(): NodeMaterialConnectionPoint;
  68866. /**
  68867. * Gets the diffuse output component
  68868. */
  68869. get diffuse(): NodeMaterialConnectionPoint;
  68870. /**
  68871. * Gets the specular output component
  68872. */
  68873. get specular(): NodeMaterialConnectionPoint;
  68874. /**
  68875. * Gets the sheen output component
  68876. */
  68877. get sheenDir(): NodeMaterialConnectionPoint;
  68878. /**
  68879. * Gets the clear coat output component
  68880. */
  68881. get clearcoatDir(): NodeMaterialConnectionPoint;
  68882. /**
  68883. * Gets the indirect diffuse output component
  68884. */
  68885. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68886. /**
  68887. * Gets the indirect specular output component
  68888. */
  68889. get specularIndirect(): NodeMaterialConnectionPoint;
  68890. /**
  68891. * Gets the indirect sheen output component
  68892. */
  68893. get sheenIndirect(): NodeMaterialConnectionPoint;
  68894. /**
  68895. * Gets the indirect clear coat output component
  68896. */
  68897. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68898. /**
  68899. * Gets the refraction output component
  68900. */
  68901. get refraction(): NodeMaterialConnectionPoint;
  68902. /**
  68903. * Gets the global lighting output component
  68904. */
  68905. get lighting(): NodeMaterialConnectionPoint;
  68906. /**
  68907. * Gets the shadow output component
  68908. */
  68909. get shadow(): NodeMaterialConnectionPoint;
  68910. /**
  68911. * Gets the alpha output component
  68912. */
  68913. get alpha(): NodeMaterialConnectionPoint;
  68914. autoConfigure(material: NodeMaterial): void;
  68915. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68916. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68917. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68918. private _injectVertexCode;
  68919. /**
  68920. * Gets the code corresponding to the albedo/opacity module
  68921. * @returns the shader code
  68922. */
  68923. getAlbedoOpacityCode(): string;
  68924. protected _buildBlock(state: NodeMaterialBuildState): this;
  68925. protected _dumpPropertiesCode(): string;
  68926. serialize(): any;
  68927. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68928. }
  68929. }
  68930. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68931. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68932. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68933. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68934. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68935. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68936. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68937. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68938. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68939. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68940. }
  68941. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68942. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68943. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68944. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68945. }
  68946. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68950. /**
  68951. * Block used to compute value of one parameter modulo another
  68952. */
  68953. export class ModBlock extends NodeMaterialBlock {
  68954. /**
  68955. * Creates a new ModBlock
  68956. * @param name defines the block name
  68957. */
  68958. constructor(name: string);
  68959. /**
  68960. * Gets the current class name
  68961. * @returns the class name
  68962. */
  68963. getClassName(): string;
  68964. /**
  68965. * Gets the left operand input component
  68966. */
  68967. get left(): NodeMaterialConnectionPoint;
  68968. /**
  68969. * Gets the right operand input component
  68970. */
  68971. get right(): NodeMaterialConnectionPoint;
  68972. /**
  68973. * Gets the output component
  68974. */
  68975. get output(): NodeMaterialConnectionPoint;
  68976. protected _buildBlock(state: NodeMaterialBuildState): this;
  68977. }
  68978. }
  68979. declare module "babylonjs/Materials/Node/Blocks/index" {
  68980. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68981. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68982. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68983. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68984. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68985. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68986. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68987. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68988. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68989. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68990. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68991. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68992. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68993. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68994. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68995. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68996. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68997. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68998. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68999. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69000. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69001. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69002. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69003. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69004. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69005. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69006. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69007. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69008. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69009. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69010. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69011. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69012. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69013. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69014. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69015. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69016. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69017. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69018. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69019. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69020. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69021. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69022. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69023. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69024. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69025. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69026. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69027. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69028. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69029. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69030. }
  69031. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69032. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69033. }
  69034. declare module "babylonjs/Materials/Node/index" {
  69035. export * from "babylonjs/Materials/Node/Enums/index";
  69036. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69037. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69038. export * from "babylonjs/Materials/Node/nodeMaterial";
  69039. export * from "babylonjs/Materials/Node/Blocks/index";
  69040. export * from "babylonjs/Materials/Node/Optimizers/index";
  69041. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69042. }
  69043. declare module "babylonjs/Materials/index" {
  69044. export * from "babylonjs/Materials/Background/index";
  69045. export * from "babylonjs/Materials/colorCurves";
  69046. export * from "babylonjs/Materials/iEffectFallbacks";
  69047. export * from "babylonjs/Materials/effectFallbacks";
  69048. export * from "babylonjs/Materials/effect";
  69049. export * from "babylonjs/Materials/fresnelParameters";
  69050. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69051. export * from "babylonjs/Materials/material";
  69052. export * from "babylonjs/Materials/materialDefines";
  69053. export * from "babylonjs/Materials/thinMaterialHelper";
  69054. export * from "babylonjs/Materials/materialHelper";
  69055. export * from "babylonjs/Materials/multiMaterial";
  69056. export * from "babylonjs/Materials/PBR/index";
  69057. export * from "babylonjs/Materials/pushMaterial";
  69058. export * from "babylonjs/Materials/shaderMaterial";
  69059. export * from "babylonjs/Materials/standardMaterial";
  69060. export * from "babylonjs/Materials/Textures/index";
  69061. export * from "babylonjs/Materials/uniformBuffer";
  69062. export * from "babylonjs/Materials/materialFlags";
  69063. export * from "babylonjs/Materials/Node/index";
  69064. export * from "babylonjs/Materials/effectRenderer";
  69065. export * from "babylonjs/Materials/shadowDepthWrapper";
  69066. }
  69067. declare module "babylonjs/Maths/index" {
  69068. export * from "babylonjs/Maths/math.scalar";
  69069. export * from "babylonjs/Maths/math";
  69070. export * from "babylonjs/Maths/sphericalPolynomial";
  69071. }
  69072. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69073. import { IDisposable } from "babylonjs/scene";
  69074. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69075. /**
  69076. * Configuration for Draco compression
  69077. */
  69078. export interface IDracoCompressionConfiguration {
  69079. /**
  69080. * Configuration for the decoder.
  69081. */
  69082. decoder: {
  69083. /**
  69084. * The url to the WebAssembly module.
  69085. */
  69086. wasmUrl?: string;
  69087. /**
  69088. * The url to the WebAssembly binary.
  69089. */
  69090. wasmBinaryUrl?: string;
  69091. /**
  69092. * The url to the fallback JavaScript module.
  69093. */
  69094. fallbackUrl?: string;
  69095. };
  69096. }
  69097. /**
  69098. * Draco compression (https://google.github.io/draco/)
  69099. *
  69100. * This class wraps the Draco module.
  69101. *
  69102. * **Encoder**
  69103. *
  69104. * The encoder is not currently implemented.
  69105. *
  69106. * **Decoder**
  69107. *
  69108. * 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.
  69109. *
  69110. * To update the configuration, use the following code:
  69111. * ```javascript
  69112. * DracoCompression.Configuration = {
  69113. * decoder: {
  69114. * wasmUrl: "<url to the WebAssembly library>",
  69115. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69116. * fallbackUrl: "<url to the fallback JavaScript library>",
  69117. * }
  69118. * };
  69119. * ```
  69120. *
  69121. * 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.
  69122. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69123. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69124. *
  69125. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69126. * ```javascript
  69127. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69128. * ```
  69129. *
  69130. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69131. */
  69132. export class DracoCompression implements IDisposable {
  69133. private _workerPoolPromise?;
  69134. private _decoderModulePromise?;
  69135. /**
  69136. * The configuration. Defaults to the following urls:
  69137. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69138. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69139. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69140. */
  69141. static Configuration: IDracoCompressionConfiguration;
  69142. /**
  69143. * Returns true if the decoder configuration is available.
  69144. */
  69145. static get DecoderAvailable(): boolean;
  69146. /**
  69147. * Default number of workers to create when creating the draco compression object.
  69148. */
  69149. static DefaultNumWorkers: number;
  69150. private static GetDefaultNumWorkers;
  69151. private static _Default;
  69152. /**
  69153. * Default instance for the draco compression object.
  69154. */
  69155. static get Default(): DracoCompression;
  69156. /**
  69157. * Constructor
  69158. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69159. */
  69160. constructor(numWorkers?: number);
  69161. /**
  69162. * Stop all async operations and release resources.
  69163. */
  69164. dispose(): void;
  69165. /**
  69166. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69167. * @returns a promise that resolves when ready
  69168. */
  69169. whenReadyAsync(): Promise<void>;
  69170. /**
  69171. * Decode Draco compressed mesh data to vertex data.
  69172. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69173. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69174. * @returns A promise that resolves with the decoded vertex data
  69175. */
  69176. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69177. [kind: string]: number;
  69178. }): Promise<VertexData>;
  69179. }
  69180. }
  69181. declare module "babylonjs/Meshes/Compression/index" {
  69182. export * from "babylonjs/Meshes/Compression/dracoCompression";
  69183. }
  69184. declare module "babylonjs/Meshes/csg" {
  69185. import { Nullable } from "babylonjs/types";
  69186. import { Scene } from "babylonjs/scene";
  69187. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  69188. import { Mesh } from "babylonjs/Meshes/mesh";
  69189. import { Material } from "babylonjs/Materials/material";
  69190. /**
  69191. * Class for building Constructive Solid Geometry
  69192. */
  69193. export class CSG {
  69194. private polygons;
  69195. /**
  69196. * The world matrix
  69197. */
  69198. matrix: Matrix;
  69199. /**
  69200. * Stores the position
  69201. */
  69202. position: Vector3;
  69203. /**
  69204. * Stores the rotation
  69205. */
  69206. rotation: Vector3;
  69207. /**
  69208. * Stores the rotation quaternion
  69209. */
  69210. rotationQuaternion: Nullable<Quaternion>;
  69211. /**
  69212. * Stores the scaling vector
  69213. */
  69214. scaling: Vector3;
  69215. /**
  69216. * Convert the Mesh to CSG
  69217. * @param mesh The Mesh to convert to CSG
  69218. * @returns A new CSG from the Mesh
  69219. */
  69220. static FromMesh(mesh: Mesh): CSG;
  69221. /**
  69222. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69223. * @param polygons Polygons used to construct a CSG solid
  69224. */
  69225. private static FromPolygons;
  69226. /**
  69227. * Clones, or makes a deep copy, of the CSG
  69228. * @returns A new CSG
  69229. */
  69230. clone(): CSG;
  69231. /**
  69232. * Unions this CSG with another CSG
  69233. * @param csg The CSG to union against this CSG
  69234. * @returns The unioned CSG
  69235. */
  69236. union(csg: CSG): CSG;
  69237. /**
  69238. * Unions this CSG with another CSG in place
  69239. * @param csg The CSG to union against this CSG
  69240. */
  69241. unionInPlace(csg: CSG): void;
  69242. /**
  69243. * Subtracts this CSG with another CSG
  69244. * @param csg The CSG to subtract against this CSG
  69245. * @returns A new CSG
  69246. */
  69247. subtract(csg: CSG): CSG;
  69248. /**
  69249. * Subtracts this CSG with another CSG in place
  69250. * @param csg The CSG to subtact against this CSG
  69251. */
  69252. subtractInPlace(csg: CSG): void;
  69253. /**
  69254. * Intersect this CSG with another CSG
  69255. * @param csg The CSG to intersect against this CSG
  69256. * @returns A new CSG
  69257. */
  69258. intersect(csg: CSG): CSG;
  69259. /**
  69260. * Intersects this CSG with another CSG in place
  69261. * @param csg The CSG to intersect against this CSG
  69262. */
  69263. intersectInPlace(csg: CSG): void;
  69264. /**
  69265. * Return a new CSG solid with solid and empty space switched. This solid is
  69266. * not modified.
  69267. * @returns A new CSG solid with solid and empty space switched
  69268. */
  69269. inverse(): CSG;
  69270. /**
  69271. * Inverses the CSG in place
  69272. */
  69273. inverseInPlace(): void;
  69274. /**
  69275. * This is used to keep meshes transformations so they can be restored
  69276. * when we build back a Babylon Mesh
  69277. * NB : All CSG operations are performed in world coordinates
  69278. * @param csg The CSG to copy the transform attributes from
  69279. * @returns This CSG
  69280. */
  69281. copyTransformAttributes(csg: CSG): CSG;
  69282. /**
  69283. * Build Raw mesh from CSG
  69284. * Coordinates here are in world space
  69285. * @param name The name of the mesh geometry
  69286. * @param scene The Scene
  69287. * @param keepSubMeshes Specifies if the submeshes should be kept
  69288. * @returns A new Mesh
  69289. */
  69290. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69291. /**
  69292. * Build Mesh from CSG taking material and transforms into account
  69293. * @param name The name of the Mesh
  69294. * @param material The material of the Mesh
  69295. * @param scene The Scene
  69296. * @param keepSubMeshes Specifies if submeshes should be kept
  69297. * @returns The new Mesh
  69298. */
  69299. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69300. }
  69301. }
  69302. declare module "babylonjs/Meshes/trailMesh" {
  69303. import { Mesh } from "babylonjs/Meshes/mesh";
  69304. import { Scene } from "babylonjs/scene";
  69305. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69306. /**
  69307. * Class used to create a trail following a mesh
  69308. */
  69309. export class TrailMesh extends Mesh {
  69310. private _generator;
  69311. private _autoStart;
  69312. private _running;
  69313. private _diameter;
  69314. private _length;
  69315. private _sectionPolygonPointsCount;
  69316. private _sectionVectors;
  69317. private _sectionNormalVectors;
  69318. private _beforeRenderObserver;
  69319. /**
  69320. * @constructor
  69321. * @param name The value used by scene.getMeshByName() to do a lookup.
  69322. * @param generator The mesh or transform node to generate a trail.
  69323. * @param scene The scene to add this mesh to.
  69324. * @param diameter Diameter of trailing mesh. Default is 1.
  69325. * @param length Length of trailing mesh. Default is 60.
  69326. * @param autoStart Automatically start trailing mesh. Default true.
  69327. */
  69328. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69329. /**
  69330. * "TrailMesh"
  69331. * @returns "TrailMesh"
  69332. */
  69333. getClassName(): string;
  69334. private _createMesh;
  69335. /**
  69336. * Start trailing mesh.
  69337. */
  69338. start(): void;
  69339. /**
  69340. * Stop trailing mesh.
  69341. */
  69342. stop(): void;
  69343. /**
  69344. * Update trailing mesh geometry.
  69345. */
  69346. update(): void;
  69347. /**
  69348. * Returns a new TrailMesh object.
  69349. * @param name is a string, the name given to the new mesh
  69350. * @param newGenerator use new generator object for cloned trail mesh
  69351. * @returns a new mesh
  69352. */
  69353. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69354. /**
  69355. * Serializes this trail mesh
  69356. * @param serializationObject object to write serialization to
  69357. */
  69358. serialize(serializationObject: any): void;
  69359. /**
  69360. * Parses a serialized trail mesh
  69361. * @param parsedMesh the serialized mesh
  69362. * @param scene the scene to create the trail mesh in
  69363. * @returns the created trail mesh
  69364. */
  69365. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69366. }
  69367. }
  69368. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  69369. import { Nullable } from "babylonjs/types";
  69370. import { Scene } from "babylonjs/scene";
  69371. import { Vector4 } from "babylonjs/Maths/math.vector";
  69372. import { Color4 } from "babylonjs/Maths/math.color";
  69373. import { Mesh } from "babylonjs/Meshes/mesh";
  69374. /**
  69375. * Class containing static functions to help procedurally build meshes
  69376. */
  69377. export class TiledBoxBuilder {
  69378. /**
  69379. * Creates a box mesh
  69380. * 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)
  69381. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69385. * @param name defines the name of the mesh
  69386. * @param options defines the options used to create the mesh
  69387. * @param scene defines the hosting scene
  69388. * @returns the box mesh
  69389. */
  69390. static CreateTiledBox(name: string, options: {
  69391. pattern?: number;
  69392. width?: number;
  69393. height?: number;
  69394. depth?: number;
  69395. tileSize?: number;
  69396. tileWidth?: number;
  69397. tileHeight?: number;
  69398. alignHorizontal?: number;
  69399. alignVertical?: number;
  69400. faceUV?: Vector4[];
  69401. faceColors?: Color4[];
  69402. sideOrientation?: number;
  69403. updatable?: boolean;
  69404. }, scene?: Nullable<Scene>): Mesh;
  69405. }
  69406. }
  69407. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  69408. import { Vector4 } from "babylonjs/Maths/math.vector";
  69409. import { Mesh } from "babylonjs/Meshes/mesh";
  69410. /**
  69411. * Class containing static functions to help procedurally build meshes
  69412. */
  69413. export class TorusKnotBuilder {
  69414. /**
  69415. * Creates a torus knot mesh
  69416. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69417. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69418. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69419. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69423. * @param name defines the name of the mesh
  69424. * @param options defines the options used to create the mesh
  69425. * @param scene defines the hosting scene
  69426. * @returns the torus knot mesh
  69427. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69428. */
  69429. static CreateTorusKnot(name: string, options: {
  69430. radius?: number;
  69431. tube?: number;
  69432. radialSegments?: number;
  69433. tubularSegments?: number;
  69434. p?: number;
  69435. q?: number;
  69436. updatable?: boolean;
  69437. sideOrientation?: number;
  69438. frontUVs?: Vector4;
  69439. backUVs?: Vector4;
  69440. }, scene: any): Mesh;
  69441. }
  69442. }
  69443. declare module "babylonjs/Meshes/polygonMesh" {
  69444. import { Scene } from "babylonjs/scene";
  69445. import { Vector2 } from "babylonjs/Maths/math.vector";
  69446. import { Mesh } from "babylonjs/Meshes/mesh";
  69447. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69448. import { Path2 } from "babylonjs/Maths/math.path";
  69449. /**
  69450. * Polygon
  69451. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69452. */
  69453. export class Polygon {
  69454. /**
  69455. * Creates a rectangle
  69456. * @param xmin bottom X coord
  69457. * @param ymin bottom Y coord
  69458. * @param xmax top X coord
  69459. * @param ymax top Y coord
  69460. * @returns points that make the resulting rectation
  69461. */
  69462. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69463. /**
  69464. * Creates a circle
  69465. * @param radius radius of circle
  69466. * @param cx scale in x
  69467. * @param cy scale in y
  69468. * @param numberOfSides number of sides that make up the circle
  69469. * @returns points that make the resulting circle
  69470. */
  69471. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69472. /**
  69473. * Creates a polygon from input string
  69474. * @param input Input polygon data
  69475. * @returns the parsed points
  69476. */
  69477. static Parse(input: string): Vector2[];
  69478. /**
  69479. * Starts building a polygon from x and y coordinates
  69480. * @param x x coordinate
  69481. * @param y y coordinate
  69482. * @returns the started path2
  69483. */
  69484. static StartingAt(x: number, y: number): Path2;
  69485. }
  69486. /**
  69487. * Builds a polygon
  69488. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69489. */
  69490. export class PolygonMeshBuilder {
  69491. private _points;
  69492. private _outlinepoints;
  69493. private _holes;
  69494. private _name;
  69495. private _scene;
  69496. private _epoints;
  69497. private _eholes;
  69498. private _addToepoint;
  69499. /**
  69500. * Babylon reference to the earcut plugin.
  69501. */
  69502. bjsEarcut: any;
  69503. /**
  69504. * Creates a PolygonMeshBuilder
  69505. * @param name name of the builder
  69506. * @param contours Path of the polygon
  69507. * @param scene scene to add to when creating the mesh
  69508. * @param earcutInjection can be used to inject your own earcut reference
  69509. */
  69510. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69511. /**
  69512. * Adds a whole within the polygon
  69513. * @param hole Array of points defining the hole
  69514. * @returns this
  69515. */
  69516. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69517. /**
  69518. * Creates the polygon
  69519. * @param updatable If the mesh should be updatable
  69520. * @param depth The depth of the mesh created
  69521. * @returns the created mesh
  69522. */
  69523. build(updatable?: boolean, depth?: number): Mesh;
  69524. /**
  69525. * Creates the polygon
  69526. * @param depth The depth of the mesh created
  69527. * @returns the created VertexData
  69528. */
  69529. buildVertexData(depth?: number): VertexData;
  69530. /**
  69531. * Adds a side to the polygon
  69532. * @param positions points that make the polygon
  69533. * @param normals normals of the polygon
  69534. * @param uvs uvs of the polygon
  69535. * @param indices indices of the polygon
  69536. * @param bounds bounds of the polygon
  69537. * @param points points of the polygon
  69538. * @param depth depth of the polygon
  69539. * @param flip flip of the polygon
  69540. */
  69541. private addSide;
  69542. }
  69543. }
  69544. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69545. import { Scene } from "babylonjs/scene";
  69546. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69547. import { Color4 } from "babylonjs/Maths/math.color";
  69548. import { Mesh } from "babylonjs/Meshes/mesh";
  69549. import { Nullable } from "babylonjs/types";
  69550. /**
  69551. * Class containing static functions to help procedurally build meshes
  69552. */
  69553. export class PolygonBuilder {
  69554. /**
  69555. * Creates a polygon mesh
  69556. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69557. * * 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
  69558. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69560. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69561. * * Remember you can only change the shape positions, not their number when updating a polygon
  69562. * @param name defines the name of the mesh
  69563. * @param options defines the options used to create the mesh
  69564. * @param scene defines the hosting scene
  69565. * @param earcutInjection can be used to inject your own earcut reference
  69566. * @returns the polygon mesh
  69567. */
  69568. static CreatePolygon(name: string, options: {
  69569. shape: Vector3[];
  69570. holes?: Vector3[][];
  69571. depth?: number;
  69572. faceUV?: Vector4[];
  69573. faceColors?: Color4[];
  69574. updatable?: boolean;
  69575. sideOrientation?: number;
  69576. frontUVs?: Vector4;
  69577. backUVs?: Vector4;
  69578. wrap?: boolean;
  69579. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69580. /**
  69581. * Creates an extruded polygon mesh, with depth in the Y direction.
  69582. * * 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)
  69583. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69584. * @param name defines the name of the mesh
  69585. * @param options defines the options used to create the mesh
  69586. * @param scene defines the hosting scene
  69587. * @param earcutInjection can be used to inject your own earcut reference
  69588. * @returns the polygon mesh
  69589. */
  69590. static ExtrudePolygon(name: string, options: {
  69591. shape: Vector3[];
  69592. holes?: Vector3[][];
  69593. depth?: number;
  69594. faceUV?: Vector4[];
  69595. faceColors?: Color4[];
  69596. updatable?: boolean;
  69597. sideOrientation?: number;
  69598. frontUVs?: Vector4;
  69599. backUVs?: Vector4;
  69600. wrap?: boolean;
  69601. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69602. }
  69603. }
  69604. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69605. import { Scene } from "babylonjs/scene";
  69606. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69607. import { Mesh } from "babylonjs/Meshes/mesh";
  69608. import { Nullable } from "babylonjs/types";
  69609. /**
  69610. * Class containing static functions to help procedurally build meshes
  69611. */
  69612. export class LatheBuilder {
  69613. /**
  69614. * Creates lathe mesh.
  69615. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69616. * * 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
  69617. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69618. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69619. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69620. * * 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
  69621. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69622. * * 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
  69623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69624. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69625. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69627. * @param name defines the name of the mesh
  69628. * @param options defines the options used to create the mesh
  69629. * @param scene defines the hosting scene
  69630. * @returns the lathe mesh
  69631. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69632. */
  69633. static CreateLathe(name: string, options: {
  69634. shape: Vector3[];
  69635. radius?: number;
  69636. tessellation?: number;
  69637. clip?: number;
  69638. arc?: number;
  69639. closed?: boolean;
  69640. updatable?: boolean;
  69641. sideOrientation?: number;
  69642. frontUVs?: Vector4;
  69643. backUVs?: Vector4;
  69644. cap?: number;
  69645. invertUV?: boolean;
  69646. }, scene?: Nullable<Scene>): Mesh;
  69647. }
  69648. }
  69649. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69650. import { Nullable } from "babylonjs/types";
  69651. import { Scene } from "babylonjs/scene";
  69652. import { Vector4 } from "babylonjs/Maths/math.vector";
  69653. import { Mesh } from "babylonjs/Meshes/mesh";
  69654. /**
  69655. * Class containing static functions to help procedurally build meshes
  69656. */
  69657. export class TiledPlaneBuilder {
  69658. /**
  69659. * Creates a tiled plane mesh
  69660. * * The parameter `pattern` will, depending on value, do nothing or
  69661. * * * flip (reflect about central vertical) alternate tiles across and up
  69662. * * * flip every tile on alternate rows
  69663. * * * rotate (180 degs) alternate tiles across and up
  69664. * * * rotate every tile on alternate rows
  69665. * * * flip and rotate alternate tiles across and up
  69666. * * * flip and rotate every tile on alternate rows
  69667. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69668. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69670. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69671. * * 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)
  69672. * * 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)
  69673. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69674. * @param name defines the name of the mesh
  69675. * @param options defines the options used to create the mesh
  69676. * @param scene defines the hosting scene
  69677. * @returns the box mesh
  69678. */
  69679. static CreateTiledPlane(name: string, options: {
  69680. pattern?: number;
  69681. tileSize?: number;
  69682. tileWidth?: number;
  69683. tileHeight?: number;
  69684. size?: number;
  69685. width?: number;
  69686. height?: number;
  69687. alignHorizontal?: number;
  69688. alignVertical?: number;
  69689. sideOrientation?: number;
  69690. frontUVs?: Vector4;
  69691. backUVs?: Vector4;
  69692. updatable?: boolean;
  69693. }, scene?: Nullable<Scene>): Mesh;
  69694. }
  69695. }
  69696. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69697. import { Nullable } from "babylonjs/types";
  69698. import { Scene } from "babylonjs/scene";
  69699. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69700. import { Mesh } from "babylonjs/Meshes/mesh";
  69701. /**
  69702. * Class containing static functions to help procedurally build meshes
  69703. */
  69704. export class TubeBuilder {
  69705. /**
  69706. * Creates a tube mesh.
  69707. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69708. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69709. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69710. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69711. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69712. * * 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)
  69713. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69714. * * 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
  69715. * * 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
  69716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69718. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69720. * @param name defines the name of the mesh
  69721. * @param options defines the options used to create the mesh
  69722. * @param scene defines the hosting scene
  69723. * @returns the tube mesh
  69724. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69725. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69726. */
  69727. static CreateTube(name: string, options: {
  69728. path: Vector3[];
  69729. radius?: number;
  69730. tessellation?: number;
  69731. radiusFunction?: {
  69732. (i: number, distance: number): number;
  69733. };
  69734. cap?: number;
  69735. arc?: number;
  69736. updatable?: boolean;
  69737. sideOrientation?: number;
  69738. frontUVs?: Vector4;
  69739. backUVs?: Vector4;
  69740. instance?: Mesh;
  69741. invertUV?: boolean;
  69742. }, scene?: Nullable<Scene>): Mesh;
  69743. }
  69744. }
  69745. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69746. import { Scene } from "babylonjs/scene";
  69747. import { Vector4 } from "babylonjs/Maths/math.vector";
  69748. import { Mesh } from "babylonjs/Meshes/mesh";
  69749. import { Nullable } from "babylonjs/types";
  69750. /**
  69751. * Class containing static functions to help procedurally build meshes
  69752. */
  69753. export class IcoSphereBuilder {
  69754. /**
  69755. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69756. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69757. * * 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`)
  69758. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69759. * * 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
  69760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69761. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69763. * @param name defines the name of the mesh
  69764. * @param options defines the options used to create the mesh
  69765. * @param scene defines the hosting scene
  69766. * @returns the icosahedron mesh
  69767. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69768. */
  69769. static CreateIcoSphere(name: string, options: {
  69770. radius?: number;
  69771. radiusX?: number;
  69772. radiusY?: number;
  69773. radiusZ?: number;
  69774. flat?: boolean;
  69775. subdivisions?: number;
  69776. sideOrientation?: number;
  69777. frontUVs?: Vector4;
  69778. backUVs?: Vector4;
  69779. updatable?: boolean;
  69780. }, scene?: Nullable<Scene>): Mesh;
  69781. }
  69782. }
  69783. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69784. import { Vector3 } from "babylonjs/Maths/math.vector";
  69785. import { Mesh } from "babylonjs/Meshes/mesh";
  69786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69787. /**
  69788. * Class containing static functions to help procedurally build meshes
  69789. */
  69790. export class DecalBuilder {
  69791. /**
  69792. * Creates a decal mesh.
  69793. * 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
  69794. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69795. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69796. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69797. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69798. * @param name defines the name of the mesh
  69799. * @param sourceMesh defines the mesh where the decal must be applied
  69800. * @param options defines the options used to create the mesh
  69801. * @param scene defines the hosting scene
  69802. * @returns the decal mesh
  69803. * @see https://doc.babylonjs.com/how_to/decals
  69804. */
  69805. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69806. position?: Vector3;
  69807. normal?: Vector3;
  69808. size?: Vector3;
  69809. angle?: number;
  69810. }): Mesh;
  69811. }
  69812. }
  69813. declare module "babylonjs/Meshes/meshBuilder" {
  69814. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69815. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69816. import { Nullable } from "babylonjs/types";
  69817. import { Scene } from "babylonjs/scene";
  69818. import { Mesh } from "babylonjs/Meshes/mesh";
  69819. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69820. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69822. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69823. import { Plane } from "babylonjs/Maths/math.plane";
  69824. /**
  69825. * Class containing static functions to help procedurally build meshes
  69826. */
  69827. export class MeshBuilder {
  69828. /**
  69829. * Creates a box mesh
  69830. * * The parameter `size` sets the size (float) of each box side (default 1)
  69831. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69832. * * 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)
  69833. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69835. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69837. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69838. * @param name defines the name of the mesh
  69839. * @param options defines the options used to create the mesh
  69840. * @param scene defines the hosting scene
  69841. * @returns the box mesh
  69842. */
  69843. static CreateBox(name: string, options: {
  69844. size?: number;
  69845. width?: number;
  69846. height?: number;
  69847. depth?: number;
  69848. faceUV?: Vector4[];
  69849. faceColors?: Color4[];
  69850. sideOrientation?: number;
  69851. frontUVs?: Vector4;
  69852. backUVs?: Vector4;
  69853. wrap?: boolean;
  69854. topBaseAt?: number;
  69855. bottomBaseAt?: number;
  69856. updatable?: boolean;
  69857. }, scene?: Nullable<Scene>): Mesh;
  69858. /**
  69859. * Creates a tiled box mesh
  69860. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69862. * @param name defines the name of the mesh
  69863. * @param options defines the options used to create the mesh
  69864. * @param scene defines the hosting scene
  69865. * @returns the tiled box mesh
  69866. */
  69867. static CreateTiledBox(name: string, options: {
  69868. pattern?: number;
  69869. size?: number;
  69870. width?: number;
  69871. height?: number;
  69872. depth: number;
  69873. tileSize?: number;
  69874. tileWidth?: number;
  69875. tileHeight?: number;
  69876. faceUV?: Vector4[];
  69877. faceColors?: Color4[];
  69878. alignHorizontal?: number;
  69879. alignVertical?: number;
  69880. sideOrientation?: number;
  69881. updatable?: boolean;
  69882. }, scene?: Nullable<Scene>): Mesh;
  69883. /**
  69884. * Creates a sphere mesh
  69885. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69886. * * 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`)
  69887. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69888. * * 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
  69889. * * 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)
  69890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69893. * @param name defines the name of the mesh
  69894. * @param options defines the options used to create the mesh
  69895. * @param scene defines the hosting scene
  69896. * @returns the sphere mesh
  69897. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69898. */
  69899. static CreateSphere(name: string, options: {
  69900. segments?: number;
  69901. diameter?: number;
  69902. diameterX?: number;
  69903. diameterY?: number;
  69904. diameterZ?: number;
  69905. arc?: number;
  69906. slice?: number;
  69907. sideOrientation?: number;
  69908. frontUVs?: Vector4;
  69909. backUVs?: Vector4;
  69910. updatable?: boolean;
  69911. }, scene?: Nullable<Scene>): Mesh;
  69912. /**
  69913. * Creates a plane polygonal mesh. By default, this is a disc
  69914. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69915. * * 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
  69916. * * 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
  69917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69920. * @param name defines the name of the mesh
  69921. * @param options defines the options used to create the mesh
  69922. * @param scene defines the hosting scene
  69923. * @returns the plane polygonal mesh
  69924. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69925. */
  69926. static CreateDisc(name: string, options: {
  69927. radius?: number;
  69928. tessellation?: number;
  69929. arc?: number;
  69930. updatable?: boolean;
  69931. sideOrientation?: number;
  69932. frontUVs?: Vector4;
  69933. backUVs?: Vector4;
  69934. }, scene?: Nullable<Scene>): Mesh;
  69935. /**
  69936. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69937. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69938. * * 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`)
  69939. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69940. * * 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
  69941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69942. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69944. * @param name defines the name of the mesh
  69945. * @param options defines the options used to create the mesh
  69946. * @param scene defines the hosting scene
  69947. * @returns the icosahedron mesh
  69948. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69949. */
  69950. static CreateIcoSphere(name: string, options: {
  69951. radius?: number;
  69952. radiusX?: number;
  69953. radiusY?: number;
  69954. radiusZ?: number;
  69955. flat?: boolean;
  69956. subdivisions?: number;
  69957. sideOrientation?: number;
  69958. frontUVs?: Vector4;
  69959. backUVs?: Vector4;
  69960. updatable?: boolean;
  69961. }, scene?: Nullable<Scene>): Mesh;
  69962. /**
  69963. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69964. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69965. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69966. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69967. * * 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
  69968. * * 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
  69969. * * 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
  69970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69971. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69972. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69973. * * 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
  69974. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69975. * * 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
  69976. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69978. * @param name defines the name of the mesh
  69979. * @param options defines the options used to create the mesh
  69980. * @param scene defines the hosting scene
  69981. * @returns the ribbon mesh
  69982. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69983. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69984. */
  69985. static CreateRibbon(name: string, options: {
  69986. pathArray: Vector3[][];
  69987. closeArray?: boolean;
  69988. closePath?: boolean;
  69989. offset?: number;
  69990. updatable?: boolean;
  69991. sideOrientation?: number;
  69992. frontUVs?: Vector4;
  69993. backUVs?: Vector4;
  69994. instance?: Mesh;
  69995. invertUV?: boolean;
  69996. uvs?: Vector2[];
  69997. colors?: Color4[];
  69998. }, scene?: Nullable<Scene>): Mesh;
  69999. /**
  70000. * Creates a cylinder or a cone mesh
  70001. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70002. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70003. * * 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.
  70004. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70005. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70006. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70007. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70008. * * 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).
  70009. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70010. * * 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).
  70011. * * 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
  70012. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70013. * * 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
  70014. * * 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.
  70015. * * If `enclose` is false, a ring surface is one element.
  70016. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70017. * * 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
  70018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70021. * @param name defines the name of the mesh
  70022. * @param options defines the options used to create the mesh
  70023. * @param scene defines the hosting scene
  70024. * @returns the cylinder mesh
  70025. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70026. */
  70027. static CreateCylinder(name: string, options: {
  70028. height?: number;
  70029. diameterTop?: number;
  70030. diameterBottom?: number;
  70031. diameter?: number;
  70032. tessellation?: number;
  70033. subdivisions?: number;
  70034. arc?: number;
  70035. faceColors?: Color4[];
  70036. faceUV?: Vector4[];
  70037. updatable?: boolean;
  70038. hasRings?: boolean;
  70039. enclose?: boolean;
  70040. cap?: number;
  70041. sideOrientation?: number;
  70042. frontUVs?: Vector4;
  70043. backUVs?: Vector4;
  70044. }, scene?: Nullable<Scene>): Mesh;
  70045. /**
  70046. * Creates a torus mesh
  70047. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70048. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70049. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70051. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70053. * @param name defines the name of the mesh
  70054. * @param options defines the options used to create the mesh
  70055. * @param scene defines the hosting scene
  70056. * @returns the torus mesh
  70057. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70058. */
  70059. static CreateTorus(name: string, options: {
  70060. diameter?: number;
  70061. thickness?: number;
  70062. tessellation?: number;
  70063. updatable?: boolean;
  70064. sideOrientation?: number;
  70065. frontUVs?: Vector4;
  70066. backUVs?: Vector4;
  70067. }, scene?: Nullable<Scene>): Mesh;
  70068. /**
  70069. * Creates a torus knot mesh
  70070. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70071. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70072. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70073. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70077. * @param name defines the name of the mesh
  70078. * @param options defines the options used to create the mesh
  70079. * @param scene defines the hosting scene
  70080. * @returns the torus knot mesh
  70081. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70082. */
  70083. static CreateTorusKnot(name: string, options: {
  70084. radius?: number;
  70085. tube?: number;
  70086. radialSegments?: number;
  70087. tubularSegments?: number;
  70088. p?: number;
  70089. q?: number;
  70090. updatable?: boolean;
  70091. sideOrientation?: number;
  70092. frontUVs?: Vector4;
  70093. backUVs?: Vector4;
  70094. }, scene?: Nullable<Scene>): Mesh;
  70095. /**
  70096. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70097. * * 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
  70098. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70099. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70100. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70101. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70102. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70103. * * 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
  70104. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70107. * @param name defines the name of the new line system
  70108. * @param options defines the options used to create the line system
  70109. * @param scene defines the hosting scene
  70110. * @returns a new line system mesh
  70111. */
  70112. static CreateLineSystem(name: string, options: {
  70113. lines: Vector3[][];
  70114. updatable?: boolean;
  70115. instance?: Nullable<LinesMesh>;
  70116. colors?: Nullable<Color4[][]>;
  70117. useVertexAlpha?: boolean;
  70118. }, scene: Nullable<Scene>): LinesMesh;
  70119. /**
  70120. * Creates a line mesh
  70121. * 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
  70122. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70123. * * The parameter `points` is an array successive Vector3
  70124. * * 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
  70125. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70126. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70127. * * When updating an instance, remember that only point positions can change, not the number of points
  70128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70130. * @param name defines the name of the new line system
  70131. * @param options defines the options used to create the line system
  70132. * @param scene defines the hosting scene
  70133. * @returns a new line mesh
  70134. */
  70135. static CreateLines(name: string, options: {
  70136. points: Vector3[];
  70137. updatable?: boolean;
  70138. instance?: Nullable<LinesMesh>;
  70139. colors?: Color4[];
  70140. useVertexAlpha?: boolean;
  70141. }, scene?: Nullable<Scene>): LinesMesh;
  70142. /**
  70143. * Creates a dashed line mesh
  70144. * * 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
  70145. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70146. * * The parameter `points` is an array successive Vector3
  70147. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70148. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70149. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70150. * * 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
  70151. * * When updating an instance, remember that only point positions can change, not the number of points
  70152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70153. * @param name defines the name of the mesh
  70154. * @param options defines the options used to create the mesh
  70155. * @param scene defines the hosting scene
  70156. * @returns the dashed line mesh
  70157. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70158. */
  70159. static CreateDashedLines(name: string, options: {
  70160. points: Vector3[];
  70161. dashSize?: number;
  70162. gapSize?: number;
  70163. dashNb?: number;
  70164. updatable?: boolean;
  70165. instance?: LinesMesh;
  70166. }, scene?: Nullable<Scene>): LinesMesh;
  70167. /**
  70168. * 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.
  70169. * * 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.
  70170. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70171. * * 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.
  70172. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70173. * * 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
  70174. * * 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
  70175. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70177. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70178. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70180. * @param name defines the name of the mesh
  70181. * @param options defines the options used to create the mesh
  70182. * @param scene defines the hosting scene
  70183. * @returns the extruded shape mesh
  70184. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70185. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70186. */
  70187. static ExtrudeShape(name: string, options: {
  70188. shape: Vector3[];
  70189. path: Vector3[];
  70190. scale?: number;
  70191. rotation?: number;
  70192. cap?: number;
  70193. updatable?: boolean;
  70194. sideOrientation?: number;
  70195. frontUVs?: Vector4;
  70196. backUVs?: Vector4;
  70197. instance?: Mesh;
  70198. invertUV?: boolean;
  70199. }, scene?: Nullable<Scene>): Mesh;
  70200. /**
  70201. * Creates an custom extruded shape mesh.
  70202. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70203. * * 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.
  70204. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70205. * * 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
  70206. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70207. * * 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
  70208. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70209. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70210. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70211. * * 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
  70212. * * 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
  70213. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70216. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70218. * @param name defines the name of the mesh
  70219. * @param options defines the options used to create the mesh
  70220. * @param scene defines the hosting scene
  70221. * @returns the custom extruded shape mesh
  70222. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70223. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70224. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70225. */
  70226. static ExtrudeShapeCustom(name: string, options: {
  70227. shape: Vector3[];
  70228. path: Vector3[];
  70229. scaleFunction?: any;
  70230. rotationFunction?: any;
  70231. ribbonCloseArray?: boolean;
  70232. ribbonClosePath?: boolean;
  70233. cap?: number;
  70234. updatable?: boolean;
  70235. sideOrientation?: number;
  70236. frontUVs?: Vector4;
  70237. backUVs?: Vector4;
  70238. instance?: Mesh;
  70239. invertUV?: boolean;
  70240. }, scene?: Nullable<Scene>): Mesh;
  70241. /**
  70242. * Creates lathe mesh.
  70243. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70244. * * 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
  70245. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70246. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70247. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70248. * * 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
  70249. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70250. * * 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
  70251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70252. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70253. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70255. * @param name defines the name of the mesh
  70256. * @param options defines the options used to create the mesh
  70257. * @param scene defines the hosting scene
  70258. * @returns the lathe mesh
  70259. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70260. */
  70261. static CreateLathe(name: string, options: {
  70262. shape: Vector3[];
  70263. radius?: number;
  70264. tessellation?: number;
  70265. clip?: number;
  70266. arc?: number;
  70267. closed?: boolean;
  70268. updatable?: boolean;
  70269. sideOrientation?: number;
  70270. frontUVs?: Vector4;
  70271. backUVs?: Vector4;
  70272. cap?: number;
  70273. invertUV?: boolean;
  70274. }, scene?: Nullable<Scene>): Mesh;
  70275. /**
  70276. * Creates a tiled plane mesh
  70277. * * You can set a limited pattern arrangement with the tiles
  70278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70281. * @param name defines the name of the mesh
  70282. * @param options defines the options used to create the mesh
  70283. * @param scene defines the hosting scene
  70284. * @returns the plane mesh
  70285. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70286. */
  70287. static CreateTiledPlane(name: string, options: {
  70288. pattern?: number;
  70289. tileSize?: number;
  70290. tileWidth?: number;
  70291. tileHeight?: number;
  70292. size?: number;
  70293. width?: number;
  70294. height?: number;
  70295. alignHorizontal?: number;
  70296. alignVertical?: number;
  70297. sideOrientation?: number;
  70298. frontUVs?: Vector4;
  70299. backUVs?: Vector4;
  70300. updatable?: boolean;
  70301. }, scene?: Nullable<Scene>): Mesh;
  70302. /**
  70303. * Creates a plane mesh
  70304. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70305. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70306. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70310. * @param name defines the name of the mesh
  70311. * @param options defines the options used to create the mesh
  70312. * @param scene defines the hosting scene
  70313. * @returns the plane mesh
  70314. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70315. */
  70316. static CreatePlane(name: string, options: {
  70317. size?: number;
  70318. width?: number;
  70319. height?: number;
  70320. sideOrientation?: number;
  70321. frontUVs?: Vector4;
  70322. backUVs?: Vector4;
  70323. updatable?: boolean;
  70324. sourcePlane?: Plane;
  70325. }, scene?: Nullable<Scene>): Mesh;
  70326. /**
  70327. * Creates a ground mesh
  70328. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70329. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70331. * @param name defines the name of the mesh
  70332. * @param options defines the options used to create the mesh
  70333. * @param scene defines the hosting scene
  70334. * @returns the ground mesh
  70335. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70336. */
  70337. static CreateGround(name: string, options: {
  70338. width?: number;
  70339. height?: number;
  70340. subdivisions?: number;
  70341. subdivisionsX?: number;
  70342. subdivisionsY?: number;
  70343. updatable?: boolean;
  70344. }, scene?: Nullable<Scene>): Mesh;
  70345. /**
  70346. * Creates a tiled ground mesh
  70347. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70348. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70349. * * 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
  70350. * * 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
  70351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70352. * @param name defines the name of the mesh
  70353. * @param options defines the options used to create the mesh
  70354. * @param scene defines the hosting scene
  70355. * @returns the tiled ground mesh
  70356. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70357. */
  70358. static CreateTiledGround(name: string, options: {
  70359. xmin: number;
  70360. zmin: number;
  70361. xmax: number;
  70362. zmax: number;
  70363. subdivisions?: {
  70364. w: number;
  70365. h: number;
  70366. };
  70367. precision?: {
  70368. w: number;
  70369. h: number;
  70370. };
  70371. updatable?: boolean;
  70372. }, scene?: Nullable<Scene>): Mesh;
  70373. /**
  70374. * Creates a ground mesh from a height map
  70375. * * The parameter `url` sets the URL of the height map image resource.
  70376. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70377. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70378. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70379. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70380. * * 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.
  70381. * * 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).
  70382. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70384. * @param name defines the name of the mesh
  70385. * @param url defines the url to the height map
  70386. * @param options defines the options used to create the mesh
  70387. * @param scene defines the hosting scene
  70388. * @returns the ground mesh
  70389. * @see https://doc.babylonjs.com/babylon101/height_map
  70390. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70391. */
  70392. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70393. width?: number;
  70394. height?: number;
  70395. subdivisions?: number;
  70396. minHeight?: number;
  70397. maxHeight?: number;
  70398. colorFilter?: Color3;
  70399. alphaFilter?: number;
  70400. updatable?: boolean;
  70401. onReady?: (mesh: GroundMesh) => void;
  70402. }, scene?: Nullable<Scene>): GroundMesh;
  70403. /**
  70404. * Creates a polygon mesh
  70405. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70406. * * 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
  70407. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70410. * * Remember you can only change the shape positions, not their number when updating a polygon
  70411. * @param name defines the name of the mesh
  70412. * @param options defines the options used to create the mesh
  70413. * @param scene defines the hosting scene
  70414. * @param earcutInjection can be used to inject your own earcut reference
  70415. * @returns the polygon mesh
  70416. */
  70417. static CreatePolygon(name: string, options: {
  70418. shape: Vector3[];
  70419. holes?: Vector3[][];
  70420. depth?: number;
  70421. faceUV?: Vector4[];
  70422. faceColors?: Color4[];
  70423. updatable?: boolean;
  70424. sideOrientation?: number;
  70425. frontUVs?: Vector4;
  70426. backUVs?: Vector4;
  70427. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70428. /**
  70429. * Creates an extruded polygon mesh, with depth in the Y direction.
  70430. * * 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)
  70431. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70432. * @param name defines the name of the mesh
  70433. * @param options defines the options used to create the mesh
  70434. * @param scene defines the hosting scene
  70435. * @param earcutInjection can be used to inject your own earcut reference
  70436. * @returns the polygon mesh
  70437. */
  70438. static ExtrudePolygon(name: string, options: {
  70439. shape: Vector3[];
  70440. holes?: Vector3[][];
  70441. depth?: number;
  70442. faceUV?: Vector4[];
  70443. faceColors?: Color4[];
  70444. updatable?: boolean;
  70445. sideOrientation?: number;
  70446. frontUVs?: Vector4;
  70447. backUVs?: Vector4;
  70448. wrap?: boolean;
  70449. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70450. /**
  70451. * Creates a tube mesh.
  70452. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70453. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70454. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70455. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70456. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70457. * * 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)
  70458. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70459. * * 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
  70460. * * 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
  70461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70463. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70465. * @param name defines the name of the mesh
  70466. * @param options defines the options used to create the mesh
  70467. * @param scene defines the hosting scene
  70468. * @returns the tube mesh
  70469. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70470. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70471. */
  70472. static CreateTube(name: string, options: {
  70473. path: Vector3[];
  70474. radius?: number;
  70475. tessellation?: number;
  70476. radiusFunction?: {
  70477. (i: number, distance: number): number;
  70478. };
  70479. cap?: number;
  70480. arc?: number;
  70481. updatable?: boolean;
  70482. sideOrientation?: number;
  70483. frontUVs?: Vector4;
  70484. backUVs?: Vector4;
  70485. instance?: Mesh;
  70486. invertUV?: boolean;
  70487. }, scene?: Nullable<Scene>): Mesh;
  70488. /**
  70489. * Creates a polyhedron mesh
  70490. * * 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
  70491. * * The parameter `size` (positive float, default 1) sets the polygon size
  70492. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70493. * * 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`
  70494. * * 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
  70495. * * 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)`)
  70496. * * 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
  70497. * * 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
  70498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70501. * @param name defines the name of the mesh
  70502. * @param options defines the options used to create the mesh
  70503. * @param scene defines the hosting scene
  70504. * @returns the polyhedron mesh
  70505. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70506. */
  70507. static CreatePolyhedron(name: string, options: {
  70508. type?: number;
  70509. size?: number;
  70510. sizeX?: number;
  70511. sizeY?: number;
  70512. sizeZ?: number;
  70513. custom?: any;
  70514. faceUV?: Vector4[];
  70515. faceColors?: Color4[];
  70516. flat?: boolean;
  70517. updatable?: boolean;
  70518. sideOrientation?: number;
  70519. frontUVs?: Vector4;
  70520. backUVs?: Vector4;
  70521. }, scene?: Nullable<Scene>): Mesh;
  70522. /**
  70523. * Creates a decal mesh.
  70524. * 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
  70525. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70526. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70527. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70528. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70529. * @param name defines the name of the mesh
  70530. * @param sourceMesh defines the mesh where the decal must be applied
  70531. * @param options defines the options used to create the mesh
  70532. * @param scene defines the hosting scene
  70533. * @returns the decal mesh
  70534. * @see https://doc.babylonjs.com/how_to/decals
  70535. */
  70536. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70537. position?: Vector3;
  70538. normal?: Vector3;
  70539. size?: Vector3;
  70540. angle?: number;
  70541. }): Mesh;
  70542. /**
  70543. * Creates a Capsule Mesh
  70544. * @param name defines the name of the mesh.
  70545. * @param options the constructors options used to shape the mesh.
  70546. * @param scene defines the scene the mesh is scoped to.
  70547. * @returns the capsule mesh
  70548. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70549. */
  70550. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70551. }
  70552. }
  70553. declare module "babylonjs/Meshes/meshSimplification" {
  70554. import { Mesh } from "babylonjs/Meshes/mesh";
  70555. /**
  70556. * A simplifier interface for future simplification implementations
  70557. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70558. */
  70559. export interface ISimplifier {
  70560. /**
  70561. * Simplification of a given mesh according to the given settings.
  70562. * Since this requires computation, it is assumed that the function runs async.
  70563. * @param settings The settings of the simplification, including quality and distance
  70564. * @param successCallback A callback that will be called after the mesh was simplified.
  70565. * @param errorCallback in case of an error, this callback will be called. optional.
  70566. */
  70567. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70568. }
  70569. /**
  70570. * Expected simplification settings.
  70571. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70572. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70573. */
  70574. export interface ISimplificationSettings {
  70575. /**
  70576. * Gets or sets the expected quality
  70577. */
  70578. quality: number;
  70579. /**
  70580. * Gets or sets the distance when this optimized version should be used
  70581. */
  70582. distance: number;
  70583. /**
  70584. * Gets an already optimized mesh
  70585. */
  70586. optimizeMesh?: boolean;
  70587. }
  70588. /**
  70589. * Class used to specify simplification options
  70590. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70591. */
  70592. export class SimplificationSettings implements ISimplificationSettings {
  70593. /** expected quality */
  70594. quality: number;
  70595. /** distance when this optimized version should be used */
  70596. distance: number;
  70597. /** already optimized mesh */
  70598. optimizeMesh?: boolean | undefined;
  70599. /**
  70600. * Creates a SimplificationSettings
  70601. * @param quality expected quality
  70602. * @param distance distance when this optimized version should be used
  70603. * @param optimizeMesh already optimized mesh
  70604. */
  70605. constructor(
  70606. /** expected quality */
  70607. quality: number,
  70608. /** distance when this optimized version should be used */
  70609. distance: number,
  70610. /** already optimized mesh */
  70611. optimizeMesh?: boolean | undefined);
  70612. }
  70613. /**
  70614. * Interface used to define a simplification task
  70615. */
  70616. export interface ISimplificationTask {
  70617. /**
  70618. * Array of settings
  70619. */
  70620. settings: Array<ISimplificationSettings>;
  70621. /**
  70622. * Simplification type
  70623. */
  70624. simplificationType: SimplificationType;
  70625. /**
  70626. * Mesh to simplify
  70627. */
  70628. mesh: Mesh;
  70629. /**
  70630. * Callback called on success
  70631. */
  70632. successCallback?: () => void;
  70633. /**
  70634. * Defines if parallel processing can be used
  70635. */
  70636. parallelProcessing: boolean;
  70637. }
  70638. /**
  70639. * Queue used to order the simplification tasks
  70640. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70641. */
  70642. export class SimplificationQueue {
  70643. private _simplificationArray;
  70644. /**
  70645. * Gets a boolean indicating that the process is still running
  70646. */
  70647. running: boolean;
  70648. /**
  70649. * Creates a new queue
  70650. */
  70651. constructor();
  70652. /**
  70653. * Adds a new simplification task
  70654. * @param task defines a task to add
  70655. */
  70656. addTask(task: ISimplificationTask): void;
  70657. /**
  70658. * Execute next task
  70659. */
  70660. executeNext(): void;
  70661. /**
  70662. * Execute a simplification task
  70663. * @param task defines the task to run
  70664. */
  70665. runSimplification(task: ISimplificationTask): void;
  70666. private getSimplifier;
  70667. }
  70668. /**
  70669. * The implemented types of simplification
  70670. * At the moment only Quadratic Error Decimation is implemented
  70671. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70672. */
  70673. export enum SimplificationType {
  70674. /** Quadratic error decimation */
  70675. QUADRATIC = 0
  70676. }
  70677. /**
  70678. * An implementation of the Quadratic Error simplification algorithm.
  70679. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70680. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70681. * @author RaananW
  70682. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70683. */
  70684. export class QuadraticErrorSimplification implements ISimplifier {
  70685. private _mesh;
  70686. private triangles;
  70687. private vertices;
  70688. private references;
  70689. private _reconstructedMesh;
  70690. /** Gets or sets the number pf sync interations */
  70691. syncIterations: number;
  70692. /** Gets or sets the aggressiveness of the simplifier */
  70693. aggressiveness: number;
  70694. /** Gets or sets the number of allowed iterations for decimation */
  70695. decimationIterations: number;
  70696. /** Gets or sets the espilon to use for bounding box computation */
  70697. boundingBoxEpsilon: number;
  70698. /**
  70699. * Creates a new QuadraticErrorSimplification
  70700. * @param _mesh defines the target mesh
  70701. */
  70702. constructor(_mesh: Mesh);
  70703. /**
  70704. * Simplification of a given mesh according to the given settings.
  70705. * Since this requires computation, it is assumed that the function runs async.
  70706. * @param settings The settings of the simplification, including quality and distance
  70707. * @param successCallback A callback that will be called after the mesh was simplified.
  70708. */
  70709. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70710. private runDecimation;
  70711. private initWithMesh;
  70712. private init;
  70713. private reconstructMesh;
  70714. private initDecimatedMesh;
  70715. private isFlipped;
  70716. private updateTriangles;
  70717. private identifyBorder;
  70718. private updateMesh;
  70719. private vertexError;
  70720. private calculateError;
  70721. }
  70722. }
  70723. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70724. import { Scene } from "babylonjs/scene";
  70725. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70726. import { ISceneComponent } from "babylonjs/sceneComponent";
  70727. module "babylonjs/scene" {
  70728. interface Scene {
  70729. /** @hidden (Backing field) */
  70730. _simplificationQueue: SimplificationQueue;
  70731. /**
  70732. * Gets or sets the simplification queue attached to the scene
  70733. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70734. */
  70735. simplificationQueue: SimplificationQueue;
  70736. }
  70737. }
  70738. module "babylonjs/Meshes/mesh" {
  70739. interface Mesh {
  70740. /**
  70741. * Simplify the mesh according to the given array of settings.
  70742. * Function will return immediately and will simplify async
  70743. * @param settings a collection of simplification settings
  70744. * @param parallelProcessing should all levels calculate parallel or one after the other
  70745. * @param simplificationType the type of simplification to run
  70746. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70747. * @returns the current mesh
  70748. */
  70749. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70750. }
  70751. }
  70752. /**
  70753. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70754. * created in a scene
  70755. */
  70756. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70757. /**
  70758. * The component name helpfull to identify the component in the list of scene components.
  70759. */
  70760. readonly name: string;
  70761. /**
  70762. * The scene the component belongs to.
  70763. */
  70764. scene: Scene;
  70765. /**
  70766. * Creates a new instance of the component for the given scene
  70767. * @param scene Defines the scene to register the component in
  70768. */
  70769. constructor(scene: Scene);
  70770. /**
  70771. * Registers the component in a given scene
  70772. */
  70773. register(): void;
  70774. /**
  70775. * Rebuilds the elements related to this component in case of
  70776. * context lost for instance.
  70777. */
  70778. rebuild(): void;
  70779. /**
  70780. * Disposes the component and the associated ressources
  70781. */
  70782. dispose(): void;
  70783. private _beforeCameraUpdate;
  70784. }
  70785. }
  70786. declare module "babylonjs/Meshes/Builders/index" {
  70787. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70788. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70789. export * from "babylonjs/Meshes/Builders/discBuilder";
  70790. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70791. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70792. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70793. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70794. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70795. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70796. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70797. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70798. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70799. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70800. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70801. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70802. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70803. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70804. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70805. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70806. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70807. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70808. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70809. }
  70810. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70811. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70812. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70813. import { Matrix } from "babylonjs/Maths/math.vector";
  70814. module "babylonjs/Meshes/mesh" {
  70815. interface Mesh {
  70816. /**
  70817. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70818. */
  70819. thinInstanceEnablePicking: boolean;
  70820. /**
  70821. * Creates a new thin instance
  70822. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70823. * @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
  70824. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70825. */
  70826. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70827. /**
  70828. * Adds the transformation (matrix) of the current mesh as a thin instance
  70829. * @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
  70830. * @returns the thin instance index number
  70831. */
  70832. thinInstanceAddSelf(refresh: boolean): number;
  70833. /**
  70834. * Registers a custom attribute to be used with thin instances
  70835. * @param kind name of the attribute
  70836. * @param stride size in floats of the attribute
  70837. */
  70838. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70839. /**
  70840. * Sets the matrix of a thin instance
  70841. * @param index index of the thin instance
  70842. * @param matrix matrix to set
  70843. * @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
  70844. */
  70845. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70846. /**
  70847. * Sets the value of a custom attribute for a thin instance
  70848. * @param kind name of the attribute
  70849. * @param index index of the thin instance
  70850. * @param value value to set
  70851. * @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
  70852. */
  70853. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70854. /**
  70855. * 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.
  70856. */
  70857. thinInstanceCount: number;
  70858. /**
  70859. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70860. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70861. * @param buffer buffer to set
  70862. * @param stride size in floats of each value of the buffer
  70863. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70864. */
  70865. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70866. /**
  70867. * Gets the list of world matrices
  70868. * @return an array containing all the world matrices from the thin instances
  70869. */
  70870. thinInstanceGetWorldMatrices(): Matrix[];
  70871. /**
  70872. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70873. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70874. */
  70875. thinInstanceBufferUpdated(kind: string): void;
  70876. /**
  70877. * Applies a partial update to a buffer directly on the GPU
  70878. * 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
  70879. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70880. * @param data the data to set in the GPU buffer
  70881. * @param offset the offset in the GPU buffer where to update the data
  70882. */
  70883. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70884. /**
  70885. * Refreshes the bounding info, taking into account all the thin instances defined
  70886. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70887. */
  70888. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70889. /** @hidden */
  70890. _thinInstanceInitializeUserStorage(): void;
  70891. /** @hidden */
  70892. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70893. /** @hidden */
  70894. _userThinInstanceBuffersStorage: {
  70895. data: {
  70896. [key: string]: Float32Array;
  70897. };
  70898. sizes: {
  70899. [key: string]: number;
  70900. };
  70901. vertexBuffers: {
  70902. [key: string]: Nullable<VertexBuffer>;
  70903. };
  70904. strides: {
  70905. [key: string]: number;
  70906. };
  70907. };
  70908. }
  70909. }
  70910. }
  70911. declare module "babylonjs/Meshes/index" {
  70912. export * from "babylonjs/Meshes/abstractMesh";
  70913. export * from "babylonjs/Meshes/buffer";
  70914. export * from "babylonjs/Meshes/Compression/index";
  70915. export * from "babylonjs/Meshes/csg";
  70916. export * from "babylonjs/Meshes/geometry";
  70917. export * from "babylonjs/Meshes/groundMesh";
  70918. export * from "babylonjs/Meshes/trailMesh";
  70919. export * from "babylonjs/Meshes/instancedMesh";
  70920. export * from "babylonjs/Meshes/linesMesh";
  70921. export * from "babylonjs/Meshes/mesh";
  70922. export * from "babylonjs/Meshes/mesh.vertexData";
  70923. export * from "babylonjs/Meshes/meshBuilder";
  70924. export * from "babylonjs/Meshes/meshSimplification";
  70925. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70926. export * from "babylonjs/Meshes/polygonMesh";
  70927. export * from "babylonjs/Meshes/subMesh";
  70928. export * from "babylonjs/Meshes/meshLODLevel";
  70929. export * from "babylonjs/Meshes/transformNode";
  70930. export * from "babylonjs/Meshes/Builders/index";
  70931. export * from "babylonjs/Meshes/dataBuffer";
  70932. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70933. import "babylonjs/Meshes/thinInstanceMesh";
  70934. export * from "babylonjs/Meshes/thinInstanceMesh";
  70935. }
  70936. declare module "babylonjs/Morph/index" {
  70937. export * from "babylonjs/Morph/morphTarget";
  70938. export * from "babylonjs/Morph/morphTargetManager";
  70939. }
  70940. declare module "babylonjs/Navigation/INavigationEngine" {
  70941. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70942. import { Vector3 } from "babylonjs/Maths/math";
  70943. import { Mesh } from "babylonjs/Meshes/mesh";
  70944. import { Scene } from "babylonjs/scene";
  70945. /**
  70946. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70947. */
  70948. export interface INavigationEnginePlugin {
  70949. /**
  70950. * plugin name
  70951. */
  70952. name: string;
  70953. /**
  70954. * Creates a navigation mesh
  70955. * @param meshes array of all the geometry used to compute the navigatio mesh
  70956. * @param parameters bunch of parameters used to filter geometry
  70957. */
  70958. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70959. /**
  70960. * Create a navigation mesh debug mesh
  70961. * @param scene is where the mesh will be added
  70962. * @returns debug display mesh
  70963. */
  70964. createDebugNavMesh(scene: Scene): Mesh;
  70965. /**
  70966. * Get a navigation mesh constrained position, closest to the parameter position
  70967. * @param position world position
  70968. * @returns the closest point to position constrained by the navigation mesh
  70969. */
  70970. getClosestPoint(position: Vector3): Vector3;
  70971. /**
  70972. * Get a navigation mesh constrained position, closest to the parameter position
  70973. * @param position world position
  70974. * @param result output the closest point to position constrained by the navigation mesh
  70975. */
  70976. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70977. /**
  70978. * Get a navigation mesh constrained position, within a particular radius
  70979. * @param position world position
  70980. * @param maxRadius the maximum distance to the constrained world position
  70981. * @returns the closest point to position constrained by the navigation mesh
  70982. */
  70983. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70984. /**
  70985. * Get a navigation mesh constrained position, within a particular radius
  70986. * @param position world position
  70987. * @param maxRadius the maximum distance to the constrained world position
  70988. * @param result output the closest point to position constrained by the navigation mesh
  70989. */
  70990. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70991. /**
  70992. * Compute the final position from a segment made of destination-position
  70993. * @param position world position
  70994. * @param destination world position
  70995. * @returns the resulting point along the navmesh
  70996. */
  70997. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70998. /**
  70999. * Compute the final position from a segment made of destination-position
  71000. * @param position world position
  71001. * @param destination world position
  71002. * @param result output the resulting point along the navmesh
  71003. */
  71004. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71005. /**
  71006. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71007. * @param start world position
  71008. * @param end world position
  71009. * @returns array containing world position composing the path
  71010. */
  71011. computePath(start: Vector3, end: Vector3): Vector3[];
  71012. /**
  71013. * If this plugin is supported
  71014. * @returns true if plugin is supported
  71015. */
  71016. isSupported(): boolean;
  71017. /**
  71018. * Create a new Crowd so you can add agents
  71019. * @param maxAgents the maximum agent count in the crowd
  71020. * @param maxAgentRadius the maximum radius an agent can have
  71021. * @param scene to attach the crowd to
  71022. * @returns the crowd you can add agents to
  71023. */
  71024. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71025. /**
  71026. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71027. * The queries will try to find a solution within those bounds
  71028. * default is (1,1,1)
  71029. * @param extent x,y,z value that define the extent around the queries point of reference
  71030. */
  71031. setDefaultQueryExtent(extent: Vector3): void;
  71032. /**
  71033. * Get the Bounding box extent specified by setDefaultQueryExtent
  71034. * @returns the box extent values
  71035. */
  71036. getDefaultQueryExtent(): Vector3;
  71037. /**
  71038. * build the navmesh from a previously saved state using getNavmeshData
  71039. * @param data the Uint8Array returned by getNavmeshData
  71040. */
  71041. buildFromNavmeshData(data: Uint8Array): void;
  71042. /**
  71043. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71044. * @returns data the Uint8Array that can be saved and reused
  71045. */
  71046. getNavmeshData(): Uint8Array;
  71047. /**
  71048. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71049. * @param result output the box extent values
  71050. */
  71051. getDefaultQueryExtentToRef(result: Vector3): void;
  71052. /**
  71053. * Release all resources
  71054. */
  71055. dispose(): void;
  71056. }
  71057. /**
  71058. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71059. */
  71060. export interface ICrowd {
  71061. /**
  71062. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71063. * You can attach anything to that node. The node position is updated in the scene update tick.
  71064. * @param pos world position that will be constrained by the navigation mesh
  71065. * @param parameters agent parameters
  71066. * @param transform hooked to the agent that will be update by the scene
  71067. * @returns agent index
  71068. */
  71069. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71070. /**
  71071. * Returns the agent position in world space
  71072. * @param index agent index returned by addAgent
  71073. * @returns world space position
  71074. */
  71075. getAgentPosition(index: number): Vector3;
  71076. /**
  71077. * Gets the agent position result in world space
  71078. * @param index agent index returned by addAgent
  71079. * @param result output world space position
  71080. */
  71081. getAgentPositionToRef(index: number, result: Vector3): void;
  71082. /**
  71083. * Gets the agent velocity in world space
  71084. * @param index agent index returned by addAgent
  71085. * @returns world space velocity
  71086. */
  71087. getAgentVelocity(index: number): Vector3;
  71088. /**
  71089. * Gets the agent velocity result in world space
  71090. * @param index agent index returned by addAgent
  71091. * @param result output world space velocity
  71092. */
  71093. getAgentVelocityToRef(index: number, result: Vector3): void;
  71094. /**
  71095. * remove a particular agent previously created
  71096. * @param index agent index returned by addAgent
  71097. */
  71098. removeAgent(index: number): void;
  71099. /**
  71100. * get the list of all agents attached to this crowd
  71101. * @returns list of agent indices
  71102. */
  71103. getAgents(): number[];
  71104. /**
  71105. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71106. * @param deltaTime in seconds
  71107. */
  71108. update(deltaTime: number): void;
  71109. /**
  71110. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71111. * @param index agent index returned by addAgent
  71112. * @param destination targeted world position
  71113. */
  71114. agentGoto(index: number, destination: Vector3): void;
  71115. /**
  71116. * Teleport the agent to a new position
  71117. * @param index agent index returned by addAgent
  71118. * @param destination targeted world position
  71119. */
  71120. agentTeleport(index: number, destination: Vector3): void;
  71121. /**
  71122. * Update agent parameters
  71123. * @param index agent index returned by addAgent
  71124. * @param parameters agent parameters
  71125. */
  71126. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71127. /**
  71128. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71129. * The queries will try to find a solution within those bounds
  71130. * default is (1,1,1)
  71131. * @param extent x,y,z value that define the extent around the queries point of reference
  71132. */
  71133. setDefaultQueryExtent(extent: Vector3): void;
  71134. /**
  71135. * Get the Bounding box extent specified by setDefaultQueryExtent
  71136. * @returns the box extent values
  71137. */
  71138. getDefaultQueryExtent(): Vector3;
  71139. /**
  71140. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71141. * @param result output the box extent values
  71142. */
  71143. getDefaultQueryExtentToRef(result: Vector3): void;
  71144. /**
  71145. * Release all resources
  71146. */
  71147. dispose(): void;
  71148. }
  71149. /**
  71150. * Configures an agent
  71151. */
  71152. export interface IAgentParameters {
  71153. /**
  71154. * Agent radius. [Limit: >= 0]
  71155. */
  71156. radius: number;
  71157. /**
  71158. * Agent height. [Limit: > 0]
  71159. */
  71160. height: number;
  71161. /**
  71162. * Maximum allowed acceleration. [Limit: >= 0]
  71163. */
  71164. maxAcceleration: number;
  71165. /**
  71166. * Maximum allowed speed. [Limit: >= 0]
  71167. */
  71168. maxSpeed: number;
  71169. /**
  71170. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71171. */
  71172. collisionQueryRange: number;
  71173. /**
  71174. * The path visibility optimization range. [Limit: > 0]
  71175. */
  71176. pathOptimizationRange: number;
  71177. /**
  71178. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71179. */
  71180. separationWeight: number;
  71181. }
  71182. /**
  71183. * Configures the navigation mesh creation
  71184. */
  71185. export interface INavMeshParameters {
  71186. /**
  71187. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71188. */
  71189. cs: number;
  71190. /**
  71191. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71192. */
  71193. ch: number;
  71194. /**
  71195. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71196. */
  71197. walkableSlopeAngle: number;
  71198. /**
  71199. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71200. * be considered walkable. [Limit: >= 3] [Units: vx]
  71201. */
  71202. walkableHeight: number;
  71203. /**
  71204. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71205. */
  71206. walkableClimb: number;
  71207. /**
  71208. * The distance to erode/shrink the walkable area of the heightfield away from
  71209. * obstructions. [Limit: >=0] [Units: vx]
  71210. */
  71211. walkableRadius: number;
  71212. /**
  71213. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71214. */
  71215. maxEdgeLen: number;
  71216. /**
  71217. * The maximum distance a simplfied contour's border edges should deviate
  71218. * the original raw contour. [Limit: >=0] [Units: vx]
  71219. */
  71220. maxSimplificationError: number;
  71221. /**
  71222. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71223. */
  71224. minRegionArea: number;
  71225. /**
  71226. * Any regions with a span count smaller than this value will, if possible,
  71227. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71228. */
  71229. mergeRegionArea: number;
  71230. /**
  71231. * The maximum number of vertices allowed for polygons generated during the
  71232. * contour to polygon conversion process. [Limit: >= 3]
  71233. */
  71234. maxVertsPerPoly: number;
  71235. /**
  71236. * Sets the sampling distance to use when generating the detail mesh.
  71237. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71238. */
  71239. detailSampleDist: number;
  71240. /**
  71241. * The maximum distance the detail mesh surface should deviate from heightfield
  71242. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71243. */
  71244. detailSampleMaxError: number;
  71245. }
  71246. }
  71247. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  71248. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  71249. import { Mesh } from "babylonjs/Meshes/mesh";
  71250. import { Scene } from "babylonjs/scene";
  71251. import { Vector3 } from "babylonjs/Maths/math";
  71252. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71253. /**
  71254. * RecastJS navigation plugin
  71255. */
  71256. export class RecastJSPlugin implements INavigationEnginePlugin {
  71257. /**
  71258. * Reference to the Recast library
  71259. */
  71260. bjsRECAST: any;
  71261. /**
  71262. * plugin name
  71263. */
  71264. name: string;
  71265. /**
  71266. * the first navmesh created. We might extend this to support multiple navmeshes
  71267. */
  71268. navMesh: any;
  71269. /**
  71270. * Initializes the recastJS plugin
  71271. * @param recastInjection can be used to inject your own recast reference
  71272. */
  71273. constructor(recastInjection?: any);
  71274. /**
  71275. * Creates a navigation mesh
  71276. * @param meshes array of all the geometry used to compute the navigatio mesh
  71277. * @param parameters bunch of parameters used to filter geometry
  71278. */
  71279. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71280. /**
  71281. * Create a navigation mesh debug mesh
  71282. * @param scene is where the mesh will be added
  71283. * @returns debug display mesh
  71284. */
  71285. createDebugNavMesh(scene: Scene): Mesh;
  71286. /**
  71287. * Get a navigation mesh constrained position, closest to the parameter position
  71288. * @param position world position
  71289. * @returns the closest point to position constrained by the navigation mesh
  71290. */
  71291. getClosestPoint(position: Vector3): Vector3;
  71292. /**
  71293. * Get a navigation mesh constrained position, closest to the parameter position
  71294. * @param position world position
  71295. * @param result output the closest point to position constrained by the navigation mesh
  71296. */
  71297. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71298. /**
  71299. * Get a navigation mesh constrained position, within a particular radius
  71300. * @param position world position
  71301. * @param maxRadius the maximum distance to the constrained world position
  71302. * @returns the closest point to position constrained by the navigation mesh
  71303. */
  71304. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71305. /**
  71306. * Get a navigation mesh constrained position, within a particular radius
  71307. * @param position world position
  71308. * @param maxRadius the maximum distance to the constrained world position
  71309. * @param result output the closest point to position constrained by the navigation mesh
  71310. */
  71311. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71312. /**
  71313. * Compute the final position from a segment made of destination-position
  71314. * @param position world position
  71315. * @param destination world position
  71316. * @returns the resulting point along the navmesh
  71317. */
  71318. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71319. /**
  71320. * Compute the final position from a segment made of destination-position
  71321. * @param position world position
  71322. * @param destination world position
  71323. * @param result output the resulting point along the navmesh
  71324. */
  71325. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71326. /**
  71327. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71328. * @param start world position
  71329. * @param end world position
  71330. * @returns array containing world position composing the path
  71331. */
  71332. computePath(start: Vector3, end: Vector3): Vector3[];
  71333. /**
  71334. * Create a new Crowd so you can add agents
  71335. * @param maxAgents the maximum agent count in the crowd
  71336. * @param maxAgentRadius the maximum radius an agent can have
  71337. * @param scene to attach the crowd to
  71338. * @returns the crowd you can add agents to
  71339. */
  71340. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71341. /**
  71342. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71343. * The queries will try to find a solution within those bounds
  71344. * default is (1,1,1)
  71345. * @param extent x,y,z value that define the extent around the queries point of reference
  71346. */
  71347. setDefaultQueryExtent(extent: Vector3): void;
  71348. /**
  71349. * Get the Bounding box extent specified by setDefaultQueryExtent
  71350. * @returns the box extent values
  71351. */
  71352. getDefaultQueryExtent(): Vector3;
  71353. /**
  71354. * build the navmesh from a previously saved state using getNavmeshData
  71355. * @param data the Uint8Array returned by getNavmeshData
  71356. */
  71357. buildFromNavmeshData(data: Uint8Array): void;
  71358. /**
  71359. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71360. * @returns data the Uint8Array that can be saved and reused
  71361. */
  71362. getNavmeshData(): Uint8Array;
  71363. /**
  71364. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71365. * @param result output the box extent values
  71366. */
  71367. getDefaultQueryExtentToRef(result: Vector3): void;
  71368. /**
  71369. * Disposes
  71370. */
  71371. dispose(): void;
  71372. /**
  71373. * If this plugin is supported
  71374. * @returns true if plugin is supported
  71375. */
  71376. isSupported(): boolean;
  71377. }
  71378. /**
  71379. * Recast detour crowd implementation
  71380. */
  71381. export class RecastJSCrowd implements ICrowd {
  71382. /**
  71383. * Recast/detour plugin
  71384. */
  71385. bjsRECASTPlugin: RecastJSPlugin;
  71386. /**
  71387. * Link to the detour crowd
  71388. */
  71389. recastCrowd: any;
  71390. /**
  71391. * One transform per agent
  71392. */
  71393. transforms: TransformNode[];
  71394. /**
  71395. * All agents created
  71396. */
  71397. agents: number[];
  71398. /**
  71399. * Link to the scene is kept to unregister the crowd from the scene
  71400. */
  71401. private _scene;
  71402. /**
  71403. * Observer for crowd updates
  71404. */
  71405. private _onBeforeAnimationsObserver;
  71406. /**
  71407. * Constructor
  71408. * @param plugin recastJS plugin
  71409. * @param maxAgents the maximum agent count in the crowd
  71410. * @param maxAgentRadius the maximum radius an agent can have
  71411. * @param scene to attach the crowd to
  71412. * @returns the crowd you can add agents to
  71413. */
  71414. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71415. /**
  71416. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71417. * You can attach anything to that node. The node position is updated in the scene update tick.
  71418. * @param pos world position that will be constrained by the navigation mesh
  71419. * @param parameters agent parameters
  71420. * @param transform hooked to the agent that will be update by the scene
  71421. * @returns agent index
  71422. */
  71423. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71424. /**
  71425. * Returns the agent position in world space
  71426. * @param index agent index returned by addAgent
  71427. * @returns world space position
  71428. */
  71429. getAgentPosition(index: number): Vector3;
  71430. /**
  71431. * Returns the agent position result in world space
  71432. * @param index agent index returned by addAgent
  71433. * @param result output world space position
  71434. */
  71435. getAgentPositionToRef(index: number, result: Vector3): void;
  71436. /**
  71437. * Returns the agent velocity in world space
  71438. * @param index agent index returned by addAgent
  71439. * @returns world space velocity
  71440. */
  71441. getAgentVelocity(index: number): Vector3;
  71442. /**
  71443. * Returns the agent velocity result in world space
  71444. * @param index agent index returned by addAgent
  71445. * @param result output world space velocity
  71446. */
  71447. getAgentVelocityToRef(index: number, result: Vector3): void;
  71448. /**
  71449. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71450. * @param index agent index returned by addAgent
  71451. * @param destination targeted world position
  71452. */
  71453. agentGoto(index: number, destination: Vector3): void;
  71454. /**
  71455. * Teleport the agent to a new position
  71456. * @param index agent index returned by addAgent
  71457. * @param destination targeted world position
  71458. */
  71459. agentTeleport(index: number, destination: Vector3): void;
  71460. /**
  71461. * Update agent parameters
  71462. * @param index agent index returned by addAgent
  71463. * @param parameters agent parameters
  71464. */
  71465. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71466. /**
  71467. * remove a particular agent previously created
  71468. * @param index agent index returned by addAgent
  71469. */
  71470. removeAgent(index: number): void;
  71471. /**
  71472. * get the list of all agents attached to this crowd
  71473. * @returns list of agent indices
  71474. */
  71475. getAgents(): number[];
  71476. /**
  71477. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71478. * @param deltaTime in seconds
  71479. */
  71480. update(deltaTime: number): void;
  71481. /**
  71482. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71483. * The queries will try to find a solution within those bounds
  71484. * default is (1,1,1)
  71485. * @param extent x,y,z value that define the extent around the queries point of reference
  71486. */
  71487. setDefaultQueryExtent(extent: Vector3): void;
  71488. /**
  71489. * Get the Bounding box extent specified by setDefaultQueryExtent
  71490. * @returns the box extent values
  71491. */
  71492. getDefaultQueryExtent(): Vector3;
  71493. /**
  71494. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71495. * @param result output the box extent values
  71496. */
  71497. getDefaultQueryExtentToRef(result: Vector3): void;
  71498. /**
  71499. * Release all resources
  71500. */
  71501. dispose(): void;
  71502. }
  71503. }
  71504. declare module "babylonjs/Navigation/Plugins/index" {
  71505. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71506. }
  71507. declare module "babylonjs/Navigation/index" {
  71508. export * from "babylonjs/Navigation/INavigationEngine";
  71509. export * from "babylonjs/Navigation/Plugins/index";
  71510. }
  71511. declare module "babylonjs/Offline/database" {
  71512. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71513. /**
  71514. * Class used to enable access to IndexedDB
  71515. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71516. */
  71517. export class Database implements IOfflineProvider {
  71518. private _callbackManifestChecked;
  71519. private _currentSceneUrl;
  71520. private _db;
  71521. private _enableSceneOffline;
  71522. private _enableTexturesOffline;
  71523. private _manifestVersionFound;
  71524. private _mustUpdateRessources;
  71525. private _hasReachedQuota;
  71526. private _isSupported;
  71527. private _idbFactory;
  71528. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71529. private static IsUASupportingBlobStorage;
  71530. /**
  71531. * Gets a boolean indicating if Database storate is enabled (off by default)
  71532. */
  71533. static IDBStorageEnabled: boolean;
  71534. /**
  71535. * Gets a boolean indicating if scene must be saved in the database
  71536. */
  71537. get enableSceneOffline(): boolean;
  71538. /**
  71539. * Gets a boolean indicating if textures must be saved in the database
  71540. */
  71541. get enableTexturesOffline(): boolean;
  71542. /**
  71543. * Creates a new Database
  71544. * @param urlToScene defines the url to load the scene
  71545. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71546. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71547. */
  71548. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71549. private static _ParseURL;
  71550. private static _ReturnFullUrlLocation;
  71551. private _checkManifestFile;
  71552. /**
  71553. * Open the database and make it available
  71554. * @param successCallback defines the callback to call on success
  71555. * @param errorCallback defines the callback to call on error
  71556. */
  71557. open(successCallback: () => void, errorCallback: () => void): void;
  71558. /**
  71559. * Loads an image from the database
  71560. * @param url defines the url to load from
  71561. * @param image defines the target DOM image
  71562. */
  71563. loadImage(url: string, image: HTMLImageElement): void;
  71564. private _loadImageFromDBAsync;
  71565. private _saveImageIntoDBAsync;
  71566. private _checkVersionFromDB;
  71567. private _loadVersionFromDBAsync;
  71568. private _saveVersionIntoDBAsync;
  71569. /**
  71570. * Loads a file from database
  71571. * @param url defines the URL to load from
  71572. * @param sceneLoaded defines a callback to call on success
  71573. * @param progressCallBack defines a callback to call when progress changed
  71574. * @param errorCallback defines a callback to call on error
  71575. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71576. */
  71577. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71578. private _loadFileAsync;
  71579. private _saveFileAsync;
  71580. /**
  71581. * Validates if xhr data is correct
  71582. * @param xhr defines the request to validate
  71583. * @param dataType defines the expected data type
  71584. * @returns true if data is correct
  71585. */
  71586. private static _ValidateXHRData;
  71587. }
  71588. }
  71589. declare module "babylonjs/Offline/index" {
  71590. export * from "babylonjs/Offline/database";
  71591. export * from "babylonjs/Offline/IOfflineProvider";
  71592. }
  71593. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71594. /** @hidden */
  71595. export var gpuUpdateParticlesPixelShader: {
  71596. name: string;
  71597. shader: string;
  71598. };
  71599. }
  71600. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71601. /** @hidden */
  71602. export var gpuUpdateParticlesVertexShader: {
  71603. name: string;
  71604. shader: string;
  71605. };
  71606. }
  71607. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71608. /** @hidden */
  71609. export var clipPlaneFragmentDeclaration2: {
  71610. name: string;
  71611. shader: string;
  71612. };
  71613. }
  71614. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71615. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71616. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71617. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71618. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71619. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71620. /** @hidden */
  71621. export var gpuRenderParticlesPixelShader: {
  71622. name: string;
  71623. shader: string;
  71624. };
  71625. }
  71626. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71627. /** @hidden */
  71628. export var clipPlaneVertexDeclaration2: {
  71629. name: string;
  71630. shader: string;
  71631. };
  71632. }
  71633. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71634. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71635. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71636. /** @hidden */
  71637. export var gpuRenderParticlesVertexShader: {
  71638. name: string;
  71639. shader: string;
  71640. };
  71641. }
  71642. declare module "babylonjs/Particles/gpuParticleSystem" {
  71643. import { Nullable } from "babylonjs/types";
  71644. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71645. import { Observable } from "babylonjs/Misc/observable";
  71646. import { Matrix } from "babylonjs/Maths/math.vector";
  71647. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71648. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71649. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71650. import { IDisposable } from "babylonjs/scene";
  71651. import { Effect } from "babylonjs/Materials/effect";
  71652. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71653. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71654. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71655. import { Scene } from "babylonjs/scene";
  71656. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71657. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71658. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71659. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71660. /**
  71661. * This represents a GPU particle system in Babylon
  71662. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71663. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71664. */
  71665. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71666. /**
  71667. * The layer mask we are rendering the particles through.
  71668. */
  71669. layerMask: number;
  71670. private _capacity;
  71671. private _activeCount;
  71672. private _currentActiveCount;
  71673. private _accumulatedCount;
  71674. private _renderEffect;
  71675. private _updateEffect;
  71676. private _buffer0;
  71677. private _buffer1;
  71678. private _spriteBuffer;
  71679. private _updateVAO;
  71680. private _renderVAO;
  71681. private _targetIndex;
  71682. private _sourceBuffer;
  71683. private _targetBuffer;
  71684. private _currentRenderId;
  71685. private _started;
  71686. private _stopped;
  71687. private _timeDelta;
  71688. private _randomTexture;
  71689. private _randomTexture2;
  71690. private _attributesStrideSize;
  71691. private _updateEffectOptions;
  71692. private _randomTextureSize;
  71693. private _actualFrame;
  71694. private _customEffect;
  71695. private readonly _rawTextureWidth;
  71696. /**
  71697. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71698. */
  71699. static get IsSupported(): boolean;
  71700. /**
  71701. * An event triggered when the system is disposed.
  71702. */
  71703. onDisposeObservable: Observable<IParticleSystem>;
  71704. /**
  71705. * An event triggered when the system is stopped
  71706. */
  71707. onStoppedObservable: Observable<IParticleSystem>;
  71708. /**
  71709. * Gets the maximum number of particles active at the same time.
  71710. * @returns The max number of active particles.
  71711. */
  71712. getCapacity(): number;
  71713. /**
  71714. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71715. * to override the particles.
  71716. */
  71717. forceDepthWrite: boolean;
  71718. /**
  71719. * Gets or set the number of active particles
  71720. */
  71721. get activeParticleCount(): number;
  71722. set activeParticleCount(value: number);
  71723. private _preWarmDone;
  71724. /**
  71725. * Specifies if the particles are updated in emitter local space or world space.
  71726. */
  71727. isLocal: boolean;
  71728. /** Gets or sets a matrix to use to compute projection */
  71729. defaultProjectionMatrix: Matrix;
  71730. /**
  71731. * Is this system ready to be used/rendered
  71732. * @return true if the system is ready
  71733. */
  71734. isReady(): boolean;
  71735. /**
  71736. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71737. * @returns True if it has been started, otherwise false.
  71738. */
  71739. isStarted(): boolean;
  71740. /**
  71741. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71742. * @returns True if it has been stopped, otherwise false.
  71743. */
  71744. isStopped(): boolean;
  71745. /**
  71746. * Gets a boolean indicating that the system is stopping
  71747. * @returns true if the system is currently stopping
  71748. */
  71749. isStopping(): boolean;
  71750. /**
  71751. * Gets the number of particles active at the same time.
  71752. * @returns The number of active particles.
  71753. */
  71754. getActiveCount(): number;
  71755. /**
  71756. * Starts the particle system and begins to emit
  71757. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71758. */
  71759. start(delay?: number): void;
  71760. /**
  71761. * Stops the particle system.
  71762. */
  71763. stop(): void;
  71764. /**
  71765. * Remove all active particles
  71766. */
  71767. reset(): void;
  71768. /**
  71769. * Returns the string "GPUParticleSystem"
  71770. * @returns a string containing the class name
  71771. */
  71772. getClassName(): string;
  71773. /**
  71774. * Gets the custom effect used to render the particles
  71775. * @param blendMode Blend mode for which the effect should be retrieved
  71776. * @returns The effect
  71777. */
  71778. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71779. /**
  71780. * Sets the custom effect used to render the particles
  71781. * @param effect The effect to set
  71782. * @param blendMode Blend mode for which the effect should be set
  71783. */
  71784. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71785. /** @hidden */
  71786. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71787. /**
  71788. * Observable that will be called just before the particles are drawn
  71789. */
  71790. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71791. /**
  71792. * Gets the name of the particle vertex shader
  71793. */
  71794. get vertexShaderName(): string;
  71795. private _colorGradientsTexture;
  71796. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71797. /**
  71798. * Adds a new color gradient
  71799. * @param gradient defines the gradient to use (between 0 and 1)
  71800. * @param color1 defines the color to affect to the specified gradient
  71801. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71802. * @returns the current particle system
  71803. */
  71804. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71805. private _refreshColorGradient;
  71806. /** Force the system to rebuild all gradients that need to be resync */
  71807. forceRefreshGradients(): void;
  71808. /**
  71809. * Remove a specific color gradient
  71810. * @param gradient defines the gradient to remove
  71811. * @returns the current particle system
  71812. */
  71813. removeColorGradient(gradient: number): GPUParticleSystem;
  71814. private _angularSpeedGradientsTexture;
  71815. private _sizeGradientsTexture;
  71816. private _velocityGradientsTexture;
  71817. private _limitVelocityGradientsTexture;
  71818. private _dragGradientsTexture;
  71819. private _addFactorGradient;
  71820. /**
  71821. * Adds a new size gradient
  71822. * @param gradient defines the gradient to use (between 0 and 1)
  71823. * @param factor defines the size factor to affect to the specified gradient
  71824. * @returns the current particle system
  71825. */
  71826. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71827. /**
  71828. * Remove a specific size gradient
  71829. * @param gradient defines the gradient to remove
  71830. * @returns the current particle system
  71831. */
  71832. removeSizeGradient(gradient: number): GPUParticleSystem;
  71833. private _refreshFactorGradient;
  71834. /**
  71835. * Adds a new angular speed gradient
  71836. * @param gradient defines the gradient to use (between 0 and 1)
  71837. * @param factor defines the angular speed to affect to the specified gradient
  71838. * @returns the current particle system
  71839. */
  71840. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71841. /**
  71842. * Remove a specific angular speed gradient
  71843. * @param gradient defines the gradient to remove
  71844. * @returns the current particle system
  71845. */
  71846. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71847. /**
  71848. * Adds a new velocity gradient
  71849. * @param gradient defines the gradient to use (between 0 and 1)
  71850. * @param factor defines the velocity to affect to the specified gradient
  71851. * @returns the current particle system
  71852. */
  71853. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71854. /**
  71855. * Remove a specific velocity gradient
  71856. * @param gradient defines the gradient to remove
  71857. * @returns the current particle system
  71858. */
  71859. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71860. /**
  71861. * Adds a new limit velocity gradient
  71862. * @param gradient defines the gradient to use (between 0 and 1)
  71863. * @param factor defines the limit velocity value to affect to the specified gradient
  71864. * @returns the current particle system
  71865. */
  71866. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71867. /**
  71868. * Remove a specific limit velocity gradient
  71869. * @param gradient defines the gradient to remove
  71870. * @returns the current particle system
  71871. */
  71872. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71873. /**
  71874. * Adds a new drag gradient
  71875. * @param gradient defines the gradient to use (between 0 and 1)
  71876. * @param factor defines the drag value to affect to the specified gradient
  71877. * @returns the current particle system
  71878. */
  71879. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71880. /**
  71881. * Remove a specific drag gradient
  71882. * @param gradient defines the gradient to remove
  71883. * @returns the current particle system
  71884. */
  71885. removeDragGradient(gradient: number): GPUParticleSystem;
  71886. /**
  71887. * Not supported by GPUParticleSystem
  71888. * @param gradient defines the gradient to use (between 0 and 1)
  71889. * @param factor defines the emit rate value to affect to the specified gradient
  71890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71891. * @returns the current particle system
  71892. */
  71893. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71894. /**
  71895. * Not supported by GPUParticleSystem
  71896. * @param gradient defines the gradient to remove
  71897. * @returns the current particle system
  71898. */
  71899. removeEmitRateGradient(gradient: number): IParticleSystem;
  71900. /**
  71901. * Not supported by GPUParticleSystem
  71902. * @param gradient defines the gradient to use (between 0 and 1)
  71903. * @param factor defines the start size value to affect to the specified gradient
  71904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71905. * @returns the current particle system
  71906. */
  71907. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71908. /**
  71909. * Not supported by GPUParticleSystem
  71910. * @param gradient defines the gradient to remove
  71911. * @returns the current particle system
  71912. */
  71913. removeStartSizeGradient(gradient: number): IParticleSystem;
  71914. /**
  71915. * Not supported by GPUParticleSystem
  71916. * @param gradient defines the gradient to use (between 0 and 1)
  71917. * @param min defines the color remap minimal range
  71918. * @param max defines the color remap maximal range
  71919. * @returns the current particle system
  71920. */
  71921. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71922. /**
  71923. * Not supported by GPUParticleSystem
  71924. * @param gradient defines the gradient to remove
  71925. * @returns the current particle system
  71926. */
  71927. removeColorRemapGradient(): IParticleSystem;
  71928. /**
  71929. * Not supported by GPUParticleSystem
  71930. * @param gradient defines the gradient to use (between 0 and 1)
  71931. * @param min defines the alpha remap minimal range
  71932. * @param max defines the alpha remap maximal range
  71933. * @returns the current particle system
  71934. */
  71935. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71936. /**
  71937. * Not supported by GPUParticleSystem
  71938. * @param gradient defines the gradient to remove
  71939. * @returns the current particle system
  71940. */
  71941. removeAlphaRemapGradient(): IParticleSystem;
  71942. /**
  71943. * Not supported by GPUParticleSystem
  71944. * @param gradient defines the gradient to use (between 0 and 1)
  71945. * @param color defines the color to affect to the specified gradient
  71946. * @returns the current particle system
  71947. */
  71948. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71949. /**
  71950. * Not supported by GPUParticleSystem
  71951. * @param gradient defines the gradient to remove
  71952. * @returns the current particle system
  71953. */
  71954. removeRampGradient(): IParticleSystem;
  71955. /**
  71956. * Not supported by GPUParticleSystem
  71957. * @returns the list of ramp gradients
  71958. */
  71959. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71960. /**
  71961. * Not supported by GPUParticleSystem
  71962. * Gets or sets a boolean indicating that ramp gradients must be used
  71963. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71964. */
  71965. get useRampGradients(): boolean;
  71966. set useRampGradients(value: boolean);
  71967. /**
  71968. * Not supported by GPUParticleSystem
  71969. * @param gradient defines the gradient to use (between 0 and 1)
  71970. * @param factor defines the life time factor to affect to the specified gradient
  71971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71972. * @returns the current particle system
  71973. */
  71974. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71975. /**
  71976. * Not supported by GPUParticleSystem
  71977. * @param gradient defines the gradient to remove
  71978. * @returns the current particle system
  71979. */
  71980. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71981. /**
  71982. * Instantiates a GPU particle system.
  71983. * 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.
  71984. * @param name The name of the particle system
  71985. * @param options The options used to create the system
  71986. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71987. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71988. * @param customEffect a custom effect used to change the way particles are rendered by default
  71989. */
  71990. constructor(name: string, options: Partial<{
  71991. capacity: number;
  71992. randomTextureSize: number;
  71993. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71994. protected _reset(): void;
  71995. private _createUpdateVAO;
  71996. private _createRenderVAO;
  71997. private _initialize;
  71998. /** @hidden */
  71999. _recreateUpdateEffect(): void;
  72000. private _getEffect;
  72001. /**
  72002. * Fill the defines array according to the current settings of the particle system
  72003. * @param defines Array to be updated
  72004. * @param blendMode blend mode to take into account when updating the array
  72005. */
  72006. fillDefines(defines: Array<string>, blendMode?: number): void;
  72007. /**
  72008. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72009. * @param uniforms Uniforms array to fill
  72010. * @param attributes Attributes array to fill
  72011. * @param samplers Samplers array to fill
  72012. */
  72013. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72014. /** @hidden */
  72015. _recreateRenderEffect(): Effect;
  72016. /**
  72017. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72018. * @param preWarm defines if we are in the pre-warmimg phase
  72019. */
  72020. animate(preWarm?: boolean): void;
  72021. private _createFactorGradientTexture;
  72022. private _createSizeGradientTexture;
  72023. private _createAngularSpeedGradientTexture;
  72024. private _createVelocityGradientTexture;
  72025. private _createLimitVelocityGradientTexture;
  72026. private _createDragGradientTexture;
  72027. private _createColorGradientTexture;
  72028. /**
  72029. * Renders the particle system in its current state
  72030. * @param preWarm defines if the system should only update the particles but not render them
  72031. * @returns the current number of particles
  72032. */
  72033. render(preWarm?: boolean): number;
  72034. /**
  72035. * Rebuilds the particle system
  72036. */
  72037. rebuild(): void;
  72038. private _releaseBuffers;
  72039. private _releaseVAOs;
  72040. /**
  72041. * Disposes the particle system and free the associated resources
  72042. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72043. */
  72044. dispose(disposeTexture?: boolean): void;
  72045. /**
  72046. * Clones the particle system.
  72047. * @param name The name of the cloned object
  72048. * @param newEmitter The new emitter to use
  72049. * @returns the cloned particle system
  72050. */
  72051. clone(name: string, newEmitter: any): GPUParticleSystem;
  72052. /**
  72053. * Serializes the particle system to a JSON object
  72054. * @param serializeTexture defines if the texture must be serialized as well
  72055. * @returns the JSON object
  72056. */
  72057. serialize(serializeTexture?: boolean): any;
  72058. /**
  72059. * Parses a JSON object to create a GPU particle system.
  72060. * @param parsedParticleSystem The JSON object to parse
  72061. * @param sceneOrEngine The scene or the engine to create the particle system in
  72062. * @param rootUrl The root url to use to load external dependencies like texture
  72063. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72064. * @returns the parsed GPU particle system
  72065. */
  72066. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72067. }
  72068. }
  72069. declare module "babylonjs/Particles/particleSystemSet" {
  72070. import { Nullable } from "babylonjs/types";
  72071. import { Color3 } from "babylonjs/Maths/math.color";
  72072. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72074. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72075. import { Scene, IDisposable } from "babylonjs/scene";
  72076. /**
  72077. * Represents a set of particle systems working together to create a specific effect
  72078. */
  72079. export class ParticleSystemSet implements IDisposable {
  72080. /**
  72081. * Gets or sets base Assets URL
  72082. */
  72083. static BaseAssetsUrl: string;
  72084. private _emitterCreationOptions;
  72085. private _emitterNode;
  72086. /**
  72087. * Gets the particle system list
  72088. */
  72089. systems: IParticleSystem[];
  72090. /**
  72091. * Gets the emitter node used with this set
  72092. */
  72093. get emitterNode(): Nullable<TransformNode>;
  72094. /**
  72095. * Creates a new emitter mesh as a sphere
  72096. * @param options defines the options used to create the sphere
  72097. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72098. * @param scene defines the hosting scene
  72099. */
  72100. setEmitterAsSphere(options: {
  72101. diameter: number;
  72102. segments: number;
  72103. color: Color3;
  72104. }, renderingGroupId: number, scene: Scene): void;
  72105. /**
  72106. * Starts all particle systems of the set
  72107. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72108. */
  72109. start(emitter?: AbstractMesh): void;
  72110. /**
  72111. * Release all associated resources
  72112. */
  72113. dispose(): void;
  72114. /**
  72115. * Serialize the set into a JSON compatible object
  72116. * @param serializeTexture defines if the texture must be serialized as well
  72117. * @returns a JSON compatible representation of the set
  72118. */
  72119. serialize(serializeTexture?: boolean): any;
  72120. /**
  72121. * Parse a new ParticleSystemSet from a serialized source
  72122. * @param data defines a JSON compatible representation of the set
  72123. * @param scene defines the hosting scene
  72124. * @param gpu defines if we want GPU particles or CPU particles
  72125. * @returns a new ParticleSystemSet
  72126. */
  72127. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72128. }
  72129. }
  72130. declare module "babylonjs/Particles/particleHelper" {
  72131. import { Nullable } from "babylonjs/types";
  72132. import { Scene } from "babylonjs/scene";
  72133. import { Vector3 } from "babylonjs/Maths/math.vector";
  72134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72135. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72136. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  72137. /**
  72138. * This class is made for on one-liner static method to help creating particle system set.
  72139. */
  72140. export class ParticleHelper {
  72141. /**
  72142. * Gets or sets base Assets URL
  72143. */
  72144. static BaseAssetsUrl: string;
  72145. /** Define the Url to load snippets */
  72146. static SnippetUrl: string;
  72147. /**
  72148. * Create a default particle system that you can tweak
  72149. * @param emitter defines the emitter to use
  72150. * @param capacity defines the system capacity (default is 500 particles)
  72151. * @param scene defines the hosting scene
  72152. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72153. * @returns the new Particle system
  72154. */
  72155. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72156. /**
  72157. * This is the main static method (one-liner) of this helper to create different particle systems
  72158. * @param type This string represents the type to the particle system to create
  72159. * @param scene The scene where the particle system should live
  72160. * @param gpu If the system will use gpu
  72161. * @returns the ParticleSystemSet created
  72162. */
  72163. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72164. /**
  72165. * Static function used to export a particle system to a ParticleSystemSet variable.
  72166. * Please note that the emitter shape is not exported
  72167. * @param systems defines the particle systems to export
  72168. * @returns the created particle system set
  72169. */
  72170. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72171. /**
  72172. * Creates a particle system from a snippet saved in a remote file
  72173. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72174. * @param url defines the url to load from
  72175. * @param scene defines the hosting scene
  72176. * @param gpu If the system will use gpu
  72177. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72178. * @returns a promise that will resolve to the new particle system
  72179. */
  72180. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72181. /**
  72182. * Creates a particle system from a snippet saved by the particle system editor
  72183. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72184. * @param scene defines the hosting scene
  72185. * @param gpu If the system will use gpu
  72186. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72187. * @returns a promise that will resolve to the new particle system
  72188. */
  72189. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72190. }
  72191. }
  72192. declare module "babylonjs/Particles/particleSystemComponent" {
  72193. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72194. import { Effect } from "babylonjs/Materials/effect";
  72195. import "babylonjs/Shaders/particles.vertex";
  72196. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  72197. module "babylonjs/Engines/engine" {
  72198. interface Engine {
  72199. /**
  72200. * Create an effect to use with particle systems.
  72201. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72202. * the particle system for which you want to create a custom effect in the last parameter
  72203. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72204. * @param uniformsNames defines a list of attribute names
  72205. * @param samplers defines an array of string used to represent textures
  72206. * @param defines defines the string containing the defines to use to compile the shaders
  72207. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72208. * @param onCompiled defines a function to call when the effect creation is successful
  72209. * @param onError defines a function to call when the effect creation has failed
  72210. * @param particleSystem the particle system you want to create the effect for
  72211. * @returns the new Effect
  72212. */
  72213. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72214. }
  72215. }
  72216. module "babylonjs/Meshes/mesh" {
  72217. interface Mesh {
  72218. /**
  72219. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72220. * @returns an array of IParticleSystem
  72221. */
  72222. getEmittedParticleSystems(): IParticleSystem[];
  72223. /**
  72224. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72225. * @returns an array of IParticleSystem
  72226. */
  72227. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72228. }
  72229. }
  72230. }
  72231. declare module "babylonjs/Particles/pointsCloudSystem" {
  72232. import { Color4 } from "babylonjs/Maths/math";
  72233. import { Mesh } from "babylonjs/Meshes/mesh";
  72234. import { Scene, IDisposable } from "babylonjs/scene";
  72235. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  72236. /** Defines the 4 color options */
  72237. export enum PointColor {
  72238. /** color value */
  72239. Color = 2,
  72240. /** uv value */
  72241. UV = 1,
  72242. /** random value */
  72243. Random = 0,
  72244. /** stated value */
  72245. Stated = 3
  72246. }
  72247. /**
  72248. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72249. * 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.
  72250. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72251. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72252. *
  72253. * Full documentation here : TO BE ENTERED
  72254. */
  72255. export class PointsCloudSystem implements IDisposable {
  72256. /**
  72257. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72258. * Example : var p = SPS.particles[i];
  72259. */
  72260. particles: CloudPoint[];
  72261. /**
  72262. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72263. */
  72264. nbParticles: number;
  72265. /**
  72266. * This a counter for your own usage. It's not set by any SPS functions.
  72267. */
  72268. counter: number;
  72269. /**
  72270. * The PCS name. This name is also given to the underlying mesh.
  72271. */
  72272. name: string;
  72273. /**
  72274. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72275. */
  72276. mesh: Mesh;
  72277. /**
  72278. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72279. * Please read :
  72280. */
  72281. vars: any;
  72282. /**
  72283. * @hidden
  72284. */
  72285. _size: number;
  72286. private _scene;
  72287. private _promises;
  72288. private _positions;
  72289. private _indices;
  72290. private _normals;
  72291. private _colors;
  72292. private _uvs;
  72293. private _indices32;
  72294. private _positions32;
  72295. private _colors32;
  72296. private _uvs32;
  72297. private _updatable;
  72298. private _isVisibilityBoxLocked;
  72299. private _alwaysVisible;
  72300. private _groups;
  72301. private _groupCounter;
  72302. private _computeParticleColor;
  72303. private _computeParticleTexture;
  72304. private _computeParticleRotation;
  72305. private _computeBoundingBox;
  72306. private _isReady;
  72307. /**
  72308. * Creates a PCS (Points Cloud System) object
  72309. * @param name (String) is the PCS name, this will be the underlying mesh name
  72310. * @param pointSize (number) is the size for each point
  72311. * @param scene (Scene) is the scene in which the PCS is added
  72312. * @param options defines the options of the PCS e.g.
  72313. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72314. */
  72315. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72316. updatable?: boolean;
  72317. });
  72318. /**
  72319. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72320. * If no points were added to the PCS, the returned mesh is just a single point.
  72321. * @returns a promise for the created mesh
  72322. */
  72323. buildMeshAsync(): Promise<Mesh>;
  72324. /**
  72325. * @hidden
  72326. */
  72327. private _buildMesh;
  72328. private _addParticle;
  72329. private _randomUnitVector;
  72330. private _getColorIndicesForCoord;
  72331. private _setPointsColorOrUV;
  72332. private _colorFromTexture;
  72333. private _calculateDensity;
  72334. /**
  72335. * Adds points to the PCS in random positions within a unit sphere
  72336. * @param nb (positive integer) the number of particles to be created from this model
  72337. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72338. * @returns the number of groups in the system
  72339. */
  72340. addPoints(nb: number, pointFunction?: any): number;
  72341. /**
  72342. * Adds points to the PCS from the surface of the model shape
  72343. * @param mesh is any Mesh object that will be used as a surface model for the points
  72344. * @param nb (positive integer) the number of particles to be created from this model
  72345. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72346. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72347. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72348. * @returns the number of groups in the system
  72349. */
  72350. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72351. /**
  72352. * Adds points to the PCS inside the model shape
  72353. * @param mesh is any Mesh object that will be used as a surface model for the points
  72354. * @param nb (positive integer) the number of particles to be created from this model
  72355. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72356. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72357. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72358. * @returns the number of groups in the system
  72359. */
  72360. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72361. /**
  72362. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72363. * This method calls `updateParticle()` for each particle of the SPS.
  72364. * For an animated SPS, it is usually called within the render loop.
  72365. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72366. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72367. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72368. * @returns the PCS.
  72369. */
  72370. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72371. /**
  72372. * Disposes the PCS.
  72373. */
  72374. dispose(): void;
  72375. /**
  72376. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72377. * doc :
  72378. * @returns the PCS.
  72379. */
  72380. refreshVisibleSize(): PointsCloudSystem;
  72381. /**
  72382. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72383. * @param size the size (float) of the visibility box
  72384. * note : this doesn't lock the PCS mesh bounding box.
  72385. * doc :
  72386. */
  72387. setVisibilityBox(size: number): void;
  72388. /**
  72389. * Gets whether the PCS is always visible or not
  72390. * doc :
  72391. */
  72392. get isAlwaysVisible(): boolean;
  72393. /**
  72394. * Sets the PCS as always visible or not
  72395. * doc :
  72396. */
  72397. set isAlwaysVisible(val: boolean);
  72398. /**
  72399. * Tells to `setParticles()` to compute the particle rotations or not
  72400. * Default value : false. The PCS is faster when it's set to false
  72401. * Note : particle rotations are only applied to parent particles
  72402. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72403. */
  72404. set computeParticleRotation(val: boolean);
  72405. /**
  72406. * Tells to `setParticles()` to compute the particle colors or not.
  72407. * Default value : true. The PCS is faster when it's set to false.
  72408. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72409. */
  72410. set computeParticleColor(val: boolean);
  72411. set computeParticleTexture(val: boolean);
  72412. /**
  72413. * Gets if `setParticles()` computes the particle colors or not.
  72414. * Default value : false. The PCS is faster when it's set to false.
  72415. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72416. */
  72417. get computeParticleColor(): boolean;
  72418. /**
  72419. * Gets if `setParticles()` computes the particle textures or not.
  72420. * Default value : false. The PCS is faster when it's set to false.
  72421. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72422. */
  72423. get computeParticleTexture(): boolean;
  72424. /**
  72425. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72426. */
  72427. set computeBoundingBox(val: boolean);
  72428. /**
  72429. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72430. */
  72431. get computeBoundingBox(): boolean;
  72432. /**
  72433. * This function does nothing. It may be overwritten to set all the particle first values.
  72434. * The PCS doesn't call this function, you may have to call it by your own.
  72435. * doc :
  72436. */
  72437. initParticles(): void;
  72438. /**
  72439. * This function does nothing. It may be overwritten to recycle a particle
  72440. * The PCS doesn't call this function, you can to call it
  72441. * doc :
  72442. * @param particle The particle to recycle
  72443. * @returns the recycled particle
  72444. */
  72445. recycleParticle(particle: CloudPoint): CloudPoint;
  72446. /**
  72447. * Updates a particle : this function should be overwritten by the user.
  72448. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72449. * doc :
  72450. * @example : just set a particle position or velocity and recycle conditions
  72451. * @param particle The particle to update
  72452. * @returns the updated particle
  72453. */
  72454. updateParticle(particle: CloudPoint): CloudPoint;
  72455. /**
  72456. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72457. * This does nothing and may be overwritten by the user.
  72458. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72459. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72460. * @param update the boolean update value actually passed to setParticles()
  72461. */
  72462. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72463. /**
  72464. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72465. * This will be passed three parameters.
  72466. * This does nothing and may be overwritten by the user.
  72467. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72468. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72469. * @param update the boolean update value actually passed to setParticles()
  72470. */
  72471. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72472. }
  72473. }
  72474. declare module "babylonjs/Particles/cloudPoint" {
  72475. import { Nullable } from "babylonjs/types";
  72476. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  72477. import { Mesh } from "babylonjs/Meshes/mesh";
  72478. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  72479. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  72480. /**
  72481. * Represents one particle of a points cloud system.
  72482. */
  72483. export class CloudPoint {
  72484. /**
  72485. * particle global index
  72486. */
  72487. idx: number;
  72488. /**
  72489. * The color of the particle
  72490. */
  72491. color: Nullable<Color4>;
  72492. /**
  72493. * The world space position of the particle.
  72494. */
  72495. position: Vector3;
  72496. /**
  72497. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72498. */
  72499. rotation: Vector3;
  72500. /**
  72501. * The world space rotation quaternion of the particle.
  72502. */
  72503. rotationQuaternion: Nullable<Quaternion>;
  72504. /**
  72505. * The uv of the particle.
  72506. */
  72507. uv: Nullable<Vector2>;
  72508. /**
  72509. * The current speed of the particle.
  72510. */
  72511. velocity: Vector3;
  72512. /**
  72513. * The pivot point in the particle local space.
  72514. */
  72515. pivot: Vector3;
  72516. /**
  72517. * Must the particle be translated from its pivot point in its local space ?
  72518. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72519. * Default : false
  72520. */
  72521. translateFromPivot: boolean;
  72522. /**
  72523. * Index of this particle in the global "positions" array (Internal use)
  72524. * @hidden
  72525. */
  72526. _pos: number;
  72527. /**
  72528. * @hidden Index of this particle in the global "indices" array (Internal use)
  72529. */
  72530. _ind: number;
  72531. /**
  72532. * Group this particle belongs to
  72533. */
  72534. _group: PointsGroup;
  72535. /**
  72536. * Group id of this particle
  72537. */
  72538. groupId: number;
  72539. /**
  72540. * Index of the particle in its group id (Internal use)
  72541. */
  72542. idxInGroup: number;
  72543. /**
  72544. * @hidden Particle BoundingInfo object (Internal use)
  72545. */
  72546. _boundingInfo: BoundingInfo;
  72547. /**
  72548. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72549. */
  72550. _pcs: PointsCloudSystem;
  72551. /**
  72552. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72553. */
  72554. _stillInvisible: boolean;
  72555. /**
  72556. * @hidden Last computed particle rotation matrix
  72557. */
  72558. _rotationMatrix: number[];
  72559. /**
  72560. * Parent particle Id, if any.
  72561. * Default null.
  72562. */
  72563. parentId: Nullable<number>;
  72564. /**
  72565. * @hidden Internal global position in the PCS.
  72566. */
  72567. _globalPosition: Vector3;
  72568. /**
  72569. * Creates a Point Cloud object.
  72570. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72571. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72572. * @param group (PointsGroup) is the group the particle belongs to
  72573. * @param groupId (integer) is the group identifier in the PCS.
  72574. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72575. * @param pcs defines the PCS it is associated to
  72576. */
  72577. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72578. /**
  72579. * get point size
  72580. */
  72581. get size(): Vector3;
  72582. /**
  72583. * Set point size
  72584. */
  72585. set size(scale: Vector3);
  72586. /**
  72587. * Legacy support, changed quaternion to rotationQuaternion
  72588. */
  72589. get quaternion(): Nullable<Quaternion>;
  72590. /**
  72591. * Legacy support, changed quaternion to rotationQuaternion
  72592. */
  72593. set quaternion(q: Nullable<Quaternion>);
  72594. /**
  72595. * Returns a boolean. True if the particle intersects a mesh, else false
  72596. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72597. * @param target is the object (point or mesh) what the intersection is computed against
  72598. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72599. * @returns true if it intersects
  72600. */
  72601. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72602. /**
  72603. * get the rotation matrix of the particle
  72604. * @hidden
  72605. */
  72606. getRotationMatrix(m: Matrix): void;
  72607. }
  72608. /**
  72609. * Represents a group of points in a points cloud system
  72610. * * PCS internal tool, don't use it manually.
  72611. */
  72612. export class PointsGroup {
  72613. /**
  72614. * The group id
  72615. * @hidden
  72616. */
  72617. groupID: number;
  72618. /**
  72619. * image data for group (internal use)
  72620. * @hidden
  72621. */
  72622. _groupImageData: Nullable<ArrayBufferView>;
  72623. /**
  72624. * Image Width (internal use)
  72625. * @hidden
  72626. */
  72627. _groupImgWidth: number;
  72628. /**
  72629. * Image Height (internal use)
  72630. * @hidden
  72631. */
  72632. _groupImgHeight: number;
  72633. /**
  72634. * Custom position function (internal use)
  72635. * @hidden
  72636. */
  72637. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72638. /**
  72639. * density per facet for surface points
  72640. * @hidden
  72641. */
  72642. _groupDensity: number[];
  72643. /**
  72644. * Only when points are colored by texture carries pointer to texture list array
  72645. * @hidden
  72646. */
  72647. _textureNb: number;
  72648. /**
  72649. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72650. * PCS internal tool, don't use it manually.
  72651. * @hidden
  72652. */
  72653. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72654. }
  72655. }
  72656. declare module "babylonjs/Particles/index" {
  72657. export * from "babylonjs/Particles/baseParticleSystem";
  72658. export * from "babylonjs/Particles/EmitterTypes/index";
  72659. export * from "babylonjs/Particles/gpuParticleSystem";
  72660. export * from "babylonjs/Particles/IParticleSystem";
  72661. export * from "babylonjs/Particles/particle";
  72662. export * from "babylonjs/Particles/particleHelper";
  72663. export * from "babylonjs/Particles/particleSystem";
  72664. import "babylonjs/Particles/particleSystemComponent";
  72665. export * from "babylonjs/Particles/particleSystemComponent";
  72666. export * from "babylonjs/Particles/particleSystemSet";
  72667. export * from "babylonjs/Particles/solidParticle";
  72668. export * from "babylonjs/Particles/solidParticleSystem";
  72669. export * from "babylonjs/Particles/cloudPoint";
  72670. export * from "babylonjs/Particles/pointsCloudSystem";
  72671. export * from "babylonjs/Particles/subEmitter";
  72672. }
  72673. declare module "babylonjs/Physics/physicsEngineComponent" {
  72674. import { Nullable } from "babylonjs/types";
  72675. import { Observable, Observer } from "babylonjs/Misc/observable";
  72676. import { Vector3 } from "babylonjs/Maths/math.vector";
  72677. import { Mesh } from "babylonjs/Meshes/mesh";
  72678. import { ISceneComponent } from "babylonjs/sceneComponent";
  72679. import { Scene } from "babylonjs/scene";
  72680. import { Node } from "babylonjs/node";
  72681. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72682. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72683. module "babylonjs/scene" {
  72684. interface Scene {
  72685. /** @hidden (Backing field) */
  72686. _physicsEngine: Nullable<IPhysicsEngine>;
  72687. /** @hidden */
  72688. _physicsTimeAccumulator: number;
  72689. /**
  72690. * Gets the current physics engine
  72691. * @returns a IPhysicsEngine or null if none attached
  72692. */
  72693. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72694. /**
  72695. * Enables physics to the current scene
  72696. * @param gravity defines the scene's gravity for the physics engine
  72697. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72698. * @return a boolean indicating if the physics engine was initialized
  72699. */
  72700. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72701. /**
  72702. * Disables and disposes the physics engine associated with the scene
  72703. */
  72704. disablePhysicsEngine(): void;
  72705. /**
  72706. * Gets a boolean indicating if there is an active physics engine
  72707. * @returns a boolean indicating if there is an active physics engine
  72708. */
  72709. isPhysicsEnabled(): boolean;
  72710. /**
  72711. * Deletes a physics compound impostor
  72712. * @param compound defines the compound to delete
  72713. */
  72714. deleteCompoundImpostor(compound: any): void;
  72715. /**
  72716. * An event triggered when physic simulation is about to be run
  72717. */
  72718. onBeforePhysicsObservable: Observable<Scene>;
  72719. /**
  72720. * An event triggered when physic simulation has been done
  72721. */
  72722. onAfterPhysicsObservable: Observable<Scene>;
  72723. }
  72724. }
  72725. module "babylonjs/Meshes/abstractMesh" {
  72726. interface AbstractMesh {
  72727. /** @hidden */
  72728. _physicsImpostor: Nullable<PhysicsImpostor>;
  72729. /**
  72730. * Gets or sets impostor used for physic simulation
  72731. * @see https://doc.babylonjs.com/features/physics_engine
  72732. */
  72733. physicsImpostor: Nullable<PhysicsImpostor>;
  72734. /**
  72735. * Gets the current physics impostor
  72736. * @see https://doc.babylonjs.com/features/physics_engine
  72737. * @returns a physics impostor or null
  72738. */
  72739. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72740. /** Apply a physic impulse to the mesh
  72741. * @param force defines the force to apply
  72742. * @param contactPoint defines where to apply the force
  72743. * @returns the current mesh
  72744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72745. */
  72746. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72747. /**
  72748. * Creates a physic joint between two meshes
  72749. * @param otherMesh defines the other mesh to use
  72750. * @param pivot1 defines the pivot to use on this mesh
  72751. * @param pivot2 defines the pivot to use on the other mesh
  72752. * @param options defines additional options (can be plugin dependent)
  72753. * @returns the current mesh
  72754. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72755. */
  72756. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72757. /** @hidden */
  72758. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72759. }
  72760. }
  72761. /**
  72762. * Defines the physics engine scene component responsible to manage a physics engine
  72763. */
  72764. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72765. /**
  72766. * The component name helpful to identify the component in the list of scene components.
  72767. */
  72768. readonly name: string;
  72769. /**
  72770. * The scene the component belongs to.
  72771. */
  72772. scene: Scene;
  72773. /**
  72774. * Creates a new instance of the component for the given scene
  72775. * @param scene Defines the scene to register the component in
  72776. */
  72777. constructor(scene: Scene);
  72778. /**
  72779. * Registers the component in a given scene
  72780. */
  72781. register(): void;
  72782. /**
  72783. * Rebuilds the elements related to this component in case of
  72784. * context lost for instance.
  72785. */
  72786. rebuild(): void;
  72787. /**
  72788. * Disposes the component and the associated ressources
  72789. */
  72790. dispose(): void;
  72791. }
  72792. }
  72793. declare module "babylonjs/Physics/physicsHelper" {
  72794. import { Nullable } from "babylonjs/types";
  72795. import { Vector3 } from "babylonjs/Maths/math.vector";
  72796. import { Mesh } from "babylonjs/Meshes/mesh";
  72797. import { Scene } from "babylonjs/scene";
  72798. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72799. /**
  72800. * A helper for physics simulations
  72801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72802. */
  72803. export class PhysicsHelper {
  72804. private _scene;
  72805. private _physicsEngine;
  72806. /**
  72807. * Initializes the Physics helper
  72808. * @param scene Babylon.js scene
  72809. */
  72810. constructor(scene: Scene);
  72811. /**
  72812. * Applies a radial explosion impulse
  72813. * @param origin the origin of the explosion
  72814. * @param radiusOrEventOptions the radius or the options of radial explosion
  72815. * @param strength the explosion strength
  72816. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72817. * @returns A physics radial explosion event, or null
  72818. */
  72819. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72820. /**
  72821. * Applies a radial explosion force
  72822. * @param origin the origin of the explosion
  72823. * @param radiusOrEventOptions the radius or the options of radial explosion
  72824. * @param strength the explosion strength
  72825. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72826. * @returns A physics radial explosion event, or null
  72827. */
  72828. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72829. /**
  72830. * Creates a gravitational field
  72831. * @param origin the origin of the explosion
  72832. * @param radiusOrEventOptions the radius or the options of radial explosion
  72833. * @param strength the explosion strength
  72834. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72835. * @returns A physics gravitational field event, or null
  72836. */
  72837. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72838. /**
  72839. * Creates a physics updraft event
  72840. * @param origin the origin of the updraft
  72841. * @param radiusOrEventOptions the radius or the options of the updraft
  72842. * @param strength the strength of the updraft
  72843. * @param height the height of the updraft
  72844. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72845. * @returns A physics updraft event, or null
  72846. */
  72847. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72848. /**
  72849. * Creates a physics vortex event
  72850. * @param origin the of the vortex
  72851. * @param radiusOrEventOptions the radius or the options of the vortex
  72852. * @param strength the strength of the vortex
  72853. * @param height the height of the vortex
  72854. * @returns a Physics vortex event, or null
  72855. * A physics vortex event or null
  72856. */
  72857. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72858. }
  72859. /**
  72860. * Represents a physics radial explosion event
  72861. */
  72862. class PhysicsRadialExplosionEvent {
  72863. private _scene;
  72864. private _options;
  72865. private _sphere;
  72866. private _dataFetched;
  72867. /**
  72868. * Initializes a radial explosioin event
  72869. * @param _scene BabylonJS scene
  72870. * @param _options The options for the vortex event
  72871. */
  72872. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72873. /**
  72874. * Returns the data related to the radial explosion event (sphere).
  72875. * @returns The radial explosion event data
  72876. */
  72877. getData(): PhysicsRadialExplosionEventData;
  72878. /**
  72879. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72880. * @param impostor A physics imposter
  72881. * @param origin the origin of the explosion
  72882. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72883. */
  72884. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72885. /**
  72886. * Triggers affecterd impostors callbacks
  72887. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72888. */
  72889. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72890. /**
  72891. * Disposes the sphere.
  72892. * @param force Specifies if the sphere should be disposed by force
  72893. */
  72894. dispose(force?: boolean): void;
  72895. /*** Helpers ***/
  72896. private _prepareSphere;
  72897. private _intersectsWithSphere;
  72898. }
  72899. /**
  72900. * Represents a gravitational field event
  72901. */
  72902. class PhysicsGravitationalFieldEvent {
  72903. private _physicsHelper;
  72904. private _scene;
  72905. private _origin;
  72906. private _options;
  72907. private _tickCallback;
  72908. private _sphere;
  72909. private _dataFetched;
  72910. /**
  72911. * Initializes the physics gravitational field event
  72912. * @param _physicsHelper A physics helper
  72913. * @param _scene BabylonJS scene
  72914. * @param _origin The origin position of the gravitational field event
  72915. * @param _options The options for the vortex event
  72916. */
  72917. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72918. /**
  72919. * Returns the data related to the gravitational field event (sphere).
  72920. * @returns A gravitational field event
  72921. */
  72922. getData(): PhysicsGravitationalFieldEventData;
  72923. /**
  72924. * Enables the gravitational field.
  72925. */
  72926. enable(): void;
  72927. /**
  72928. * Disables the gravitational field.
  72929. */
  72930. disable(): void;
  72931. /**
  72932. * Disposes the sphere.
  72933. * @param force The force to dispose from the gravitational field event
  72934. */
  72935. dispose(force?: boolean): void;
  72936. private _tick;
  72937. }
  72938. /**
  72939. * Represents a physics updraft event
  72940. */
  72941. class PhysicsUpdraftEvent {
  72942. private _scene;
  72943. private _origin;
  72944. private _options;
  72945. private _physicsEngine;
  72946. private _originTop;
  72947. private _originDirection;
  72948. private _tickCallback;
  72949. private _cylinder;
  72950. private _cylinderPosition;
  72951. private _dataFetched;
  72952. /**
  72953. * Initializes the physics updraft event
  72954. * @param _scene BabylonJS scene
  72955. * @param _origin The origin position of the updraft
  72956. * @param _options The options for the updraft event
  72957. */
  72958. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72959. /**
  72960. * Returns the data related to the updraft event (cylinder).
  72961. * @returns A physics updraft event
  72962. */
  72963. getData(): PhysicsUpdraftEventData;
  72964. /**
  72965. * Enables the updraft.
  72966. */
  72967. enable(): void;
  72968. /**
  72969. * Disables the updraft.
  72970. */
  72971. disable(): void;
  72972. /**
  72973. * Disposes the cylinder.
  72974. * @param force Specifies if the updraft should be disposed by force
  72975. */
  72976. dispose(force?: boolean): void;
  72977. private getImpostorHitData;
  72978. private _tick;
  72979. /*** Helpers ***/
  72980. private _prepareCylinder;
  72981. private _intersectsWithCylinder;
  72982. }
  72983. /**
  72984. * Represents a physics vortex event
  72985. */
  72986. class PhysicsVortexEvent {
  72987. private _scene;
  72988. private _origin;
  72989. private _options;
  72990. private _physicsEngine;
  72991. private _originTop;
  72992. private _tickCallback;
  72993. private _cylinder;
  72994. private _cylinderPosition;
  72995. private _dataFetched;
  72996. /**
  72997. * Initializes the physics vortex event
  72998. * @param _scene The BabylonJS scene
  72999. * @param _origin The origin position of the vortex
  73000. * @param _options The options for the vortex event
  73001. */
  73002. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73003. /**
  73004. * Returns the data related to the vortex event (cylinder).
  73005. * @returns The physics vortex event data
  73006. */
  73007. getData(): PhysicsVortexEventData;
  73008. /**
  73009. * Enables the vortex.
  73010. */
  73011. enable(): void;
  73012. /**
  73013. * Disables the cortex.
  73014. */
  73015. disable(): void;
  73016. /**
  73017. * Disposes the sphere.
  73018. * @param force
  73019. */
  73020. dispose(force?: boolean): void;
  73021. private getImpostorHitData;
  73022. private _tick;
  73023. /*** Helpers ***/
  73024. private _prepareCylinder;
  73025. private _intersectsWithCylinder;
  73026. }
  73027. /**
  73028. * Options fot the radial explosion event
  73029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73030. */
  73031. export class PhysicsRadialExplosionEventOptions {
  73032. /**
  73033. * The radius of the sphere for the radial explosion.
  73034. */
  73035. radius: number;
  73036. /**
  73037. * The strenth of the explosion.
  73038. */
  73039. strength: number;
  73040. /**
  73041. * The strenght of the force in correspondence to the distance of the affected object
  73042. */
  73043. falloff: PhysicsRadialImpulseFalloff;
  73044. /**
  73045. * Sphere options for the radial explosion.
  73046. */
  73047. sphere: {
  73048. segments: number;
  73049. diameter: number;
  73050. };
  73051. /**
  73052. * Sphere options for the radial explosion.
  73053. */
  73054. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73055. }
  73056. /**
  73057. * Options fot the updraft event
  73058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73059. */
  73060. export class PhysicsUpdraftEventOptions {
  73061. /**
  73062. * The radius of the cylinder for the vortex
  73063. */
  73064. radius: number;
  73065. /**
  73066. * The strenth of the updraft.
  73067. */
  73068. strength: number;
  73069. /**
  73070. * The height of the cylinder for the updraft.
  73071. */
  73072. height: number;
  73073. /**
  73074. * The mode for the the updraft.
  73075. */
  73076. updraftMode: PhysicsUpdraftMode;
  73077. }
  73078. /**
  73079. * Options fot the vortex event
  73080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73081. */
  73082. export class PhysicsVortexEventOptions {
  73083. /**
  73084. * The radius of the cylinder for the vortex
  73085. */
  73086. radius: number;
  73087. /**
  73088. * The strenth of the vortex.
  73089. */
  73090. strength: number;
  73091. /**
  73092. * The height of the cylinder for the vortex.
  73093. */
  73094. height: number;
  73095. /**
  73096. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73097. */
  73098. centripetalForceThreshold: number;
  73099. /**
  73100. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73101. */
  73102. centripetalForceMultiplier: number;
  73103. /**
  73104. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73105. */
  73106. centrifugalForceMultiplier: number;
  73107. /**
  73108. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73109. */
  73110. updraftForceMultiplier: number;
  73111. }
  73112. /**
  73113. * The strenght of the force in correspondence to the distance of the affected object
  73114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73115. */
  73116. export enum PhysicsRadialImpulseFalloff {
  73117. /** Defines that impulse is constant in strength across it's whole radius */
  73118. Constant = 0,
  73119. /** Defines that impulse gets weaker if it's further from the origin */
  73120. Linear = 1
  73121. }
  73122. /**
  73123. * The strength of the force in correspondence to the distance of the affected object
  73124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73125. */
  73126. export enum PhysicsUpdraftMode {
  73127. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73128. Center = 0,
  73129. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73130. Perpendicular = 1
  73131. }
  73132. /**
  73133. * Interface for a physics hit data
  73134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73135. */
  73136. export interface PhysicsHitData {
  73137. /**
  73138. * The force applied at the contact point
  73139. */
  73140. force: Vector3;
  73141. /**
  73142. * The contact point
  73143. */
  73144. contactPoint: Vector3;
  73145. /**
  73146. * The distance from the origin to the contact point
  73147. */
  73148. distanceFromOrigin: number;
  73149. }
  73150. /**
  73151. * Interface for radial explosion event data
  73152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73153. */
  73154. export interface PhysicsRadialExplosionEventData {
  73155. /**
  73156. * A sphere used for the radial explosion event
  73157. */
  73158. sphere: Mesh;
  73159. }
  73160. /**
  73161. * Interface for gravitational field event data
  73162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73163. */
  73164. export interface PhysicsGravitationalFieldEventData {
  73165. /**
  73166. * A sphere mesh used for the gravitational field event
  73167. */
  73168. sphere: Mesh;
  73169. }
  73170. /**
  73171. * Interface for updraft event data
  73172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73173. */
  73174. export interface PhysicsUpdraftEventData {
  73175. /**
  73176. * A cylinder used for the updraft event
  73177. */
  73178. cylinder: Mesh;
  73179. }
  73180. /**
  73181. * Interface for vortex event data
  73182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73183. */
  73184. export interface PhysicsVortexEventData {
  73185. /**
  73186. * A cylinder used for the vortex event
  73187. */
  73188. cylinder: Mesh;
  73189. }
  73190. /**
  73191. * Interface for an affected physics impostor
  73192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73193. */
  73194. export interface PhysicsAffectedImpostorWithData {
  73195. /**
  73196. * The impostor affected by the effect
  73197. */
  73198. impostor: PhysicsImpostor;
  73199. /**
  73200. * The data about the hit/horce from the explosion
  73201. */
  73202. hitData: PhysicsHitData;
  73203. }
  73204. }
  73205. declare module "babylonjs/Physics/Plugins/index" {
  73206. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  73207. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  73208. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  73209. }
  73210. declare module "babylonjs/Physics/index" {
  73211. export * from "babylonjs/Physics/IPhysicsEngine";
  73212. export * from "babylonjs/Physics/physicsEngine";
  73213. export * from "babylonjs/Physics/physicsEngineComponent";
  73214. export * from "babylonjs/Physics/physicsHelper";
  73215. export * from "babylonjs/Physics/physicsImpostor";
  73216. export * from "babylonjs/Physics/physicsJoint";
  73217. export * from "babylonjs/Physics/Plugins/index";
  73218. }
  73219. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  73220. /** @hidden */
  73221. export var blackAndWhitePixelShader: {
  73222. name: string;
  73223. shader: string;
  73224. };
  73225. }
  73226. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  73227. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73228. import { Camera } from "babylonjs/Cameras/camera";
  73229. import { Engine } from "babylonjs/Engines/engine";
  73230. import "babylonjs/Shaders/blackAndWhite.fragment";
  73231. import { Nullable } from "babylonjs/types";
  73232. import { Scene } from "babylonjs/scene";
  73233. /**
  73234. * Post process used to render in black and white
  73235. */
  73236. export class BlackAndWhitePostProcess extends PostProcess {
  73237. /**
  73238. * Linear about to convert he result to black and white (default: 1)
  73239. */
  73240. degree: number;
  73241. /**
  73242. * Gets a string identifying the name of the class
  73243. * @returns "BlackAndWhitePostProcess" string
  73244. */
  73245. getClassName(): string;
  73246. /**
  73247. * Creates a black and white post process
  73248. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73249. * @param name The name of the effect.
  73250. * @param options The required width/height ratio to downsize to before computing the render pass.
  73251. * @param camera The camera to apply the render pass to.
  73252. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73253. * @param engine The engine which the post process will be applied. (default: current engine)
  73254. * @param reusable If the post process can be reused on the same frame. (default: false)
  73255. */
  73256. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73257. /** @hidden */
  73258. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73259. }
  73260. }
  73261. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  73262. import { Nullable } from "babylonjs/types";
  73263. import { Camera } from "babylonjs/Cameras/camera";
  73264. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73265. import { Engine } from "babylonjs/Engines/engine";
  73266. /**
  73267. * This represents a set of one or more post processes in Babylon.
  73268. * A post process can be used to apply a shader to a texture after it is rendered.
  73269. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73270. */
  73271. export class PostProcessRenderEffect {
  73272. private _postProcesses;
  73273. private _getPostProcesses;
  73274. private _singleInstance;
  73275. private _cameras;
  73276. private _indicesForCamera;
  73277. /**
  73278. * Name of the effect
  73279. * @hidden
  73280. */
  73281. _name: string;
  73282. /**
  73283. * Instantiates a post process render effect.
  73284. * A post process can be used to apply a shader to a texture after it is rendered.
  73285. * @param engine The engine the effect is tied to
  73286. * @param name The name of the effect
  73287. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73288. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73289. */
  73290. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73291. /**
  73292. * Checks if all the post processes in the effect are supported.
  73293. */
  73294. get isSupported(): boolean;
  73295. /**
  73296. * Updates the current state of the effect
  73297. * @hidden
  73298. */
  73299. _update(): void;
  73300. /**
  73301. * Attaches the effect on cameras
  73302. * @param cameras The camera to attach to.
  73303. * @hidden
  73304. */
  73305. _attachCameras(cameras: Camera): void;
  73306. /**
  73307. * Attaches the effect on cameras
  73308. * @param cameras The camera to attach to.
  73309. * @hidden
  73310. */
  73311. _attachCameras(cameras: Camera[]): void;
  73312. /**
  73313. * Detaches the effect on cameras
  73314. * @param cameras The camera to detatch from.
  73315. * @hidden
  73316. */
  73317. _detachCameras(cameras: Camera): void;
  73318. /**
  73319. * Detatches the effect on cameras
  73320. * @param cameras The camera to detatch from.
  73321. * @hidden
  73322. */
  73323. _detachCameras(cameras: Camera[]): void;
  73324. /**
  73325. * Enables the effect on given cameras
  73326. * @param cameras The camera to enable.
  73327. * @hidden
  73328. */
  73329. _enable(cameras: Camera): void;
  73330. /**
  73331. * Enables the effect on given cameras
  73332. * @param cameras The camera to enable.
  73333. * @hidden
  73334. */
  73335. _enable(cameras: Nullable<Camera[]>): void;
  73336. /**
  73337. * Disables the effect on the given cameras
  73338. * @param cameras The camera to disable.
  73339. * @hidden
  73340. */
  73341. _disable(cameras: Camera): void;
  73342. /**
  73343. * Disables the effect on the given cameras
  73344. * @param cameras The camera to disable.
  73345. * @hidden
  73346. */
  73347. _disable(cameras: Nullable<Camera[]>): void;
  73348. /**
  73349. * Gets a list of the post processes contained in the effect.
  73350. * @param camera The camera to get the post processes on.
  73351. * @returns The list of the post processes in the effect.
  73352. */
  73353. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73354. }
  73355. }
  73356. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  73357. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73358. /** @hidden */
  73359. export var extractHighlightsPixelShader: {
  73360. name: string;
  73361. shader: string;
  73362. };
  73363. }
  73364. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  73365. import { Nullable } from "babylonjs/types";
  73366. import { Camera } from "babylonjs/Cameras/camera";
  73367. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73368. import { Engine } from "babylonjs/Engines/engine";
  73369. import "babylonjs/Shaders/extractHighlights.fragment";
  73370. /**
  73371. * 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.
  73372. */
  73373. export class ExtractHighlightsPostProcess extends PostProcess {
  73374. /**
  73375. * The luminance threshold, pixels below this value will be set to black.
  73376. */
  73377. threshold: number;
  73378. /** @hidden */
  73379. _exposure: number;
  73380. /**
  73381. * Post process which has the input texture to be used when performing highlight extraction
  73382. * @hidden
  73383. */
  73384. _inputPostProcess: Nullable<PostProcess>;
  73385. /**
  73386. * Gets a string identifying the name of the class
  73387. * @returns "ExtractHighlightsPostProcess" string
  73388. */
  73389. getClassName(): string;
  73390. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73391. }
  73392. }
  73393. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  73394. /** @hidden */
  73395. export var bloomMergePixelShader: {
  73396. name: string;
  73397. shader: string;
  73398. };
  73399. }
  73400. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  73401. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73402. import { Nullable } from "babylonjs/types";
  73403. import { Engine } from "babylonjs/Engines/engine";
  73404. import { Camera } from "babylonjs/Cameras/camera";
  73405. import "babylonjs/Shaders/bloomMerge.fragment";
  73406. /**
  73407. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73408. */
  73409. export class BloomMergePostProcess extends PostProcess {
  73410. /** Weight of the bloom to be added to the original input. */
  73411. weight: number;
  73412. /**
  73413. * Gets a string identifying the name of the class
  73414. * @returns "BloomMergePostProcess" string
  73415. */
  73416. getClassName(): string;
  73417. /**
  73418. * Creates a new instance of @see BloomMergePostProcess
  73419. * @param name The name of the effect.
  73420. * @param originalFromInput Post process which's input will be used for the merge.
  73421. * @param blurred Blurred highlights post process which's output will be used.
  73422. * @param weight Weight of the bloom to be added to the original input.
  73423. * @param options The required width/height ratio to downsize to before computing the render pass.
  73424. * @param camera The camera to apply the render pass to.
  73425. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73426. * @param engine The engine which the post process will be applied. (default: current engine)
  73427. * @param reusable If the post process can be reused on the same frame. (default: false)
  73428. * @param textureType Type of textures used when performing the post process. (default: 0)
  73429. * @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)
  73430. */
  73431. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73432. /** Weight of the bloom to be added to the original input. */
  73433. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73434. }
  73435. }
  73436. declare module "babylonjs/PostProcesses/bloomEffect" {
  73437. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73438. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73439. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73440. import { Camera } from "babylonjs/Cameras/camera";
  73441. import { Scene } from "babylonjs/scene";
  73442. /**
  73443. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73444. */
  73445. export class BloomEffect extends PostProcessRenderEffect {
  73446. private bloomScale;
  73447. /**
  73448. * @hidden Internal
  73449. */
  73450. _effects: Array<PostProcess>;
  73451. /**
  73452. * @hidden Internal
  73453. */
  73454. _downscale: ExtractHighlightsPostProcess;
  73455. private _blurX;
  73456. private _blurY;
  73457. private _merge;
  73458. /**
  73459. * The luminance threshold to find bright areas of the image to bloom.
  73460. */
  73461. get threshold(): number;
  73462. set threshold(value: number);
  73463. /**
  73464. * The strength of the bloom.
  73465. */
  73466. get weight(): number;
  73467. set weight(value: number);
  73468. /**
  73469. * Specifies the size of the bloom blur kernel, relative to the final output size
  73470. */
  73471. get kernel(): number;
  73472. set kernel(value: number);
  73473. /**
  73474. * Creates a new instance of @see BloomEffect
  73475. * @param scene The scene the effect belongs to.
  73476. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73477. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73478. * @param bloomWeight The the strength of bloom.
  73479. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73480. * @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)
  73481. */
  73482. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73483. /**
  73484. * Disposes each of the internal effects for a given camera.
  73485. * @param camera The camera to dispose the effect on.
  73486. */
  73487. disposeEffects(camera: Camera): void;
  73488. /**
  73489. * @hidden Internal
  73490. */
  73491. _updateEffects(): void;
  73492. /**
  73493. * Internal
  73494. * @returns if all the contained post processes are ready.
  73495. * @hidden
  73496. */
  73497. _isReady(): boolean;
  73498. }
  73499. }
  73500. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  73501. /** @hidden */
  73502. export var chromaticAberrationPixelShader: {
  73503. name: string;
  73504. shader: string;
  73505. };
  73506. }
  73507. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73508. import { Vector2 } from "babylonjs/Maths/math.vector";
  73509. import { Nullable } from "babylonjs/types";
  73510. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73511. import { Camera } from "babylonjs/Cameras/camera";
  73512. import { Engine } from "babylonjs/Engines/engine";
  73513. import "babylonjs/Shaders/chromaticAberration.fragment";
  73514. import { Scene } from "babylonjs/scene";
  73515. /**
  73516. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73517. */
  73518. export class ChromaticAberrationPostProcess extends PostProcess {
  73519. /**
  73520. * The amount of seperation of rgb channels (default: 30)
  73521. */
  73522. aberrationAmount: number;
  73523. /**
  73524. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73525. */
  73526. radialIntensity: number;
  73527. /**
  73528. * 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))
  73529. */
  73530. direction: Vector2;
  73531. /**
  73532. * 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))
  73533. */
  73534. centerPosition: Vector2;
  73535. /** The width of the screen to apply the effect on */
  73536. screenWidth: number;
  73537. /** The height of the screen to apply the effect on */
  73538. screenHeight: number;
  73539. /**
  73540. * Gets a string identifying the name of the class
  73541. * @returns "ChromaticAberrationPostProcess" string
  73542. */
  73543. getClassName(): string;
  73544. /**
  73545. * Creates a new instance ChromaticAberrationPostProcess
  73546. * @param name The name of the effect.
  73547. * @param screenWidth The width of the screen to apply the effect on.
  73548. * @param screenHeight The height of the screen to apply the effect on.
  73549. * @param options The required width/height ratio to downsize to before computing the render pass.
  73550. * @param camera The camera to apply the render pass to.
  73551. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73552. * @param engine The engine which the post process will be applied. (default: current engine)
  73553. * @param reusable If the post process can be reused on the same frame. (default: false)
  73554. * @param textureType Type of textures used when performing the post process. (default: 0)
  73555. * @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)
  73556. */
  73557. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73558. /** @hidden */
  73559. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73560. }
  73561. }
  73562. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73563. /** @hidden */
  73564. export var circleOfConfusionPixelShader: {
  73565. name: string;
  73566. shader: string;
  73567. };
  73568. }
  73569. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73570. import { Nullable } from "babylonjs/types";
  73571. import { Engine } from "babylonjs/Engines/engine";
  73572. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73573. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73574. import { Camera } from "babylonjs/Cameras/camera";
  73575. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73576. /**
  73577. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73578. */
  73579. export class CircleOfConfusionPostProcess extends PostProcess {
  73580. /**
  73581. * 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.
  73582. */
  73583. lensSize: number;
  73584. /**
  73585. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73586. */
  73587. fStop: number;
  73588. /**
  73589. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73590. */
  73591. focusDistance: number;
  73592. /**
  73593. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73594. */
  73595. focalLength: number;
  73596. /**
  73597. * Gets a string identifying the name of the class
  73598. * @returns "CircleOfConfusionPostProcess" string
  73599. */
  73600. getClassName(): string;
  73601. private _depthTexture;
  73602. /**
  73603. * Creates a new instance CircleOfConfusionPostProcess
  73604. * @param name The name of the effect.
  73605. * @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.
  73606. * @param options The required width/height ratio to downsize to before computing the render pass.
  73607. * @param camera The camera to apply the render pass to.
  73608. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73609. * @param engine The engine which the post process will be applied. (default: current engine)
  73610. * @param reusable If the post process can be reused on the same frame. (default: false)
  73611. * @param textureType Type of textures used when performing the post process. (default: 0)
  73612. * @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)
  73613. */
  73614. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73615. /**
  73616. * 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.
  73617. */
  73618. set depthTexture(value: RenderTargetTexture);
  73619. }
  73620. }
  73621. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73622. /** @hidden */
  73623. export var colorCorrectionPixelShader: {
  73624. name: string;
  73625. shader: string;
  73626. };
  73627. }
  73628. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73629. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73630. import { Engine } from "babylonjs/Engines/engine";
  73631. import { Camera } from "babylonjs/Cameras/camera";
  73632. import "babylonjs/Shaders/colorCorrection.fragment";
  73633. import { Nullable } from "babylonjs/types";
  73634. import { Scene } from "babylonjs/scene";
  73635. /**
  73636. *
  73637. * This post-process allows the modification of rendered colors by using
  73638. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73639. *
  73640. * The object needs to be provided an url to a texture containing the color
  73641. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73642. * Use an image editing software to tweak the LUT to match your needs.
  73643. *
  73644. * For an example of a color LUT, see here:
  73645. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73646. * For explanations on color grading, see here:
  73647. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73648. *
  73649. */
  73650. export class ColorCorrectionPostProcess extends PostProcess {
  73651. private _colorTableTexture;
  73652. /**
  73653. * Gets the color table url used to create the LUT texture
  73654. */
  73655. colorTableUrl: string;
  73656. /**
  73657. * Gets a string identifying the name of the class
  73658. * @returns "ColorCorrectionPostProcess" string
  73659. */
  73660. getClassName(): string;
  73661. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73662. /** @hidden */
  73663. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73664. }
  73665. }
  73666. declare module "babylonjs/Shaders/convolution.fragment" {
  73667. /** @hidden */
  73668. export var convolutionPixelShader: {
  73669. name: string;
  73670. shader: string;
  73671. };
  73672. }
  73673. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73674. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73675. import { Nullable } from "babylonjs/types";
  73676. import { Camera } from "babylonjs/Cameras/camera";
  73677. import { Engine } from "babylonjs/Engines/engine";
  73678. import "babylonjs/Shaders/convolution.fragment";
  73679. import { Scene } from "babylonjs/scene";
  73680. /**
  73681. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73682. * input texture to perform effects such as edge detection or sharpening
  73683. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73684. */
  73685. export class ConvolutionPostProcess extends PostProcess {
  73686. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73687. kernel: number[];
  73688. /**
  73689. * Gets a string identifying the name of the class
  73690. * @returns "ConvolutionPostProcess" string
  73691. */
  73692. getClassName(): string;
  73693. /**
  73694. * Creates a new instance ConvolutionPostProcess
  73695. * @param name The name of the effect.
  73696. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73697. * @param options The required width/height ratio to downsize to before computing the render pass.
  73698. * @param camera The camera to apply the render pass to.
  73699. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73700. * @param engine The engine which the post process will be applied. (default: current engine)
  73701. * @param reusable If the post process can be reused on the same frame. (default: false)
  73702. * @param textureType Type of textures used when performing the post process. (default: 0)
  73703. */
  73704. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73705. /** @hidden */
  73706. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73707. /**
  73708. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73709. */
  73710. static EdgeDetect0Kernel: number[];
  73711. /**
  73712. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73713. */
  73714. static EdgeDetect1Kernel: number[];
  73715. /**
  73716. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73717. */
  73718. static EdgeDetect2Kernel: number[];
  73719. /**
  73720. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73721. */
  73722. static SharpenKernel: number[];
  73723. /**
  73724. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73725. */
  73726. static EmbossKernel: number[];
  73727. /**
  73728. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73729. */
  73730. static GaussianKernel: number[];
  73731. }
  73732. }
  73733. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73734. import { Nullable } from "babylonjs/types";
  73735. import { Vector2 } from "babylonjs/Maths/math.vector";
  73736. import { Camera } from "babylonjs/Cameras/camera";
  73737. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73738. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73739. import { Engine } from "babylonjs/Engines/engine";
  73740. import { Scene } from "babylonjs/scene";
  73741. /**
  73742. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73743. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73744. * based on samples that have a large difference in distance than the center pixel.
  73745. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73746. */
  73747. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73748. /**
  73749. * The direction the blur should be applied
  73750. */
  73751. direction: Vector2;
  73752. /**
  73753. * Gets a string identifying the name of the class
  73754. * @returns "DepthOfFieldBlurPostProcess" string
  73755. */
  73756. getClassName(): string;
  73757. /**
  73758. * Creates a new instance CircleOfConfusionPostProcess
  73759. * @param name The name of the effect.
  73760. * @param scene The scene the effect belongs to.
  73761. * @param direction The direction the blur should be applied.
  73762. * @param kernel The size of the kernel used to blur.
  73763. * @param options The required width/height ratio to downsize to before computing the render pass.
  73764. * @param camera The camera to apply the render pass to.
  73765. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73766. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73768. * @param engine The engine which the post process will be applied. (default: current engine)
  73769. * @param reusable If the post process can be reused on the same frame. (default: false)
  73770. * @param textureType Type of textures used when performing the post process. (default: 0)
  73771. * @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)
  73772. */
  73773. 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);
  73774. }
  73775. }
  73776. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73777. /** @hidden */
  73778. export var depthOfFieldMergePixelShader: {
  73779. name: string;
  73780. shader: string;
  73781. };
  73782. }
  73783. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73784. import { Nullable } from "babylonjs/types";
  73785. import { Camera } from "babylonjs/Cameras/camera";
  73786. import { Effect } from "babylonjs/Materials/effect";
  73787. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73788. import { Engine } from "babylonjs/Engines/engine";
  73789. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73790. /**
  73791. * Options to be set when merging outputs from the default pipeline.
  73792. */
  73793. export class DepthOfFieldMergePostProcessOptions {
  73794. /**
  73795. * The original image to merge on top of
  73796. */
  73797. originalFromInput: PostProcess;
  73798. /**
  73799. * Parameters to perform the merge of the depth of field effect
  73800. */
  73801. depthOfField?: {
  73802. circleOfConfusion: PostProcess;
  73803. blurSteps: Array<PostProcess>;
  73804. };
  73805. /**
  73806. * Parameters to perform the merge of bloom effect
  73807. */
  73808. bloom?: {
  73809. blurred: PostProcess;
  73810. weight: number;
  73811. };
  73812. }
  73813. /**
  73814. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73815. */
  73816. export class DepthOfFieldMergePostProcess extends PostProcess {
  73817. private blurSteps;
  73818. /**
  73819. * Gets a string identifying the name of the class
  73820. * @returns "DepthOfFieldMergePostProcess" string
  73821. */
  73822. getClassName(): string;
  73823. /**
  73824. * Creates a new instance of DepthOfFieldMergePostProcess
  73825. * @param name The name of the effect.
  73826. * @param originalFromInput Post process which's input will be used for the merge.
  73827. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73828. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73829. * @param options The required width/height ratio to downsize to before computing the render pass.
  73830. * @param camera The camera to apply the render pass to.
  73831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73832. * @param engine The engine which the post process will be applied. (default: current engine)
  73833. * @param reusable If the post process can be reused on the same frame. (default: false)
  73834. * @param textureType Type of textures used when performing the post process. (default: 0)
  73835. * @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)
  73836. */
  73837. 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);
  73838. /**
  73839. * Updates the effect with the current post process compile time values and recompiles the shader.
  73840. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73841. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73842. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73843. * @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
  73844. * @param onCompiled Called when the shader has been compiled.
  73845. * @param onError Called if there is an error when compiling a shader.
  73846. */
  73847. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73848. }
  73849. }
  73850. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73851. import { Nullable } from "babylonjs/types";
  73852. import { Camera } from "babylonjs/Cameras/camera";
  73853. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73854. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73855. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73856. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73857. import { Scene } from "babylonjs/scene";
  73858. /**
  73859. * Specifies the level of max blur that should be applied when using the depth of field effect
  73860. */
  73861. export enum DepthOfFieldEffectBlurLevel {
  73862. /**
  73863. * Subtle blur
  73864. */
  73865. Low = 0,
  73866. /**
  73867. * Medium blur
  73868. */
  73869. Medium = 1,
  73870. /**
  73871. * Large blur
  73872. */
  73873. High = 2
  73874. }
  73875. /**
  73876. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73877. */
  73878. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73879. private _circleOfConfusion;
  73880. /**
  73881. * @hidden Internal, blurs from high to low
  73882. */
  73883. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73884. private _depthOfFieldBlurY;
  73885. private _dofMerge;
  73886. /**
  73887. * @hidden Internal post processes in depth of field effect
  73888. */
  73889. _effects: Array<PostProcess>;
  73890. /**
  73891. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73892. */
  73893. set focalLength(value: number);
  73894. get focalLength(): number;
  73895. /**
  73896. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73897. */
  73898. set fStop(value: number);
  73899. get fStop(): number;
  73900. /**
  73901. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73902. */
  73903. set focusDistance(value: number);
  73904. get focusDistance(): number;
  73905. /**
  73906. * 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.
  73907. */
  73908. set lensSize(value: number);
  73909. get lensSize(): number;
  73910. /**
  73911. * Creates a new instance DepthOfFieldEffect
  73912. * @param scene The scene the effect belongs to.
  73913. * @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.
  73914. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73915. * @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)
  73916. */
  73917. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73918. /**
  73919. * Get the current class name of the current effet
  73920. * @returns "DepthOfFieldEffect"
  73921. */
  73922. getClassName(): string;
  73923. /**
  73924. * 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.
  73925. */
  73926. set depthTexture(value: RenderTargetTexture);
  73927. /**
  73928. * Disposes each of the internal effects for a given camera.
  73929. * @param camera The camera to dispose the effect on.
  73930. */
  73931. disposeEffects(camera: Camera): void;
  73932. /**
  73933. * @hidden Internal
  73934. */
  73935. _updateEffects(): void;
  73936. /**
  73937. * Internal
  73938. * @returns if all the contained post processes are ready.
  73939. * @hidden
  73940. */
  73941. _isReady(): boolean;
  73942. }
  73943. }
  73944. declare module "babylonjs/Shaders/displayPass.fragment" {
  73945. /** @hidden */
  73946. export var displayPassPixelShader: {
  73947. name: string;
  73948. shader: string;
  73949. };
  73950. }
  73951. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73952. import { Nullable } from "babylonjs/types";
  73953. import { Camera } from "babylonjs/Cameras/camera";
  73954. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73955. import { Engine } from "babylonjs/Engines/engine";
  73956. import "babylonjs/Shaders/displayPass.fragment";
  73957. import { Scene } from "babylonjs/scene";
  73958. /**
  73959. * DisplayPassPostProcess which produces an output the same as it's input
  73960. */
  73961. export class DisplayPassPostProcess extends PostProcess {
  73962. /**
  73963. * Gets a string identifying the name of the class
  73964. * @returns "DisplayPassPostProcess" string
  73965. */
  73966. getClassName(): string;
  73967. /**
  73968. * Creates the DisplayPassPostProcess
  73969. * @param name The name of the effect.
  73970. * @param options The required width/height ratio to downsize to before computing the render pass.
  73971. * @param camera The camera to apply the render pass to.
  73972. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73973. * @param engine The engine which the post process will be applied. (default: current engine)
  73974. * @param reusable If the post process can be reused on the same frame. (default: false)
  73975. */
  73976. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73977. /** @hidden */
  73978. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73979. }
  73980. }
  73981. declare module "babylonjs/Shaders/filter.fragment" {
  73982. /** @hidden */
  73983. export var filterPixelShader: {
  73984. name: string;
  73985. shader: string;
  73986. };
  73987. }
  73988. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73989. import { Nullable } from "babylonjs/types";
  73990. import { Matrix } from "babylonjs/Maths/math.vector";
  73991. import { Camera } from "babylonjs/Cameras/camera";
  73992. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73993. import { Engine } from "babylonjs/Engines/engine";
  73994. import "babylonjs/Shaders/filter.fragment";
  73995. import { Scene } from "babylonjs/scene";
  73996. /**
  73997. * Applies a kernel filter to the image
  73998. */
  73999. export class FilterPostProcess extends PostProcess {
  74000. /** The matrix to be applied to the image */
  74001. kernelMatrix: Matrix;
  74002. /**
  74003. * Gets a string identifying the name of the class
  74004. * @returns "FilterPostProcess" string
  74005. */
  74006. getClassName(): string;
  74007. /**
  74008. *
  74009. * @param name The name of the effect.
  74010. * @param kernelMatrix The matrix to be applied to the image
  74011. * @param options The required width/height ratio to downsize to before computing the render pass.
  74012. * @param camera The camera to apply the render pass to.
  74013. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74014. * @param engine The engine which the post process will be applied. (default: current engine)
  74015. * @param reusable If the post process can be reused on the same frame. (default: false)
  74016. */
  74017. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74018. /** @hidden */
  74019. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74020. }
  74021. }
  74022. declare module "babylonjs/Shaders/fxaa.fragment" {
  74023. /** @hidden */
  74024. export var fxaaPixelShader: {
  74025. name: string;
  74026. shader: string;
  74027. };
  74028. }
  74029. declare module "babylonjs/Shaders/fxaa.vertex" {
  74030. /** @hidden */
  74031. export var fxaaVertexShader: {
  74032. name: string;
  74033. shader: string;
  74034. };
  74035. }
  74036. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74037. import { Nullable } from "babylonjs/types";
  74038. import { Camera } from "babylonjs/Cameras/camera";
  74039. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74040. import { Engine } from "babylonjs/Engines/engine";
  74041. import "babylonjs/Shaders/fxaa.fragment";
  74042. import "babylonjs/Shaders/fxaa.vertex";
  74043. import { Scene } from "babylonjs/scene";
  74044. /**
  74045. * Fxaa post process
  74046. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74047. */
  74048. export class FxaaPostProcess extends PostProcess {
  74049. /**
  74050. * Gets a string identifying the name of the class
  74051. * @returns "FxaaPostProcess" string
  74052. */
  74053. getClassName(): string;
  74054. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74055. private _getDefines;
  74056. /** @hidden */
  74057. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74058. }
  74059. }
  74060. declare module "babylonjs/Shaders/grain.fragment" {
  74061. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74062. /** @hidden */
  74063. export var grainPixelShader: {
  74064. name: string;
  74065. shader: string;
  74066. };
  74067. }
  74068. declare module "babylonjs/PostProcesses/grainPostProcess" {
  74069. import { Nullable } from "babylonjs/types";
  74070. import { Camera } from "babylonjs/Cameras/camera";
  74071. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74072. import { Engine } from "babylonjs/Engines/engine";
  74073. import "babylonjs/Shaders/grain.fragment";
  74074. import { Scene } from "babylonjs/scene";
  74075. /**
  74076. * The GrainPostProcess adds noise to the image at mid luminance levels
  74077. */
  74078. export class GrainPostProcess extends PostProcess {
  74079. /**
  74080. * The intensity of the grain added (default: 30)
  74081. */
  74082. intensity: number;
  74083. /**
  74084. * If the grain should be randomized on every frame
  74085. */
  74086. animated: boolean;
  74087. /**
  74088. * Gets a string identifying the name of the class
  74089. * @returns "GrainPostProcess" string
  74090. */
  74091. getClassName(): string;
  74092. /**
  74093. * Creates a new instance of @see GrainPostProcess
  74094. * @param name The name of the effect.
  74095. * @param options The required width/height ratio to downsize to before computing the render pass.
  74096. * @param camera The camera to apply the render pass to.
  74097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74098. * @param engine The engine which the post process will be applied. (default: current engine)
  74099. * @param reusable If the post process can be reused on the same frame. (default: false)
  74100. * @param textureType Type of textures used when performing the post process. (default: 0)
  74101. * @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)
  74102. */
  74103. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74104. /** @hidden */
  74105. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74106. }
  74107. }
  74108. declare module "babylonjs/Shaders/highlights.fragment" {
  74109. /** @hidden */
  74110. export var highlightsPixelShader: {
  74111. name: string;
  74112. shader: string;
  74113. };
  74114. }
  74115. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  74116. import { Nullable } from "babylonjs/types";
  74117. import { Camera } from "babylonjs/Cameras/camera";
  74118. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74119. import { Engine } from "babylonjs/Engines/engine";
  74120. import "babylonjs/Shaders/highlights.fragment";
  74121. /**
  74122. * Extracts highlights from the image
  74123. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74124. */
  74125. export class HighlightsPostProcess extends PostProcess {
  74126. /**
  74127. * Gets a string identifying the name of the class
  74128. * @returns "HighlightsPostProcess" string
  74129. */
  74130. getClassName(): string;
  74131. /**
  74132. * Extracts highlights from the image
  74133. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74134. * @param name The name of the effect.
  74135. * @param options The required width/height ratio to downsize to before computing the render pass.
  74136. * @param camera The camera to apply the render pass to.
  74137. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74138. * @param engine The engine which the post process will be applied. (default: current engine)
  74139. * @param reusable If the post process can be reused on the same frame. (default: false)
  74140. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74141. */
  74142. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74143. }
  74144. }
  74145. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74146. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74147. /**
  74148. * Contains all parameters needed for the prepass to perform
  74149. * motion blur
  74150. */
  74151. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74152. /**
  74153. * Is motion blur enabled
  74154. */
  74155. enabled: boolean;
  74156. /**
  74157. * Name of the configuration
  74158. */
  74159. name: string;
  74160. /**
  74161. * Textures that should be present in the MRT for this effect to work
  74162. */
  74163. readonly texturesRequired: number[];
  74164. }
  74165. }
  74166. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74167. import { Nullable } from "babylonjs/types";
  74168. import { Scene } from "babylonjs/scene";
  74169. import { ISceneComponent } from "babylonjs/sceneComponent";
  74170. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74171. module "babylonjs/scene" {
  74172. interface Scene {
  74173. /** @hidden (Backing field) */
  74174. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74175. /**
  74176. * Gets or Sets the current geometry buffer associated to the scene.
  74177. */
  74178. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74179. /**
  74180. * Enables a GeometryBufferRender and associates it with the scene
  74181. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74182. * @returns the GeometryBufferRenderer
  74183. */
  74184. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74185. /**
  74186. * Disables the GeometryBufferRender associated with the scene
  74187. */
  74188. disableGeometryBufferRenderer(): void;
  74189. }
  74190. }
  74191. /**
  74192. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74193. * in several rendering techniques.
  74194. */
  74195. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74196. /**
  74197. * The component name helpful to identify the component in the list of scene components.
  74198. */
  74199. readonly name: string;
  74200. /**
  74201. * The scene the component belongs to.
  74202. */
  74203. scene: Scene;
  74204. /**
  74205. * Creates a new instance of the component for the given scene
  74206. * @param scene Defines the scene to register the component in
  74207. */
  74208. constructor(scene: Scene);
  74209. /**
  74210. * Registers the component in a given scene
  74211. */
  74212. register(): void;
  74213. /**
  74214. * Rebuilds the elements related to this component in case of
  74215. * context lost for instance.
  74216. */
  74217. rebuild(): void;
  74218. /**
  74219. * Disposes the component and the associated ressources
  74220. */
  74221. dispose(): void;
  74222. private _gatherRenderTargets;
  74223. }
  74224. }
  74225. declare module "babylonjs/Shaders/motionBlur.fragment" {
  74226. /** @hidden */
  74227. export var motionBlurPixelShader: {
  74228. name: string;
  74229. shader: string;
  74230. };
  74231. }
  74232. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  74233. import { Nullable } from "babylonjs/types";
  74234. import { Camera } from "babylonjs/Cameras/camera";
  74235. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74237. import "babylonjs/Animations/animatable";
  74238. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74239. import "babylonjs/Shaders/motionBlur.fragment";
  74240. import { Engine } from "babylonjs/Engines/engine";
  74241. import { Scene } from "babylonjs/scene";
  74242. /**
  74243. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74244. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74245. * As an example, all you have to do is to create the post-process:
  74246. * var mb = new BABYLON.MotionBlurPostProcess(
  74247. * 'mb', // The name of the effect.
  74248. * scene, // The scene containing the objects to blur according to their velocity.
  74249. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74250. * camera // The camera to apply the render pass to.
  74251. * );
  74252. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74253. */
  74254. export class MotionBlurPostProcess extends PostProcess {
  74255. /**
  74256. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74257. */
  74258. motionStrength: number;
  74259. /**
  74260. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74261. */
  74262. get motionBlurSamples(): number;
  74263. /**
  74264. * Sets the number of iterations to be used for motion blur quality
  74265. */
  74266. set motionBlurSamples(samples: number);
  74267. private _motionBlurSamples;
  74268. private _forceGeometryBuffer;
  74269. private _geometryBufferRenderer;
  74270. private _prePassRenderer;
  74271. /**
  74272. * Gets a string identifying the name of the class
  74273. * @returns "MotionBlurPostProcess" string
  74274. */
  74275. getClassName(): string;
  74276. /**
  74277. * Creates a new instance MotionBlurPostProcess
  74278. * @param name The name of the effect.
  74279. * @param scene The scene containing the objects to blur according to their velocity.
  74280. * @param options The required width/height ratio to downsize to before computing the render pass.
  74281. * @param camera The camera to apply the render pass to.
  74282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74283. * @param engine The engine which the post process will be applied. (default: current engine)
  74284. * @param reusable If the post process can be reused on the same frame. (default: false)
  74285. * @param textureType Type of textures used when performing the post process. (default: 0)
  74286. * @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)
  74287. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74288. */
  74289. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74290. /**
  74291. * Excludes the given skinned mesh from computing bones velocities.
  74292. * 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.
  74293. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74294. */
  74295. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74296. /**
  74297. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74298. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74299. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74300. */
  74301. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74302. /**
  74303. * Disposes the post process.
  74304. * @param camera The camera to dispose the post process on.
  74305. */
  74306. dispose(camera?: Camera): void;
  74307. /** @hidden */
  74308. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74309. }
  74310. }
  74311. declare module "babylonjs/Shaders/refraction.fragment" {
  74312. /** @hidden */
  74313. export var refractionPixelShader: {
  74314. name: string;
  74315. shader: string;
  74316. };
  74317. }
  74318. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  74319. import { Color3 } from "babylonjs/Maths/math.color";
  74320. import { Camera } from "babylonjs/Cameras/camera";
  74321. import { Texture } from "babylonjs/Materials/Textures/texture";
  74322. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74323. import { Engine } from "babylonjs/Engines/engine";
  74324. import "babylonjs/Shaders/refraction.fragment";
  74325. import { Scene } from "babylonjs/scene";
  74326. /**
  74327. * Post process which applies a refractin texture
  74328. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74329. */
  74330. export class RefractionPostProcess extends PostProcess {
  74331. private _refTexture;
  74332. private _ownRefractionTexture;
  74333. /** the base color of the refraction (used to taint the rendering) */
  74334. color: Color3;
  74335. /** simulated refraction depth */
  74336. depth: number;
  74337. /** the coefficient of the base color (0 to remove base color tainting) */
  74338. colorLevel: number;
  74339. /** Gets the url used to load the refraction texture */
  74340. refractionTextureUrl: string;
  74341. /**
  74342. * Gets or sets the refraction texture
  74343. * Please note that you are responsible for disposing the texture if you set it manually
  74344. */
  74345. get refractionTexture(): Texture;
  74346. set refractionTexture(value: Texture);
  74347. /**
  74348. * Gets a string identifying the name of the class
  74349. * @returns "RefractionPostProcess" string
  74350. */
  74351. getClassName(): string;
  74352. /**
  74353. * Initializes the RefractionPostProcess
  74354. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74355. * @param name The name of the effect.
  74356. * @param refractionTextureUrl Url of the refraction texture to use
  74357. * @param color the base color of the refraction (used to taint the rendering)
  74358. * @param depth simulated refraction depth
  74359. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74360. * @param camera The camera to apply the render pass to.
  74361. * @param options The required width/height ratio to downsize to before computing the render pass.
  74362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74363. * @param engine The engine which the post process will be applied. (default: current engine)
  74364. * @param reusable If the post process can be reused on the same frame. (default: false)
  74365. */
  74366. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74367. /**
  74368. * Disposes of the post process
  74369. * @param camera Camera to dispose post process on
  74370. */
  74371. dispose(camera: Camera): void;
  74372. /** @hidden */
  74373. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74374. }
  74375. }
  74376. declare module "babylonjs/Shaders/sharpen.fragment" {
  74377. /** @hidden */
  74378. export var sharpenPixelShader: {
  74379. name: string;
  74380. shader: string;
  74381. };
  74382. }
  74383. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74384. import { Nullable } from "babylonjs/types";
  74385. import { Camera } from "babylonjs/Cameras/camera";
  74386. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74387. import "babylonjs/Shaders/sharpen.fragment";
  74388. import { Engine } from "babylonjs/Engines/engine";
  74389. import { Scene } from "babylonjs/scene";
  74390. /**
  74391. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74392. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74393. */
  74394. export class SharpenPostProcess extends PostProcess {
  74395. /**
  74396. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74397. */
  74398. colorAmount: number;
  74399. /**
  74400. * How much sharpness should be applied (default: 0.3)
  74401. */
  74402. edgeAmount: number;
  74403. /**
  74404. * Gets a string identifying the name of the class
  74405. * @returns "SharpenPostProcess" string
  74406. */
  74407. getClassName(): string;
  74408. /**
  74409. * Creates a new instance ConvolutionPostProcess
  74410. * @param name The name of the effect.
  74411. * @param options The required width/height ratio to downsize to before computing the render pass.
  74412. * @param camera The camera to apply the render pass to.
  74413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74414. * @param engine The engine which the post process will be applied. (default: current engine)
  74415. * @param reusable If the post process can be reused on the same frame. (default: false)
  74416. * @param textureType Type of textures used when performing the post process. (default: 0)
  74417. * @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)
  74418. */
  74419. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74420. /** @hidden */
  74421. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74422. }
  74423. }
  74424. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74425. import { Nullable } from "babylonjs/types";
  74426. import { Camera } from "babylonjs/Cameras/camera";
  74427. import { Engine } from "babylonjs/Engines/engine";
  74428. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74429. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74430. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74431. /**
  74432. * PostProcessRenderPipeline
  74433. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74434. */
  74435. export class PostProcessRenderPipeline {
  74436. private engine;
  74437. private _renderEffects;
  74438. private _renderEffectsForIsolatedPass;
  74439. /**
  74440. * List of inspectable custom properties (used by the Inspector)
  74441. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74442. */
  74443. inspectableCustomProperties: IInspectable[];
  74444. /**
  74445. * @hidden
  74446. */
  74447. protected _cameras: Camera[];
  74448. /** @hidden */
  74449. _name: string;
  74450. /**
  74451. * Gets pipeline name
  74452. */
  74453. get name(): string;
  74454. /** Gets the list of attached cameras */
  74455. get cameras(): Camera[];
  74456. /**
  74457. * Initializes a PostProcessRenderPipeline
  74458. * @param engine engine to add the pipeline to
  74459. * @param name name of the pipeline
  74460. */
  74461. constructor(engine: Engine, name: string);
  74462. /**
  74463. * Gets the class name
  74464. * @returns "PostProcessRenderPipeline"
  74465. */
  74466. getClassName(): string;
  74467. /**
  74468. * If all the render effects in the pipeline are supported
  74469. */
  74470. get isSupported(): boolean;
  74471. /**
  74472. * Adds an effect to the pipeline
  74473. * @param renderEffect the effect to add
  74474. */
  74475. addEffect(renderEffect: PostProcessRenderEffect): void;
  74476. /** @hidden */
  74477. _rebuild(): void;
  74478. /** @hidden */
  74479. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74480. /** @hidden */
  74481. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74482. /** @hidden */
  74483. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74484. /** @hidden */
  74485. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74486. /** @hidden */
  74487. _attachCameras(cameras: Camera, unique: boolean): void;
  74488. /** @hidden */
  74489. _attachCameras(cameras: Camera[], unique: boolean): void;
  74490. /** @hidden */
  74491. _detachCameras(cameras: Camera): void;
  74492. /** @hidden */
  74493. _detachCameras(cameras: Nullable<Camera[]>): void;
  74494. /** @hidden */
  74495. _update(): void;
  74496. /** @hidden */
  74497. _reset(): void;
  74498. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74499. /**
  74500. * Sets the required values to the prepass renderer.
  74501. * @param prePassRenderer defines the prepass renderer to setup.
  74502. * @returns true if the pre pass is needed.
  74503. */
  74504. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74505. /**
  74506. * Disposes of the pipeline
  74507. */
  74508. dispose(): void;
  74509. }
  74510. }
  74511. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74512. import { Camera } from "babylonjs/Cameras/camera";
  74513. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74514. /**
  74515. * PostProcessRenderPipelineManager class
  74516. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74517. */
  74518. export class PostProcessRenderPipelineManager {
  74519. private _renderPipelines;
  74520. /**
  74521. * Initializes a PostProcessRenderPipelineManager
  74522. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74523. */
  74524. constructor();
  74525. /**
  74526. * Gets the list of supported render pipelines
  74527. */
  74528. get supportedPipelines(): PostProcessRenderPipeline[];
  74529. /**
  74530. * Adds a pipeline to the manager
  74531. * @param renderPipeline The pipeline to add
  74532. */
  74533. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74534. /**
  74535. * Attaches a camera to the pipeline
  74536. * @param renderPipelineName The name of the pipeline to attach to
  74537. * @param cameras the camera to attach
  74538. * @param unique if the camera can be attached multiple times to the pipeline
  74539. */
  74540. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74541. /**
  74542. * Detaches a camera from the pipeline
  74543. * @param renderPipelineName The name of the pipeline to detach from
  74544. * @param cameras the camera to detach
  74545. */
  74546. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74547. /**
  74548. * Enables an effect by name on a pipeline
  74549. * @param renderPipelineName the name of the pipeline to enable the effect in
  74550. * @param renderEffectName the name of the effect to enable
  74551. * @param cameras the cameras that the effect should be enabled on
  74552. */
  74553. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74554. /**
  74555. * Disables an effect by name on a pipeline
  74556. * @param renderPipelineName the name of the pipeline to disable the effect in
  74557. * @param renderEffectName the name of the effect to disable
  74558. * @param cameras the cameras that the effect should be disabled on
  74559. */
  74560. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74561. /**
  74562. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74563. */
  74564. update(): void;
  74565. /** @hidden */
  74566. _rebuild(): void;
  74567. /**
  74568. * Disposes of the manager and pipelines
  74569. */
  74570. dispose(): void;
  74571. }
  74572. }
  74573. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74574. import { ISceneComponent } from "babylonjs/sceneComponent";
  74575. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74576. import { Scene } from "babylonjs/scene";
  74577. module "babylonjs/scene" {
  74578. interface Scene {
  74579. /** @hidden (Backing field) */
  74580. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74581. /**
  74582. * Gets the postprocess render pipeline manager
  74583. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74584. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74585. */
  74586. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74587. }
  74588. }
  74589. /**
  74590. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74591. */
  74592. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74593. /**
  74594. * The component name helpfull to identify the component in the list of scene components.
  74595. */
  74596. readonly name: string;
  74597. /**
  74598. * The scene the component belongs to.
  74599. */
  74600. scene: Scene;
  74601. /**
  74602. * Creates a new instance of the component for the given scene
  74603. * @param scene Defines the scene to register the component in
  74604. */
  74605. constructor(scene: Scene);
  74606. /**
  74607. * Registers the component in a given scene
  74608. */
  74609. register(): void;
  74610. /**
  74611. * Rebuilds the elements related to this component in case of
  74612. * context lost for instance.
  74613. */
  74614. rebuild(): void;
  74615. /**
  74616. * Disposes the component and the associated ressources
  74617. */
  74618. dispose(): void;
  74619. private _gatherRenderTargets;
  74620. }
  74621. }
  74622. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74623. import { Nullable } from "babylonjs/types";
  74624. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74625. import { Camera } from "babylonjs/Cameras/camera";
  74626. import { IDisposable } from "babylonjs/scene";
  74627. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74628. import { Scene } from "babylonjs/scene";
  74629. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74630. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74631. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74632. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74633. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74634. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74635. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74636. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74637. import { Animation } from "babylonjs/Animations/animation";
  74638. /**
  74639. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74640. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74641. */
  74642. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74643. private _scene;
  74644. private _camerasToBeAttached;
  74645. /**
  74646. * ID of the sharpen post process,
  74647. */
  74648. private readonly SharpenPostProcessId;
  74649. /**
  74650. * @ignore
  74651. * ID of the image processing post process;
  74652. */
  74653. readonly ImageProcessingPostProcessId: string;
  74654. /**
  74655. * @ignore
  74656. * ID of the Fast Approximate Anti-Aliasing post process;
  74657. */
  74658. readonly FxaaPostProcessId: string;
  74659. /**
  74660. * ID of the chromatic aberration post process,
  74661. */
  74662. private readonly ChromaticAberrationPostProcessId;
  74663. /**
  74664. * ID of the grain post process
  74665. */
  74666. private readonly GrainPostProcessId;
  74667. /**
  74668. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74669. */
  74670. sharpen: SharpenPostProcess;
  74671. private _sharpenEffect;
  74672. private bloom;
  74673. /**
  74674. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74675. */
  74676. depthOfField: DepthOfFieldEffect;
  74677. /**
  74678. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74679. */
  74680. fxaa: FxaaPostProcess;
  74681. /**
  74682. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74683. */
  74684. imageProcessing: ImageProcessingPostProcess;
  74685. /**
  74686. * Chromatic aberration post process which will shift rgb colors in the image
  74687. */
  74688. chromaticAberration: ChromaticAberrationPostProcess;
  74689. private _chromaticAberrationEffect;
  74690. /**
  74691. * Grain post process which add noise to the image
  74692. */
  74693. grain: GrainPostProcess;
  74694. private _grainEffect;
  74695. /**
  74696. * Glow post process which adds a glow to emissive areas of the image
  74697. */
  74698. private _glowLayer;
  74699. /**
  74700. * Animations which can be used to tweak settings over a period of time
  74701. */
  74702. animations: Animation[];
  74703. private _imageProcessingConfigurationObserver;
  74704. private _sharpenEnabled;
  74705. private _bloomEnabled;
  74706. private _depthOfFieldEnabled;
  74707. private _depthOfFieldBlurLevel;
  74708. private _fxaaEnabled;
  74709. private _imageProcessingEnabled;
  74710. private _defaultPipelineTextureType;
  74711. private _bloomScale;
  74712. private _chromaticAberrationEnabled;
  74713. private _grainEnabled;
  74714. private _buildAllowed;
  74715. /**
  74716. * Gets active scene
  74717. */
  74718. get scene(): Scene;
  74719. /**
  74720. * Enable or disable the sharpen process from the pipeline
  74721. */
  74722. set sharpenEnabled(enabled: boolean);
  74723. get sharpenEnabled(): boolean;
  74724. private _resizeObserver;
  74725. private _hardwareScaleLevel;
  74726. private _bloomKernel;
  74727. /**
  74728. * Specifies the size of the bloom blur kernel, relative to the final output size
  74729. */
  74730. get bloomKernel(): number;
  74731. set bloomKernel(value: number);
  74732. /**
  74733. * Specifies the weight of the bloom in the final rendering
  74734. */
  74735. private _bloomWeight;
  74736. /**
  74737. * Specifies the luma threshold for the area that will be blurred by the bloom
  74738. */
  74739. private _bloomThreshold;
  74740. private _hdr;
  74741. /**
  74742. * The strength of the bloom.
  74743. */
  74744. set bloomWeight(value: number);
  74745. get bloomWeight(): number;
  74746. /**
  74747. * The strength of the bloom.
  74748. */
  74749. set bloomThreshold(value: number);
  74750. get bloomThreshold(): number;
  74751. /**
  74752. * The scale of the bloom, lower value will provide better performance.
  74753. */
  74754. set bloomScale(value: number);
  74755. get bloomScale(): number;
  74756. /**
  74757. * Enable or disable the bloom from the pipeline
  74758. */
  74759. set bloomEnabled(enabled: boolean);
  74760. get bloomEnabled(): boolean;
  74761. private _rebuildBloom;
  74762. /**
  74763. * If the depth of field is enabled.
  74764. */
  74765. get depthOfFieldEnabled(): boolean;
  74766. set depthOfFieldEnabled(enabled: boolean);
  74767. /**
  74768. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74769. */
  74770. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74771. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74772. /**
  74773. * If the anti aliasing is enabled.
  74774. */
  74775. set fxaaEnabled(enabled: boolean);
  74776. get fxaaEnabled(): boolean;
  74777. private _samples;
  74778. /**
  74779. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74780. */
  74781. set samples(sampleCount: number);
  74782. get samples(): number;
  74783. /**
  74784. * If image processing is enabled.
  74785. */
  74786. set imageProcessingEnabled(enabled: boolean);
  74787. get imageProcessingEnabled(): boolean;
  74788. /**
  74789. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74790. */
  74791. set glowLayerEnabled(enabled: boolean);
  74792. get glowLayerEnabled(): boolean;
  74793. /**
  74794. * Gets the glow layer (or null if not defined)
  74795. */
  74796. get glowLayer(): Nullable<GlowLayer>;
  74797. /**
  74798. * Enable or disable the chromaticAberration process from the pipeline
  74799. */
  74800. set chromaticAberrationEnabled(enabled: boolean);
  74801. get chromaticAberrationEnabled(): boolean;
  74802. /**
  74803. * Enable or disable the grain process from the pipeline
  74804. */
  74805. set grainEnabled(enabled: boolean);
  74806. get grainEnabled(): boolean;
  74807. /**
  74808. * @constructor
  74809. * @param name - The rendering pipeline name (default: "")
  74810. * @param hdr - If high dynamic range textures should be used (default: true)
  74811. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74812. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74813. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74814. */
  74815. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74816. /**
  74817. * Get the class name
  74818. * @returns "DefaultRenderingPipeline"
  74819. */
  74820. getClassName(): string;
  74821. /**
  74822. * Force the compilation of the entire pipeline.
  74823. */
  74824. prepare(): void;
  74825. private _hasCleared;
  74826. private _prevPostProcess;
  74827. private _prevPrevPostProcess;
  74828. private _setAutoClearAndTextureSharing;
  74829. private _depthOfFieldSceneObserver;
  74830. private _buildPipeline;
  74831. private _disposePostProcesses;
  74832. /**
  74833. * Adds a camera to the pipeline
  74834. * @param camera the camera to be added
  74835. */
  74836. addCamera(camera: Camera): void;
  74837. /**
  74838. * Removes a camera from the pipeline
  74839. * @param camera the camera to remove
  74840. */
  74841. removeCamera(camera: Camera): void;
  74842. /**
  74843. * Dispose of the pipeline and stop all post processes
  74844. */
  74845. dispose(): void;
  74846. /**
  74847. * Serialize the rendering pipeline (Used when exporting)
  74848. * @returns the serialized object
  74849. */
  74850. serialize(): any;
  74851. /**
  74852. * Parse the serialized pipeline
  74853. * @param source Source pipeline.
  74854. * @param scene The scene to load the pipeline to.
  74855. * @param rootUrl The URL of the serialized pipeline.
  74856. * @returns An instantiated pipeline from the serialized object.
  74857. */
  74858. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74859. }
  74860. }
  74861. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74862. /** @hidden */
  74863. export var lensHighlightsPixelShader: {
  74864. name: string;
  74865. shader: string;
  74866. };
  74867. }
  74868. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74869. /** @hidden */
  74870. export var depthOfFieldPixelShader: {
  74871. name: string;
  74872. shader: string;
  74873. };
  74874. }
  74875. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74876. import { Camera } from "babylonjs/Cameras/camera";
  74877. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74878. import { Scene } from "babylonjs/scene";
  74879. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74880. import "babylonjs/Shaders/chromaticAberration.fragment";
  74881. import "babylonjs/Shaders/lensHighlights.fragment";
  74882. import "babylonjs/Shaders/depthOfField.fragment";
  74883. /**
  74884. * BABYLON.JS Chromatic Aberration GLSL Shader
  74885. * Author: Olivier Guyot
  74886. * Separates very slightly R, G and B colors on the edges of the screen
  74887. * Inspired by Francois Tarlier & Martins Upitis
  74888. */
  74889. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74890. /**
  74891. * @ignore
  74892. * The chromatic aberration PostProcess id in the pipeline
  74893. */
  74894. LensChromaticAberrationEffect: string;
  74895. /**
  74896. * @ignore
  74897. * The highlights enhancing PostProcess id in the pipeline
  74898. */
  74899. HighlightsEnhancingEffect: string;
  74900. /**
  74901. * @ignore
  74902. * The depth-of-field PostProcess id in the pipeline
  74903. */
  74904. LensDepthOfFieldEffect: string;
  74905. private _scene;
  74906. private _depthTexture;
  74907. private _grainTexture;
  74908. private _chromaticAberrationPostProcess;
  74909. private _highlightsPostProcess;
  74910. private _depthOfFieldPostProcess;
  74911. private _edgeBlur;
  74912. private _grainAmount;
  74913. private _chromaticAberration;
  74914. private _distortion;
  74915. private _highlightsGain;
  74916. private _highlightsThreshold;
  74917. private _dofDistance;
  74918. private _dofAperture;
  74919. private _dofDarken;
  74920. private _dofPentagon;
  74921. private _blurNoise;
  74922. /**
  74923. * @constructor
  74924. *
  74925. * Effect parameters are as follow:
  74926. * {
  74927. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74928. * edge_blur: number; // from 0 to x (1 for realism)
  74929. * distortion: number; // from 0 to x (1 for realism)
  74930. * grain_amount: number; // from 0 to 1
  74931. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74932. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74933. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74934. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74935. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74936. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74937. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74938. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74939. * }
  74940. * Note: if an effect parameter is unset, effect is disabled
  74941. *
  74942. * @param name The rendering pipeline name
  74943. * @param parameters - An object containing all parameters (see above)
  74944. * @param scene The scene linked to this pipeline
  74945. * @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)
  74946. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74947. */
  74948. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74949. /**
  74950. * Get the class name
  74951. * @returns "LensRenderingPipeline"
  74952. */
  74953. getClassName(): string;
  74954. /**
  74955. * Gets associated scene
  74956. */
  74957. get scene(): Scene;
  74958. /**
  74959. * Gets or sets the edge blur
  74960. */
  74961. get edgeBlur(): number;
  74962. set edgeBlur(value: number);
  74963. /**
  74964. * Gets or sets the grain amount
  74965. */
  74966. get grainAmount(): number;
  74967. set grainAmount(value: number);
  74968. /**
  74969. * Gets or sets the chromatic aberration amount
  74970. */
  74971. get chromaticAberration(): number;
  74972. set chromaticAberration(value: number);
  74973. /**
  74974. * Gets or sets the depth of field aperture
  74975. */
  74976. get dofAperture(): number;
  74977. set dofAperture(value: number);
  74978. /**
  74979. * Gets or sets the edge distortion
  74980. */
  74981. get edgeDistortion(): number;
  74982. set edgeDistortion(value: number);
  74983. /**
  74984. * Gets or sets the depth of field distortion
  74985. */
  74986. get dofDistortion(): number;
  74987. set dofDistortion(value: number);
  74988. /**
  74989. * Gets or sets the darken out of focus amount
  74990. */
  74991. get darkenOutOfFocus(): number;
  74992. set darkenOutOfFocus(value: number);
  74993. /**
  74994. * Gets or sets a boolean indicating if blur noise is enabled
  74995. */
  74996. get blurNoise(): boolean;
  74997. set blurNoise(value: boolean);
  74998. /**
  74999. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75000. */
  75001. get pentagonBokeh(): boolean;
  75002. set pentagonBokeh(value: boolean);
  75003. /**
  75004. * Gets or sets the highlight grain amount
  75005. */
  75006. get highlightsGain(): number;
  75007. set highlightsGain(value: number);
  75008. /**
  75009. * Gets or sets the highlight threshold
  75010. */
  75011. get highlightsThreshold(): number;
  75012. set highlightsThreshold(value: number);
  75013. /**
  75014. * Sets the amount of blur at the edges
  75015. * @param amount blur amount
  75016. */
  75017. setEdgeBlur(amount: number): void;
  75018. /**
  75019. * Sets edge blur to 0
  75020. */
  75021. disableEdgeBlur(): void;
  75022. /**
  75023. * Sets the amout of grain
  75024. * @param amount Amount of grain
  75025. */
  75026. setGrainAmount(amount: number): void;
  75027. /**
  75028. * Set grain amount to 0
  75029. */
  75030. disableGrain(): void;
  75031. /**
  75032. * Sets the chromatic aberration amount
  75033. * @param amount amount of chromatic aberration
  75034. */
  75035. setChromaticAberration(amount: number): void;
  75036. /**
  75037. * Sets chromatic aberration amount to 0
  75038. */
  75039. disableChromaticAberration(): void;
  75040. /**
  75041. * Sets the EdgeDistortion amount
  75042. * @param amount amount of EdgeDistortion
  75043. */
  75044. setEdgeDistortion(amount: number): void;
  75045. /**
  75046. * Sets edge distortion to 0
  75047. */
  75048. disableEdgeDistortion(): void;
  75049. /**
  75050. * Sets the FocusDistance amount
  75051. * @param amount amount of FocusDistance
  75052. */
  75053. setFocusDistance(amount: number): void;
  75054. /**
  75055. * Disables depth of field
  75056. */
  75057. disableDepthOfField(): void;
  75058. /**
  75059. * Sets the Aperture amount
  75060. * @param amount amount of Aperture
  75061. */
  75062. setAperture(amount: number): void;
  75063. /**
  75064. * Sets the DarkenOutOfFocus amount
  75065. * @param amount amount of DarkenOutOfFocus
  75066. */
  75067. setDarkenOutOfFocus(amount: number): void;
  75068. private _pentagonBokehIsEnabled;
  75069. /**
  75070. * Creates a pentagon bokeh effect
  75071. */
  75072. enablePentagonBokeh(): void;
  75073. /**
  75074. * Disables the pentagon bokeh effect
  75075. */
  75076. disablePentagonBokeh(): void;
  75077. /**
  75078. * Enables noise blur
  75079. */
  75080. enableNoiseBlur(): void;
  75081. /**
  75082. * Disables noise blur
  75083. */
  75084. disableNoiseBlur(): void;
  75085. /**
  75086. * Sets the HighlightsGain amount
  75087. * @param amount amount of HighlightsGain
  75088. */
  75089. setHighlightsGain(amount: number): void;
  75090. /**
  75091. * Sets the HighlightsThreshold amount
  75092. * @param amount amount of HighlightsThreshold
  75093. */
  75094. setHighlightsThreshold(amount: number): void;
  75095. /**
  75096. * Disables highlights
  75097. */
  75098. disableHighlights(): void;
  75099. /**
  75100. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75101. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75102. */
  75103. dispose(disableDepthRender?: boolean): void;
  75104. private _createChromaticAberrationPostProcess;
  75105. private _createHighlightsPostProcess;
  75106. private _createDepthOfFieldPostProcess;
  75107. private _createGrainTexture;
  75108. }
  75109. }
  75110. declare module "babylonjs/Rendering/ssao2Configuration" {
  75111. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75112. /**
  75113. * Contains all parameters needed for the prepass to perform
  75114. * screen space subsurface scattering
  75115. */
  75116. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75117. /**
  75118. * Is subsurface enabled
  75119. */
  75120. enabled: boolean;
  75121. /**
  75122. * Name of the configuration
  75123. */
  75124. name: string;
  75125. /**
  75126. * Textures that should be present in the MRT for this effect to work
  75127. */
  75128. readonly texturesRequired: number[];
  75129. }
  75130. }
  75131. declare module "babylonjs/Shaders/ssao2.fragment" {
  75132. /** @hidden */
  75133. export var ssao2PixelShader: {
  75134. name: string;
  75135. shader: string;
  75136. };
  75137. }
  75138. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75139. /** @hidden */
  75140. export var ssaoCombinePixelShader: {
  75141. name: string;
  75142. shader: string;
  75143. };
  75144. }
  75145. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75146. import { Camera } from "babylonjs/Cameras/camera";
  75147. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75148. import { Scene } from "babylonjs/scene";
  75149. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75150. import "babylonjs/Shaders/ssao2.fragment";
  75151. import "babylonjs/Shaders/ssaoCombine.fragment";
  75152. /**
  75153. * Render pipeline to produce ssao effect
  75154. */
  75155. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75156. /**
  75157. * @ignore
  75158. * The PassPostProcess id in the pipeline that contains the original scene color
  75159. */
  75160. SSAOOriginalSceneColorEffect: string;
  75161. /**
  75162. * @ignore
  75163. * The SSAO PostProcess id in the pipeline
  75164. */
  75165. SSAORenderEffect: string;
  75166. /**
  75167. * @ignore
  75168. * The horizontal blur PostProcess id in the pipeline
  75169. */
  75170. SSAOBlurHRenderEffect: string;
  75171. /**
  75172. * @ignore
  75173. * The vertical blur PostProcess id in the pipeline
  75174. */
  75175. SSAOBlurVRenderEffect: string;
  75176. /**
  75177. * @ignore
  75178. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75179. */
  75180. SSAOCombineRenderEffect: string;
  75181. /**
  75182. * The output strength of the SSAO post-process. Default value is 1.0.
  75183. */
  75184. totalStrength: number;
  75185. /**
  75186. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75187. */
  75188. maxZ: number;
  75189. /**
  75190. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75191. */
  75192. minZAspect: number;
  75193. private _samples;
  75194. /**
  75195. * Number of samples used for the SSAO calculations. Default value is 8
  75196. */
  75197. set samples(n: number);
  75198. get samples(): number;
  75199. private _textureSamples;
  75200. /**
  75201. * Number of samples to use for antialiasing
  75202. */
  75203. set textureSamples(n: number);
  75204. get textureSamples(): number;
  75205. /**
  75206. * Force rendering the geometry through geometry buffer
  75207. */
  75208. private _forceGeometryBuffer;
  75209. /**
  75210. * Ratio object used for SSAO ratio and blur ratio
  75211. */
  75212. private _ratio;
  75213. /**
  75214. * Dynamically generated sphere sampler.
  75215. */
  75216. private _sampleSphere;
  75217. /**
  75218. * Blur filter offsets
  75219. */
  75220. private _samplerOffsets;
  75221. private _expensiveBlur;
  75222. /**
  75223. * If bilateral blur should be used
  75224. */
  75225. set expensiveBlur(b: boolean);
  75226. get expensiveBlur(): boolean;
  75227. /**
  75228. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75229. */
  75230. radius: number;
  75231. /**
  75232. * The base color of the SSAO post-process
  75233. * The final result is "base + ssao" between [0, 1]
  75234. */
  75235. base: number;
  75236. /**
  75237. * Support test.
  75238. */
  75239. static get IsSupported(): boolean;
  75240. private _scene;
  75241. private _randomTexture;
  75242. private _originalColorPostProcess;
  75243. private _ssaoPostProcess;
  75244. private _blurHPostProcess;
  75245. private _blurVPostProcess;
  75246. private _ssaoCombinePostProcess;
  75247. private _prePassRenderer;
  75248. /**
  75249. * Gets active scene
  75250. */
  75251. get scene(): Scene;
  75252. /**
  75253. * @constructor
  75254. * @param name The rendering pipeline name
  75255. * @param scene The scene linked to this pipeline
  75256. * @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 }
  75257. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75258. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75259. */
  75260. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75261. /**
  75262. * Get the class name
  75263. * @returns "SSAO2RenderingPipeline"
  75264. */
  75265. getClassName(): string;
  75266. /**
  75267. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75268. */
  75269. dispose(disableGeometryBufferRenderer?: boolean): void;
  75270. private _createBlurPostProcess;
  75271. /** @hidden */
  75272. _rebuild(): void;
  75273. private _bits;
  75274. private _radicalInverse_VdC;
  75275. private _hammersley;
  75276. private _hemisphereSample_uniform;
  75277. private _generateHemisphere;
  75278. private _getDefinesForSSAO;
  75279. private _createSSAOPostProcess;
  75280. private _createSSAOCombinePostProcess;
  75281. private _createRandomTexture;
  75282. /**
  75283. * Serialize the rendering pipeline (Used when exporting)
  75284. * @returns the serialized object
  75285. */
  75286. serialize(): any;
  75287. /**
  75288. * Parse the serialized pipeline
  75289. * @param source Source pipeline.
  75290. * @param scene The scene to load the pipeline to.
  75291. * @param rootUrl The URL of the serialized pipeline.
  75292. * @returns An instantiated pipeline from the serialized object.
  75293. */
  75294. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75295. }
  75296. }
  75297. declare module "babylonjs/Shaders/ssao.fragment" {
  75298. /** @hidden */
  75299. export var ssaoPixelShader: {
  75300. name: string;
  75301. shader: string;
  75302. };
  75303. }
  75304. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  75305. import { Camera } from "babylonjs/Cameras/camera";
  75306. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75307. import { Scene } from "babylonjs/scene";
  75308. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75309. import "babylonjs/Shaders/ssao.fragment";
  75310. import "babylonjs/Shaders/ssaoCombine.fragment";
  75311. /**
  75312. * Render pipeline to produce ssao effect
  75313. */
  75314. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75315. /**
  75316. * @ignore
  75317. * The PassPostProcess id in the pipeline that contains the original scene color
  75318. */
  75319. SSAOOriginalSceneColorEffect: string;
  75320. /**
  75321. * @ignore
  75322. * The SSAO PostProcess id in the pipeline
  75323. */
  75324. SSAORenderEffect: string;
  75325. /**
  75326. * @ignore
  75327. * The horizontal blur PostProcess id in the pipeline
  75328. */
  75329. SSAOBlurHRenderEffect: string;
  75330. /**
  75331. * @ignore
  75332. * The vertical blur PostProcess id in the pipeline
  75333. */
  75334. SSAOBlurVRenderEffect: string;
  75335. /**
  75336. * @ignore
  75337. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75338. */
  75339. SSAOCombineRenderEffect: string;
  75340. /**
  75341. * The output strength of the SSAO post-process. Default value is 1.0.
  75342. */
  75343. totalStrength: number;
  75344. /**
  75345. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75346. */
  75347. radius: number;
  75348. /**
  75349. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75350. * Must not be equal to fallOff and superior to fallOff.
  75351. * Default value is 0.0075
  75352. */
  75353. area: number;
  75354. /**
  75355. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75356. * Must not be equal to area and inferior to area.
  75357. * Default value is 0.000001
  75358. */
  75359. fallOff: number;
  75360. /**
  75361. * The base color of the SSAO post-process
  75362. * The final result is "base + ssao" between [0, 1]
  75363. */
  75364. base: number;
  75365. private _scene;
  75366. private _depthTexture;
  75367. private _randomTexture;
  75368. private _originalColorPostProcess;
  75369. private _ssaoPostProcess;
  75370. private _blurHPostProcess;
  75371. private _blurVPostProcess;
  75372. private _ssaoCombinePostProcess;
  75373. private _firstUpdate;
  75374. /**
  75375. * Gets active scene
  75376. */
  75377. get scene(): Scene;
  75378. /**
  75379. * @constructor
  75380. * @param name - The rendering pipeline name
  75381. * @param scene - The scene linked to this pipeline
  75382. * @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 }
  75383. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75384. */
  75385. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75386. /**
  75387. * Get the class name
  75388. * @returns "SSAORenderingPipeline"
  75389. */
  75390. getClassName(): string;
  75391. /**
  75392. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75393. */
  75394. dispose(disableDepthRender?: boolean): void;
  75395. private _createBlurPostProcess;
  75396. /** @hidden */
  75397. _rebuild(): void;
  75398. private _createSSAOPostProcess;
  75399. private _createSSAOCombinePostProcess;
  75400. private _createRandomTexture;
  75401. }
  75402. }
  75403. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  75404. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75405. /**
  75406. * Contains all parameters needed for the prepass to perform
  75407. * screen space reflections
  75408. */
  75409. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75410. /**
  75411. * Is ssr enabled
  75412. */
  75413. enabled: boolean;
  75414. /**
  75415. * Name of the configuration
  75416. */
  75417. name: string;
  75418. /**
  75419. * Textures that should be present in the MRT for this effect to work
  75420. */
  75421. readonly texturesRequired: number[];
  75422. }
  75423. }
  75424. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75425. /** @hidden */
  75426. export var screenSpaceReflectionPixelShader: {
  75427. name: string;
  75428. shader: string;
  75429. };
  75430. }
  75431. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75432. import { Nullable } from "babylonjs/types";
  75433. import { Camera } from "babylonjs/Cameras/camera";
  75434. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75435. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75436. import { Engine } from "babylonjs/Engines/engine";
  75437. import { Scene } from "babylonjs/scene";
  75438. /**
  75439. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75440. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75441. */
  75442. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75443. /**
  75444. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75445. */
  75446. threshold: number;
  75447. /**
  75448. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75449. */
  75450. strength: number;
  75451. /**
  75452. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75453. */
  75454. reflectionSpecularFalloffExponent: number;
  75455. /**
  75456. * 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]
  75457. */
  75458. step: number;
  75459. /**
  75460. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75461. */
  75462. roughnessFactor: number;
  75463. private _forceGeometryBuffer;
  75464. private _geometryBufferRenderer;
  75465. private _prePassRenderer;
  75466. private _enableSmoothReflections;
  75467. private _reflectionSamples;
  75468. private _smoothSteps;
  75469. /**
  75470. * Gets a string identifying the name of the class
  75471. * @returns "ScreenSpaceReflectionPostProcess" string
  75472. */
  75473. getClassName(): string;
  75474. /**
  75475. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75476. * @param name The name of the effect.
  75477. * @param scene The scene containing the objects to calculate reflections.
  75478. * @param options The required width/height ratio to downsize to before computing the render pass.
  75479. * @param camera The camera to apply the render pass to.
  75480. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75481. * @param engine The engine which the post process will be applied. (default: current engine)
  75482. * @param reusable If the post process can be reused on the same frame. (default: false)
  75483. * @param textureType Type of textures used when performing the post process. (default: 0)
  75484. * @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)
  75485. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75486. */
  75487. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75488. /**
  75489. * Gets wether or not smoothing reflections is enabled.
  75490. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75491. */
  75492. get enableSmoothReflections(): boolean;
  75493. /**
  75494. * Sets wether or not smoothing reflections is enabled.
  75495. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75496. */
  75497. set enableSmoothReflections(enabled: boolean);
  75498. /**
  75499. * Gets 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. get reflectionSamples(): number;
  75503. /**
  75504. * Sets the number of samples taken while computing reflections. More samples count is high,
  75505. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75506. */
  75507. set reflectionSamples(samples: number);
  75508. /**
  75509. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75510. * more the post-process will require GPU power and can generate a drop in FPS.
  75511. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75512. */
  75513. get smoothSteps(): number;
  75514. set smoothSteps(steps: number);
  75515. private _updateEffectDefines;
  75516. /** @hidden */
  75517. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75518. }
  75519. }
  75520. declare module "babylonjs/Shaders/standard.fragment" {
  75521. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75522. /** @hidden */
  75523. export var standardPixelShader: {
  75524. name: string;
  75525. shader: string;
  75526. };
  75527. }
  75528. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75529. import { Nullable } from "babylonjs/types";
  75530. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75531. import { Camera } from "babylonjs/Cameras/camera";
  75532. import { Texture } from "babylonjs/Materials/Textures/texture";
  75533. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75534. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75535. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75536. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75537. import { IDisposable } from "babylonjs/scene";
  75538. import { SpotLight } from "babylonjs/Lights/spotLight";
  75539. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75540. import { Scene } from "babylonjs/scene";
  75541. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75542. import { Animation } from "babylonjs/Animations/animation";
  75543. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75544. import "babylonjs/Shaders/standard.fragment";
  75545. /**
  75546. * Standard rendering pipeline
  75547. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75548. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75549. */
  75550. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75551. /**
  75552. * Public members
  75553. */
  75554. /**
  75555. * Post-process which contains the original scene color before the pipeline applies all the effects
  75556. */
  75557. originalPostProcess: Nullable<PostProcess>;
  75558. /**
  75559. * Post-process used to down scale an image x4
  75560. */
  75561. downSampleX4PostProcess: Nullable<PostProcess>;
  75562. /**
  75563. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75564. */
  75565. brightPassPostProcess: Nullable<PostProcess>;
  75566. /**
  75567. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75568. */
  75569. blurHPostProcesses: PostProcess[];
  75570. /**
  75571. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75572. */
  75573. blurVPostProcesses: PostProcess[];
  75574. /**
  75575. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75576. */
  75577. textureAdderPostProcess: Nullable<PostProcess>;
  75578. /**
  75579. * Post-process used to create volumetric lighting effect
  75580. */
  75581. volumetricLightPostProcess: Nullable<PostProcess>;
  75582. /**
  75583. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75584. */
  75585. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75586. /**
  75587. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75588. */
  75589. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75590. /**
  75591. * Post-process used to merge the volumetric light effect and the real scene color
  75592. */
  75593. volumetricLightMergePostProces: Nullable<PostProcess>;
  75594. /**
  75595. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75596. */
  75597. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75598. /**
  75599. * Base post-process used to calculate the average luminance of the final image for HDR
  75600. */
  75601. luminancePostProcess: Nullable<PostProcess>;
  75602. /**
  75603. * Post-processes used to create down sample post-processes in order to get
  75604. * the average luminance of the final image for HDR
  75605. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75606. */
  75607. luminanceDownSamplePostProcesses: PostProcess[];
  75608. /**
  75609. * Post-process used to create a HDR effect (light adaptation)
  75610. */
  75611. hdrPostProcess: Nullable<PostProcess>;
  75612. /**
  75613. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75614. */
  75615. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75616. /**
  75617. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75618. */
  75619. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75620. /**
  75621. * Post-process used to merge the final HDR post-process and the real scene color
  75622. */
  75623. hdrFinalPostProcess: Nullable<PostProcess>;
  75624. /**
  75625. * Post-process used to create a lens flare effect
  75626. */
  75627. lensFlarePostProcess: Nullable<PostProcess>;
  75628. /**
  75629. * Post-process that merges the result of the lens flare post-process and the real scene color
  75630. */
  75631. lensFlareComposePostProcess: Nullable<PostProcess>;
  75632. /**
  75633. * Post-process used to create a motion blur effect
  75634. */
  75635. motionBlurPostProcess: Nullable<PostProcess>;
  75636. /**
  75637. * Post-process used to create a depth of field effect
  75638. */
  75639. depthOfFieldPostProcess: Nullable<PostProcess>;
  75640. /**
  75641. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75642. */
  75643. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75644. /**
  75645. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75646. */
  75647. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75648. /**
  75649. * Represents the brightness threshold in order to configure the illuminated surfaces
  75650. */
  75651. brightThreshold: number;
  75652. /**
  75653. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75654. */
  75655. blurWidth: number;
  75656. /**
  75657. * Sets if the blur for highlighted surfaces must be only horizontal
  75658. */
  75659. horizontalBlur: boolean;
  75660. /**
  75661. * Gets the overall exposure used by the pipeline
  75662. */
  75663. get exposure(): number;
  75664. /**
  75665. * Sets the overall exposure used by the pipeline
  75666. */
  75667. set exposure(value: number);
  75668. /**
  75669. * Texture used typically to simulate "dirty" on camera lens
  75670. */
  75671. lensTexture: Nullable<Texture>;
  75672. /**
  75673. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75674. */
  75675. volumetricLightCoefficient: number;
  75676. /**
  75677. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75678. */
  75679. volumetricLightPower: number;
  75680. /**
  75681. * Used the set the blur intensity to smooth the volumetric lights
  75682. */
  75683. volumetricLightBlurScale: number;
  75684. /**
  75685. * Light (spot or directional) used to generate the volumetric lights rays
  75686. * The source light must have a shadow generate so the pipeline can get its
  75687. * depth map
  75688. */
  75689. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75690. /**
  75691. * For eye adaptation, represents the minimum luminance the eye can see
  75692. */
  75693. hdrMinimumLuminance: number;
  75694. /**
  75695. * For eye adaptation, represents the decrease luminance speed
  75696. */
  75697. hdrDecreaseRate: number;
  75698. /**
  75699. * For eye adaptation, represents the increase luminance speed
  75700. */
  75701. hdrIncreaseRate: number;
  75702. /**
  75703. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75704. */
  75705. get hdrAutoExposure(): boolean;
  75706. /**
  75707. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75708. */
  75709. set hdrAutoExposure(value: boolean);
  75710. /**
  75711. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75712. */
  75713. lensColorTexture: Nullable<Texture>;
  75714. /**
  75715. * The overall strengh for the lens flare effect
  75716. */
  75717. lensFlareStrength: number;
  75718. /**
  75719. * Dispersion coefficient for lens flare ghosts
  75720. */
  75721. lensFlareGhostDispersal: number;
  75722. /**
  75723. * Main lens flare halo width
  75724. */
  75725. lensFlareHaloWidth: number;
  75726. /**
  75727. * Based on the lens distortion effect, defines how much the lens flare result
  75728. * is distorted
  75729. */
  75730. lensFlareDistortionStrength: number;
  75731. /**
  75732. * Configures the blur intensity used for for lens flare (halo)
  75733. */
  75734. lensFlareBlurWidth: number;
  75735. /**
  75736. * Lens star texture must be used to simulate rays on the flares and is available
  75737. * in the documentation
  75738. */
  75739. lensStarTexture: Nullable<Texture>;
  75740. /**
  75741. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75742. * flare effect by taking account of the dirt texture
  75743. */
  75744. lensFlareDirtTexture: Nullable<Texture>;
  75745. /**
  75746. * Represents the focal length for the depth of field effect
  75747. */
  75748. depthOfFieldDistance: number;
  75749. /**
  75750. * Represents the blur intensity for the blurred part of the depth of field effect
  75751. */
  75752. depthOfFieldBlurWidth: number;
  75753. /**
  75754. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75755. */
  75756. get motionStrength(): number;
  75757. /**
  75758. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75759. */
  75760. set motionStrength(strength: number);
  75761. /**
  75762. * Gets wether or not the motion blur post-process is object based or screen based.
  75763. */
  75764. get objectBasedMotionBlur(): boolean;
  75765. /**
  75766. * Sets wether or not the motion blur post-process should be object based or screen based
  75767. */
  75768. set objectBasedMotionBlur(value: boolean);
  75769. /**
  75770. * List of animations for the pipeline (IAnimatable implementation)
  75771. */
  75772. animations: Animation[];
  75773. /**
  75774. * Private members
  75775. */
  75776. private _scene;
  75777. private _currentDepthOfFieldSource;
  75778. private _basePostProcess;
  75779. private _fixedExposure;
  75780. private _currentExposure;
  75781. private _hdrAutoExposure;
  75782. private _hdrCurrentLuminance;
  75783. private _motionStrength;
  75784. private _isObjectBasedMotionBlur;
  75785. private _floatTextureType;
  75786. private _camerasToBeAttached;
  75787. private _ratio;
  75788. private _bloomEnabled;
  75789. private _depthOfFieldEnabled;
  75790. private _vlsEnabled;
  75791. private _lensFlareEnabled;
  75792. private _hdrEnabled;
  75793. private _motionBlurEnabled;
  75794. private _fxaaEnabled;
  75795. private _screenSpaceReflectionsEnabled;
  75796. private _motionBlurSamples;
  75797. private _volumetricLightStepsCount;
  75798. private _samples;
  75799. /**
  75800. * @ignore
  75801. * Specifies if the bloom pipeline is enabled
  75802. */
  75803. get BloomEnabled(): boolean;
  75804. set BloomEnabled(enabled: boolean);
  75805. /**
  75806. * @ignore
  75807. * Specifies if the depth of field pipeline is enabed
  75808. */
  75809. get DepthOfFieldEnabled(): boolean;
  75810. set DepthOfFieldEnabled(enabled: boolean);
  75811. /**
  75812. * @ignore
  75813. * Specifies if the lens flare pipeline is enabed
  75814. */
  75815. get LensFlareEnabled(): boolean;
  75816. set LensFlareEnabled(enabled: boolean);
  75817. /**
  75818. * @ignore
  75819. * Specifies if the HDR pipeline is enabled
  75820. */
  75821. get HDREnabled(): boolean;
  75822. set HDREnabled(enabled: boolean);
  75823. /**
  75824. * @ignore
  75825. * Specifies if the volumetric lights scattering effect is enabled
  75826. */
  75827. get VLSEnabled(): boolean;
  75828. set VLSEnabled(enabled: boolean);
  75829. /**
  75830. * @ignore
  75831. * Specifies if the motion blur effect is enabled
  75832. */
  75833. get MotionBlurEnabled(): boolean;
  75834. set MotionBlurEnabled(enabled: boolean);
  75835. /**
  75836. * Specifies if anti-aliasing is enabled
  75837. */
  75838. get fxaaEnabled(): boolean;
  75839. set fxaaEnabled(enabled: boolean);
  75840. /**
  75841. * Specifies if screen space reflections are enabled.
  75842. */
  75843. get screenSpaceReflectionsEnabled(): boolean;
  75844. set screenSpaceReflectionsEnabled(enabled: boolean);
  75845. /**
  75846. * Specifies the number of steps used to calculate the volumetric lights
  75847. * Typically in interval [50, 200]
  75848. */
  75849. get volumetricLightStepsCount(): number;
  75850. set volumetricLightStepsCount(count: number);
  75851. /**
  75852. * Specifies the number of samples used for the motion blur effect
  75853. * Typically in interval [16, 64]
  75854. */
  75855. get motionBlurSamples(): number;
  75856. set motionBlurSamples(samples: number);
  75857. /**
  75858. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75859. */
  75860. get samples(): number;
  75861. set samples(sampleCount: number);
  75862. /**
  75863. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75864. * @constructor
  75865. * @param name The rendering pipeline name
  75866. * @param scene The scene linked to this pipeline
  75867. * @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)
  75868. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75869. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75870. */
  75871. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75872. private _buildPipeline;
  75873. private _createDownSampleX4PostProcess;
  75874. private _createBrightPassPostProcess;
  75875. private _createBlurPostProcesses;
  75876. private _createTextureAdderPostProcess;
  75877. private _createVolumetricLightPostProcess;
  75878. private _createLuminancePostProcesses;
  75879. private _createHdrPostProcess;
  75880. private _createLensFlarePostProcess;
  75881. private _createDepthOfFieldPostProcess;
  75882. private _createMotionBlurPostProcess;
  75883. private _getDepthTexture;
  75884. private _disposePostProcesses;
  75885. /**
  75886. * Dispose of the pipeline and stop all post processes
  75887. */
  75888. dispose(): void;
  75889. /**
  75890. * Serialize the rendering pipeline (Used when exporting)
  75891. * @returns the serialized object
  75892. */
  75893. serialize(): any;
  75894. /**
  75895. * Parse the serialized pipeline
  75896. * @param source Source pipeline.
  75897. * @param scene The scene to load the pipeline to.
  75898. * @param rootUrl The URL of the serialized pipeline.
  75899. * @returns An instantiated pipeline from the serialized object.
  75900. */
  75901. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75902. /**
  75903. * Luminance steps
  75904. */
  75905. static LuminanceSteps: number;
  75906. }
  75907. }
  75908. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75909. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75910. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75911. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75912. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75913. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75914. }
  75915. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75916. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75917. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75918. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75919. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75920. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75921. }
  75922. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75923. /** @hidden */
  75924. export var stereoscopicInterlacePixelShader: {
  75925. name: string;
  75926. shader: string;
  75927. };
  75928. }
  75929. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75930. import { Camera } from "babylonjs/Cameras/camera";
  75931. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75932. import { Engine } from "babylonjs/Engines/engine";
  75933. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75934. /**
  75935. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75936. */
  75937. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75938. private _stepSize;
  75939. private _passedProcess;
  75940. /**
  75941. * Gets a string identifying the name of the class
  75942. * @returns "StereoscopicInterlacePostProcessI" string
  75943. */
  75944. getClassName(): string;
  75945. /**
  75946. * Initializes a StereoscopicInterlacePostProcessI
  75947. * @param name The name of the effect.
  75948. * @param rigCameras The rig cameras to be appled to the post process
  75949. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75950. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75951. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75952. * @param engine The engine which the post process will be applied. (default: current engine)
  75953. * @param reusable If the post process can be reused on the same frame. (default: false)
  75954. */
  75955. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75956. }
  75957. /**
  75958. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75959. */
  75960. export class StereoscopicInterlacePostProcess extends PostProcess {
  75961. private _stepSize;
  75962. private _passedProcess;
  75963. /**
  75964. * Gets a string identifying the name of the class
  75965. * @returns "StereoscopicInterlacePostProcess" string
  75966. */
  75967. getClassName(): string;
  75968. /**
  75969. * Initializes a StereoscopicInterlacePostProcess
  75970. * @param name The name of the effect.
  75971. * @param rigCameras The rig cameras to be appled to the post process
  75972. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75974. * @param engine The engine which the post process will be applied. (default: current engine)
  75975. * @param reusable If the post process can be reused on the same frame. (default: false)
  75976. */
  75977. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75978. }
  75979. }
  75980. declare module "babylonjs/Shaders/tonemap.fragment" {
  75981. /** @hidden */
  75982. export var tonemapPixelShader: {
  75983. name: string;
  75984. shader: string;
  75985. };
  75986. }
  75987. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75988. import { Camera } from "babylonjs/Cameras/camera";
  75989. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75990. import "babylonjs/Shaders/tonemap.fragment";
  75991. import { Engine } from "babylonjs/Engines/engine";
  75992. /** Defines operator used for tonemapping */
  75993. export enum TonemappingOperator {
  75994. /** Hable */
  75995. Hable = 0,
  75996. /** Reinhard */
  75997. Reinhard = 1,
  75998. /** HejiDawson */
  75999. HejiDawson = 2,
  76000. /** Photographic */
  76001. Photographic = 3
  76002. }
  76003. /**
  76004. * Defines a post process to apply tone mapping
  76005. */
  76006. export class TonemapPostProcess extends PostProcess {
  76007. private _operator;
  76008. /** Defines the required exposure adjustement */
  76009. exposureAdjustment: number;
  76010. /**
  76011. * Gets a string identifying the name of the class
  76012. * @returns "TonemapPostProcess" string
  76013. */
  76014. getClassName(): string;
  76015. /**
  76016. * Creates a new TonemapPostProcess
  76017. * @param name defines the name of the postprocess
  76018. * @param _operator defines the operator to use
  76019. * @param exposureAdjustment defines the required exposure adjustement
  76020. * @param camera defines the camera to use (can be null)
  76021. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76022. * @param engine defines the hosting engine (can be ignore if camera is set)
  76023. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76024. */
  76025. constructor(name: string, _operator: TonemappingOperator,
  76026. /** Defines the required exposure adjustement */
  76027. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76028. }
  76029. }
  76030. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76031. /** @hidden */
  76032. export var volumetricLightScatteringPixelShader: {
  76033. name: string;
  76034. shader: string;
  76035. };
  76036. }
  76037. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  76038. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76039. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76040. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76041. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76042. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76043. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76044. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76045. /** @hidden */
  76046. export var volumetricLightScatteringPassVertexShader: {
  76047. name: string;
  76048. shader: string;
  76049. };
  76050. }
  76051. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  76052. /** @hidden */
  76053. export var volumetricLightScatteringPassPixelShader: {
  76054. name: string;
  76055. shader: string;
  76056. };
  76057. }
  76058. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  76059. import { Vector3 } from "babylonjs/Maths/math.vector";
  76060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76061. import { Mesh } from "babylonjs/Meshes/mesh";
  76062. import { Camera } from "babylonjs/Cameras/camera";
  76063. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  76064. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76065. import { Scene } from "babylonjs/scene";
  76066. import "babylonjs/Meshes/Builders/planeBuilder";
  76067. import "babylonjs/Shaders/depth.vertex";
  76068. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  76069. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  76070. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  76071. import { Engine } from "babylonjs/Engines/engine";
  76072. /**
  76073. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76074. */
  76075. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76076. private _volumetricLightScatteringPass;
  76077. private _volumetricLightScatteringRTT;
  76078. private _viewPort;
  76079. private _screenCoordinates;
  76080. private _cachedDefines;
  76081. /**
  76082. * If not undefined, the mesh position is computed from the attached node position
  76083. */
  76084. attachedNode: {
  76085. position: Vector3;
  76086. };
  76087. /**
  76088. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76089. */
  76090. customMeshPosition: Vector3;
  76091. /**
  76092. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76093. */
  76094. useCustomMeshPosition: boolean;
  76095. /**
  76096. * If the post-process should inverse the light scattering direction
  76097. */
  76098. invert: boolean;
  76099. /**
  76100. * The internal mesh used by the post-process
  76101. */
  76102. mesh: Mesh;
  76103. /**
  76104. * @hidden
  76105. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76106. */
  76107. get useDiffuseColor(): boolean;
  76108. set useDiffuseColor(useDiffuseColor: boolean);
  76109. /**
  76110. * Array containing the excluded meshes not rendered in the internal pass
  76111. */
  76112. excludedMeshes: AbstractMesh[];
  76113. /**
  76114. * Controls the overall intensity of the post-process
  76115. */
  76116. exposure: number;
  76117. /**
  76118. * Dissipates each sample's contribution in range [0, 1]
  76119. */
  76120. decay: number;
  76121. /**
  76122. * Controls the overall intensity of each sample
  76123. */
  76124. weight: number;
  76125. /**
  76126. * Controls the density of each sample
  76127. */
  76128. density: number;
  76129. /**
  76130. * @constructor
  76131. * @param name The post-process name
  76132. * @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)
  76133. * @param camera The camera that the post-process will be attached to
  76134. * @param mesh The mesh used to create the light scattering
  76135. * @param samples The post-process quality, default 100
  76136. * @param samplingModeThe post-process filtering mode
  76137. * @param engine The babylon engine
  76138. * @param reusable If the post-process is reusable
  76139. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76140. */
  76141. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76142. /**
  76143. * Returns the string "VolumetricLightScatteringPostProcess"
  76144. * @returns "VolumetricLightScatteringPostProcess"
  76145. */
  76146. getClassName(): string;
  76147. private _isReady;
  76148. /**
  76149. * Sets the new light position for light scattering effect
  76150. * @param position The new custom light position
  76151. */
  76152. setCustomMeshPosition(position: Vector3): void;
  76153. /**
  76154. * Returns the light position for light scattering effect
  76155. * @return Vector3 The custom light position
  76156. */
  76157. getCustomMeshPosition(): Vector3;
  76158. /**
  76159. * Disposes the internal assets and detaches the post-process from the camera
  76160. */
  76161. dispose(camera: Camera): void;
  76162. /**
  76163. * Returns the render target texture used by the post-process
  76164. * @return the render target texture used by the post-process
  76165. */
  76166. getPass(): RenderTargetTexture;
  76167. private _meshExcluded;
  76168. private _createPass;
  76169. private _updateMeshScreenCoordinates;
  76170. /**
  76171. * Creates a default mesh for the Volumeric Light Scattering post-process
  76172. * @param name The mesh name
  76173. * @param scene The scene where to create the mesh
  76174. * @return the default mesh
  76175. */
  76176. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76177. }
  76178. }
  76179. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76180. /** @hidden */
  76181. export var screenSpaceCurvaturePixelShader: {
  76182. name: string;
  76183. shader: string;
  76184. };
  76185. }
  76186. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  76187. import { Nullable } from "babylonjs/types";
  76188. import { Camera } from "babylonjs/Cameras/camera";
  76189. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76190. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76191. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  76192. import { Engine } from "babylonjs/Engines/engine";
  76193. import { Scene } from "babylonjs/scene";
  76194. /**
  76195. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76196. */
  76197. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76198. /**
  76199. * Defines how much ridge the curvature effect displays.
  76200. */
  76201. ridge: number;
  76202. /**
  76203. * Defines how much valley the curvature effect displays.
  76204. */
  76205. valley: number;
  76206. private _geometryBufferRenderer;
  76207. /**
  76208. * Gets a string identifying the name of the class
  76209. * @returns "ScreenSpaceCurvaturePostProcess" string
  76210. */
  76211. getClassName(): string;
  76212. /**
  76213. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76214. * @param name The name of the effect.
  76215. * @param scene The scene containing the objects to blur according to their velocity.
  76216. * @param options The required width/height ratio to downsize to before computing the render pass.
  76217. * @param camera The camera to apply the render pass to.
  76218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76219. * @param engine The engine which the post process will be applied. (default: current engine)
  76220. * @param reusable If the post process can be reused on the same frame. (default: false)
  76221. * @param textureType Type of textures used when performing the post process. (default: 0)
  76222. * @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)
  76223. */
  76224. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76225. /**
  76226. * Support test.
  76227. */
  76228. static get IsSupported(): boolean;
  76229. /** @hidden */
  76230. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76231. }
  76232. }
  76233. declare module "babylonjs/PostProcesses/index" {
  76234. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  76235. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  76236. export * from "babylonjs/PostProcesses/bloomEffect";
  76237. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  76238. export * from "babylonjs/PostProcesses/blurPostProcess";
  76239. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  76240. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  76241. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  76242. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  76243. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  76244. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  76245. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  76246. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  76247. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  76248. export * from "babylonjs/PostProcesses/filterPostProcess";
  76249. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  76250. export * from "babylonjs/PostProcesses/grainPostProcess";
  76251. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  76252. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  76253. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  76254. export * from "babylonjs/PostProcesses/passPostProcess";
  76255. export * from "babylonjs/PostProcesses/postProcess";
  76256. export * from "babylonjs/PostProcesses/postProcessManager";
  76257. export * from "babylonjs/PostProcesses/refractionPostProcess";
  76258. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  76259. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  76260. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  76261. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  76262. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  76263. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  76264. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  76265. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76266. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  76267. }
  76268. declare module "babylonjs/Probes/index" {
  76269. export * from "babylonjs/Probes/reflectionProbe";
  76270. }
  76271. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  76272. import { Scene } from "babylonjs/scene";
  76273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76274. import { SmartArray } from "babylonjs/Misc/smartArray";
  76275. import { ISceneComponent } from "babylonjs/sceneComponent";
  76276. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  76277. import "babylonjs/Meshes/Builders/boxBuilder";
  76278. import "babylonjs/Shaders/color.fragment";
  76279. import "babylonjs/Shaders/color.vertex";
  76280. import { Color3 } from "babylonjs/Maths/math.color";
  76281. import { Observable } from "babylonjs/Misc/observable";
  76282. module "babylonjs/scene" {
  76283. interface Scene {
  76284. /** @hidden (Backing field) */
  76285. _boundingBoxRenderer: BoundingBoxRenderer;
  76286. /** @hidden (Backing field) */
  76287. _forceShowBoundingBoxes: boolean;
  76288. /**
  76289. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76290. */
  76291. forceShowBoundingBoxes: boolean;
  76292. /**
  76293. * Gets the bounding box renderer associated with the scene
  76294. * @returns a BoundingBoxRenderer
  76295. */
  76296. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76297. }
  76298. }
  76299. module "babylonjs/Meshes/abstractMesh" {
  76300. interface AbstractMesh {
  76301. /** @hidden (Backing field) */
  76302. _showBoundingBox: boolean;
  76303. /**
  76304. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76305. */
  76306. showBoundingBox: boolean;
  76307. }
  76308. }
  76309. /**
  76310. * Component responsible of rendering the bounding box of the meshes in a scene.
  76311. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76312. */
  76313. export class BoundingBoxRenderer implements ISceneComponent {
  76314. /**
  76315. * The component name helpfull to identify the component in the list of scene components.
  76316. */
  76317. readonly name: string;
  76318. /**
  76319. * The scene the component belongs to.
  76320. */
  76321. scene: Scene;
  76322. /**
  76323. * Color of the bounding box lines placed in front of an object
  76324. */
  76325. frontColor: Color3;
  76326. /**
  76327. * Color of the bounding box lines placed behind an object
  76328. */
  76329. backColor: Color3;
  76330. /**
  76331. * Defines if the renderer should show the back lines or not
  76332. */
  76333. showBackLines: boolean;
  76334. /**
  76335. * Observable raised before rendering a bounding box
  76336. */
  76337. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76338. /**
  76339. * Observable raised after rendering a bounding box
  76340. */
  76341. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76342. /**
  76343. * @hidden
  76344. */
  76345. renderList: SmartArray<BoundingBox>;
  76346. private _colorShader;
  76347. private _vertexBuffers;
  76348. private _indexBuffer;
  76349. private _fillIndexBuffer;
  76350. private _fillIndexData;
  76351. /**
  76352. * Instantiates a new bounding box renderer in a scene.
  76353. * @param scene the scene the renderer renders in
  76354. */
  76355. constructor(scene: Scene);
  76356. /**
  76357. * Registers the component in a given scene
  76358. */
  76359. register(): void;
  76360. private _evaluateSubMesh;
  76361. private _activeMesh;
  76362. private _prepareRessources;
  76363. private _createIndexBuffer;
  76364. /**
  76365. * Rebuilds the elements related to this component in case of
  76366. * context lost for instance.
  76367. */
  76368. rebuild(): void;
  76369. /**
  76370. * @hidden
  76371. */
  76372. reset(): void;
  76373. /**
  76374. * Render the bounding boxes of a specific rendering group
  76375. * @param renderingGroupId defines the rendering group to render
  76376. */
  76377. render(renderingGroupId: number): void;
  76378. /**
  76379. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76380. * @param mesh Define the mesh to render the occlusion bounding box for
  76381. */
  76382. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76383. /**
  76384. * Dispose and release the resources attached to this renderer.
  76385. */
  76386. dispose(): void;
  76387. }
  76388. }
  76389. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76390. import { Nullable } from "babylonjs/types";
  76391. import { Scene } from "babylonjs/scene";
  76392. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76393. import { Camera } from "babylonjs/Cameras/camera";
  76394. import { ISceneComponent } from "babylonjs/sceneComponent";
  76395. module "babylonjs/scene" {
  76396. interface Scene {
  76397. /** @hidden (Backing field) */
  76398. _depthRenderer: {
  76399. [id: string]: DepthRenderer;
  76400. };
  76401. /**
  76402. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76403. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76404. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76405. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76406. * @returns the created depth renderer
  76407. */
  76408. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76409. /**
  76410. * Disables a depth renderer for a given camera
  76411. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76412. */
  76413. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76414. }
  76415. }
  76416. /**
  76417. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76418. * in several rendering techniques.
  76419. */
  76420. export class DepthRendererSceneComponent implements ISceneComponent {
  76421. /**
  76422. * The component name helpfull to identify the component in the list of scene components.
  76423. */
  76424. readonly name: string;
  76425. /**
  76426. * The scene the component belongs to.
  76427. */
  76428. scene: Scene;
  76429. /**
  76430. * Creates a new instance of the component for the given scene
  76431. * @param scene Defines the scene to register the component in
  76432. */
  76433. constructor(scene: Scene);
  76434. /**
  76435. * Registers the component in a given scene
  76436. */
  76437. register(): void;
  76438. /**
  76439. * Rebuilds the elements related to this component in case of
  76440. * context lost for instance.
  76441. */
  76442. rebuild(): void;
  76443. /**
  76444. * Disposes the component and the associated ressources
  76445. */
  76446. dispose(): void;
  76447. private _gatherRenderTargets;
  76448. private _gatherActiveCameraRenderTargets;
  76449. }
  76450. }
  76451. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76452. import { Nullable } from "babylonjs/types";
  76453. import { Scene } from "babylonjs/scene";
  76454. import { ISceneComponent } from "babylonjs/sceneComponent";
  76455. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76456. module "babylonjs/abstractScene" {
  76457. interface AbstractScene {
  76458. /** @hidden (Backing field) */
  76459. _prePassRenderer: Nullable<PrePassRenderer>;
  76460. /**
  76461. * Gets or Sets the current prepass renderer associated to the scene.
  76462. */
  76463. prePassRenderer: Nullable<PrePassRenderer>;
  76464. /**
  76465. * Enables the prepass and associates it with the scene
  76466. * @returns the PrePassRenderer
  76467. */
  76468. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76469. /**
  76470. * Disables the prepass associated with the scene
  76471. */
  76472. disablePrePassRenderer(): void;
  76473. }
  76474. }
  76475. /**
  76476. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76477. * in several rendering techniques.
  76478. */
  76479. export class PrePassRendererSceneComponent implements ISceneComponent {
  76480. /**
  76481. * The component name helpful to identify the component in the list of scene components.
  76482. */
  76483. readonly name: string;
  76484. /**
  76485. * The scene the component belongs to.
  76486. */
  76487. scene: Scene;
  76488. /**
  76489. * Creates a new instance of the component for the given scene
  76490. * @param scene Defines the scene to register the component in
  76491. */
  76492. constructor(scene: Scene);
  76493. /**
  76494. * Registers the component in a given scene
  76495. */
  76496. register(): void;
  76497. private _beforeCameraDraw;
  76498. private _afterCameraDraw;
  76499. private _beforeClearStage;
  76500. /**
  76501. * Rebuilds the elements related to this component in case of
  76502. * context lost for instance.
  76503. */
  76504. rebuild(): void;
  76505. /**
  76506. * Disposes the component and the associated ressources
  76507. */
  76508. dispose(): void;
  76509. }
  76510. }
  76511. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76512. /** @hidden */
  76513. export var fibonacci: {
  76514. name: string;
  76515. shader: string;
  76516. };
  76517. }
  76518. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76519. /** @hidden */
  76520. export var diffusionProfile: {
  76521. name: string;
  76522. shader: string;
  76523. };
  76524. }
  76525. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76526. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76527. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76528. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76529. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76530. /** @hidden */
  76531. export var subSurfaceScatteringPixelShader: {
  76532. name: string;
  76533. shader: string;
  76534. };
  76535. }
  76536. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76537. import { Nullable } from "babylonjs/types";
  76538. import { Camera } from "babylonjs/Cameras/camera";
  76539. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76540. import { Engine } from "babylonjs/Engines/engine";
  76541. import { Scene } from "babylonjs/scene";
  76542. import "babylonjs/Shaders/imageProcessing.fragment";
  76543. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76544. import "babylonjs/Shaders/postprocess.vertex";
  76545. /**
  76546. * Sub surface scattering post process
  76547. */
  76548. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76549. /**
  76550. * Gets a string identifying the name of the class
  76551. * @returns "SubSurfaceScatteringPostProcess" string
  76552. */
  76553. getClassName(): string;
  76554. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76555. }
  76556. }
  76557. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76558. import { Scene } from "babylonjs/scene";
  76559. import { Color3 } from "babylonjs/Maths/math.color";
  76560. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76561. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76562. /**
  76563. * Contains all parameters needed for the prepass to perform
  76564. * screen space subsurface scattering
  76565. */
  76566. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76567. /** @hidden */
  76568. static _SceneComponentInitialization: (scene: Scene) => void;
  76569. private _ssDiffusionS;
  76570. private _ssFilterRadii;
  76571. private _ssDiffusionD;
  76572. /**
  76573. * Post process to attach for screen space subsurface scattering
  76574. */
  76575. postProcess: SubSurfaceScatteringPostProcess;
  76576. /**
  76577. * Diffusion profile color for subsurface scattering
  76578. */
  76579. get ssDiffusionS(): number[];
  76580. /**
  76581. * Diffusion profile max color channel value for subsurface scattering
  76582. */
  76583. get ssDiffusionD(): number[];
  76584. /**
  76585. * Diffusion profile filter radius for subsurface scattering
  76586. */
  76587. get ssFilterRadii(): number[];
  76588. /**
  76589. * Is subsurface enabled
  76590. */
  76591. enabled: boolean;
  76592. /**
  76593. * Name of the configuration
  76594. */
  76595. name: string;
  76596. /**
  76597. * Diffusion profile colors for subsurface scattering
  76598. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76599. * See ...
  76600. * Note that you can only store up to 5 of them
  76601. */
  76602. ssDiffusionProfileColors: Color3[];
  76603. /**
  76604. * Defines the ratio real world => scene units.
  76605. * Used for subsurface scattering
  76606. */
  76607. metersPerUnit: number;
  76608. /**
  76609. * Textures that should be present in the MRT for this effect to work
  76610. */
  76611. readonly texturesRequired: number[];
  76612. private _scene;
  76613. /**
  76614. * Builds a subsurface configuration object
  76615. * @param scene The scene
  76616. */
  76617. constructor(scene: Scene);
  76618. /**
  76619. * Adds a new diffusion profile.
  76620. * Useful for more realistic subsurface scattering on diverse materials.
  76621. * @param color The color of the diffusion profile. Should be the average color of the material.
  76622. * @return The index of the diffusion profile for the material subsurface configuration
  76623. */
  76624. addDiffusionProfile(color: Color3): number;
  76625. /**
  76626. * Creates the sss post process
  76627. * @return The created post process
  76628. */
  76629. createPostProcess(): SubSurfaceScatteringPostProcess;
  76630. /**
  76631. * Deletes all diffusion profiles.
  76632. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76633. */
  76634. clearAllDiffusionProfiles(): void;
  76635. /**
  76636. * Disposes this object
  76637. */
  76638. dispose(): void;
  76639. /**
  76640. * @hidden
  76641. * https://zero-radiance.github.io/post/sampling-diffusion/
  76642. *
  76643. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76644. * ------------------------------------------------------------------------------------
  76645. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76646. * PDF[r, phi, s] = r * R[r, phi, s]
  76647. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76648. * ------------------------------------------------------------------------------------
  76649. * We importance sample the color channel with the widest scattering distance.
  76650. */
  76651. getDiffusionProfileParameters(color: Color3): number;
  76652. /**
  76653. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76654. * 'u' is the random number (the value of the CDF): [0, 1).
  76655. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76656. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76657. */
  76658. private _sampleBurleyDiffusionProfile;
  76659. }
  76660. }
  76661. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76662. import { Nullable } from "babylonjs/types";
  76663. import { Scene } from "babylonjs/scene";
  76664. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76665. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76666. import { AbstractScene } from "babylonjs/abstractScene";
  76667. module "babylonjs/abstractScene" {
  76668. interface AbstractScene {
  76669. /** @hidden (Backing field) */
  76670. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76671. /**
  76672. * Gets or Sets the current prepass renderer associated to the scene.
  76673. */
  76674. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76675. /**
  76676. * Enables the subsurface effect for prepass
  76677. * @returns the SubSurfaceConfiguration
  76678. */
  76679. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76680. /**
  76681. * Disables the subsurface effect for prepass
  76682. */
  76683. disableSubSurfaceForPrePass(): void;
  76684. }
  76685. }
  76686. /**
  76687. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76688. * in several rendering techniques.
  76689. */
  76690. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76691. /**
  76692. * The component name helpful to identify the component in the list of scene components.
  76693. */
  76694. readonly name: string;
  76695. /**
  76696. * The scene the component belongs to.
  76697. */
  76698. scene: Scene;
  76699. /**
  76700. * Creates a new instance of the component for the given scene
  76701. * @param scene Defines the scene to register the component in
  76702. */
  76703. constructor(scene: Scene);
  76704. /**
  76705. * Registers the component in a given scene
  76706. */
  76707. register(): void;
  76708. /**
  76709. * Serializes the component data to the specified json object
  76710. * @param serializationObject The object to serialize to
  76711. */
  76712. serialize(serializationObject: any): void;
  76713. /**
  76714. * Adds all the elements from the container to the scene
  76715. * @param container the container holding the elements
  76716. */
  76717. addFromContainer(container: AbstractScene): void;
  76718. /**
  76719. * Removes all the elements in the container from the scene
  76720. * @param container contains the elements to remove
  76721. * @param dispose if the removed element should be disposed (default: false)
  76722. */
  76723. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76724. /**
  76725. * Rebuilds the elements related to this component in case of
  76726. * context lost for instance.
  76727. */
  76728. rebuild(): void;
  76729. /**
  76730. * Disposes the component and the associated ressources
  76731. */
  76732. dispose(): void;
  76733. }
  76734. }
  76735. declare module "babylonjs/Shaders/outline.fragment" {
  76736. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76737. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76738. /** @hidden */
  76739. export var outlinePixelShader: {
  76740. name: string;
  76741. shader: string;
  76742. };
  76743. }
  76744. declare module "babylonjs/Shaders/outline.vertex" {
  76745. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76746. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76747. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76748. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76749. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76750. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76751. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76752. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76753. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76754. /** @hidden */
  76755. export var outlineVertexShader: {
  76756. name: string;
  76757. shader: string;
  76758. };
  76759. }
  76760. declare module "babylonjs/Rendering/outlineRenderer" {
  76761. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76762. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76763. import { Scene } from "babylonjs/scene";
  76764. import { ISceneComponent } from "babylonjs/sceneComponent";
  76765. import "babylonjs/Shaders/outline.fragment";
  76766. import "babylonjs/Shaders/outline.vertex";
  76767. module "babylonjs/scene" {
  76768. interface Scene {
  76769. /** @hidden */
  76770. _outlineRenderer: OutlineRenderer;
  76771. /**
  76772. * Gets the outline renderer associated with the scene
  76773. * @returns a OutlineRenderer
  76774. */
  76775. getOutlineRenderer(): OutlineRenderer;
  76776. }
  76777. }
  76778. module "babylonjs/Meshes/abstractMesh" {
  76779. interface AbstractMesh {
  76780. /** @hidden (Backing field) */
  76781. _renderOutline: boolean;
  76782. /**
  76783. * Gets or sets a boolean indicating if the outline must be rendered as well
  76784. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76785. */
  76786. renderOutline: boolean;
  76787. /** @hidden (Backing field) */
  76788. _renderOverlay: boolean;
  76789. /**
  76790. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76791. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76792. */
  76793. renderOverlay: boolean;
  76794. }
  76795. }
  76796. /**
  76797. * This class is responsible to draw bothe outline/overlay of meshes.
  76798. * It should not be used directly but through the available method on mesh.
  76799. */
  76800. export class OutlineRenderer implements ISceneComponent {
  76801. /**
  76802. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76803. */
  76804. private static _StencilReference;
  76805. /**
  76806. * The name of the component. Each component must have a unique name.
  76807. */
  76808. name: string;
  76809. /**
  76810. * The scene the component belongs to.
  76811. */
  76812. scene: Scene;
  76813. /**
  76814. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76815. */
  76816. zOffset: number;
  76817. private _engine;
  76818. private _effect;
  76819. private _cachedDefines;
  76820. private _savedDepthWrite;
  76821. /**
  76822. * Instantiates a new outline renderer. (There could be only one per scene).
  76823. * @param scene Defines the scene it belongs to
  76824. */
  76825. constructor(scene: Scene);
  76826. /**
  76827. * Register the component to one instance of a scene.
  76828. */
  76829. register(): void;
  76830. /**
  76831. * Rebuilds the elements related to this component in case of
  76832. * context lost for instance.
  76833. */
  76834. rebuild(): void;
  76835. /**
  76836. * Disposes the component and the associated ressources.
  76837. */
  76838. dispose(): void;
  76839. /**
  76840. * Renders the outline in the canvas.
  76841. * @param subMesh Defines the sumesh to render
  76842. * @param batch Defines the batch of meshes in case of instances
  76843. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76844. */
  76845. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76846. /**
  76847. * Returns whether or not the outline renderer is ready for a given submesh.
  76848. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76849. * @param subMesh Defines the submesh to check readyness for
  76850. * @param useInstances Defines wheter wee are trying to render instances or not
  76851. * @returns true if ready otherwise false
  76852. */
  76853. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76854. private _beforeRenderingMesh;
  76855. private _afterRenderingMesh;
  76856. }
  76857. }
  76858. declare module "babylonjs/Rendering/index" {
  76859. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76860. export * from "babylonjs/Rendering/depthRenderer";
  76861. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76862. export * from "babylonjs/Rendering/edgesRenderer";
  76863. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76864. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76865. export * from "babylonjs/Rendering/prePassRenderer";
  76866. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76867. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  76868. export * from "babylonjs/Rendering/outlineRenderer";
  76869. export * from "babylonjs/Rendering/renderingGroup";
  76870. export * from "babylonjs/Rendering/renderingManager";
  76871. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76872. }
  76873. declare module "babylonjs/Sprites/ISprites" {
  76874. /**
  76875. * Defines the basic options interface of a Sprite Frame Source Size.
  76876. */
  76877. export interface ISpriteJSONSpriteSourceSize {
  76878. /**
  76879. * number of the original width of the Frame
  76880. */
  76881. w: number;
  76882. /**
  76883. * number of the original height of the Frame
  76884. */
  76885. h: number;
  76886. }
  76887. /**
  76888. * Defines the basic options interface of a Sprite Frame Data.
  76889. */
  76890. export interface ISpriteJSONSpriteFrameData {
  76891. /**
  76892. * number of the x offset of the Frame
  76893. */
  76894. x: number;
  76895. /**
  76896. * number of the y offset of the Frame
  76897. */
  76898. y: number;
  76899. /**
  76900. * number of the width of the Frame
  76901. */
  76902. w: number;
  76903. /**
  76904. * number of the height of the Frame
  76905. */
  76906. h: number;
  76907. }
  76908. /**
  76909. * Defines the basic options interface of a JSON Sprite.
  76910. */
  76911. export interface ISpriteJSONSprite {
  76912. /**
  76913. * string name of the Frame
  76914. */
  76915. filename: string;
  76916. /**
  76917. * ISpriteJSONSpriteFrame basic object of the frame data
  76918. */
  76919. frame: ISpriteJSONSpriteFrameData;
  76920. /**
  76921. * boolean to flag is the frame was rotated.
  76922. */
  76923. rotated: boolean;
  76924. /**
  76925. * boolean to flag is the frame was trimmed.
  76926. */
  76927. trimmed: boolean;
  76928. /**
  76929. * ISpriteJSONSpriteFrame basic object of the source data
  76930. */
  76931. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76932. /**
  76933. * ISpriteJSONSpriteFrame basic object of the source data
  76934. */
  76935. sourceSize: ISpriteJSONSpriteSourceSize;
  76936. }
  76937. /**
  76938. * Defines the basic options interface of a JSON atlas.
  76939. */
  76940. export interface ISpriteJSONAtlas {
  76941. /**
  76942. * Array of objects that contain the frame data.
  76943. */
  76944. frames: Array<ISpriteJSONSprite>;
  76945. /**
  76946. * object basic object containing the sprite meta data.
  76947. */
  76948. meta?: object;
  76949. }
  76950. }
  76951. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76952. /** @hidden */
  76953. export var spriteMapPixelShader: {
  76954. name: string;
  76955. shader: string;
  76956. };
  76957. }
  76958. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76959. /** @hidden */
  76960. export var spriteMapVertexShader: {
  76961. name: string;
  76962. shader: string;
  76963. };
  76964. }
  76965. declare module "babylonjs/Sprites/spriteMap" {
  76966. import { IDisposable, Scene } from "babylonjs/scene";
  76967. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76968. import { Texture } from "babylonjs/Materials/Textures/texture";
  76969. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76970. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76971. import "babylonjs/Meshes/Builders/planeBuilder";
  76972. import "babylonjs/Shaders/spriteMap.fragment";
  76973. import "babylonjs/Shaders/spriteMap.vertex";
  76974. /**
  76975. * Defines the basic options interface of a SpriteMap
  76976. */
  76977. export interface ISpriteMapOptions {
  76978. /**
  76979. * Vector2 of the number of cells in the grid.
  76980. */
  76981. stageSize?: Vector2;
  76982. /**
  76983. * Vector2 of the size of the output plane in World Units.
  76984. */
  76985. outputSize?: Vector2;
  76986. /**
  76987. * Vector3 of the position of the output plane in World Units.
  76988. */
  76989. outputPosition?: Vector3;
  76990. /**
  76991. * Vector3 of the rotation of the output plane.
  76992. */
  76993. outputRotation?: Vector3;
  76994. /**
  76995. * number of layers that the system will reserve in resources.
  76996. */
  76997. layerCount?: number;
  76998. /**
  76999. * number of max animation frames a single cell will reserve in resources.
  77000. */
  77001. maxAnimationFrames?: number;
  77002. /**
  77003. * number cell index of the base tile when the system compiles.
  77004. */
  77005. baseTile?: number;
  77006. /**
  77007. * boolean flip the sprite after its been repositioned by the framing data.
  77008. */
  77009. flipU?: boolean;
  77010. /**
  77011. * Vector3 scalar of the global RGB values of the SpriteMap.
  77012. */
  77013. colorMultiply?: Vector3;
  77014. }
  77015. /**
  77016. * Defines the IDisposable interface in order to be cleanable from resources.
  77017. */
  77018. export interface ISpriteMap extends IDisposable {
  77019. /**
  77020. * String name of the SpriteMap.
  77021. */
  77022. name: string;
  77023. /**
  77024. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77025. */
  77026. atlasJSON: ISpriteJSONAtlas;
  77027. /**
  77028. * Texture of the SpriteMap.
  77029. */
  77030. spriteSheet: Texture;
  77031. /**
  77032. * The parameters to initialize the SpriteMap with.
  77033. */
  77034. options: ISpriteMapOptions;
  77035. }
  77036. /**
  77037. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77038. */
  77039. export class SpriteMap implements ISpriteMap {
  77040. /** The Name of the spriteMap */
  77041. name: string;
  77042. /** The JSON file with the frame and meta data */
  77043. atlasJSON: ISpriteJSONAtlas;
  77044. /** The systems Sprite Sheet Texture */
  77045. spriteSheet: Texture;
  77046. /** Arguments passed with the Constructor */
  77047. options: ISpriteMapOptions;
  77048. /** Public Sprite Storage array, parsed from atlasJSON */
  77049. sprites: Array<ISpriteJSONSprite>;
  77050. /** Returns the Number of Sprites in the System */
  77051. get spriteCount(): number;
  77052. /** Returns the Position of Output Plane*/
  77053. get position(): Vector3;
  77054. /** Returns the Position of Output Plane*/
  77055. set position(v: Vector3);
  77056. /** Returns the Rotation of Output Plane*/
  77057. get rotation(): Vector3;
  77058. /** Returns the Rotation of Output Plane*/
  77059. set rotation(v: Vector3);
  77060. /** Sets the AnimationMap*/
  77061. get animationMap(): RawTexture;
  77062. /** Sets the AnimationMap*/
  77063. set animationMap(v: RawTexture);
  77064. /** Scene that the SpriteMap was created in */
  77065. private _scene;
  77066. /** Texture Buffer of Float32 that holds tile frame data*/
  77067. private _frameMap;
  77068. /** Texture Buffers of Float32 that holds tileMap data*/
  77069. private _tileMaps;
  77070. /** Texture Buffer of Float32 that holds Animation Data*/
  77071. private _animationMap;
  77072. /** Custom ShaderMaterial Central to the System*/
  77073. private _material;
  77074. /** Custom ShaderMaterial Central to the System*/
  77075. private _output;
  77076. /** Systems Time Ticker*/
  77077. private _time;
  77078. /**
  77079. * Creates a new SpriteMap
  77080. * @param name defines the SpriteMaps Name
  77081. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77082. * @param spriteSheet is the Texture that the Sprites are on.
  77083. * @param options a basic deployment configuration
  77084. * @param scene The Scene that the map is deployed on
  77085. */
  77086. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77087. /**
  77088. * Returns tileID location
  77089. * @returns Vector2 the cell position ID
  77090. */
  77091. getTileID(): Vector2;
  77092. /**
  77093. * Gets the UV location of the mouse over the SpriteMap.
  77094. * @returns Vector2 the UV position of the mouse interaction
  77095. */
  77096. getMousePosition(): Vector2;
  77097. /**
  77098. * Creates the "frame" texture Buffer
  77099. * -------------------------------------
  77100. * Structure of frames
  77101. * "filename": "Falling-Water-2.png",
  77102. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77103. * "rotated": true,
  77104. * "trimmed": true,
  77105. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77106. * "sourceSize": {"w":32,"h":32}
  77107. * @returns RawTexture of the frameMap
  77108. */
  77109. private _createFrameBuffer;
  77110. /**
  77111. * Creates the tileMap texture Buffer
  77112. * @param buffer normally and array of numbers, or a false to generate from scratch
  77113. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77114. * @returns RawTexture of the tileMap
  77115. */
  77116. private _createTileBuffer;
  77117. /**
  77118. * Modifies the data of the tileMaps
  77119. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77120. * @param pos is the iVector2 Coordinates of the Tile
  77121. * @param tile The SpriteIndex of the new Tile
  77122. */
  77123. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77124. /**
  77125. * Creates the animationMap texture Buffer
  77126. * @param buffer normally and array of numbers, or a false to generate from scratch
  77127. * @returns RawTexture of the animationMap
  77128. */
  77129. private _createTileAnimationBuffer;
  77130. /**
  77131. * Modifies the data of the animationMap
  77132. * @param cellID is the Index of the Sprite
  77133. * @param _frame is the target Animation frame
  77134. * @param toCell is the Target Index of the next frame of the animation
  77135. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77136. * @param speed is a global scalar of the time variable on the map.
  77137. */
  77138. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77139. /**
  77140. * Exports the .tilemaps file
  77141. */
  77142. saveTileMaps(): void;
  77143. /**
  77144. * Imports the .tilemaps file
  77145. * @param url of the .tilemaps file
  77146. */
  77147. loadTileMaps(url: string): void;
  77148. /**
  77149. * Release associated resources
  77150. */
  77151. dispose(): void;
  77152. }
  77153. }
  77154. declare module "babylonjs/Sprites/spritePackedManager" {
  77155. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77156. import { Scene } from "babylonjs/scene";
  77157. /**
  77158. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77159. * @see https://doc.babylonjs.com/babylon101/sprites
  77160. */
  77161. export class SpritePackedManager extends SpriteManager {
  77162. /** defines the packed manager's name */
  77163. name: string;
  77164. /**
  77165. * Creates a new sprite manager from a packed sprite sheet
  77166. * @param name defines the manager's name
  77167. * @param imgUrl defines the sprite sheet url
  77168. * @param capacity defines the maximum allowed number of sprites
  77169. * @param scene defines the hosting scene
  77170. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77171. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77172. * @param samplingMode defines the smapling mode to use with spritesheet
  77173. * @param fromPacked set to true; do not alter
  77174. */
  77175. constructor(
  77176. /** defines the packed manager's name */
  77177. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77178. }
  77179. }
  77180. declare module "babylonjs/Sprites/index" {
  77181. export * from "babylonjs/Sprites/sprite";
  77182. export * from "babylonjs/Sprites/ISprites";
  77183. export * from "babylonjs/Sprites/spriteManager";
  77184. export * from "babylonjs/Sprites/spriteMap";
  77185. export * from "babylonjs/Sprites/spritePackedManager";
  77186. export * from "babylonjs/Sprites/spriteSceneComponent";
  77187. }
  77188. declare module "babylonjs/States/index" {
  77189. export * from "babylonjs/States/alphaCullingState";
  77190. export * from "babylonjs/States/depthCullingState";
  77191. export * from "babylonjs/States/stencilState";
  77192. }
  77193. declare module "babylonjs/Misc/assetsManager" {
  77194. import { Scene } from "babylonjs/scene";
  77195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77196. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  77197. import { Skeleton } from "babylonjs/Bones/skeleton";
  77198. import { Observable } from "babylonjs/Misc/observable";
  77199. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  77200. import { Texture } from "babylonjs/Materials/Textures/texture";
  77201. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  77202. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  77203. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  77204. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  77205. import { AssetContainer } from "babylonjs/assetContainer";
  77206. /**
  77207. * Defines the list of states available for a task inside a AssetsManager
  77208. */
  77209. export enum AssetTaskState {
  77210. /**
  77211. * Initialization
  77212. */
  77213. INIT = 0,
  77214. /**
  77215. * Running
  77216. */
  77217. RUNNING = 1,
  77218. /**
  77219. * Done
  77220. */
  77221. DONE = 2,
  77222. /**
  77223. * Error
  77224. */
  77225. ERROR = 3
  77226. }
  77227. /**
  77228. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77229. */
  77230. export abstract class AbstractAssetTask {
  77231. /**
  77232. * Task name
  77233. */ name: string;
  77234. /**
  77235. * Callback called when the task is successful
  77236. */
  77237. onSuccess: (task: any) => void;
  77238. /**
  77239. * Callback called when the task is not successful
  77240. */
  77241. onError: (task: any, message?: string, exception?: any) => void;
  77242. /**
  77243. * Creates a new AssetsManager
  77244. * @param name defines the name of the task
  77245. */
  77246. constructor(
  77247. /**
  77248. * Task name
  77249. */ name: string);
  77250. private _isCompleted;
  77251. private _taskState;
  77252. private _errorObject;
  77253. /**
  77254. * Get if the task is completed
  77255. */
  77256. get isCompleted(): boolean;
  77257. /**
  77258. * Gets the current state of the task
  77259. */
  77260. get taskState(): AssetTaskState;
  77261. /**
  77262. * Gets the current error object (if task is in error)
  77263. */
  77264. get errorObject(): {
  77265. message?: string;
  77266. exception?: any;
  77267. };
  77268. /**
  77269. * Internal only
  77270. * @hidden
  77271. */
  77272. _setErrorObject(message?: string, exception?: any): void;
  77273. /**
  77274. * Execute the current task
  77275. * @param scene defines the scene where you want your assets to be loaded
  77276. * @param onSuccess is a callback called when the task is successfully executed
  77277. * @param onError is a callback called if an error occurs
  77278. */
  77279. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77280. /**
  77281. * Execute the current task
  77282. * @param scene defines the scene where you want your assets to be loaded
  77283. * @param onSuccess is a callback called when the task is successfully executed
  77284. * @param onError is a callback called if an error occurs
  77285. */
  77286. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77287. /**
  77288. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77289. * This can be used with failed tasks that have the reason for failure fixed.
  77290. */
  77291. reset(): void;
  77292. private onErrorCallback;
  77293. private onDoneCallback;
  77294. }
  77295. /**
  77296. * Define the interface used by progress events raised during assets loading
  77297. */
  77298. export interface IAssetsProgressEvent {
  77299. /**
  77300. * Defines the number of remaining tasks to process
  77301. */
  77302. remainingCount: number;
  77303. /**
  77304. * Defines the total number of tasks
  77305. */
  77306. totalCount: number;
  77307. /**
  77308. * Defines the task that was just processed
  77309. */
  77310. task: AbstractAssetTask;
  77311. }
  77312. /**
  77313. * Class used to share progress information about assets loading
  77314. */
  77315. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77316. /**
  77317. * Defines the number of remaining tasks to process
  77318. */
  77319. remainingCount: number;
  77320. /**
  77321. * Defines the total number of tasks
  77322. */
  77323. totalCount: number;
  77324. /**
  77325. * Defines the task that was just processed
  77326. */
  77327. task: AbstractAssetTask;
  77328. /**
  77329. * Creates a AssetsProgressEvent
  77330. * @param remainingCount defines the number of remaining tasks to process
  77331. * @param totalCount defines the total number of tasks
  77332. * @param task defines the task that was just processed
  77333. */
  77334. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77335. }
  77336. /**
  77337. * Define a task used by AssetsManager to load assets into a container
  77338. */
  77339. export class ContainerAssetTask extends AbstractAssetTask {
  77340. /**
  77341. * Defines the name of the task
  77342. */
  77343. name: string;
  77344. /**
  77345. * Defines the list of mesh's names you want to load
  77346. */
  77347. meshesNames: any;
  77348. /**
  77349. * Defines the root url to use as a base to load your meshes and associated resources
  77350. */
  77351. rootUrl: string;
  77352. /**
  77353. * Defines the filename or File of the scene to load from
  77354. */
  77355. sceneFilename: string | File;
  77356. /**
  77357. * Get the loaded asset container
  77358. */
  77359. loadedContainer: AssetContainer;
  77360. /**
  77361. * Gets the list of loaded meshes
  77362. */
  77363. loadedMeshes: Array<AbstractMesh>;
  77364. /**
  77365. * Gets the list of loaded particle systems
  77366. */
  77367. loadedParticleSystems: Array<IParticleSystem>;
  77368. /**
  77369. * Gets the list of loaded skeletons
  77370. */
  77371. loadedSkeletons: Array<Skeleton>;
  77372. /**
  77373. * Gets the list of loaded animation groups
  77374. */
  77375. loadedAnimationGroups: Array<AnimationGroup>;
  77376. /**
  77377. * Callback called when the task is successful
  77378. */
  77379. onSuccess: (task: ContainerAssetTask) => void;
  77380. /**
  77381. * Callback called when the task is successful
  77382. */
  77383. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77384. /**
  77385. * Creates a new ContainerAssetTask
  77386. * @param name defines the name of the task
  77387. * @param meshesNames defines the list of mesh's names you want to load
  77388. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77389. * @param sceneFilename defines the filename or File of the scene to load from
  77390. */
  77391. constructor(
  77392. /**
  77393. * Defines the name of the task
  77394. */
  77395. name: string,
  77396. /**
  77397. * Defines the list of mesh's names you want to load
  77398. */
  77399. meshesNames: any,
  77400. /**
  77401. * Defines the root url to use as a base to load your meshes and associated resources
  77402. */
  77403. rootUrl: string,
  77404. /**
  77405. * Defines the filename or File of the scene to load from
  77406. */
  77407. sceneFilename: string | File);
  77408. /**
  77409. * Execute the current task
  77410. * @param scene defines the scene where you want your assets to be loaded
  77411. * @param onSuccess is a callback called when the task is successfully executed
  77412. * @param onError is a callback called if an error occurs
  77413. */
  77414. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77415. }
  77416. /**
  77417. * Define a task used by AssetsManager to load meshes
  77418. */
  77419. export class MeshAssetTask extends AbstractAssetTask {
  77420. /**
  77421. * Defines the name of the task
  77422. */
  77423. name: string;
  77424. /**
  77425. * Defines the list of mesh's names you want to load
  77426. */
  77427. meshesNames: any;
  77428. /**
  77429. * Defines the root url to use as a base to load your meshes and associated resources
  77430. */
  77431. rootUrl: string;
  77432. /**
  77433. * Defines the filename or File of the scene to load from
  77434. */
  77435. sceneFilename: string | File;
  77436. /**
  77437. * Gets the list of loaded meshes
  77438. */
  77439. loadedMeshes: Array<AbstractMesh>;
  77440. /**
  77441. * Gets the list of loaded particle systems
  77442. */
  77443. loadedParticleSystems: Array<IParticleSystem>;
  77444. /**
  77445. * Gets the list of loaded skeletons
  77446. */
  77447. loadedSkeletons: Array<Skeleton>;
  77448. /**
  77449. * Gets the list of loaded animation groups
  77450. */
  77451. loadedAnimationGroups: Array<AnimationGroup>;
  77452. /**
  77453. * Callback called when the task is successful
  77454. */
  77455. onSuccess: (task: MeshAssetTask) => void;
  77456. /**
  77457. * Callback called when the task is successful
  77458. */
  77459. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77460. /**
  77461. * Creates a new MeshAssetTask
  77462. * @param name defines the name of the task
  77463. * @param meshesNames defines the list of mesh's names you want to load
  77464. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77465. * @param sceneFilename defines the filename or File of the scene to load from
  77466. */
  77467. constructor(
  77468. /**
  77469. * Defines the name of the task
  77470. */
  77471. name: string,
  77472. /**
  77473. * Defines the list of mesh's names you want to load
  77474. */
  77475. meshesNames: any,
  77476. /**
  77477. * Defines the root url to use as a base to load your meshes and associated resources
  77478. */
  77479. rootUrl: string,
  77480. /**
  77481. * Defines the filename or File of the scene to load from
  77482. */
  77483. sceneFilename: string | File);
  77484. /**
  77485. * Execute the current task
  77486. * @param scene defines the scene where you want your assets to be loaded
  77487. * @param onSuccess is a callback called when the task is successfully executed
  77488. * @param onError is a callback called if an error occurs
  77489. */
  77490. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77491. }
  77492. /**
  77493. * Define a task used by AssetsManager to load text content
  77494. */
  77495. export class TextFileAssetTask extends AbstractAssetTask {
  77496. /**
  77497. * Defines the name of the task
  77498. */
  77499. name: string;
  77500. /**
  77501. * Defines the location of the file to load
  77502. */
  77503. url: string;
  77504. /**
  77505. * Gets the loaded text string
  77506. */
  77507. text: string;
  77508. /**
  77509. * Callback called when the task is successful
  77510. */
  77511. onSuccess: (task: TextFileAssetTask) => void;
  77512. /**
  77513. * Callback called when the task is successful
  77514. */
  77515. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77516. /**
  77517. * Creates a new TextFileAssetTask object
  77518. * @param name defines the name of the task
  77519. * @param url defines the location of the file to load
  77520. */
  77521. constructor(
  77522. /**
  77523. * Defines the name of the task
  77524. */
  77525. name: string,
  77526. /**
  77527. * Defines the location of the file to load
  77528. */
  77529. url: string);
  77530. /**
  77531. * Execute the current task
  77532. * @param scene defines the scene where you want your assets to be loaded
  77533. * @param onSuccess is a callback called when the task is successfully executed
  77534. * @param onError is a callback called if an error occurs
  77535. */
  77536. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77537. }
  77538. /**
  77539. * Define a task used by AssetsManager to load binary data
  77540. */
  77541. export class BinaryFileAssetTask extends AbstractAssetTask {
  77542. /**
  77543. * Defines the name of the task
  77544. */
  77545. name: string;
  77546. /**
  77547. * Defines the location of the file to load
  77548. */
  77549. url: string;
  77550. /**
  77551. * Gets the lodaded data (as an array buffer)
  77552. */
  77553. data: ArrayBuffer;
  77554. /**
  77555. * Callback called when the task is successful
  77556. */
  77557. onSuccess: (task: BinaryFileAssetTask) => void;
  77558. /**
  77559. * Callback called when the task is successful
  77560. */
  77561. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77562. /**
  77563. * Creates a new BinaryFileAssetTask object
  77564. * @param name defines the name of the new task
  77565. * @param url defines the location of the file to load
  77566. */
  77567. constructor(
  77568. /**
  77569. * Defines the name of the task
  77570. */
  77571. name: string,
  77572. /**
  77573. * Defines the location of the file to load
  77574. */
  77575. url: string);
  77576. /**
  77577. * Execute the current task
  77578. * @param scene defines the scene where you want your assets to be loaded
  77579. * @param onSuccess is a callback called when the task is successfully executed
  77580. * @param onError is a callback called if an error occurs
  77581. */
  77582. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77583. }
  77584. /**
  77585. * Define a task used by AssetsManager to load images
  77586. */
  77587. export class ImageAssetTask extends AbstractAssetTask {
  77588. /**
  77589. * Defines the name of the task
  77590. */
  77591. name: string;
  77592. /**
  77593. * Defines the location of the image to load
  77594. */
  77595. url: string;
  77596. /**
  77597. * Gets the loaded images
  77598. */
  77599. image: HTMLImageElement;
  77600. /**
  77601. * Callback called when the task is successful
  77602. */
  77603. onSuccess: (task: ImageAssetTask) => void;
  77604. /**
  77605. * Callback called when the task is successful
  77606. */
  77607. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77608. /**
  77609. * Creates a new ImageAssetTask
  77610. * @param name defines the name of the task
  77611. * @param url defines the location of the image to load
  77612. */
  77613. constructor(
  77614. /**
  77615. * Defines the name of the task
  77616. */
  77617. name: string,
  77618. /**
  77619. * Defines the location of the image to load
  77620. */
  77621. url: string);
  77622. /**
  77623. * Execute the current task
  77624. * @param scene defines the scene where you want your assets to be loaded
  77625. * @param onSuccess is a callback called when the task is successfully executed
  77626. * @param onError is a callback called if an error occurs
  77627. */
  77628. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77629. }
  77630. /**
  77631. * Defines the interface used by texture loading tasks
  77632. */
  77633. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77634. /**
  77635. * Gets the loaded texture
  77636. */
  77637. texture: TEX;
  77638. }
  77639. /**
  77640. * Define a task used by AssetsManager to load 2D textures
  77641. */
  77642. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77643. /**
  77644. * Defines the name of the task
  77645. */
  77646. name: string;
  77647. /**
  77648. * Defines the location of the file to load
  77649. */
  77650. url: string;
  77651. /**
  77652. * Defines if mipmap should not be generated (default is false)
  77653. */
  77654. noMipmap?: boolean | undefined;
  77655. /**
  77656. * Defines if texture must be inverted on Y axis (default is true)
  77657. */
  77658. invertY: boolean;
  77659. /**
  77660. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77661. */
  77662. samplingMode: number;
  77663. /**
  77664. * Gets the loaded texture
  77665. */
  77666. texture: Texture;
  77667. /**
  77668. * Callback called when the task is successful
  77669. */
  77670. onSuccess: (task: TextureAssetTask) => void;
  77671. /**
  77672. * Callback called when the task is successful
  77673. */
  77674. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77675. /**
  77676. * Creates a new TextureAssetTask object
  77677. * @param name defines the name of the task
  77678. * @param url defines the location of the file to load
  77679. * @param noMipmap defines if mipmap should not be generated (default is false)
  77680. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77681. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77682. */
  77683. constructor(
  77684. /**
  77685. * Defines the name of the task
  77686. */
  77687. name: string,
  77688. /**
  77689. * Defines the location of the file to load
  77690. */
  77691. url: string,
  77692. /**
  77693. * Defines if mipmap should not be generated (default is false)
  77694. */
  77695. noMipmap?: boolean | undefined,
  77696. /**
  77697. * Defines if texture must be inverted on Y axis (default is true)
  77698. */
  77699. invertY?: boolean,
  77700. /**
  77701. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77702. */
  77703. samplingMode?: number);
  77704. /**
  77705. * Execute the current task
  77706. * @param scene defines the scene where you want your assets to be loaded
  77707. * @param onSuccess is a callback called when the task is successfully executed
  77708. * @param onError is a callback called if an error occurs
  77709. */
  77710. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77711. }
  77712. /**
  77713. * Define a task used by AssetsManager to load cube textures
  77714. */
  77715. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77716. /**
  77717. * Defines the name of the task
  77718. */
  77719. name: string;
  77720. /**
  77721. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77722. */
  77723. url: string;
  77724. /**
  77725. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77726. */
  77727. extensions?: string[] | undefined;
  77728. /**
  77729. * Defines if mipmaps should not be generated (default is false)
  77730. */
  77731. noMipmap?: boolean | undefined;
  77732. /**
  77733. * Defines the explicit list of files (undefined by default)
  77734. */
  77735. files?: string[] | undefined;
  77736. /**
  77737. * Gets the loaded texture
  77738. */
  77739. texture: CubeTexture;
  77740. /**
  77741. * Callback called when the task is successful
  77742. */
  77743. onSuccess: (task: CubeTextureAssetTask) => void;
  77744. /**
  77745. * Callback called when the task is successful
  77746. */
  77747. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77748. /**
  77749. * Creates a new CubeTextureAssetTask
  77750. * @param name defines the name of the task
  77751. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77752. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77753. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77754. * @param files defines the explicit list of files (undefined by default)
  77755. */
  77756. constructor(
  77757. /**
  77758. * Defines the name of the task
  77759. */
  77760. name: string,
  77761. /**
  77762. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77763. */
  77764. url: string,
  77765. /**
  77766. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77767. */
  77768. extensions?: string[] | undefined,
  77769. /**
  77770. * Defines if mipmaps should not be generated (default is false)
  77771. */
  77772. noMipmap?: boolean | undefined,
  77773. /**
  77774. * Defines the explicit list of files (undefined by default)
  77775. */
  77776. files?: string[] | undefined);
  77777. /**
  77778. * Execute the current task
  77779. * @param scene defines the scene where you want your assets to be loaded
  77780. * @param onSuccess is a callback called when the task is successfully executed
  77781. * @param onError is a callback called if an error occurs
  77782. */
  77783. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77784. }
  77785. /**
  77786. * Define a task used by AssetsManager to load HDR cube textures
  77787. */
  77788. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77789. /**
  77790. * Defines the name of the task
  77791. */
  77792. name: string;
  77793. /**
  77794. * Defines the location of the file to load
  77795. */
  77796. url: string;
  77797. /**
  77798. * Defines the desired size (the more it increases the longer the generation will be)
  77799. */
  77800. size: number;
  77801. /**
  77802. * Defines if mipmaps should not be generated (default is false)
  77803. */
  77804. noMipmap: boolean;
  77805. /**
  77806. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77807. */
  77808. generateHarmonics: boolean;
  77809. /**
  77810. * 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)
  77811. */
  77812. gammaSpace: boolean;
  77813. /**
  77814. * Internal Use Only
  77815. */
  77816. reserved: boolean;
  77817. /**
  77818. * Gets the loaded texture
  77819. */
  77820. texture: HDRCubeTexture;
  77821. /**
  77822. * Callback called when the task is successful
  77823. */
  77824. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77825. /**
  77826. * Callback called when the task is successful
  77827. */
  77828. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77829. /**
  77830. * Creates a new HDRCubeTextureAssetTask object
  77831. * @param name defines the name of the task
  77832. * @param url defines the location of the file to load
  77833. * @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.
  77834. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77835. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77836. * @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)
  77837. * @param reserved Internal use only
  77838. */
  77839. constructor(
  77840. /**
  77841. * Defines the name of the task
  77842. */
  77843. name: string,
  77844. /**
  77845. * Defines the location of the file to load
  77846. */
  77847. url: string,
  77848. /**
  77849. * Defines the desired size (the more it increases the longer the generation will be)
  77850. */
  77851. size: number,
  77852. /**
  77853. * Defines if mipmaps should not be generated (default is false)
  77854. */
  77855. noMipmap?: boolean,
  77856. /**
  77857. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77858. */
  77859. generateHarmonics?: boolean,
  77860. /**
  77861. * 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)
  77862. */
  77863. gammaSpace?: boolean,
  77864. /**
  77865. * Internal Use Only
  77866. */
  77867. reserved?: boolean);
  77868. /**
  77869. * Execute the current task
  77870. * @param scene defines the scene where you want your assets to be loaded
  77871. * @param onSuccess is a callback called when the task is successfully executed
  77872. * @param onError is a callback called if an error occurs
  77873. */
  77874. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77875. }
  77876. /**
  77877. * Define a task used by AssetsManager to load Equirectangular cube textures
  77878. */
  77879. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77880. /**
  77881. * Defines the name of the task
  77882. */
  77883. name: string;
  77884. /**
  77885. * Defines the location of the file to load
  77886. */
  77887. url: string;
  77888. /**
  77889. * Defines the desired size (the more it increases the longer the generation will be)
  77890. */
  77891. size: number;
  77892. /**
  77893. * Defines if mipmaps should not be generated (default is false)
  77894. */
  77895. noMipmap: boolean;
  77896. /**
  77897. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77898. * but the standard material would require them in Gamma space) (default is true)
  77899. */
  77900. gammaSpace: boolean;
  77901. /**
  77902. * Gets the loaded texture
  77903. */
  77904. texture: EquiRectangularCubeTexture;
  77905. /**
  77906. * Callback called when the task is successful
  77907. */
  77908. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77909. /**
  77910. * Callback called when the task is successful
  77911. */
  77912. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77913. /**
  77914. * Creates a new EquiRectangularCubeTextureAssetTask object
  77915. * @param name defines the name of the task
  77916. * @param url defines the location of the file to load
  77917. * @param size defines the desired size (the more it increases the longer the generation will be)
  77918. * If the size is omitted this implies you are using a preprocessed cubemap.
  77919. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77920. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77921. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77922. * (default is true)
  77923. */
  77924. constructor(
  77925. /**
  77926. * Defines the name of the task
  77927. */
  77928. name: string,
  77929. /**
  77930. * Defines the location of the file to load
  77931. */
  77932. url: string,
  77933. /**
  77934. * Defines the desired size (the more it increases the longer the generation will be)
  77935. */
  77936. size: number,
  77937. /**
  77938. * Defines if mipmaps should not be generated (default is false)
  77939. */
  77940. noMipmap?: boolean,
  77941. /**
  77942. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77943. * but the standard material would require them in Gamma space) (default is true)
  77944. */
  77945. gammaSpace?: boolean);
  77946. /**
  77947. * Execute the current task
  77948. * @param scene defines the scene where you want your assets to be loaded
  77949. * @param onSuccess is a callback called when the task is successfully executed
  77950. * @param onError is a callback called if an error occurs
  77951. */
  77952. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77953. }
  77954. /**
  77955. * This class can be used to easily import assets into a scene
  77956. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77957. */
  77958. export class AssetsManager {
  77959. private _scene;
  77960. private _isLoading;
  77961. protected _tasks: AbstractAssetTask[];
  77962. protected _waitingTasksCount: number;
  77963. protected _totalTasksCount: number;
  77964. /**
  77965. * Callback called when all tasks are processed
  77966. */
  77967. onFinish: (tasks: AbstractAssetTask[]) => void;
  77968. /**
  77969. * Callback called when a task is successful
  77970. */
  77971. onTaskSuccess: (task: AbstractAssetTask) => void;
  77972. /**
  77973. * Callback called when a task had an error
  77974. */
  77975. onTaskError: (task: AbstractAssetTask) => void;
  77976. /**
  77977. * Callback called when a task is done (whatever the result is)
  77978. */
  77979. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77980. /**
  77981. * Observable called when all tasks are processed
  77982. */
  77983. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77984. /**
  77985. * Observable called when a task had an error
  77986. */
  77987. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77988. /**
  77989. * Observable called when all tasks were executed
  77990. */
  77991. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77992. /**
  77993. * Observable called when a task is done (whatever the result is)
  77994. */
  77995. onProgressObservable: Observable<IAssetsProgressEvent>;
  77996. /**
  77997. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77998. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77999. */
  78000. useDefaultLoadingScreen: boolean;
  78001. /**
  78002. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78003. * when all assets have been downloaded.
  78004. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78005. */
  78006. autoHideLoadingUI: boolean;
  78007. /**
  78008. * Creates a new AssetsManager
  78009. * @param scene defines the scene to work on
  78010. */
  78011. constructor(scene: Scene);
  78012. /**
  78013. * Add a ContainerAssetTask to the list of active tasks
  78014. * @param taskName defines the name of the new task
  78015. * @param meshesNames defines the name of meshes to load
  78016. * @param rootUrl defines the root url to use to locate files
  78017. * @param sceneFilename defines the filename of the scene file
  78018. * @returns a new ContainerAssetTask object
  78019. */
  78020. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78021. /**
  78022. * Add a MeshAssetTask to the list of active tasks
  78023. * @param taskName defines the name of the new task
  78024. * @param meshesNames defines the name of meshes to load
  78025. * @param rootUrl defines the root url to use to locate files
  78026. * @param sceneFilename defines the filename of the scene file
  78027. * @returns a new MeshAssetTask object
  78028. */
  78029. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78030. /**
  78031. * Add a TextFileAssetTask to the list of active tasks
  78032. * @param taskName defines the name of the new task
  78033. * @param url defines the url of the file to load
  78034. * @returns a new TextFileAssetTask object
  78035. */
  78036. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78037. /**
  78038. * Add a BinaryFileAssetTask to the list of active tasks
  78039. * @param taskName defines the name of the new task
  78040. * @param url defines the url of the file to load
  78041. * @returns a new BinaryFileAssetTask object
  78042. */
  78043. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78044. /**
  78045. * Add a ImageAssetTask to the list of active tasks
  78046. * @param taskName defines the name of the new task
  78047. * @param url defines the url of the file to load
  78048. * @returns a new ImageAssetTask object
  78049. */
  78050. addImageTask(taskName: string, url: string): ImageAssetTask;
  78051. /**
  78052. * Add a TextureAssetTask to the list of active tasks
  78053. * @param taskName defines the name of the new task
  78054. * @param url defines the url of the file to load
  78055. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78056. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78057. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78058. * @returns a new TextureAssetTask object
  78059. */
  78060. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78061. /**
  78062. * Add a CubeTextureAssetTask to the list of active tasks
  78063. * @param taskName defines the name of the new task
  78064. * @param url defines the url of the file to load
  78065. * @param extensions defines the extension to use to load the cube map (can be null)
  78066. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78067. * @param files defines the list of files to load (can be null)
  78068. * @returns a new CubeTextureAssetTask object
  78069. */
  78070. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78071. /**
  78072. *
  78073. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78074. * @param taskName defines the name of the new task
  78075. * @param url defines the url of the file to load
  78076. * @param size defines the size you want for the cubemap (can be null)
  78077. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78078. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78079. * @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)
  78080. * @param reserved Internal use only
  78081. * @returns a new HDRCubeTextureAssetTask object
  78082. */
  78083. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78084. /**
  78085. *
  78086. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78087. * @param taskName defines the name of the new task
  78088. * @param url defines the url of the file to load
  78089. * @param size defines the size you want for the cubemap (can be null)
  78090. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78091. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78092. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78093. * @returns a new EquiRectangularCubeTextureAssetTask object
  78094. */
  78095. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78096. /**
  78097. * Remove a task from the assets manager.
  78098. * @param task the task to remove
  78099. */
  78100. removeTask(task: AbstractAssetTask): void;
  78101. private _decreaseWaitingTasksCount;
  78102. private _runTask;
  78103. /**
  78104. * Reset the AssetsManager and remove all tasks
  78105. * @return the current instance of the AssetsManager
  78106. */
  78107. reset(): AssetsManager;
  78108. /**
  78109. * Start the loading process
  78110. * @return the current instance of the AssetsManager
  78111. */
  78112. load(): AssetsManager;
  78113. /**
  78114. * Start the loading process as an async operation
  78115. * @return a promise returning the list of failed tasks
  78116. */
  78117. loadAsync(): Promise<void>;
  78118. }
  78119. }
  78120. declare module "babylonjs/Misc/deferred" {
  78121. /**
  78122. * Wrapper class for promise with external resolve and reject.
  78123. */
  78124. export class Deferred<T> {
  78125. /**
  78126. * The promise associated with this deferred object.
  78127. */
  78128. readonly promise: Promise<T>;
  78129. private _resolve;
  78130. private _reject;
  78131. /**
  78132. * The resolve method of the promise associated with this deferred object.
  78133. */
  78134. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  78135. /**
  78136. * The reject method of the promise associated with this deferred object.
  78137. */
  78138. get reject(): (reason?: any) => void;
  78139. /**
  78140. * Constructor for this deferred object.
  78141. */
  78142. constructor();
  78143. }
  78144. }
  78145. declare module "babylonjs/Misc/meshExploder" {
  78146. import { Mesh } from "babylonjs/Meshes/mesh";
  78147. /**
  78148. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78149. */
  78150. export class MeshExploder {
  78151. private _centerMesh;
  78152. private _meshes;
  78153. private _meshesOrigins;
  78154. private _toCenterVectors;
  78155. private _scaledDirection;
  78156. private _newPosition;
  78157. private _centerPosition;
  78158. /**
  78159. * Explodes meshes from a center mesh.
  78160. * @param meshes The meshes to explode.
  78161. * @param centerMesh The mesh to be center of explosion.
  78162. */
  78163. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78164. private _setCenterMesh;
  78165. /**
  78166. * Get class name
  78167. * @returns "MeshExploder"
  78168. */
  78169. getClassName(): string;
  78170. /**
  78171. * "Exploded meshes"
  78172. * @returns Array of meshes with the centerMesh at index 0.
  78173. */
  78174. getMeshes(): Array<Mesh>;
  78175. /**
  78176. * Explodes meshes giving a specific direction
  78177. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78178. */
  78179. explode(direction?: number): void;
  78180. }
  78181. }
  78182. declare module "babylonjs/Misc/filesInput" {
  78183. import { Engine } from "babylonjs/Engines/engine";
  78184. import { Scene } from "babylonjs/scene";
  78185. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  78186. import { Nullable } from "babylonjs/types";
  78187. /**
  78188. * Class used to help managing file picking and drag'n'drop
  78189. */
  78190. export class FilesInput {
  78191. /**
  78192. * List of files ready to be loaded
  78193. */
  78194. static get FilesToLoad(): {
  78195. [key: string]: File;
  78196. };
  78197. /**
  78198. * Callback called when a file is processed
  78199. */
  78200. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  78201. private _engine;
  78202. private _currentScene;
  78203. private _sceneLoadedCallback;
  78204. private _progressCallback;
  78205. private _additionalRenderLoopLogicCallback;
  78206. private _textureLoadingCallback;
  78207. private _startingProcessingFilesCallback;
  78208. private _onReloadCallback;
  78209. private _errorCallback;
  78210. private _elementToMonitor;
  78211. private _sceneFileToLoad;
  78212. private _filesToLoad;
  78213. /**
  78214. * Creates a new FilesInput
  78215. * @param engine defines the rendering engine
  78216. * @param scene defines the hosting scene
  78217. * @param sceneLoadedCallback callback called when scene is loaded
  78218. * @param progressCallback callback called to track progress
  78219. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78220. * @param textureLoadingCallback callback called when a texture is loading
  78221. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78222. * @param onReloadCallback callback called when a reload is requested
  78223. * @param errorCallback callback call if an error occurs
  78224. */
  78225. 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>);
  78226. private _dragEnterHandler;
  78227. private _dragOverHandler;
  78228. private _dropHandler;
  78229. /**
  78230. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78231. * @param elementToMonitor defines the DOM element to track
  78232. */
  78233. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78234. /** Gets the current list of files to load */
  78235. get filesToLoad(): File[];
  78236. /**
  78237. * Release all associated resources
  78238. */
  78239. dispose(): void;
  78240. private renderFunction;
  78241. private drag;
  78242. private drop;
  78243. private _traverseFolder;
  78244. private _processFiles;
  78245. /**
  78246. * Load files from a drop event
  78247. * @param event defines the drop event to use as source
  78248. */
  78249. loadFiles(event: any): void;
  78250. private _processReload;
  78251. /**
  78252. * Reload the current scene from the loaded files
  78253. */
  78254. reload(): void;
  78255. }
  78256. }
  78257. declare module "babylonjs/Misc/HighDynamicRange/index" {
  78258. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  78259. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  78260. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  78261. }
  78262. declare module "babylonjs/Misc/sceneOptimizer" {
  78263. import { Scene, IDisposable } from "babylonjs/scene";
  78264. import { Observable } from "babylonjs/Misc/observable";
  78265. /**
  78266. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78267. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78268. */
  78269. export class SceneOptimization {
  78270. /**
  78271. * Defines the priority of this optimization (0 by default which means first in the list)
  78272. */
  78273. priority: number;
  78274. /**
  78275. * Gets a string describing the action executed by the current optimization
  78276. * @returns description string
  78277. */
  78278. getDescription(): string;
  78279. /**
  78280. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78281. * @param scene defines the current scene where to apply this optimization
  78282. * @param optimizer defines the current optimizer
  78283. * @returns true if everything that can be done was applied
  78284. */
  78285. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78286. /**
  78287. * Creates the SceneOptimization object
  78288. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78289. * @param desc defines the description associated with the optimization
  78290. */
  78291. constructor(
  78292. /**
  78293. * Defines the priority of this optimization (0 by default which means first in the list)
  78294. */
  78295. priority?: number);
  78296. }
  78297. /**
  78298. * Defines an optimization used to reduce the size of render target textures
  78299. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78300. */
  78301. export class TextureOptimization extends SceneOptimization {
  78302. /**
  78303. * Defines the priority of this optimization (0 by default which means first in the list)
  78304. */
  78305. priority: number;
  78306. /**
  78307. * 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
  78308. */
  78309. maximumSize: number;
  78310. /**
  78311. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78312. */
  78313. step: number;
  78314. /**
  78315. * Gets a string describing the action executed by the current optimization
  78316. * @returns description string
  78317. */
  78318. getDescription(): string;
  78319. /**
  78320. * Creates the TextureOptimization object
  78321. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78322. * @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
  78323. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78324. */
  78325. constructor(
  78326. /**
  78327. * Defines the priority of this optimization (0 by default which means first in the list)
  78328. */
  78329. priority?: number,
  78330. /**
  78331. * 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
  78332. */
  78333. maximumSize?: number,
  78334. /**
  78335. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78336. */
  78337. step?: number);
  78338. /**
  78339. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78340. * @param scene defines the current scene where to apply this optimization
  78341. * @param optimizer defines the current optimizer
  78342. * @returns true if everything that can be done was applied
  78343. */
  78344. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78345. }
  78346. /**
  78347. * Defines an optimization used to increase or decrease the rendering resolution
  78348. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78349. */
  78350. export class HardwareScalingOptimization extends SceneOptimization {
  78351. /**
  78352. * Defines the priority of this optimization (0 by default which means first in the list)
  78353. */
  78354. priority: number;
  78355. /**
  78356. * Defines the maximum scale to use (2 by default)
  78357. */
  78358. maximumScale: number;
  78359. /**
  78360. * Defines the step to use between two passes (0.5 by default)
  78361. */
  78362. step: number;
  78363. private _currentScale;
  78364. private _directionOffset;
  78365. /**
  78366. * Gets a string describing the action executed by the current optimization
  78367. * @return description string
  78368. */
  78369. getDescription(): string;
  78370. /**
  78371. * Creates the HardwareScalingOptimization object
  78372. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78373. * @param maximumScale defines the maximum scale to use (2 by default)
  78374. * @param step defines the step to use between two passes (0.5 by default)
  78375. */
  78376. constructor(
  78377. /**
  78378. * Defines the priority of this optimization (0 by default which means first in the list)
  78379. */
  78380. priority?: number,
  78381. /**
  78382. * Defines the maximum scale to use (2 by default)
  78383. */
  78384. maximumScale?: number,
  78385. /**
  78386. * Defines the step to use between two passes (0.5 by default)
  78387. */
  78388. step?: number);
  78389. /**
  78390. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78391. * @param scene defines the current scene where to apply this optimization
  78392. * @param optimizer defines the current optimizer
  78393. * @returns true if everything that can be done was applied
  78394. */
  78395. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78396. }
  78397. /**
  78398. * Defines an optimization used to remove shadows
  78399. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78400. */
  78401. export class ShadowsOptimization extends SceneOptimization {
  78402. /**
  78403. * Gets a string describing the action executed by the current optimization
  78404. * @return description string
  78405. */
  78406. getDescription(): string;
  78407. /**
  78408. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78409. * @param scene defines the current scene where to apply this optimization
  78410. * @param optimizer defines the current optimizer
  78411. * @returns true if everything that can be done was applied
  78412. */
  78413. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78414. }
  78415. /**
  78416. * Defines an optimization used to turn post-processes off
  78417. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78418. */
  78419. export class PostProcessesOptimization extends SceneOptimization {
  78420. /**
  78421. * Gets a string describing the action executed by the current optimization
  78422. * @return description string
  78423. */
  78424. getDescription(): string;
  78425. /**
  78426. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78427. * @param scene defines the current scene where to apply this optimization
  78428. * @param optimizer defines the current optimizer
  78429. * @returns true if everything that can be done was applied
  78430. */
  78431. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78432. }
  78433. /**
  78434. * Defines an optimization used to turn lens flares off
  78435. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78436. */
  78437. export class LensFlaresOptimization extends SceneOptimization {
  78438. /**
  78439. * Gets a string describing the action executed by the current optimization
  78440. * @return description string
  78441. */
  78442. getDescription(): string;
  78443. /**
  78444. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78445. * @param scene defines the current scene where to apply this optimization
  78446. * @param optimizer defines the current optimizer
  78447. * @returns true if everything that can be done was applied
  78448. */
  78449. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78450. }
  78451. /**
  78452. * Defines an optimization based on user defined callback.
  78453. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78454. */
  78455. export class CustomOptimization extends SceneOptimization {
  78456. /**
  78457. * Callback called to apply the custom optimization.
  78458. */
  78459. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78460. /**
  78461. * Callback called to get custom description
  78462. */
  78463. onGetDescription: () => string;
  78464. /**
  78465. * Gets a string describing the action executed by the current optimization
  78466. * @returns description string
  78467. */
  78468. getDescription(): string;
  78469. /**
  78470. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78471. * @param scene defines the current scene where to apply this optimization
  78472. * @param optimizer defines the current optimizer
  78473. * @returns true if everything that can be done was applied
  78474. */
  78475. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78476. }
  78477. /**
  78478. * Defines an optimization used to turn particles off
  78479. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78480. */
  78481. export class ParticlesOptimization extends SceneOptimization {
  78482. /**
  78483. * Gets a string describing the action executed by the current optimization
  78484. * @return description string
  78485. */
  78486. getDescription(): string;
  78487. /**
  78488. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78489. * @param scene defines the current scene where to apply this optimization
  78490. * @param optimizer defines the current optimizer
  78491. * @returns true if everything that can be done was applied
  78492. */
  78493. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78494. }
  78495. /**
  78496. * Defines an optimization used to turn render targets off
  78497. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78498. */
  78499. export class RenderTargetsOptimization extends SceneOptimization {
  78500. /**
  78501. * Gets a string describing the action executed by the current optimization
  78502. * @return description string
  78503. */
  78504. getDescription(): string;
  78505. /**
  78506. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78507. * @param scene defines the current scene where to apply this optimization
  78508. * @param optimizer defines the current optimizer
  78509. * @returns true if everything that can be done was applied
  78510. */
  78511. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78512. }
  78513. /**
  78514. * Defines an optimization used to merge meshes with compatible materials
  78515. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78516. */
  78517. export class MergeMeshesOptimization extends SceneOptimization {
  78518. private static _UpdateSelectionTree;
  78519. /**
  78520. * Gets or sets a boolean which defines if optimization octree has to be updated
  78521. */
  78522. static get UpdateSelectionTree(): boolean;
  78523. /**
  78524. * Gets or sets a boolean which defines if optimization octree has to be updated
  78525. */
  78526. static set UpdateSelectionTree(value: boolean);
  78527. /**
  78528. * Gets a string describing the action executed by the current optimization
  78529. * @return description string
  78530. */
  78531. getDescription(): string;
  78532. private _canBeMerged;
  78533. /**
  78534. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78535. * @param scene defines the current scene where to apply this optimization
  78536. * @param optimizer defines the current optimizer
  78537. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78538. * @returns true if everything that can be done was applied
  78539. */
  78540. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78541. }
  78542. /**
  78543. * Defines a list of options used by SceneOptimizer
  78544. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78545. */
  78546. export class SceneOptimizerOptions {
  78547. /**
  78548. * Defines the target frame rate to reach (60 by default)
  78549. */
  78550. targetFrameRate: number;
  78551. /**
  78552. * Defines the interval between two checkes (2000ms by default)
  78553. */
  78554. trackerDuration: number;
  78555. /**
  78556. * Gets the list of optimizations to apply
  78557. */
  78558. optimizations: SceneOptimization[];
  78559. /**
  78560. * Creates a new list of options used by SceneOptimizer
  78561. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78562. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78563. */
  78564. constructor(
  78565. /**
  78566. * Defines the target frame rate to reach (60 by default)
  78567. */
  78568. targetFrameRate?: number,
  78569. /**
  78570. * Defines the interval between two checkes (2000ms by default)
  78571. */
  78572. trackerDuration?: number);
  78573. /**
  78574. * Add a new optimization
  78575. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78576. * @returns the current SceneOptimizerOptions
  78577. */
  78578. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78579. /**
  78580. * Add a new custom optimization
  78581. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78582. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78583. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78584. * @returns the current SceneOptimizerOptions
  78585. */
  78586. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78587. /**
  78588. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78589. * @param targetFrameRate defines the target frame rate (60 by default)
  78590. * @returns a SceneOptimizerOptions object
  78591. */
  78592. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78593. /**
  78594. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78595. * @param targetFrameRate defines the target frame rate (60 by default)
  78596. * @returns a SceneOptimizerOptions object
  78597. */
  78598. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78599. /**
  78600. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78601. * @param targetFrameRate defines the target frame rate (60 by default)
  78602. * @returns a SceneOptimizerOptions object
  78603. */
  78604. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78605. }
  78606. /**
  78607. * Class used to run optimizations in order to reach a target frame rate
  78608. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78609. */
  78610. export class SceneOptimizer implements IDisposable {
  78611. private _isRunning;
  78612. private _options;
  78613. private _scene;
  78614. private _currentPriorityLevel;
  78615. private _targetFrameRate;
  78616. private _trackerDuration;
  78617. private _currentFrameRate;
  78618. private _sceneDisposeObserver;
  78619. private _improvementMode;
  78620. /**
  78621. * Defines an observable called when the optimizer reaches the target frame rate
  78622. */
  78623. onSuccessObservable: Observable<SceneOptimizer>;
  78624. /**
  78625. * Defines an observable called when the optimizer enables an optimization
  78626. */
  78627. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78628. /**
  78629. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78630. */
  78631. onFailureObservable: Observable<SceneOptimizer>;
  78632. /**
  78633. * Gets a boolean indicating if the optimizer is in improvement mode
  78634. */
  78635. get isInImprovementMode(): boolean;
  78636. /**
  78637. * Gets the current priority level (0 at start)
  78638. */
  78639. get currentPriorityLevel(): number;
  78640. /**
  78641. * Gets the current frame rate checked by the SceneOptimizer
  78642. */
  78643. get currentFrameRate(): number;
  78644. /**
  78645. * Gets or sets the current target frame rate (60 by default)
  78646. */
  78647. get targetFrameRate(): number;
  78648. /**
  78649. * Gets or sets the current target frame rate (60 by default)
  78650. */
  78651. set targetFrameRate(value: number);
  78652. /**
  78653. * Gets or sets the current interval between two checks (every 2000ms by default)
  78654. */
  78655. get trackerDuration(): number;
  78656. /**
  78657. * Gets or sets the current interval between two checks (every 2000ms by default)
  78658. */
  78659. set trackerDuration(value: number);
  78660. /**
  78661. * Gets the list of active optimizations
  78662. */
  78663. get optimizations(): SceneOptimization[];
  78664. /**
  78665. * Creates a new SceneOptimizer
  78666. * @param scene defines the scene to work on
  78667. * @param options defines the options to use with the SceneOptimizer
  78668. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78669. * @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)
  78670. */
  78671. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78672. /**
  78673. * Stops the current optimizer
  78674. */
  78675. stop(): void;
  78676. /**
  78677. * Reset the optimizer to initial step (current priority level = 0)
  78678. */
  78679. reset(): void;
  78680. /**
  78681. * Start the optimizer. By default it will try to reach a specific framerate
  78682. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78683. */
  78684. start(): void;
  78685. private _checkCurrentState;
  78686. /**
  78687. * Release all resources
  78688. */
  78689. dispose(): void;
  78690. /**
  78691. * Helper function to create a SceneOptimizer with one single line of code
  78692. * @param scene defines the scene to work on
  78693. * @param options defines the options to use with the SceneOptimizer
  78694. * @param onSuccess defines a callback to call on success
  78695. * @param onFailure defines a callback to call on failure
  78696. * @returns the new SceneOptimizer object
  78697. */
  78698. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78699. }
  78700. }
  78701. declare module "babylonjs/Misc/sceneSerializer" {
  78702. import { Scene } from "babylonjs/scene";
  78703. /**
  78704. * Class used to serialize a scene into a string
  78705. */
  78706. export class SceneSerializer {
  78707. /**
  78708. * Clear cache used by a previous serialization
  78709. */
  78710. static ClearCache(): void;
  78711. /**
  78712. * Serialize a scene into a JSON compatible object
  78713. * @param scene defines the scene to serialize
  78714. * @returns a JSON compatible object
  78715. */
  78716. static Serialize(scene: Scene): any;
  78717. /**
  78718. * Serialize a mesh into a JSON compatible object
  78719. * @param toSerialize defines the mesh to serialize
  78720. * @param withParents defines if parents must be serialized as well
  78721. * @param withChildren defines if children must be serialized as well
  78722. * @returns a JSON compatible object
  78723. */
  78724. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78725. }
  78726. }
  78727. declare module "babylonjs/Misc/textureTools" {
  78728. import { Texture } from "babylonjs/Materials/Textures/texture";
  78729. /**
  78730. * Class used to host texture specific utilities
  78731. */
  78732. export class TextureTools {
  78733. /**
  78734. * Uses the GPU to create a copy texture rescaled at a given size
  78735. * @param texture Texture to copy from
  78736. * @param width defines the desired width
  78737. * @param height defines the desired height
  78738. * @param useBilinearMode defines if bilinear mode has to be used
  78739. * @return the generated texture
  78740. */
  78741. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78742. }
  78743. }
  78744. declare module "babylonjs/Misc/videoRecorder" {
  78745. import { Nullable } from "babylonjs/types";
  78746. import { Engine } from "babylonjs/Engines/engine";
  78747. /**
  78748. * This represents the different options available for the video capture.
  78749. */
  78750. export interface VideoRecorderOptions {
  78751. /** Defines the mime type of the video. */
  78752. mimeType: string;
  78753. /** Defines the FPS the video should be recorded at. */
  78754. fps: number;
  78755. /** Defines the chunk size for the recording data. */
  78756. recordChunckSize: number;
  78757. /** The audio tracks to attach to the recording. */
  78758. audioTracks?: MediaStreamTrack[];
  78759. }
  78760. /**
  78761. * This can help with recording videos from BabylonJS.
  78762. * This is based on the available WebRTC functionalities of the browser.
  78763. *
  78764. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78765. */
  78766. export class VideoRecorder {
  78767. private static readonly _defaultOptions;
  78768. /**
  78769. * Returns whether or not the VideoRecorder is available in your browser.
  78770. * @param engine Defines the Babylon Engine.
  78771. * @returns true if supported otherwise false.
  78772. */
  78773. static IsSupported(engine: Engine): boolean;
  78774. private readonly _options;
  78775. private _canvas;
  78776. private _mediaRecorder;
  78777. private _recordedChunks;
  78778. private _fileName;
  78779. private _resolve;
  78780. private _reject;
  78781. /**
  78782. * True when a recording is already in progress.
  78783. */
  78784. get isRecording(): boolean;
  78785. /**
  78786. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78787. * @param engine Defines the BabylonJS Engine you wish to record.
  78788. * @param options Defines options that can be used to customize the capture.
  78789. */
  78790. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78791. /**
  78792. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78793. */
  78794. stopRecording(): void;
  78795. /**
  78796. * Starts recording the canvas for a max duration specified in parameters.
  78797. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78798. * If null no automatic download will start and you can rely on the promise to get the data back.
  78799. * @param maxDuration Defines the maximum recording time in seconds.
  78800. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78801. * @return A promise callback at the end of the recording with the video data in Blob.
  78802. */
  78803. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78804. /**
  78805. * Releases internal resources used during the recording.
  78806. */
  78807. dispose(): void;
  78808. private _handleDataAvailable;
  78809. private _handleError;
  78810. private _handleStop;
  78811. }
  78812. }
  78813. declare module "babylonjs/Misc/screenshotTools" {
  78814. import { Camera } from "babylonjs/Cameras/camera";
  78815. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78816. import { Engine } from "babylonjs/Engines/engine";
  78817. /**
  78818. * Class containing a set of static utilities functions for screenshots
  78819. */
  78820. export class ScreenshotTools {
  78821. /**
  78822. * Captures a screenshot of the current rendering
  78823. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78824. * @param engine defines the rendering engine
  78825. * @param camera defines the source camera
  78826. * @param size This parameter can be set to a single number or to an object with the
  78827. * following (optional) properties: precision, width, height. If a single number is passed,
  78828. * it will be used for both width and height. If an object is passed, the screenshot size
  78829. * will be derived from the parameters. The precision property is a multiplier allowing
  78830. * rendering at a higher or lower resolution
  78831. * @param successCallback defines the callback receives a single parameter which contains the
  78832. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78833. * src parameter of an <img> to display it
  78834. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78835. * Check your browser for supported MIME types
  78836. */
  78837. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78838. /**
  78839. * Captures a screenshot of the current rendering
  78840. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78841. * @param engine defines the rendering engine
  78842. * @param camera defines the source camera
  78843. * @param size This parameter can be set to a single number or to an object with the
  78844. * following (optional) properties: precision, width, height. If a single number is passed,
  78845. * it will be used for both width and height. If an object is passed, the screenshot size
  78846. * will be derived from the parameters. The precision property is a multiplier allowing
  78847. * rendering at a higher or lower resolution
  78848. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78849. * Check your browser for supported MIME types
  78850. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78851. * to the src parameter of an <img> to display it
  78852. */
  78853. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78854. /**
  78855. * Generates an image screenshot from the specified camera.
  78856. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78857. * @param engine The engine to use for rendering
  78858. * @param camera The camera to use for rendering
  78859. * @param size This parameter can be set to a single number or to an object with the
  78860. * following (optional) properties: precision, width, height. If a single number is passed,
  78861. * it will be used for both width and height. If an object is passed, the screenshot size
  78862. * will be derived from the parameters. The precision property is a multiplier allowing
  78863. * rendering at a higher or lower resolution
  78864. * @param successCallback The callback receives a single parameter which contains the
  78865. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78866. * src parameter of an <img> to display it
  78867. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78868. * Check your browser for supported MIME types
  78869. * @param samples Texture samples (default: 1)
  78870. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78871. * @param fileName A name for for the downloaded file.
  78872. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78873. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78874. */
  78875. 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;
  78876. /**
  78877. * Generates an image screenshot from the specified camera.
  78878. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78879. * @param engine The engine to use for rendering
  78880. * @param camera The camera to use for rendering
  78881. * @param size This parameter can be set to a single number or to an object with the
  78882. * following (optional) properties: precision, width, height. If a single number is passed,
  78883. * it will be used for both width and height. If an object is passed, the screenshot size
  78884. * will be derived from the parameters. The precision property is a multiplier allowing
  78885. * rendering at a higher or lower resolution
  78886. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78887. * Check your browser for supported MIME types
  78888. * @param samples Texture samples (default: 1)
  78889. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78890. * @param fileName A name for for the downloaded file.
  78891. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78892. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78893. * to the src parameter of an <img> to display it
  78894. */
  78895. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78896. /**
  78897. * Gets height and width for screenshot size
  78898. * @private
  78899. */
  78900. private static _getScreenshotSize;
  78901. }
  78902. }
  78903. declare module "babylonjs/Misc/dataReader" {
  78904. /**
  78905. * Interface for a data buffer
  78906. */
  78907. export interface IDataBuffer {
  78908. /**
  78909. * Reads bytes from the data buffer.
  78910. * @param byteOffset The byte offset to read
  78911. * @param byteLength The byte length to read
  78912. * @returns A promise that resolves when the bytes are read
  78913. */
  78914. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78915. /**
  78916. * The byte length of the buffer.
  78917. */
  78918. readonly byteLength: number;
  78919. }
  78920. /**
  78921. * Utility class for reading from a data buffer
  78922. */
  78923. export class DataReader {
  78924. /**
  78925. * The data buffer associated with this data reader.
  78926. */
  78927. readonly buffer: IDataBuffer;
  78928. /**
  78929. * The current byte offset from the beginning of the data buffer.
  78930. */
  78931. byteOffset: number;
  78932. private _dataView;
  78933. private _dataByteOffset;
  78934. /**
  78935. * Constructor
  78936. * @param buffer The buffer to read
  78937. */
  78938. constructor(buffer: IDataBuffer);
  78939. /**
  78940. * Loads the given byte length.
  78941. * @param byteLength The byte length to load
  78942. * @returns A promise that resolves when the load is complete
  78943. */
  78944. loadAsync(byteLength: number): Promise<void>;
  78945. /**
  78946. * Read a unsigned 32-bit integer from the currently loaded data range.
  78947. * @returns The 32-bit integer read
  78948. */
  78949. readUint32(): number;
  78950. /**
  78951. * Read a byte array from the currently loaded data range.
  78952. * @param byteLength The byte length to read
  78953. * @returns The byte array read
  78954. */
  78955. readUint8Array(byteLength: number): Uint8Array;
  78956. /**
  78957. * Read a string from the currently loaded data range.
  78958. * @param byteLength The byte length to read
  78959. * @returns The string read
  78960. */
  78961. readString(byteLength: number): string;
  78962. /**
  78963. * Skips the given byte length the currently loaded data range.
  78964. * @param byteLength The byte length to skip
  78965. */
  78966. skipBytes(byteLength: number): void;
  78967. }
  78968. }
  78969. declare module "babylonjs/Misc/dataStorage" {
  78970. /**
  78971. * Class for storing data to local storage if available or in-memory storage otherwise
  78972. */
  78973. export class DataStorage {
  78974. private static _Storage;
  78975. private static _GetStorage;
  78976. /**
  78977. * Reads a string from the data storage
  78978. * @param key The key to read
  78979. * @param defaultValue The value if the key doesn't exist
  78980. * @returns The string value
  78981. */
  78982. static ReadString(key: string, defaultValue: string): string;
  78983. /**
  78984. * Writes a string to the data storage
  78985. * @param key The key to write
  78986. * @param value The value to write
  78987. */
  78988. static WriteString(key: string, value: string): void;
  78989. /**
  78990. * Reads a boolean from the data storage
  78991. * @param key The key to read
  78992. * @param defaultValue The value if the key doesn't exist
  78993. * @returns The boolean value
  78994. */
  78995. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78996. /**
  78997. * Writes a boolean to the data storage
  78998. * @param key The key to write
  78999. * @param value The value to write
  79000. */
  79001. static WriteBoolean(key: string, value: boolean): void;
  79002. /**
  79003. * Reads a number from the data storage
  79004. * @param key The key to read
  79005. * @param defaultValue The value if the key doesn't exist
  79006. * @returns The number value
  79007. */
  79008. static ReadNumber(key: string, defaultValue: number): number;
  79009. /**
  79010. * Writes a number to the data storage
  79011. * @param key The key to write
  79012. * @param value The value to write
  79013. */
  79014. static WriteNumber(key: string, value: number): void;
  79015. }
  79016. }
  79017. declare module "babylonjs/Misc/sceneRecorder" {
  79018. import { Scene } from "babylonjs/scene";
  79019. /**
  79020. * Class used to record delta files between 2 scene states
  79021. */
  79022. export class SceneRecorder {
  79023. private _trackedScene;
  79024. private _savedJSON;
  79025. /**
  79026. * Track a given scene. This means the current scene state will be considered the original state
  79027. * @param scene defines the scene to track
  79028. */
  79029. track(scene: Scene): void;
  79030. /**
  79031. * Get the delta between current state and original state
  79032. * @returns a string containing the delta
  79033. */
  79034. getDelta(): any;
  79035. private _compareArray;
  79036. private _compareObjects;
  79037. private _compareCollections;
  79038. private static GetShadowGeneratorById;
  79039. /**
  79040. * Apply a given delta to a given scene
  79041. * @param deltaJSON defines the JSON containing the delta
  79042. * @param scene defines the scene to apply the delta to
  79043. */
  79044. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79045. private static _ApplyPropertiesToEntity;
  79046. private static _ApplyDeltaForEntity;
  79047. }
  79048. }
  79049. declare module "babylonjs/Misc/trajectoryClassifier" {
  79050. import { DeepImmutable, Nullable } from "babylonjs/types";
  79051. import { Vector3 } from "babylonjs/Maths/math.vector";
  79052. /**
  79053. * A 3D trajectory consisting of an order list of vectors describing a
  79054. * path of motion through 3D space.
  79055. */
  79056. export class Trajectory {
  79057. private _points;
  79058. private readonly _segmentLength;
  79059. /**
  79060. * Serialize to JSON.
  79061. * @returns serialized JSON string
  79062. */
  79063. serialize(): string;
  79064. /**
  79065. * Deserialize from JSON.
  79066. * @param json serialized JSON string
  79067. * @returns deserialized Trajectory
  79068. */
  79069. static Deserialize(json: string): Trajectory;
  79070. /**
  79071. * Create a new empty Trajectory.
  79072. * @param segmentLength radius of discretization for Trajectory points
  79073. */
  79074. constructor(segmentLength?: number);
  79075. /**
  79076. * Get the length of the Trajectory.
  79077. * @returns length of the Trajectory
  79078. */
  79079. getLength(): number;
  79080. /**
  79081. * Append a new point to the Trajectory.
  79082. * NOTE: This implementation has many allocations.
  79083. * @param point point to append to the Trajectory
  79084. */
  79085. add(point: DeepImmutable<Vector3>): void;
  79086. /**
  79087. * Create a new Trajectory with a segment length chosen to make it
  79088. * probable that the new Trajectory will have a specified number of
  79089. * segments. This operation is imprecise.
  79090. * @param targetResolution number of segments desired
  79091. * @returns new Trajectory with approximately the requested number of segments
  79092. */
  79093. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79094. /**
  79095. * Convert Trajectory segments into tokenized representation. This
  79096. * representation is an array of numbers where each nth number is the
  79097. * index of the token which is most similar to the nth segment of the
  79098. * Trajectory.
  79099. * @param tokens list of vectors which serve as discrete tokens
  79100. * @returns list of indices of most similar token per segment
  79101. */
  79102. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79103. private static _forwardDir;
  79104. private static _inverseFromVec;
  79105. private static _upDir;
  79106. private static _fromToVec;
  79107. private static _lookMatrix;
  79108. /**
  79109. * Transform the rotation (i.e., direction) of a segment to isolate
  79110. * the relative transformation represented by the segment. This operation
  79111. * may or may not succeed due to singularities in the equations that define
  79112. * motion relativity in this context.
  79113. * @param priorVec the origin of the prior segment
  79114. * @param fromVec the origin of the current segment
  79115. * @param toVec the destination of the current segment
  79116. * @param result reference to output variable
  79117. * @returns whether or not transformation was successful
  79118. */
  79119. private static _transformSegmentDirToRef;
  79120. private static _bestMatch;
  79121. private static _score;
  79122. private static _bestScore;
  79123. /**
  79124. * Determine which token vector is most similar to the
  79125. * segment vector.
  79126. * @param segment segment vector
  79127. * @param tokens token vector list
  79128. * @returns index of the most similar token to the segment
  79129. */
  79130. private static _tokenizeSegment;
  79131. }
  79132. /**
  79133. * Class representing a set of known, named trajectories to which Trajectories can be
  79134. * added and using which Trajectories can be recognized.
  79135. */
  79136. export class TrajectoryClassifier {
  79137. private _maximumAllowableMatchCost;
  79138. private _vector3Alphabet;
  79139. private _levenshteinAlphabet;
  79140. private _nameToDescribedTrajectory;
  79141. /**
  79142. * Serialize to JSON.
  79143. * @returns JSON serialization
  79144. */
  79145. serialize(): string;
  79146. /**
  79147. * Deserialize from JSON.
  79148. * @param json JSON serialization
  79149. * @returns deserialized TrajectorySet
  79150. */
  79151. static Deserialize(json: string): TrajectoryClassifier;
  79152. /**
  79153. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79154. * VERY naive, need to be generating these things from known
  79155. * sets. Better version later, probably eliminating this one.
  79156. * @returns auto-generated TrajectorySet
  79157. */
  79158. static Generate(): TrajectoryClassifier;
  79159. private constructor();
  79160. /**
  79161. * Add a new Trajectory to the set with a given name.
  79162. * @param trajectory new Trajectory to be added
  79163. * @param classification name to which to add the Trajectory
  79164. */
  79165. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79166. /**
  79167. * Remove a known named trajectory and all Trajectories associated with it.
  79168. * @param classification name to remove
  79169. * @returns whether anything was removed
  79170. */
  79171. deleteClassification(classification: string): boolean;
  79172. /**
  79173. * Attempt to recognize a Trajectory from among all the classifications
  79174. * already known to the classifier.
  79175. * @param trajectory Trajectory to be recognized
  79176. * @returns classification of Trajectory if recognized, null otherwise
  79177. */
  79178. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79179. }
  79180. }
  79181. declare module "babylonjs/Misc/index" {
  79182. export * from "babylonjs/Misc/andOrNotEvaluator";
  79183. export * from "babylonjs/Misc/assetsManager";
  79184. export * from "babylonjs/Misc/basis";
  79185. export * from "babylonjs/Misc/dds";
  79186. export * from "babylonjs/Misc/decorators";
  79187. export * from "babylonjs/Misc/deferred";
  79188. export * from "babylonjs/Misc/environmentTextureTools";
  79189. export * from "babylonjs/Misc/meshExploder";
  79190. export * from "babylonjs/Misc/filesInput";
  79191. export * from "babylonjs/Misc/HighDynamicRange/index";
  79192. export * from "babylonjs/Misc/khronosTextureContainer";
  79193. export * from "babylonjs/Misc/observable";
  79194. export * from "babylonjs/Misc/performanceMonitor";
  79195. export * from "babylonjs/Misc/promise";
  79196. export * from "babylonjs/Misc/sceneOptimizer";
  79197. export * from "babylonjs/Misc/sceneSerializer";
  79198. export * from "babylonjs/Misc/smartArray";
  79199. export * from "babylonjs/Misc/stringDictionary";
  79200. export * from "babylonjs/Misc/tags";
  79201. export * from "babylonjs/Misc/textureTools";
  79202. export * from "babylonjs/Misc/tga";
  79203. export * from "babylonjs/Misc/tools";
  79204. export * from "babylonjs/Misc/videoRecorder";
  79205. export * from "babylonjs/Misc/virtualJoystick";
  79206. export * from "babylonjs/Misc/workerPool";
  79207. export * from "babylonjs/Misc/logger";
  79208. export * from "babylonjs/Misc/typeStore";
  79209. export * from "babylonjs/Misc/filesInputStore";
  79210. export * from "babylonjs/Misc/deepCopier";
  79211. export * from "babylonjs/Misc/pivotTools";
  79212. export * from "babylonjs/Misc/precisionDate";
  79213. export * from "babylonjs/Misc/screenshotTools";
  79214. export * from "babylonjs/Misc/typeStore";
  79215. export * from "babylonjs/Misc/webRequest";
  79216. export * from "babylonjs/Misc/iInspectable";
  79217. export * from "babylonjs/Misc/brdfTextureTools";
  79218. export * from "babylonjs/Misc/rgbdTextureTools";
  79219. export * from "babylonjs/Misc/gradients";
  79220. export * from "babylonjs/Misc/perfCounter";
  79221. export * from "babylonjs/Misc/fileRequest";
  79222. export * from "babylonjs/Misc/customAnimationFrameRequester";
  79223. export * from "babylonjs/Misc/retryStrategy";
  79224. export * from "babylonjs/Misc/interfaces/screenshotSize";
  79225. export * from "babylonjs/Misc/canvasGenerator";
  79226. export * from "babylonjs/Misc/fileTools";
  79227. export * from "babylonjs/Misc/stringTools";
  79228. export * from "babylonjs/Misc/dataReader";
  79229. export * from "babylonjs/Misc/minMaxReducer";
  79230. export * from "babylonjs/Misc/depthReducer";
  79231. export * from "babylonjs/Misc/dataStorage";
  79232. export * from "babylonjs/Misc/sceneRecorder";
  79233. export * from "babylonjs/Misc/khronosTextureContainer2";
  79234. export * from "babylonjs/Misc/trajectoryClassifier";
  79235. export * from "babylonjs/Misc/timer";
  79236. }
  79237. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  79238. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  79239. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79240. import { Observable } from "babylonjs/Misc/observable";
  79241. import { Matrix } from "babylonjs/Maths/math.vector";
  79242. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79243. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79244. /**
  79245. * An interface for all Hit test features
  79246. */
  79247. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79248. /**
  79249. * Triggered when new babylon (transformed) hit test results are available
  79250. */
  79251. onHitTestResultObservable: Observable<T[]>;
  79252. }
  79253. /**
  79254. * Options used for hit testing
  79255. */
  79256. export interface IWebXRLegacyHitTestOptions {
  79257. /**
  79258. * Only test when user interacted with the scene. Default - hit test every frame
  79259. */
  79260. testOnPointerDownOnly?: boolean;
  79261. /**
  79262. * The node to use to transform the local results to world coordinates
  79263. */
  79264. worldParentNode?: TransformNode;
  79265. }
  79266. /**
  79267. * Interface defining the babylon result of raycasting/hit-test
  79268. */
  79269. export interface IWebXRLegacyHitResult {
  79270. /**
  79271. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79272. */
  79273. transformationMatrix: Matrix;
  79274. /**
  79275. * The native hit test result
  79276. */
  79277. xrHitResult: XRHitResult | XRHitTestResult;
  79278. }
  79279. /**
  79280. * The currently-working hit-test module.
  79281. * Hit test (or Ray-casting) is used to interact with the real world.
  79282. * For further information read here - https://github.com/immersive-web/hit-test
  79283. */
  79284. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79285. /**
  79286. * options to use when constructing this feature
  79287. */
  79288. readonly options: IWebXRLegacyHitTestOptions;
  79289. private _direction;
  79290. private _mat;
  79291. private _onSelectEnabled;
  79292. private _origin;
  79293. /**
  79294. * The module's name
  79295. */
  79296. static readonly Name: string;
  79297. /**
  79298. * The (Babylon) version of this module.
  79299. * This is an integer representing the implementation version.
  79300. * This number does not correspond to the WebXR specs version
  79301. */
  79302. static readonly Version: number;
  79303. /**
  79304. * Populated with the last native XR Hit Results
  79305. */
  79306. lastNativeXRHitResults: XRHitResult[];
  79307. /**
  79308. * Triggered when new babylon (transformed) hit test results are available
  79309. */
  79310. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79311. /**
  79312. * Creates a new instance of the (legacy version) hit test feature
  79313. * @param _xrSessionManager an instance of WebXRSessionManager
  79314. * @param options options to use when constructing this feature
  79315. */
  79316. constructor(_xrSessionManager: WebXRSessionManager,
  79317. /**
  79318. * options to use when constructing this feature
  79319. */
  79320. options?: IWebXRLegacyHitTestOptions);
  79321. /**
  79322. * execute a hit test with an XR Ray
  79323. *
  79324. * @param xrSession a native xrSession that will execute this hit test
  79325. * @param xrRay the ray (position and direction) to use for ray-casting
  79326. * @param referenceSpace native XR reference space to use for the hit-test
  79327. * @param filter filter function that will filter the results
  79328. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79329. */
  79330. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79331. /**
  79332. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79333. * @param event the (select) event to use to select with
  79334. * @param referenceSpace the reference space to use for this hit test
  79335. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79336. */
  79337. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79338. /**
  79339. * attach this feature
  79340. * Will usually be called by the features manager
  79341. *
  79342. * @returns true if successful.
  79343. */
  79344. attach(): boolean;
  79345. /**
  79346. * detach this feature.
  79347. * Will usually be called by the features manager
  79348. *
  79349. * @returns true if successful.
  79350. */
  79351. detach(): boolean;
  79352. /**
  79353. * Dispose this feature and all of the resources attached
  79354. */
  79355. dispose(): void;
  79356. protected _onXRFrame(frame: XRFrame): void;
  79357. private _onHitTestResults;
  79358. private _onSelect;
  79359. }
  79360. }
  79361. declare module "babylonjs/XR/features/WebXRHitTest" {
  79362. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79363. import { Observable } from "babylonjs/Misc/observable";
  79364. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79365. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79366. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79367. /**
  79368. * Options used for hit testing (version 2)
  79369. */
  79370. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79371. /**
  79372. * Do not create a permanent hit test. Will usually be used when only
  79373. * transient inputs are needed.
  79374. */
  79375. disablePermanentHitTest?: boolean;
  79376. /**
  79377. * Enable transient (for example touch-based) hit test inspections
  79378. */
  79379. enableTransientHitTest?: boolean;
  79380. /**
  79381. * Offset ray for the permanent hit test
  79382. */
  79383. offsetRay?: Vector3;
  79384. /**
  79385. * Offset ray for the transient hit test
  79386. */
  79387. transientOffsetRay?: Vector3;
  79388. /**
  79389. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79390. */
  79391. useReferenceSpace?: boolean;
  79392. /**
  79393. * Override the default entity type(s) of the hit-test result
  79394. */
  79395. entityTypes?: XRHitTestTrackableType[];
  79396. }
  79397. /**
  79398. * Interface defining the babylon result of hit-test
  79399. */
  79400. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79401. /**
  79402. * The input source that generated this hit test (if transient)
  79403. */
  79404. inputSource?: XRInputSource;
  79405. /**
  79406. * Is this a transient hit test
  79407. */
  79408. isTransient?: boolean;
  79409. /**
  79410. * Position of the hit test result
  79411. */
  79412. position: Vector3;
  79413. /**
  79414. * Rotation of the hit test result
  79415. */
  79416. rotationQuaternion: Quaternion;
  79417. /**
  79418. * The native hit test result
  79419. */
  79420. xrHitResult: XRHitTestResult;
  79421. }
  79422. /**
  79423. * The currently-working hit-test module.
  79424. * Hit test (or Ray-casting) is used to interact with the real world.
  79425. * For further information read here - https://github.com/immersive-web/hit-test
  79426. *
  79427. * Tested on chrome (mobile) 80.
  79428. */
  79429. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79430. /**
  79431. * options to use when constructing this feature
  79432. */
  79433. readonly options: IWebXRHitTestOptions;
  79434. private _tmpMat;
  79435. private _tmpPos;
  79436. private _tmpQuat;
  79437. private _transientXrHitTestSource;
  79438. private _xrHitTestSource;
  79439. private initHitTestSource;
  79440. /**
  79441. * The module's name
  79442. */
  79443. static readonly Name: string;
  79444. /**
  79445. * The (Babylon) version of this module.
  79446. * This is an integer representing the implementation version.
  79447. * This number does not correspond to the WebXR specs version
  79448. */
  79449. static readonly Version: number;
  79450. /**
  79451. * When set to true, each hit test will have its own position/rotation objects
  79452. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79453. * the developers will clone them or copy them as they see fit.
  79454. */
  79455. autoCloneTransformation: boolean;
  79456. /**
  79457. * Triggered when new babylon (transformed) hit test results are available
  79458. * Note - this will be called when results come back from the device. It can be an empty array!!
  79459. */
  79460. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79461. /**
  79462. * Use this to temporarily pause hit test checks.
  79463. */
  79464. paused: boolean;
  79465. /**
  79466. * Creates a new instance of the hit test feature
  79467. * @param _xrSessionManager an instance of WebXRSessionManager
  79468. * @param options options to use when constructing this feature
  79469. */
  79470. constructor(_xrSessionManager: WebXRSessionManager,
  79471. /**
  79472. * options to use when constructing this feature
  79473. */
  79474. options?: IWebXRHitTestOptions);
  79475. /**
  79476. * attach this feature
  79477. * Will usually be called by the features manager
  79478. *
  79479. * @returns true if successful.
  79480. */
  79481. attach(): boolean;
  79482. /**
  79483. * detach this feature.
  79484. * Will usually be called by the features manager
  79485. *
  79486. * @returns true if successful.
  79487. */
  79488. detach(): boolean;
  79489. /**
  79490. * Dispose this feature and all of the resources attached
  79491. */
  79492. dispose(): void;
  79493. protected _onXRFrame(frame: XRFrame): void;
  79494. private _processWebXRHitTestResult;
  79495. }
  79496. }
  79497. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79498. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79499. import { Observable } from "babylonjs/Misc/observable";
  79500. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79501. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79502. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79503. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79504. /**
  79505. * Configuration options of the anchor system
  79506. */
  79507. export interface IWebXRAnchorSystemOptions {
  79508. /**
  79509. * a node that will be used to convert local to world coordinates
  79510. */
  79511. worldParentNode?: TransformNode;
  79512. /**
  79513. * If set to true a reference of the created anchors will be kept until the next session starts
  79514. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79515. */
  79516. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79517. }
  79518. /**
  79519. * A babylon container for an XR Anchor
  79520. */
  79521. export interface IWebXRAnchor {
  79522. /**
  79523. * A babylon-assigned ID for this anchor
  79524. */
  79525. id: number;
  79526. /**
  79527. * Transformation matrix to apply to an object attached to this anchor
  79528. */
  79529. transformationMatrix: Matrix;
  79530. /**
  79531. * The native anchor object
  79532. */
  79533. xrAnchor: XRAnchor;
  79534. /**
  79535. * if defined, this object will be constantly updated by the anchor's position and rotation
  79536. */
  79537. attachedNode?: TransformNode;
  79538. }
  79539. /**
  79540. * An implementation of the anchor system for WebXR.
  79541. * For further information see https://github.com/immersive-web/anchors/
  79542. */
  79543. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79544. private _options;
  79545. private _lastFrameDetected;
  79546. private _trackedAnchors;
  79547. private _referenceSpaceForFrameAnchors;
  79548. private _futureAnchors;
  79549. /**
  79550. * The module's name
  79551. */
  79552. static readonly Name: string;
  79553. /**
  79554. * The (Babylon) version of this module.
  79555. * This is an integer representing the implementation version.
  79556. * This number does not correspond to the WebXR specs version
  79557. */
  79558. static readonly Version: number;
  79559. /**
  79560. * Observers registered here will be executed when a new anchor was added to the session
  79561. */
  79562. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79563. /**
  79564. * Observers registered here will be executed when an anchor was removed from the session
  79565. */
  79566. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79567. /**
  79568. * Observers registered here will be executed when an existing anchor updates
  79569. * This can execute N times every frame
  79570. */
  79571. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79572. /**
  79573. * Set the reference space to use for anchor creation, when not using a hit test.
  79574. * Will default to the session's reference space if not defined
  79575. */
  79576. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79577. /**
  79578. * constructs a new anchor system
  79579. * @param _xrSessionManager an instance of WebXRSessionManager
  79580. * @param _options configuration object for this feature
  79581. */
  79582. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79583. private _tmpVector;
  79584. private _tmpQuaternion;
  79585. private _populateTmpTransformation;
  79586. /**
  79587. * Create a new anchor point using a hit test result at a specific point in the scene
  79588. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79589. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79590. *
  79591. * @param hitTestResult The hit test result to use for this anchor creation
  79592. * @param position an optional position offset for this anchor
  79593. * @param rotationQuaternion an optional rotation offset for this anchor
  79594. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79595. */
  79596. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79597. /**
  79598. * Add a new anchor at a specific position and rotation
  79599. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79600. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79601. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79602. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79603. *
  79604. * @param position the position in which to add an anchor
  79605. * @param rotationQuaternion an optional rotation for the anchor transformation
  79606. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79607. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79608. */
  79609. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79610. /**
  79611. * detach this feature.
  79612. * Will usually be called by the features manager
  79613. *
  79614. * @returns true if successful.
  79615. */
  79616. detach(): boolean;
  79617. /**
  79618. * Dispose this feature and all of the resources attached
  79619. */
  79620. dispose(): void;
  79621. protected _onXRFrame(frame: XRFrame): void;
  79622. /**
  79623. * avoiding using Array.find for global support.
  79624. * @param xrAnchor the plane to find in the array
  79625. */
  79626. private _findIndexInAnchorArray;
  79627. private _updateAnchorWithXRFrame;
  79628. private _createAnchorAtTransformation;
  79629. }
  79630. }
  79631. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79632. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79633. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79634. import { Observable } from "babylonjs/Misc/observable";
  79635. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79636. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79637. /**
  79638. * Options used in the plane detector module
  79639. */
  79640. export interface IWebXRPlaneDetectorOptions {
  79641. /**
  79642. * The node to use to transform the local results to world coordinates
  79643. */
  79644. worldParentNode?: TransformNode;
  79645. /**
  79646. * If set to true a reference of the created planes will be kept until the next session starts
  79647. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79648. */
  79649. doNotRemovePlanesOnSessionEnded?: boolean;
  79650. }
  79651. /**
  79652. * A babylon interface for a WebXR plane.
  79653. * A Plane is actually a polygon, built from N points in space
  79654. *
  79655. * Supported in chrome 79, not supported in canary 81 ATM
  79656. */
  79657. export interface IWebXRPlane {
  79658. /**
  79659. * a babylon-assigned ID for this polygon
  79660. */
  79661. id: number;
  79662. /**
  79663. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79664. */
  79665. polygonDefinition: Array<Vector3>;
  79666. /**
  79667. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79668. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79669. */
  79670. transformationMatrix: Matrix;
  79671. /**
  79672. * the native xr-plane object
  79673. */
  79674. xrPlane: XRPlane;
  79675. }
  79676. /**
  79677. * The plane detector is used to detect planes in the real world when in AR
  79678. * For more information see https://github.com/immersive-web/real-world-geometry/
  79679. */
  79680. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79681. private _options;
  79682. private _detectedPlanes;
  79683. private _enabled;
  79684. private _lastFrameDetected;
  79685. /**
  79686. * The module's name
  79687. */
  79688. static readonly Name: string;
  79689. /**
  79690. * The (Babylon) version of this module.
  79691. * This is an integer representing the implementation version.
  79692. * This number does not correspond to the WebXR specs version
  79693. */
  79694. static readonly Version: number;
  79695. /**
  79696. * Observers registered here will be executed when a new plane was added to the session
  79697. */
  79698. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79699. /**
  79700. * Observers registered here will be executed when a plane is no longer detected in the session
  79701. */
  79702. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79703. /**
  79704. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79705. * This can execute N times every frame
  79706. */
  79707. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79708. /**
  79709. * construct a new Plane Detector
  79710. * @param _xrSessionManager an instance of xr Session manager
  79711. * @param _options configuration to use when constructing this feature
  79712. */
  79713. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79714. /**
  79715. * detach this feature.
  79716. * Will usually be called by the features manager
  79717. *
  79718. * @returns true if successful.
  79719. */
  79720. detach(): boolean;
  79721. /**
  79722. * Dispose this feature and all of the resources attached
  79723. */
  79724. dispose(): void;
  79725. protected _onXRFrame(frame: XRFrame): void;
  79726. private _init;
  79727. private _updatePlaneWithXRPlane;
  79728. /**
  79729. * avoiding using Array.find for global support.
  79730. * @param xrPlane the plane to find in the array
  79731. */
  79732. private findIndexInPlaneArray;
  79733. }
  79734. }
  79735. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79736. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79737. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79738. import { Observable } from "babylonjs/Misc/observable";
  79739. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79740. /**
  79741. * Options interface for the background remover plugin
  79742. */
  79743. export interface IWebXRBackgroundRemoverOptions {
  79744. /**
  79745. * Further background meshes to disable when entering AR
  79746. */
  79747. backgroundMeshes?: AbstractMesh[];
  79748. /**
  79749. * flags to configure the removal of the environment helper.
  79750. * If not set, the entire background will be removed. If set, flags should be set as well.
  79751. */
  79752. environmentHelperRemovalFlags?: {
  79753. /**
  79754. * Should the skybox be removed (default false)
  79755. */
  79756. skyBox?: boolean;
  79757. /**
  79758. * Should the ground be removed (default false)
  79759. */
  79760. ground?: boolean;
  79761. };
  79762. /**
  79763. * don't disable the environment helper
  79764. */
  79765. ignoreEnvironmentHelper?: boolean;
  79766. }
  79767. /**
  79768. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79769. */
  79770. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79771. /**
  79772. * read-only options to be used in this module
  79773. */
  79774. readonly options: IWebXRBackgroundRemoverOptions;
  79775. /**
  79776. * The module's name
  79777. */
  79778. static readonly Name: string;
  79779. /**
  79780. * The (Babylon) version of this module.
  79781. * This is an integer representing the implementation version.
  79782. * This number does not correspond to the WebXR specs version
  79783. */
  79784. static readonly Version: number;
  79785. /**
  79786. * registered observers will be triggered when the background state changes
  79787. */
  79788. onBackgroundStateChangedObservable: Observable<boolean>;
  79789. /**
  79790. * constructs a new background remover module
  79791. * @param _xrSessionManager the session manager for this module
  79792. * @param options read-only options to be used in this module
  79793. */
  79794. constructor(_xrSessionManager: WebXRSessionManager,
  79795. /**
  79796. * read-only options to be used in this module
  79797. */
  79798. options?: IWebXRBackgroundRemoverOptions);
  79799. /**
  79800. * attach this feature
  79801. * Will usually be called by the features manager
  79802. *
  79803. * @returns true if successful.
  79804. */
  79805. attach(): boolean;
  79806. /**
  79807. * detach this feature.
  79808. * Will usually be called by the features manager
  79809. *
  79810. * @returns true if successful.
  79811. */
  79812. detach(): boolean;
  79813. /**
  79814. * Dispose this feature and all of the resources attached
  79815. */
  79816. dispose(): void;
  79817. protected _onXRFrame(_xrFrame: XRFrame): void;
  79818. private _setBackgroundState;
  79819. }
  79820. }
  79821. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79822. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79823. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79824. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79825. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79826. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79827. import { Nullable } from "babylonjs/types";
  79828. /**
  79829. * Options for the controller physics feature
  79830. */
  79831. export class IWebXRControllerPhysicsOptions {
  79832. /**
  79833. * Should the headset get its own impostor
  79834. */
  79835. enableHeadsetImpostor?: boolean;
  79836. /**
  79837. * Optional parameters for the headset impostor
  79838. */
  79839. headsetImpostorParams?: {
  79840. /**
  79841. * The type of impostor to create. Default is sphere
  79842. */
  79843. impostorType: number;
  79844. /**
  79845. * the size of the impostor. Defaults to 10cm
  79846. */
  79847. impostorSize?: number | {
  79848. width: number;
  79849. height: number;
  79850. depth: number;
  79851. };
  79852. /**
  79853. * Friction definitions
  79854. */
  79855. friction?: number;
  79856. /**
  79857. * Restitution
  79858. */
  79859. restitution?: number;
  79860. };
  79861. /**
  79862. * The physics properties of the future impostors
  79863. */
  79864. physicsProperties?: {
  79865. /**
  79866. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79867. * Note that this requires a physics engine that supports mesh impostors!
  79868. */
  79869. useControllerMesh?: boolean;
  79870. /**
  79871. * The type of impostor to create. Default is sphere
  79872. */
  79873. impostorType?: number;
  79874. /**
  79875. * the size of the impostor. Defaults to 10cm
  79876. */
  79877. impostorSize?: number | {
  79878. width: number;
  79879. height: number;
  79880. depth: number;
  79881. };
  79882. /**
  79883. * Friction definitions
  79884. */
  79885. friction?: number;
  79886. /**
  79887. * Restitution
  79888. */
  79889. restitution?: number;
  79890. };
  79891. /**
  79892. * the xr input to use with this pointer selection
  79893. */
  79894. xrInput: WebXRInput;
  79895. }
  79896. /**
  79897. * Add physics impostor to your webxr controllers,
  79898. * including naive calculation of their linear and angular velocity
  79899. */
  79900. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79901. private readonly _options;
  79902. private _attachController;
  79903. private _controllers;
  79904. private _debugMode;
  79905. private _delta;
  79906. private _headsetImpostor?;
  79907. private _headsetMesh?;
  79908. private _lastTimestamp;
  79909. private _tmpQuaternion;
  79910. private _tmpVector;
  79911. /**
  79912. * The module's name
  79913. */
  79914. static readonly Name: string;
  79915. /**
  79916. * The (Babylon) version of this module.
  79917. * This is an integer representing the implementation version.
  79918. * This number does not correspond to the webxr specs version
  79919. */
  79920. static readonly Version: number;
  79921. /**
  79922. * Construct a new Controller Physics Feature
  79923. * @param _xrSessionManager the corresponding xr session manager
  79924. * @param _options options to create this feature with
  79925. */
  79926. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79927. /**
  79928. * @hidden
  79929. * enable debugging - will show console outputs and the impostor mesh
  79930. */
  79931. _enablePhysicsDebug(): void;
  79932. /**
  79933. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79934. * @param xrController the controller to add
  79935. */
  79936. addController(xrController: WebXRInputSource): void;
  79937. /**
  79938. * attach this feature
  79939. * Will usually be called by the features manager
  79940. *
  79941. * @returns true if successful.
  79942. */
  79943. attach(): boolean;
  79944. /**
  79945. * detach this feature.
  79946. * Will usually be called by the features manager
  79947. *
  79948. * @returns true if successful.
  79949. */
  79950. detach(): boolean;
  79951. /**
  79952. * Get the headset impostor, if enabled
  79953. * @returns the impostor
  79954. */
  79955. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79956. /**
  79957. * Get the physics impostor of a specific controller.
  79958. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79959. * @param controller the controller or the controller id of which to get the impostor
  79960. * @returns the impostor or null
  79961. */
  79962. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79963. /**
  79964. * Update the physics properties provided in the constructor
  79965. * @param newProperties the new properties object
  79966. */
  79967. setPhysicsProperties(newProperties: {
  79968. impostorType?: number;
  79969. impostorSize?: number | {
  79970. width: number;
  79971. height: number;
  79972. depth: number;
  79973. };
  79974. friction?: number;
  79975. restitution?: number;
  79976. }): void;
  79977. protected _onXRFrame(_xrFrame: any): void;
  79978. private _detachController;
  79979. }
  79980. }
  79981. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79982. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79983. import { Observable } from "babylonjs/Misc/observable";
  79984. import { Vector3 } from "babylonjs/Maths/math.vector";
  79985. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79986. /**
  79987. * A babylon interface for a "WebXR" feature point.
  79988. * Represents the position and confidence value of a given feature point.
  79989. */
  79990. export interface IWebXRFeaturePoint {
  79991. /**
  79992. * Represents the position of the feature point in world space.
  79993. */
  79994. position: Vector3;
  79995. /**
  79996. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79997. */
  79998. confidenceValue: number;
  79999. }
  80000. /**
  80001. * The feature point system is used to detect feature points from real world geometry.
  80002. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80003. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80004. */
  80005. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80006. private _enabled;
  80007. private _featurePointCloud;
  80008. /**
  80009. * The module's name
  80010. */
  80011. static readonly Name: string;
  80012. /**
  80013. * The (Babylon) version of this module.
  80014. * This is an integer representing the implementation version.
  80015. * This number does not correspond to the WebXR specs version
  80016. */
  80017. static readonly Version: number;
  80018. /**
  80019. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80020. * Will notify the observers about which feature points have been added.
  80021. */
  80022. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80023. /**
  80024. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80025. * Will notify the observers about which feature points have been updated.
  80026. */
  80027. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80028. /**
  80029. * The current feature point cloud maintained across frames.
  80030. */
  80031. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80032. /**
  80033. * construct the feature point system
  80034. * @param _xrSessionManager an instance of xr Session manager
  80035. */
  80036. constructor(_xrSessionManager: WebXRSessionManager);
  80037. /**
  80038. * Detach this feature.
  80039. * Will usually be called by the features manager
  80040. *
  80041. * @returns true if successful.
  80042. */
  80043. detach(): boolean;
  80044. /**
  80045. * Dispose this feature and all of the resources attached
  80046. */
  80047. dispose(): void;
  80048. /**
  80049. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80050. */
  80051. protected _onXRFrame(frame: XRFrame): void;
  80052. /**
  80053. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80054. */
  80055. private _init;
  80056. }
  80057. }
  80058. declare module "babylonjs/XR/features/WebXRHandTracking" {
  80059. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80060. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80062. import { Mesh } from "babylonjs/Meshes/mesh";
  80063. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80064. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80065. import { Nullable } from "babylonjs/types";
  80066. import { IDisposable } from "babylonjs/scene";
  80067. import { Observable } from "babylonjs/Misc/observable";
  80068. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  80069. /**
  80070. * Configuration interface for the hand tracking feature
  80071. */
  80072. export interface IWebXRHandTrackingOptions {
  80073. /**
  80074. * The xrInput that will be used as source for new hands
  80075. */
  80076. xrInput: WebXRInput;
  80077. /**
  80078. * Configuration object for the joint meshes
  80079. */
  80080. jointMeshes?: {
  80081. /**
  80082. * Should the meshes created be invisible (defaults to false)
  80083. */
  80084. invisible?: boolean;
  80085. /**
  80086. * A source mesh to be used to create instances. Defaults to a sphere.
  80087. * This mesh will be the source for all other (25) meshes.
  80088. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80089. */
  80090. sourceMesh?: Mesh;
  80091. /**
  80092. * This function will be called after a mesh was created for a specific joint.
  80093. * Using this function you can either manipulate the instance or return a new mesh.
  80094. * When returning a new mesh the instance created before will be disposed
  80095. */
  80096. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80097. /**
  80098. * Should the source mesh stay visible. Defaults to false
  80099. */
  80100. keepOriginalVisible?: boolean;
  80101. /**
  80102. * Scale factor for all instances (defaults to 2)
  80103. */
  80104. scaleFactor?: number;
  80105. /**
  80106. * Should each instance have its own physics impostor
  80107. */
  80108. enablePhysics?: boolean;
  80109. /**
  80110. * If enabled, override default physics properties
  80111. */
  80112. physicsProps?: {
  80113. friction?: number;
  80114. restitution?: number;
  80115. impostorType?: number;
  80116. };
  80117. /**
  80118. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  80119. */
  80120. handMesh?: AbstractMesh;
  80121. };
  80122. }
  80123. /**
  80124. * Parts of the hands divided to writs and finger names
  80125. */
  80126. export const enum HandPart {
  80127. /**
  80128. * HandPart - Wrist
  80129. */
  80130. WRIST = "wrist",
  80131. /**
  80132. * HandPart - The THumb
  80133. */
  80134. THUMB = "thumb",
  80135. /**
  80136. * HandPart - Index finger
  80137. */
  80138. INDEX = "index",
  80139. /**
  80140. * HandPart - Middle finger
  80141. */
  80142. MIDDLE = "middle",
  80143. /**
  80144. * HandPart - Ring finger
  80145. */
  80146. RING = "ring",
  80147. /**
  80148. * HandPart - Little finger
  80149. */
  80150. LITTLE = "little"
  80151. }
  80152. /**
  80153. * Representing a single hand (with its corresponding native XRHand object)
  80154. */
  80155. export class WebXRHand implements IDisposable {
  80156. /** the controller to which the hand correlates */
  80157. readonly xrController: WebXRInputSource;
  80158. /** the meshes to be used to track the hand joints */
  80159. readonly trackedMeshes: AbstractMesh[];
  80160. /**
  80161. * Hand-parts definition (key is HandPart)
  80162. */
  80163. handPartsDefinition: {
  80164. [key: string]: number[];
  80165. };
  80166. /**
  80167. * Populate the HandPartsDefinition object.
  80168. * This is called as a side effect since certain browsers don't have XRHand defined.
  80169. */
  80170. private generateHandPartsDefinition;
  80171. /**
  80172. * Construct a new hand object
  80173. * @param xrController the controller to which the hand correlates
  80174. * @param trackedMeshes the meshes to be used to track the hand joints
  80175. */
  80176. constructor(
  80177. /** the controller to which the hand correlates */
  80178. xrController: WebXRInputSource,
  80179. /** the meshes to be used to track the hand joints */
  80180. trackedMeshes: AbstractMesh[]);
  80181. /**
  80182. * Update this hand from the latest xr frame
  80183. * @param xrFrame xrFrame to update from
  80184. * @param referenceSpace The current viewer reference space
  80185. * @param scaleFactor optional scale factor for the meshes
  80186. */
  80187. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80188. /**
  80189. * Get meshes of part of the hand
  80190. * @param part the part of hand to get
  80191. * @returns An array of meshes that correlate to the hand part requested
  80192. */
  80193. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80194. /**
  80195. * Dispose this Hand object
  80196. */
  80197. dispose(): void;
  80198. }
  80199. /**
  80200. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80201. */
  80202. export class WebXRHandTracking extends WebXRAbstractFeature {
  80203. /**
  80204. * options to use when constructing this feature
  80205. */
  80206. readonly options: IWebXRHandTrackingOptions;
  80207. private static _idCounter;
  80208. /**
  80209. * The module's name
  80210. */
  80211. static readonly Name: string;
  80212. /**
  80213. * The (Babylon) version of this module.
  80214. * This is an integer representing the implementation version.
  80215. * This number does not correspond to the WebXR specs version
  80216. */
  80217. static readonly Version: number;
  80218. /**
  80219. * This observable will notify registered observers when a new hand object was added and initialized
  80220. */
  80221. onHandAddedObservable: Observable<WebXRHand>;
  80222. /**
  80223. * This observable will notify its observers right before the hand object is disposed
  80224. */
  80225. onHandRemovedObservable: Observable<WebXRHand>;
  80226. private _hands;
  80227. /**
  80228. * Creates a new instance of the hit test feature
  80229. * @param _xrSessionManager an instance of WebXRSessionManager
  80230. * @param options options to use when constructing this feature
  80231. */
  80232. constructor(_xrSessionManager: WebXRSessionManager,
  80233. /**
  80234. * options to use when constructing this feature
  80235. */
  80236. options: IWebXRHandTrackingOptions);
  80237. /**
  80238. * Check if the needed objects are defined.
  80239. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80240. */
  80241. isCompatible(): boolean;
  80242. /**
  80243. * attach this feature
  80244. * Will usually be called by the features manager
  80245. *
  80246. * @returns true if successful.
  80247. */
  80248. attach(): boolean;
  80249. /**
  80250. * detach this feature.
  80251. * Will usually be called by the features manager
  80252. *
  80253. * @returns true if successful.
  80254. */
  80255. detach(): boolean;
  80256. /**
  80257. * Dispose this feature and all of the resources attached
  80258. */
  80259. dispose(): void;
  80260. /**
  80261. * Get the hand object according to the controller id
  80262. * @param controllerId the controller id to which we want to get the hand
  80263. * @returns null if not found or the WebXRHand object if found
  80264. */
  80265. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80266. /**
  80267. * Get a hand object according to the requested handedness
  80268. * @param handedness the handedness to request
  80269. * @returns null if not found or the WebXRHand object if found
  80270. */
  80271. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80272. protected _onXRFrame(_xrFrame: XRFrame): void;
  80273. private _attachHand;
  80274. private _detachHand;
  80275. }
  80276. }
  80277. declare module "babylonjs/XR/features/index" {
  80278. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  80279. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  80280. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  80281. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  80282. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  80283. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  80284. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  80285. export * from "babylonjs/XR/features/WebXRHitTest";
  80286. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  80287. export * from "babylonjs/XR/features/WebXRHandTracking";
  80288. }
  80289. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  80290. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80292. import { Scene } from "babylonjs/scene";
  80293. /**
  80294. * The motion controller class for all microsoft mixed reality controllers
  80295. */
  80296. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80297. protected readonly _mapping: {
  80298. defaultButton: {
  80299. valueNodeName: string;
  80300. unpressedNodeName: string;
  80301. pressedNodeName: string;
  80302. };
  80303. defaultAxis: {
  80304. valueNodeName: string;
  80305. minNodeName: string;
  80306. maxNodeName: string;
  80307. };
  80308. buttons: {
  80309. "xr-standard-trigger": {
  80310. rootNodeName: string;
  80311. componentProperty: string;
  80312. states: string[];
  80313. };
  80314. "xr-standard-squeeze": {
  80315. rootNodeName: string;
  80316. componentProperty: string;
  80317. states: string[];
  80318. };
  80319. "xr-standard-touchpad": {
  80320. rootNodeName: string;
  80321. labelAnchorNodeName: string;
  80322. touchPointNodeName: string;
  80323. };
  80324. "xr-standard-thumbstick": {
  80325. rootNodeName: string;
  80326. componentProperty: string;
  80327. states: string[];
  80328. };
  80329. };
  80330. axes: {
  80331. "xr-standard-touchpad": {
  80332. "x-axis": {
  80333. rootNodeName: string;
  80334. };
  80335. "y-axis": {
  80336. rootNodeName: string;
  80337. };
  80338. };
  80339. "xr-standard-thumbstick": {
  80340. "x-axis": {
  80341. rootNodeName: string;
  80342. };
  80343. "y-axis": {
  80344. rootNodeName: string;
  80345. };
  80346. };
  80347. };
  80348. };
  80349. /**
  80350. * The base url used to load the left and right controller models
  80351. */
  80352. static MODEL_BASE_URL: string;
  80353. /**
  80354. * The name of the left controller model file
  80355. */
  80356. static MODEL_LEFT_FILENAME: string;
  80357. /**
  80358. * The name of the right controller model file
  80359. */
  80360. static MODEL_RIGHT_FILENAME: string;
  80361. profileId: string;
  80362. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80363. protected _getFilenameAndPath(): {
  80364. filename: string;
  80365. path: string;
  80366. };
  80367. protected _getModelLoadingConstraints(): boolean;
  80368. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80369. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80370. protected _updateModel(): void;
  80371. }
  80372. }
  80373. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80374. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80376. import { Scene } from "babylonjs/scene";
  80377. /**
  80378. * The motion controller class for oculus touch (quest, rift).
  80379. * This class supports legacy mapping as well the standard xr mapping
  80380. */
  80381. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80382. private _forceLegacyControllers;
  80383. private _modelRootNode;
  80384. /**
  80385. * The base url used to load the left and right controller models
  80386. */
  80387. static MODEL_BASE_URL: string;
  80388. /**
  80389. * The name of the left controller model file
  80390. */
  80391. static MODEL_LEFT_FILENAME: string;
  80392. /**
  80393. * The name of the right controller model file
  80394. */
  80395. static MODEL_RIGHT_FILENAME: string;
  80396. /**
  80397. * Base Url for the Quest controller model.
  80398. */
  80399. static QUEST_MODEL_BASE_URL: string;
  80400. profileId: string;
  80401. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80402. protected _getFilenameAndPath(): {
  80403. filename: string;
  80404. path: string;
  80405. };
  80406. protected _getModelLoadingConstraints(): boolean;
  80407. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80408. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80409. protected _updateModel(): void;
  80410. /**
  80411. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80412. * between the touch and touch 2.
  80413. */
  80414. private _isQuest;
  80415. }
  80416. }
  80417. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80418. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80419. import { Scene } from "babylonjs/scene";
  80420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80421. /**
  80422. * The motion controller class for the standard HTC-Vive controllers
  80423. */
  80424. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80425. private _modelRootNode;
  80426. /**
  80427. * The base url used to load the left and right controller models
  80428. */
  80429. static MODEL_BASE_URL: string;
  80430. /**
  80431. * File name for the controller model.
  80432. */
  80433. static MODEL_FILENAME: string;
  80434. profileId: string;
  80435. /**
  80436. * Create a new Vive motion controller object
  80437. * @param scene the scene to use to create this controller
  80438. * @param gamepadObject the corresponding gamepad object
  80439. * @param handedness the handedness of the controller
  80440. */
  80441. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80442. protected _getFilenameAndPath(): {
  80443. filename: string;
  80444. path: string;
  80445. };
  80446. protected _getModelLoadingConstraints(): boolean;
  80447. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80448. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80449. protected _updateModel(): void;
  80450. }
  80451. }
  80452. declare module "babylonjs/XR/motionController/index" {
  80453. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80454. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80455. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80456. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80457. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80458. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80459. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80460. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80461. }
  80462. declare module "babylonjs/XR/index" {
  80463. export * from "babylonjs/XR/webXRCamera";
  80464. export * from "babylonjs/XR/webXREnterExitUI";
  80465. export * from "babylonjs/XR/webXRExperienceHelper";
  80466. export * from "babylonjs/XR/webXRInput";
  80467. export * from "babylonjs/XR/webXRInputSource";
  80468. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80469. export * from "babylonjs/XR/webXRTypes";
  80470. export * from "babylonjs/XR/webXRSessionManager";
  80471. export * from "babylonjs/XR/webXRDefaultExperience";
  80472. export * from "babylonjs/XR/webXRFeaturesManager";
  80473. export * from "babylonjs/XR/features/index";
  80474. export * from "babylonjs/XR/motionController/index";
  80475. }
  80476. declare module "babylonjs/index" {
  80477. export * from "babylonjs/abstractScene";
  80478. export * from "babylonjs/Actions/index";
  80479. export * from "babylonjs/Animations/index";
  80480. export * from "babylonjs/assetContainer";
  80481. export * from "babylonjs/Audio/index";
  80482. export * from "babylonjs/Behaviors/index";
  80483. export * from "babylonjs/Bones/index";
  80484. export * from "babylonjs/Cameras/index";
  80485. export * from "babylonjs/Collisions/index";
  80486. export * from "babylonjs/Culling/index";
  80487. export * from "babylonjs/Debug/index";
  80488. export * from "babylonjs/DeviceInput/index";
  80489. export * from "babylonjs/Engines/index";
  80490. export * from "babylonjs/Events/index";
  80491. export * from "babylonjs/Gamepads/index";
  80492. export * from "babylonjs/Gizmos/index";
  80493. export * from "babylonjs/Helpers/index";
  80494. export * from "babylonjs/Instrumentation/index";
  80495. export * from "babylonjs/Layers/index";
  80496. export * from "babylonjs/LensFlares/index";
  80497. export * from "babylonjs/Lights/index";
  80498. export * from "babylonjs/Loading/index";
  80499. export * from "babylonjs/Materials/index";
  80500. export * from "babylonjs/Maths/index";
  80501. export * from "babylonjs/Meshes/index";
  80502. export * from "babylonjs/Morph/index";
  80503. export * from "babylonjs/Navigation/index";
  80504. export * from "babylonjs/node";
  80505. export * from "babylonjs/Offline/index";
  80506. export * from "babylonjs/Particles/index";
  80507. export * from "babylonjs/Physics/index";
  80508. export * from "babylonjs/PostProcesses/index";
  80509. export * from "babylonjs/Probes/index";
  80510. export * from "babylonjs/Rendering/index";
  80511. export * from "babylonjs/scene";
  80512. export * from "babylonjs/sceneComponent";
  80513. export * from "babylonjs/Sprites/index";
  80514. export * from "babylonjs/States/index";
  80515. export * from "babylonjs/Misc/index";
  80516. export * from "babylonjs/XR/index";
  80517. export * from "babylonjs/types";
  80518. }
  80519. declare module "babylonjs/Animations/pathCursor" {
  80520. import { Vector3 } from "babylonjs/Maths/math.vector";
  80521. import { Path2 } from "babylonjs/Maths/math.path";
  80522. /**
  80523. * A cursor which tracks a point on a path
  80524. */
  80525. export class PathCursor {
  80526. private path;
  80527. /**
  80528. * Stores path cursor callbacks for when an onchange event is triggered
  80529. */
  80530. private _onchange;
  80531. /**
  80532. * The value of the path cursor
  80533. */
  80534. value: number;
  80535. /**
  80536. * The animation array of the path cursor
  80537. */
  80538. animations: Animation[];
  80539. /**
  80540. * Initializes the path cursor
  80541. * @param path The path to track
  80542. */
  80543. constructor(path: Path2);
  80544. /**
  80545. * Gets the cursor point on the path
  80546. * @returns A point on the path cursor at the cursor location
  80547. */
  80548. getPoint(): Vector3;
  80549. /**
  80550. * Moves the cursor ahead by the step amount
  80551. * @param step The amount to move the cursor forward
  80552. * @returns This path cursor
  80553. */
  80554. moveAhead(step?: number): PathCursor;
  80555. /**
  80556. * Moves the cursor behind by the step amount
  80557. * @param step The amount to move the cursor back
  80558. * @returns This path cursor
  80559. */
  80560. moveBack(step?: number): PathCursor;
  80561. /**
  80562. * Moves the cursor by the step amount
  80563. * If the step amount is greater than one, an exception is thrown
  80564. * @param step The amount to move the cursor
  80565. * @returns This path cursor
  80566. */
  80567. move(step: number): PathCursor;
  80568. /**
  80569. * Ensures that the value is limited between zero and one
  80570. * @returns This path cursor
  80571. */
  80572. private ensureLimits;
  80573. /**
  80574. * Runs onchange callbacks on change (used by the animation engine)
  80575. * @returns This path cursor
  80576. */
  80577. private raiseOnChange;
  80578. /**
  80579. * Executes a function on change
  80580. * @param f A path cursor onchange callback
  80581. * @returns This path cursor
  80582. */
  80583. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80584. }
  80585. }
  80586. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80587. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80588. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80589. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80590. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80591. }
  80592. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80593. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80594. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80595. }
  80596. declare module "babylonjs/Engines/Processors/index" {
  80597. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80598. export * from "babylonjs/Engines/Processors/Expressions/index";
  80599. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80600. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80601. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80602. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80603. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80604. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80605. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80606. }
  80607. declare module "babylonjs/Legacy/legacy" {
  80608. import * as Babylon from "babylonjs/index";
  80609. export * from "babylonjs/index";
  80610. }
  80611. declare module "babylonjs/Shaders/blur.fragment" {
  80612. /** @hidden */
  80613. export var blurPixelShader: {
  80614. name: string;
  80615. shader: string;
  80616. };
  80617. }
  80618. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80619. /** @hidden */
  80620. export var pointCloudVertexDeclaration: {
  80621. name: string;
  80622. shader: string;
  80623. };
  80624. }
  80625. declare module "babylonjs" {
  80626. export * from "babylonjs/Legacy/legacy";
  80627. }
  80628. declare module BABYLON {
  80629. /** Alias type for value that can be null */
  80630. export type Nullable<T> = T | null;
  80631. /**
  80632. * Alias type for number that are floats
  80633. * @ignorenaming
  80634. */
  80635. export type float = number;
  80636. /**
  80637. * Alias type for number that are doubles.
  80638. * @ignorenaming
  80639. */
  80640. export type double = number;
  80641. /**
  80642. * Alias type for number that are integer
  80643. * @ignorenaming
  80644. */
  80645. export type int = number;
  80646. /** Alias type for number array or Float32Array */
  80647. export type FloatArray = number[] | Float32Array;
  80648. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80649. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80650. /**
  80651. * Alias for types that can be used by a Buffer or VertexBuffer.
  80652. */
  80653. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80654. /**
  80655. * Alias type for primitive types
  80656. * @ignorenaming
  80657. */
  80658. type Primitive = undefined | null | boolean | string | number | Function;
  80659. /**
  80660. * Type modifier to make all the properties of an object Readonly
  80661. */
  80662. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80663. /**
  80664. * Type modifier to make all the properties of an object Readonly recursively
  80665. */
  80666. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80667. /**
  80668. * Type modifier to make object properties readonly.
  80669. */
  80670. export type DeepImmutableObject<T> = {
  80671. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80672. };
  80673. /** @hidden */
  80674. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80675. }
  80676. }
  80677. declare module BABYLON {
  80678. /**
  80679. * A class serves as a medium between the observable and its observers
  80680. */
  80681. export class EventState {
  80682. /**
  80683. * Create a new EventState
  80684. * @param mask defines the mask associated with this state
  80685. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80686. * @param target defines the original target of the state
  80687. * @param currentTarget defines the current target of the state
  80688. */
  80689. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80690. /**
  80691. * Initialize the current event state
  80692. * @param mask defines the mask associated with this state
  80693. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80694. * @param target defines the original target of the state
  80695. * @param currentTarget defines the current target of the state
  80696. * @returns the current event state
  80697. */
  80698. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80699. /**
  80700. * An Observer can set this property to true to prevent subsequent observers of being notified
  80701. */
  80702. skipNextObservers: boolean;
  80703. /**
  80704. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80705. */
  80706. mask: number;
  80707. /**
  80708. * The object that originally notified the event
  80709. */
  80710. target?: any;
  80711. /**
  80712. * The current object in the bubbling phase
  80713. */
  80714. currentTarget?: any;
  80715. /**
  80716. * This will be populated with the return value of the last function that was executed.
  80717. * If it is the first function in the callback chain it will be the event data.
  80718. */
  80719. lastReturnValue?: any;
  80720. }
  80721. /**
  80722. * Represent an Observer registered to a given Observable object.
  80723. */
  80724. export class Observer<T> {
  80725. /**
  80726. * Defines the callback to call when the observer is notified
  80727. */
  80728. callback: (eventData: T, eventState: EventState) => void;
  80729. /**
  80730. * Defines the mask of the observer (used to filter notifications)
  80731. */
  80732. mask: number;
  80733. /**
  80734. * Defines the current scope used to restore the JS context
  80735. */
  80736. scope: any;
  80737. /** @hidden */
  80738. _willBeUnregistered: boolean;
  80739. /**
  80740. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80741. */
  80742. unregisterOnNextCall: boolean;
  80743. /**
  80744. * Creates a new observer
  80745. * @param callback defines the callback to call when the observer is notified
  80746. * @param mask defines the mask of the observer (used to filter notifications)
  80747. * @param scope defines the current scope used to restore the JS context
  80748. */
  80749. constructor(
  80750. /**
  80751. * Defines the callback to call when the observer is notified
  80752. */
  80753. callback: (eventData: T, eventState: EventState) => void,
  80754. /**
  80755. * Defines the mask of the observer (used to filter notifications)
  80756. */
  80757. mask: number,
  80758. /**
  80759. * Defines the current scope used to restore the JS context
  80760. */
  80761. scope?: any);
  80762. }
  80763. /**
  80764. * Represent a list of observers registered to multiple Observables object.
  80765. */
  80766. export class MultiObserver<T> {
  80767. private _observers;
  80768. private _observables;
  80769. /**
  80770. * Release associated resources
  80771. */
  80772. dispose(): void;
  80773. /**
  80774. * Raise a callback when one of the observable will notify
  80775. * @param observables defines a list of observables to watch
  80776. * @param callback defines the callback to call on notification
  80777. * @param mask defines the mask used to filter notifications
  80778. * @param scope defines the current scope used to restore the JS context
  80779. * @returns the new MultiObserver
  80780. */
  80781. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80782. }
  80783. /**
  80784. * The Observable class is a simple implementation of the Observable pattern.
  80785. *
  80786. * 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.
  80787. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80788. * 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).
  80789. * 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.
  80790. */
  80791. export class Observable<T> {
  80792. private _observers;
  80793. private _eventState;
  80794. private _onObserverAdded;
  80795. /**
  80796. * Gets the list of observers
  80797. */
  80798. get observers(): Array<Observer<T>>;
  80799. /**
  80800. * Creates a new observable
  80801. * @param onObserverAdded defines a callback to call when a new observer is added
  80802. */
  80803. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80804. /**
  80805. * Create a new Observer with the specified callback
  80806. * @param callback the callback that will be executed for that Observer
  80807. * @param mask the mask used to filter observers
  80808. * @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.
  80809. * @param scope optional scope for the callback to be called from
  80810. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80811. * @returns the new observer created for the callback
  80812. */
  80813. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80814. /**
  80815. * Create a new Observer with the specified callback and unregisters after the next notification
  80816. * @param callback the callback that will be executed for that Observer
  80817. * @returns the new observer created for the callback
  80818. */
  80819. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80820. /**
  80821. * Remove an Observer from the Observable object
  80822. * @param observer the instance of the Observer to remove
  80823. * @returns false if it doesn't belong to this Observable
  80824. */
  80825. remove(observer: Nullable<Observer<T>>): boolean;
  80826. /**
  80827. * Remove a callback from the Observable object
  80828. * @param callback the callback to remove
  80829. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80830. * @returns false if it doesn't belong to this Observable
  80831. */
  80832. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80833. private _deferUnregister;
  80834. private _remove;
  80835. /**
  80836. * Moves the observable to the top of the observer list making it get called first when notified
  80837. * @param observer the observer to move
  80838. */
  80839. makeObserverTopPriority(observer: Observer<T>): void;
  80840. /**
  80841. * Moves the observable to the bottom of the observer list making it get called last when notified
  80842. * @param observer the observer to move
  80843. */
  80844. makeObserverBottomPriority(observer: Observer<T>): void;
  80845. /**
  80846. * Notify all Observers by calling their respective callback with the given data
  80847. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80848. * @param eventData defines the data to send to all observers
  80849. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80850. * @param target defines the original target of the state
  80851. * @param currentTarget defines the current target of the state
  80852. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80853. */
  80854. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  80855. /**
  80856. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80857. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80858. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80859. * and it is crucial that all callbacks will be executed.
  80860. * The order of the callbacks is kept, callbacks are not executed parallel.
  80861. *
  80862. * @param eventData The data to be sent to each callback
  80863. * @param mask is used to filter observers defaults to -1
  80864. * @param target defines the callback target (see EventState)
  80865. * @param currentTarget defines he current object in the bubbling phase
  80866. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80867. */
  80868. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  80869. /**
  80870. * Notify a specific observer
  80871. * @param observer defines the observer to notify
  80872. * @param eventData defines the data to be sent to each callback
  80873. * @param mask is used to filter observers defaults to -1
  80874. */
  80875. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80876. /**
  80877. * Gets a boolean indicating if the observable has at least one observer
  80878. * @returns true is the Observable has at least one Observer registered
  80879. */
  80880. hasObservers(): boolean;
  80881. /**
  80882. * Clear the list of observers
  80883. */
  80884. clear(): void;
  80885. /**
  80886. * Clone the current observable
  80887. * @returns a new observable
  80888. */
  80889. clone(): Observable<T>;
  80890. /**
  80891. * Does this observable handles observer registered with a given mask
  80892. * @param mask defines the mask to be tested
  80893. * @return whether or not one observer registered with the given mask is handeled
  80894. **/
  80895. hasSpecificMask(mask?: number): boolean;
  80896. }
  80897. }
  80898. declare module BABYLON {
  80899. /**
  80900. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80901. * Babylon.js
  80902. */
  80903. export class DomManagement {
  80904. /**
  80905. * Checks if the window object exists
  80906. * @returns true if the window object exists
  80907. */
  80908. static IsWindowObjectExist(): boolean;
  80909. /**
  80910. * Checks if the navigator object exists
  80911. * @returns true if the navigator object exists
  80912. */
  80913. static IsNavigatorAvailable(): boolean;
  80914. /**
  80915. * Check if the document object exists
  80916. * @returns true if the document object exists
  80917. */
  80918. static IsDocumentAvailable(): boolean;
  80919. /**
  80920. * Extracts text content from a DOM element hierarchy
  80921. * @param element defines the root element
  80922. * @returns a string
  80923. */
  80924. static GetDOMTextContent(element: HTMLElement): string;
  80925. }
  80926. }
  80927. declare module BABYLON {
  80928. /**
  80929. * Logger used througouht the application to allow configuration of
  80930. * the log level required for the messages.
  80931. */
  80932. export class Logger {
  80933. /**
  80934. * No log
  80935. */
  80936. static readonly NoneLogLevel: number;
  80937. /**
  80938. * Only message logs
  80939. */
  80940. static readonly MessageLogLevel: number;
  80941. /**
  80942. * Only warning logs
  80943. */
  80944. static readonly WarningLogLevel: number;
  80945. /**
  80946. * Only error logs
  80947. */
  80948. static readonly ErrorLogLevel: number;
  80949. /**
  80950. * All logs
  80951. */
  80952. static readonly AllLogLevel: number;
  80953. private static _LogCache;
  80954. /**
  80955. * Gets a value indicating the number of loading errors
  80956. * @ignorenaming
  80957. */
  80958. static errorsCount: number;
  80959. /**
  80960. * Callback called when a new log is added
  80961. */
  80962. static OnNewCacheEntry: (entry: string) => void;
  80963. private static _AddLogEntry;
  80964. private static _FormatMessage;
  80965. private static _LogDisabled;
  80966. private static _LogEnabled;
  80967. private static _WarnDisabled;
  80968. private static _WarnEnabled;
  80969. private static _ErrorDisabled;
  80970. private static _ErrorEnabled;
  80971. /**
  80972. * Log a message to the console
  80973. */
  80974. static Log: (message: string) => void;
  80975. /**
  80976. * Write a warning message to the console
  80977. */
  80978. static Warn: (message: string) => void;
  80979. /**
  80980. * Write an error message to the console
  80981. */
  80982. static Error: (message: string) => void;
  80983. /**
  80984. * Gets current log cache (list of logs)
  80985. */
  80986. static get LogCache(): string;
  80987. /**
  80988. * Clears the log cache
  80989. */
  80990. static ClearLogCache(): void;
  80991. /**
  80992. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80993. */
  80994. static set LogLevels(level: number);
  80995. }
  80996. }
  80997. declare module BABYLON {
  80998. /** @hidden */
  80999. export class _TypeStore {
  81000. /** @hidden */
  81001. static RegisteredTypes: {
  81002. [key: string]: Object;
  81003. };
  81004. /** @hidden */
  81005. static GetClass(fqdn: string): any;
  81006. }
  81007. }
  81008. declare module BABYLON {
  81009. /**
  81010. * Helper to manipulate strings
  81011. */
  81012. export class StringTools {
  81013. /**
  81014. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  81015. * @param str Source string
  81016. * @param suffix Suffix to search for in the source string
  81017. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81018. */
  81019. static EndsWith(str: string, suffix: string): boolean;
  81020. /**
  81021. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  81022. * @param str Source string
  81023. * @param suffix Suffix to search for in the source string
  81024. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81025. */
  81026. static StartsWith(str: string, suffix: string): boolean;
  81027. /**
  81028. * Decodes a buffer into a string
  81029. * @param buffer The buffer to decode
  81030. * @returns The decoded string
  81031. */
  81032. static Decode(buffer: Uint8Array | Uint16Array): string;
  81033. /**
  81034. * Encode a buffer to a base64 string
  81035. * @param buffer defines the buffer to encode
  81036. * @returns the encoded string
  81037. */
  81038. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  81039. /**
  81040. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  81041. * @param num the number to convert and pad
  81042. * @param length the expected length of the string
  81043. * @returns the padded string
  81044. */
  81045. static PadNumber(num: number, length: number): string;
  81046. }
  81047. }
  81048. declare module BABYLON {
  81049. /**
  81050. * Class containing a set of static utilities functions for deep copy.
  81051. */
  81052. export class DeepCopier {
  81053. /**
  81054. * Tries to copy an object by duplicating every property
  81055. * @param source defines the source object
  81056. * @param destination defines the target object
  81057. * @param doNotCopyList defines a list of properties to avoid
  81058. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  81059. */
  81060. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  81061. }
  81062. }
  81063. declare module BABYLON {
  81064. /**
  81065. * Class containing a set of static utilities functions for precision date
  81066. */
  81067. export class PrecisionDate {
  81068. /**
  81069. * Gets either window.performance.now() if supported or Date.now() else
  81070. */
  81071. static get Now(): number;
  81072. }
  81073. }
  81074. declare module BABYLON {
  81075. /** @hidden */
  81076. export class _DevTools {
  81077. static WarnImport(name: string): string;
  81078. }
  81079. }
  81080. declare module BABYLON {
  81081. /**
  81082. * Interface used to define the mechanism to get data from the network
  81083. */
  81084. export interface IWebRequest {
  81085. /**
  81086. * Returns client's response url
  81087. */
  81088. responseURL: string;
  81089. /**
  81090. * Returns client's status
  81091. */
  81092. status: number;
  81093. /**
  81094. * Returns client's status as a text
  81095. */
  81096. statusText: string;
  81097. }
  81098. }
  81099. declare module BABYLON {
  81100. /**
  81101. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  81102. */
  81103. export class WebRequest implements IWebRequest {
  81104. private _xhr;
  81105. /**
  81106. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  81107. * i.e. when loading files, where the server/service expects an Authorization header
  81108. */
  81109. static CustomRequestHeaders: {
  81110. [key: string]: string;
  81111. };
  81112. /**
  81113. * Add callback functions in this array to update all the requests before they get sent to the network
  81114. */
  81115. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  81116. private _injectCustomRequestHeaders;
  81117. /**
  81118. * Gets or sets a function to be called when loading progress changes
  81119. */
  81120. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  81121. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  81122. /**
  81123. * Returns client's state
  81124. */
  81125. get readyState(): number;
  81126. /**
  81127. * Returns client's status
  81128. */
  81129. get status(): number;
  81130. /**
  81131. * Returns client's status as a text
  81132. */
  81133. get statusText(): string;
  81134. /**
  81135. * Returns client's response
  81136. */
  81137. get response(): any;
  81138. /**
  81139. * Returns client's response url
  81140. */
  81141. get responseURL(): string;
  81142. /**
  81143. * Returns client's response as text
  81144. */
  81145. get responseText(): string;
  81146. /**
  81147. * Gets or sets the expected response type
  81148. */
  81149. get responseType(): XMLHttpRequestResponseType;
  81150. set responseType(value: XMLHttpRequestResponseType);
  81151. /** @hidden */
  81152. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81153. /** @hidden */
  81154. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  81155. /**
  81156. * Cancels any network activity
  81157. */
  81158. abort(): void;
  81159. /**
  81160. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  81161. * @param body defines an optional request body
  81162. */
  81163. send(body?: Document | BodyInit | null): void;
  81164. /**
  81165. * Sets the request method, request URL
  81166. * @param method defines the method to use (GET, POST, etc..)
  81167. * @param url defines the url to connect with
  81168. */
  81169. open(method: string, url: string): void;
  81170. /**
  81171. * Sets the value of a request header.
  81172. * @param name The name of the header whose value is to be set
  81173. * @param value The value to set as the body of the header
  81174. */
  81175. setRequestHeader(name: string, value: string): void;
  81176. /**
  81177. * Get the string containing the text of a particular header's value.
  81178. * @param name The name of the header
  81179. * @returns The string containing the text of the given header name
  81180. */
  81181. getResponseHeader(name: string): Nullable<string>;
  81182. }
  81183. }
  81184. declare module BABYLON {
  81185. /**
  81186. * File request interface
  81187. */
  81188. export interface IFileRequest {
  81189. /**
  81190. * Raised when the request is complete (success or error).
  81191. */
  81192. onCompleteObservable: Observable<IFileRequest>;
  81193. /**
  81194. * Aborts the request for a file.
  81195. */
  81196. abort: () => void;
  81197. }
  81198. }
  81199. declare module BABYLON {
  81200. /**
  81201. * Define options used to create a render target texture
  81202. */
  81203. export class RenderTargetCreationOptions {
  81204. /**
  81205. * Specifies is mipmaps must be generated
  81206. */
  81207. generateMipMaps?: boolean;
  81208. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  81209. generateDepthBuffer?: boolean;
  81210. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  81211. generateStencilBuffer?: boolean;
  81212. /** Defines texture type (int by default) */
  81213. type?: number;
  81214. /** Defines sampling mode (trilinear by default) */
  81215. samplingMode?: number;
  81216. /** Defines format (RGBA by default) */
  81217. format?: number;
  81218. }
  81219. }
  81220. declare module BABYLON {
  81221. /** Defines the cross module used constants to avoid circular dependncies */
  81222. export class Constants {
  81223. /** Defines that alpha blending is disabled */
  81224. static readonly ALPHA_DISABLE: number;
  81225. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  81226. static readonly ALPHA_ADD: number;
  81227. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  81228. static readonly ALPHA_COMBINE: number;
  81229. /** Defines that alpha blending is DEST - SRC * DEST */
  81230. static readonly ALPHA_SUBTRACT: number;
  81231. /** Defines that alpha blending is SRC * DEST */
  81232. static readonly ALPHA_MULTIPLY: number;
  81233. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  81234. static readonly ALPHA_MAXIMIZED: number;
  81235. /** Defines that alpha blending is SRC + DEST */
  81236. static readonly ALPHA_ONEONE: number;
  81237. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  81238. static readonly ALPHA_PREMULTIPLIED: number;
  81239. /**
  81240. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  81241. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  81242. */
  81243. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  81244. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  81245. static readonly ALPHA_INTERPOLATE: number;
  81246. /**
  81247. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  81248. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  81249. */
  81250. static readonly ALPHA_SCREENMODE: number;
  81251. /**
  81252. * Defines that alpha blending is SRC + DST
  81253. * Alpha will be set to SRC ALPHA + DST ALPHA
  81254. */
  81255. static readonly ALPHA_ONEONE_ONEONE: number;
  81256. /**
  81257. * Defines that alpha blending is SRC * DST ALPHA + DST
  81258. * Alpha will be set to 0
  81259. */
  81260. static readonly ALPHA_ALPHATOCOLOR: number;
  81261. /**
  81262. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81263. */
  81264. static readonly ALPHA_REVERSEONEMINUS: number;
  81265. /**
  81266. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  81267. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  81268. */
  81269. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  81270. /**
  81271. * Defines that alpha blending is SRC + DST
  81272. * Alpha will be set to SRC ALPHA
  81273. */
  81274. static readonly ALPHA_ONEONE_ONEZERO: number;
  81275. /**
  81276. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81277. * Alpha will be set to DST ALPHA
  81278. */
  81279. static readonly ALPHA_EXCLUSION: number;
  81280. /** Defines that alpha blending equation a SUM */
  81281. static readonly ALPHA_EQUATION_ADD: number;
  81282. /** Defines that alpha blending equation a SUBSTRACTION */
  81283. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  81284. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  81285. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  81286. /** Defines that alpha blending equation a MAX operation */
  81287. static readonly ALPHA_EQUATION_MAX: number;
  81288. /** Defines that alpha blending equation a MIN operation */
  81289. static readonly ALPHA_EQUATION_MIN: number;
  81290. /**
  81291. * Defines that alpha blending equation a DARKEN operation:
  81292. * It takes the min of the src and sums the alpha channels.
  81293. */
  81294. static readonly ALPHA_EQUATION_DARKEN: number;
  81295. /** Defines that the ressource is not delayed*/
  81296. static readonly DELAYLOADSTATE_NONE: number;
  81297. /** Defines that the ressource was successfully delay loaded */
  81298. static readonly DELAYLOADSTATE_LOADED: number;
  81299. /** Defines that the ressource is currently delay loading */
  81300. static readonly DELAYLOADSTATE_LOADING: number;
  81301. /** Defines that the ressource is delayed and has not started loading */
  81302. static readonly DELAYLOADSTATE_NOTLOADED: number;
  81303. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  81304. static readonly NEVER: number;
  81305. /** 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 */
  81306. static readonly ALWAYS: number;
  81307. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  81308. static readonly LESS: number;
  81309. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  81310. static readonly EQUAL: number;
  81311. /** 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 */
  81312. static readonly LEQUAL: number;
  81313. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  81314. static readonly GREATER: number;
  81315. /** 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 */
  81316. static readonly GEQUAL: number;
  81317. /** 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 */
  81318. static readonly NOTEQUAL: number;
  81319. /** Passed to stencilOperation to specify that stencil value must be kept */
  81320. static readonly KEEP: number;
  81321. /** Passed to stencilOperation to specify that stencil value must be replaced */
  81322. static readonly REPLACE: number;
  81323. /** Passed to stencilOperation to specify that stencil value must be incremented */
  81324. static readonly INCR: number;
  81325. /** Passed to stencilOperation to specify that stencil value must be decremented */
  81326. static readonly DECR: number;
  81327. /** Passed to stencilOperation to specify that stencil value must be inverted */
  81328. static readonly INVERT: number;
  81329. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  81330. static readonly INCR_WRAP: number;
  81331. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  81332. static readonly DECR_WRAP: number;
  81333. /** Texture is not repeating outside of 0..1 UVs */
  81334. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  81335. /** Texture is repeating outside of 0..1 UVs */
  81336. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  81337. /** Texture is repeating and mirrored */
  81338. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81339. /** ALPHA */
  81340. static readonly TEXTUREFORMAT_ALPHA: number;
  81341. /** LUMINANCE */
  81342. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81343. /** LUMINANCE_ALPHA */
  81344. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81345. /** RGB */
  81346. static readonly TEXTUREFORMAT_RGB: number;
  81347. /** RGBA */
  81348. static readonly TEXTUREFORMAT_RGBA: number;
  81349. /** RED */
  81350. static readonly TEXTUREFORMAT_RED: number;
  81351. /** RED (2nd reference) */
  81352. static readonly TEXTUREFORMAT_R: number;
  81353. /** RG */
  81354. static readonly TEXTUREFORMAT_RG: number;
  81355. /** RED_INTEGER */
  81356. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81357. /** RED_INTEGER (2nd reference) */
  81358. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81359. /** RG_INTEGER */
  81360. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81361. /** RGB_INTEGER */
  81362. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81363. /** RGBA_INTEGER */
  81364. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81365. /** UNSIGNED_BYTE */
  81366. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81367. /** UNSIGNED_BYTE (2nd reference) */
  81368. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81369. /** FLOAT */
  81370. static readonly TEXTURETYPE_FLOAT: number;
  81371. /** HALF_FLOAT */
  81372. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81373. /** BYTE */
  81374. static readonly TEXTURETYPE_BYTE: number;
  81375. /** SHORT */
  81376. static readonly TEXTURETYPE_SHORT: number;
  81377. /** UNSIGNED_SHORT */
  81378. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81379. /** INT */
  81380. static readonly TEXTURETYPE_INT: number;
  81381. /** UNSIGNED_INT */
  81382. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81383. /** UNSIGNED_SHORT_4_4_4_4 */
  81384. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81385. /** UNSIGNED_SHORT_5_5_5_1 */
  81386. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81387. /** UNSIGNED_SHORT_5_6_5 */
  81388. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81389. /** UNSIGNED_INT_2_10_10_10_REV */
  81390. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81391. /** UNSIGNED_INT_24_8 */
  81392. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81393. /** UNSIGNED_INT_10F_11F_11F_REV */
  81394. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81395. /** UNSIGNED_INT_5_9_9_9_REV */
  81396. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81397. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81398. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81399. /** nearest is mag = nearest and min = nearest and no mip */
  81400. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81401. /** mag = nearest and min = nearest and mip = none */
  81402. static readonly TEXTURE_NEAREST_NEAREST: number;
  81403. /** Bilinear is mag = linear and min = linear and no mip */
  81404. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81405. /** mag = linear and min = linear and mip = none */
  81406. static readonly TEXTURE_LINEAR_LINEAR: number;
  81407. /** Trilinear is mag = linear and min = linear and mip = linear */
  81408. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81409. /** Trilinear is mag = linear and min = linear and mip = linear */
  81410. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81411. /** mag = nearest and min = nearest and mip = nearest */
  81412. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81413. /** mag = nearest and min = linear and mip = nearest */
  81414. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81415. /** mag = nearest and min = linear and mip = linear */
  81416. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81417. /** mag = nearest and min = linear and mip = none */
  81418. static readonly TEXTURE_NEAREST_LINEAR: number;
  81419. /** nearest is mag = nearest and min = nearest and mip = linear */
  81420. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81421. /** mag = linear and min = nearest and mip = nearest */
  81422. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81423. /** mag = linear and min = nearest and mip = linear */
  81424. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81425. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81426. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81427. /** mag = linear and min = nearest and mip = none */
  81428. static readonly TEXTURE_LINEAR_NEAREST: number;
  81429. /** Explicit coordinates mode */
  81430. static readonly TEXTURE_EXPLICIT_MODE: number;
  81431. /** Spherical coordinates mode */
  81432. static readonly TEXTURE_SPHERICAL_MODE: number;
  81433. /** Planar coordinates mode */
  81434. static readonly TEXTURE_PLANAR_MODE: number;
  81435. /** Cubic coordinates mode */
  81436. static readonly TEXTURE_CUBIC_MODE: number;
  81437. /** Projection coordinates mode */
  81438. static readonly TEXTURE_PROJECTION_MODE: number;
  81439. /** Skybox coordinates mode */
  81440. static readonly TEXTURE_SKYBOX_MODE: number;
  81441. /** Inverse Cubic coordinates mode */
  81442. static readonly TEXTURE_INVCUBIC_MODE: number;
  81443. /** Equirectangular coordinates mode */
  81444. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81445. /** Equirectangular Fixed coordinates mode */
  81446. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81447. /** Equirectangular Fixed Mirrored coordinates mode */
  81448. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81449. /** Offline (baking) quality for texture filtering */
  81450. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81451. /** High quality for texture filtering */
  81452. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81453. /** Medium quality for texture filtering */
  81454. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81455. /** Low quality for texture filtering */
  81456. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81457. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81458. static readonly SCALEMODE_FLOOR: number;
  81459. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81460. static readonly SCALEMODE_NEAREST: number;
  81461. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81462. static readonly SCALEMODE_CEILING: number;
  81463. /**
  81464. * The dirty texture flag value
  81465. */
  81466. static readonly MATERIAL_TextureDirtyFlag: number;
  81467. /**
  81468. * The dirty light flag value
  81469. */
  81470. static readonly MATERIAL_LightDirtyFlag: number;
  81471. /**
  81472. * The dirty fresnel flag value
  81473. */
  81474. static readonly MATERIAL_FresnelDirtyFlag: number;
  81475. /**
  81476. * The dirty attribute flag value
  81477. */
  81478. static readonly MATERIAL_AttributesDirtyFlag: number;
  81479. /**
  81480. * The dirty misc flag value
  81481. */
  81482. static readonly MATERIAL_MiscDirtyFlag: number;
  81483. /**
  81484. * The dirty prepass flag value
  81485. */
  81486. static readonly MATERIAL_PrePassDirtyFlag: number;
  81487. /**
  81488. * The all dirty flag value
  81489. */
  81490. static readonly MATERIAL_AllDirtyFlag: number;
  81491. /**
  81492. * Returns the triangle fill mode
  81493. */
  81494. static readonly MATERIAL_TriangleFillMode: number;
  81495. /**
  81496. * Returns the wireframe mode
  81497. */
  81498. static readonly MATERIAL_WireFrameFillMode: number;
  81499. /**
  81500. * Returns the point fill mode
  81501. */
  81502. static readonly MATERIAL_PointFillMode: number;
  81503. /**
  81504. * Returns the point list draw mode
  81505. */
  81506. static readonly MATERIAL_PointListDrawMode: number;
  81507. /**
  81508. * Returns the line list draw mode
  81509. */
  81510. static readonly MATERIAL_LineListDrawMode: number;
  81511. /**
  81512. * Returns the line loop draw mode
  81513. */
  81514. static readonly MATERIAL_LineLoopDrawMode: number;
  81515. /**
  81516. * Returns the line strip draw mode
  81517. */
  81518. static readonly MATERIAL_LineStripDrawMode: number;
  81519. /**
  81520. * Returns the triangle strip draw mode
  81521. */
  81522. static readonly MATERIAL_TriangleStripDrawMode: number;
  81523. /**
  81524. * Returns the triangle fan draw mode
  81525. */
  81526. static readonly MATERIAL_TriangleFanDrawMode: number;
  81527. /**
  81528. * Stores the clock-wise side orientation
  81529. */
  81530. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81531. /**
  81532. * Stores the counter clock-wise side orientation
  81533. */
  81534. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81535. /**
  81536. * Nothing
  81537. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81538. */
  81539. static readonly ACTION_NothingTrigger: number;
  81540. /**
  81541. * On pick
  81542. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81543. */
  81544. static readonly ACTION_OnPickTrigger: number;
  81545. /**
  81546. * On left pick
  81547. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81548. */
  81549. static readonly ACTION_OnLeftPickTrigger: number;
  81550. /**
  81551. * On right pick
  81552. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81553. */
  81554. static readonly ACTION_OnRightPickTrigger: number;
  81555. /**
  81556. * On center pick
  81557. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81558. */
  81559. static readonly ACTION_OnCenterPickTrigger: number;
  81560. /**
  81561. * On pick down
  81562. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81563. */
  81564. static readonly ACTION_OnPickDownTrigger: number;
  81565. /**
  81566. * On double pick
  81567. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81568. */
  81569. static readonly ACTION_OnDoublePickTrigger: number;
  81570. /**
  81571. * On pick up
  81572. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81573. */
  81574. static readonly ACTION_OnPickUpTrigger: number;
  81575. /**
  81576. * On pick out.
  81577. * This trigger will only be raised if you also declared a OnPickDown
  81578. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81579. */
  81580. static readonly ACTION_OnPickOutTrigger: number;
  81581. /**
  81582. * On long press
  81583. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81584. */
  81585. static readonly ACTION_OnLongPressTrigger: number;
  81586. /**
  81587. * On pointer over
  81588. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81589. */
  81590. static readonly ACTION_OnPointerOverTrigger: number;
  81591. /**
  81592. * On pointer out
  81593. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81594. */
  81595. static readonly ACTION_OnPointerOutTrigger: number;
  81596. /**
  81597. * On every frame
  81598. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81599. */
  81600. static readonly ACTION_OnEveryFrameTrigger: number;
  81601. /**
  81602. * On intersection enter
  81603. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81604. */
  81605. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81606. /**
  81607. * On intersection exit
  81608. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81609. */
  81610. static readonly ACTION_OnIntersectionExitTrigger: number;
  81611. /**
  81612. * On key down
  81613. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81614. */
  81615. static readonly ACTION_OnKeyDownTrigger: number;
  81616. /**
  81617. * On key up
  81618. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81619. */
  81620. static readonly ACTION_OnKeyUpTrigger: number;
  81621. /**
  81622. * Billboard mode will only apply to Y axis
  81623. */
  81624. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81625. /**
  81626. * Billboard mode will apply to all axes
  81627. */
  81628. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81629. /**
  81630. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81631. */
  81632. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81633. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81634. * Test order :
  81635. * Is the bounding sphere outside the frustum ?
  81636. * If not, are the bounding box vertices outside the frustum ?
  81637. * It not, then the cullable object is in the frustum.
  81638. */
  81639. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81640. /** Culling strategy : Bounding Sphere Only.
  81641. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81642. * It's also less accurate than the standard because some not visible objects can still be selected.
  81643. * Test : is the bounding sphere outside the frustum ?
  81644. * If not, then the cullable object is in the frustum.
  81645. */
  81646. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81647. /** Culling strategy : Optimistic Inclusion.
  81648. * This in an inclusion test first, then the standard exclusion test.
  81649. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81650. * 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.
  81651. * Anyway, it's as accurate as the standard strategy.
  81652. * Test :
  81653. * Is the cullable object bounding sphere center in the frustum ?
  81654. * If not, apply the default culling strategy.
  81655. */
  81656. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81657. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81658. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81659. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81660. * 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.
  81661. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81662. * Test :
  81663. * Is the cullable object bounding sphere center in the frustum ?
  81664. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81665. */
  81666. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81667. /**
  81668. * No logging while loading
  81669. */
  81670. static readonly SCENELOADER_NO_LOGGING: number;
  81671. /**
  81672. * Minimal logging while loading
  81673. */
  81674. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81675. /**
  81676. * Summary logging while loading
  81677. */
  81678. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81679. /**
  81680. * Detailled logging while loading
  81681. */
  81682. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81683. /**
  81684. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81685. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81686. */
  81687. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81688. /**
  81689. * Constant used to retrieve the position texture index in the textures array in the prepass
  81690. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81691. */
  81692. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81693. /**
  81694. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81695. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81696. */
  81697. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81698. /**
  81699. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81700. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81701. */
  81702. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81703. /**
  81704. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81705. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81706. */
  81707. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81708. /**
  81709. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81710. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81711. */
  81712. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81713. /**
  81714. * Constant used to retrieve albedo index in the textures array in the prepass
  81715. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81716. */
  81717. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81718. }
  81719. }
  81720. declare module BABYLON {
  81721. /**
  81722. * This represents the required contract to create a new type of texture loader.
  81723. */
  81724. export interface IInternalTextureLoader {
  81725. /**
  81726. * Defines wether the loader supports cascade loading the different faces.
  81727. */
  81728. supportCascades: boolean;
  81729. /**
  81730. * This returns if the loader support the current file information.
  81731. * @param extension defines the file extension of the file being loaded
  81732. * @param mimeType defines the optional mime type of the file being loaded
  81733. * @returns true if the loader can load the specified file
  81734. */
  81735. canLoad(extension: string, mimeType?: string): boolean;
  81736. /**
  81737. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81738. * @param data contains the texture data
  81739. * @param texture defines the BabylonJS internal texture
  81740. * @param createPolynomials will be true if polynomials have been requested
  81741. * @param onLoad defines the callback to trigger once the texture is ready
  81742. * @param onError defines the callback to trigger in case of error
  81743. */
  81744. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81745. /**
  81746. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81747. * @param data contains the texture data
  81748. * @param texture defines the BabylonJS internal texture
  81749. * @param callback defines the method to call once ready to upload
  81750. */
  81751. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81752. }
  81753. }
  81754. declare module BABYLON {
  81755. /**
  81756. * Class used to store and describe the pipeline context associated with an effect
  81757. */
  81758. export interface IPipelineContext {
  81759. /**
  81760. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81761. */
  81762. isAsync: boolean;
  81763. /**
  81764. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81765. */
  81766. isReady: boolean;
  81767. /** @hidden */
  81768. _getVertexShaderCode(): string | null;
  81769. /** @hidden */
  81770. _getFragmentShaderCode(): string | null;
  81771. /** @hidden */
  81772. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81773. }
  81774. }
  81775. declare module BABYLON {
  81776. /**
  81777. * Class used to store gfx data (like WebGLBuffer)
  81778. */
  81779. export class DataBuffer {
  81780. /**
  81781. * Gets or sets the number of objects referencing this buffer
  81782. */
  81783. references: number;
  81784. /** Gets or sets the size of the underlying buffer */
  81785. capacity: number;
  81786. /**
  81787. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81788. */
  81789. is32Bits: boolean;
  81790. /**
  81791. * Gets the underlying buffer
  81792. */
  81793. get underlyingResource(): any;
  81794. }
  81795. }
  81796. declare module BABYLON {
  81797. /** @hidden */
  81798. export interface IShaderProcessor {
  81799. attributeProcessor?: (attribute: string) => string;
  81800. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81801. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81802. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81803. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81804. lineProcessor?: (line: string, isFragment: boolean) => string;
  81805. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81806. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81807. }
  81808. }
  81809. declare module BABYLON {
  81810. /** @hidden */
  81811. export interface ProcessingOptions {
  81812. defines: string[];
  81813. indexParameters: any;
  81814. isFragment: boolean;
  81815. shouldUseHighPrecisionShader: boolean;
  81816. supportsUniformBuffers: boolean;
  81817. shadersRepository: string;
  81818. includesShadersStore: {
  81819. [key: string]: string;
  81820. };
  81821. processor?: IShaderProcessor;
  81822. version: string;
  81823. platformName: string;
  81824. lookForClosingBracketForUniformBuffer?: boolean;
  81825. }
  81826. }
  81827. declare module BABYLON {
  81828. /** @hidden */
  81829. export class ShaderCodeNode {
  81830. line: string;
  81831. children: ShaderCodeNode[];
  81832. additionalDefineKey?: string;
  81833. additionalDefineValue?: string;
  81834. isValid(preprocessors: {
  81835. [key: string]: string;
  81836. }): boolean;
  81837. process(preprocessors: {
  81838. [key: string]: string;
  81839. }, options: ProcessingOptions): string;
  81840. }
  81841. }
  81842. declare module BABYLON {
  81843. /** @hidden */
  81844. export class ShaderCodeCursor {
  81845. private _lines;
  81846. lineIndex: number;
  81847. get currentLine(): string;
  81848. get canRead(): boolean;
  81849. set lines(value: string[]);
  81850. }
  81851. }
  81852. declare module BABYLON {
  81853. /** @hidden */
  81854. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81855. process(preprocessors: {
  81856. [key: string]: string;
  81857. }, options: ProcessingOptions): string;
  81858. }
  81859. }
  81860. declare module BABYLON {
  81861. /** @hidden */
  81862. export class ShaderDefineExpression {
  81863. isTrue(preprocessors: {
  81864. [key: string]: string;
  81865. }): boolean;
  81866. private static _OperatorPriority;
  81867. private static _Stack;
  81868. static postfixToInfix(postfix: string[]): string;
  81869. static infixToPostfix(infix: string): string[];
  81870. }
  81871. }
  81872. declare module BABYLON {
  81873. /** @hidden */
  81874. export class ShaderCodeTestNode extends ShaderCodeNode {
  81875. testExpression: ShaderDefineExpression;
  81876. isValid(preprocessors: {
  81877. [key: string]: string;
  81878. }): boolean;
  81879. }
  81880. }
  81881. declare module BABYLON {
  81882. /** @hidden */
  81883. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81884. define: string;
  81885. not: boolean;
  81886. constructor(define: string, not?: boolean);
  81887. isTrue(preprocessors: {
  81888. [key: string]: string;
  81889. }): boolean;
  81890. }
  81891. }
  81892. declare module BABYLON {
  81893. /** @hidden */
  81894. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81895. leftOperand: ShaderDefineExpression;
  81896. rightOperand: ShaderDefineExpression;
  81897. isTrue(preprocessors: {
  81898. [key: string]: string;
  81899. }): boolean;
  81900. }
  81901. }
  81902. declare module BABYLON {
  81903. /** @hidden */
  81904. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81905. leftOperand: ShaderDefineExpression;
  81906. rightOperand: ShaderDefineExpression;
  81907. isTrue(preprocessors: {
  81908. [key: string]: string;
  81909. }): boolean;
  81910. }
  81911. }
  81912. declare module BABYLON {
  81913. /** @hidden */
  81914. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81915. define: string;
  81916. operand: string;
  81917. testValue: string;
  81918. constructor(define: string, operand: string, testValue: string);
  81919. isTrue(preprocessors: {
  81920. [key: string]: string;
  81921. }): boolean;
  81922. }
  81923. }
  81924. declare module BABYLON {
  81925. /**
  81926. * Class used to enable access to offline support
  81927. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81928. */
  81929. export interface IOfflineProvider {
  81930. /**
  81931. * Gets a boolean indicating if scene must be saved in the database
  81932. */
  81933. enableSceneOffline: boolean;
  81934. /**
  81935. * Gets a boolean indicating if textures must be saved in the database
  81936. */
  81937. enableTexturesOffline: boolean;
  81938. /**
  81939. * Open the offline support and make it available
  81940. * @param successCallback defines the callback to call on success
  81941. * @param errorCallback defines the callback to call on error
  81942. */
  81943. open(successCallback: () => void, errorCallback: () => void): void;
  81944. /**
  81945. * Loads an image from the offline support
  81946. * @param url defines the url to load from
  81947. * @param image defines the target DOM image
  81948. */
  81949. loadImage(url: string, image: HTMLImageElement): void;
  81950. /**
  81951. * Loads a file from offline support
  81952. * @param url defines the URL to load from
  81953. * @param sceneLoaded defines a callback to call on success
  81954. * @param progressCallBack defines a callback to call when progress changed
  81955. * @param errorCallback defines a callback to call on error
  81956. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81957. */
  81958. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81959. }
  81960. }
  81961. declare module BABYLON {
  81962. /**
  81963. * Class used to help managing file picking and drag'n'drop
  81964. * File Storage
  81965. */
  81966. export class FilesInputStore {
  81967. /**
  81968. * List of files ready to be loaded
  81969. */
  81970. static FilesToLoad: {
  81971. [key: string]: File;
  81972. };
  81973. }
  81974. }
  81975. declare module BABYLON {
  81976. /**
  81977. * Class used to define a retry strategy when error happens while loading assets
  81978. */
  81979. export class RetryStrategy {
  81980. /**
  81981. * Function used to defines an exponential back off strategy
  81982. * @param maxRetries defines the maximum number of retries (3 by default)
  81983. * @param baseInterval defines the interval between retries
  81984. * @returns the strategy function to use
  81985. */
  81986. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81987. }
  81988. }
  81989. declare module BABYLON {
  81990. /**
  81991. * @ignore
  81992. * Application error to support additional information when loading a file
  81993. */
  81994. export abstract class BaseError extends Error {
  81995. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81996. }
  81997. }
  81998. declare module BABYLON {
  81999. /** @ignore */
  82000. export class LoadFileError extends BaseError {
  82001. request?: WebRequest;
  82002. file?: File;
  82003. /**
  82004. * Creates a new LoadFileError
  82005. * @param message defines the message of the error
  82006. * @param request defines the optional web request
  82007. * @param file defines the optional file
  82008. */
  82009. constructor(message: string, object?: WebRequest | File);
  82010. }
  82011. /** @ignore */
  82012. export class RequestFileError extends BaseError {
  82013. request: WebRequest;
  82014. /**
  82015. * Creates a new LoadFileError
  82016. * @param message defines the message of the error
  82017. * @param request defines the optional web request
  82018. */
  82019. constructor(message: string, request: WebRequest);
  82020. }
  82021. /** @ignore */
  82022. export class ReadFileError extends BaseError {
  82023. file: File;
  82024. /**
  82025. * Creates a new ReadFileError
  82026. * @param message defines the message of the error
  82027. * @param file defines the optional file
  82028. */
  82029. constructor(message: string, file: File);
  82030. }
  82031. /**
  82032. * @hidden
  82033. */
  82034. export class FileTools {
  82035. /**
  82036. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  82037. */
  82038. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  82039. /**
  82040. * Gets or sets the base URL to use to load assets
  82041. */
  82042. static BaseUrl: string;
  82043. /**
  82044. * Default behaviour for cors in the application.
  82045. * It can be a string if the expected behavior is identical in the entire app.
  82046. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  82047. */
  82048. static CorsBehavior: string | ((url: string | string[]) => string);
  82049. /**
  82050. * Gets or sets a function used to pre-process url before using them to load assets
  82051. */
  82052. static PreprocessUrl: (url: string) => string;
  82053. /**
  82054. * Removes unwanted characters from an url
  82055. * @param url defines the url to clean
  82056. * @returns the cleaned url
  82057. */
  82058. private static _CleanUrl;
  82059. /**
  82060. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  82061. * @param url define the url we are trying
  82062. * @param element define the dom element where to configure the cors policy
  82063. */
  82064. static SetCorsBehavior(url: string | string[], element: {
  82065. crossOrigin: string | null;
  82066. }): void;
  82067. /**
  82068. * Loads an image as an HTMLImageElement.
  82069. * @param input url string, ArrayBuffer, or Blob to load
  82070. * @param onLoad callback called when the image successfully loads
  82071. * @param onError callback called when the image fails to load
  82072. * @param offlineProvider offline provider for caching
  82073. * @param mimeType optional mime type
  82074. * @returns the HTMLImageElement of the loaded image
  82075. */
  82076. 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>;
  82077. /**
  82078. * Reads a file from a File object
  82079. * @param file defines the file to load
  82080. * @param onSuccess defines the callback to call when data is loaded
  82081. * @param onProgress defines the callback to call during loading process
  82082. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  82083. * @param onError defines the callback to call when an error occurs
  82084. * @returns a file request object
  82085. */
  82086. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  82087. /**
  82088. * Loads a file from a url
  82089. * @param url url to load
  82090. * @param onSuccess callback called when the file successfully loads
  82091. * @param onProgress callback called while file is loading (if the server supports this mode)
  82092. * @param offlineProvider defines the offline provider for caching
  82093. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82094. * @param onError callback called when the file fails to load
  82095. * @returns a file request object
  82096. */
  82097. 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;
  82098. /**
  82099. * Loads a file
  82100. * @param url url to load
  82101. * @param onSuccess callback called when the file successfully loads
  82102. * @param onProgress callback called while file is loading (if the server supports this mode)
  82103. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82104. * @param onError callback called when the file fails to load
  82105. * @param onOpened callback called when the web request is opened
  82106. * @returns a file request object
  82107. */
  82108. 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;
  82109. /**
  82110. * Checks if the loaded document was accessed via `file:`-Protocol.
  82111. * @returns boolean
  82112. */
  82113. static IsFileURL(): boolean;
  82114. }
  82115. }
  82116. declare module BABYLON {
  82117. /** @hidden */
  82118. export class ShaderProcessor {
  82119. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  82120. private static _ProcessPrecision;
  82121. private static _ExtractOperation;
  82122. private static _BuildSubExpression;
  82123. private static _BuildExpression;
  82124. private static _MoveCursorWithinIf;
  82125. private static _MoveCursor;
  82126. private static _EvaluatePreProcessors;
  82127. private static _PreparePreProcessors;
  82128. private static _ProcessShaderConversion;
  82129. private static _ProcessIncludes;
  82130. /**
  82131. * Loads a file from a url
  82132. * @param url url to load
  82133. * @param onSuccess callback called when the file successfully loads
  82134. * @param onProgress callback called while file is loading (if the server supports this mode)
  82135. * @param offlineProvider defines the offline provider for caching
  82136. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82137. * @param onError callback called when the file fails to load
  82138. * @returns a file request object
  82139. * @hidden
  82140. */
  82141. 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;
  82142. }
  82143. }
  82144. declare module BABYLON {
  82145. /**
  82146. * @hidden
  82147. */
  82148. export interface IColor4Like {
  82149. r: float;
  82150. g: float;
  82151. b: float;
  82152. a: float;
  82153. }
  82154. /**
  82155. * @hidden
  82156. */
  82157. export interface IColor3Like {
  82158. r: float;
  82159. g: float;
  82160. b: float;
  82161. }
  82162. /**
  82163. * @hidden
  82164. */
  82165. export interface IVector4Like {
  82166. x: float;
  82167. y: float;
  82168. z: float;
  82169. w: float;
  82170. }
  82171. /**
  82172. * @hidden
  82173. */
  82174. export interface IVector3Like {
  82175. x: float;
  82176. y: float;
  82177. z: float;
  82178. }
  82179. /**
  82180. * @hidden
  82181. */
  82182. export interface IVector2Like {
  82183. x: float;
  82184. y: float;
  82185. }
  82186. /**
  82187. * @hidden
  82188. */
  82189. export interface IMatrixLike {
  82190. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82191. updateFlag: int;
  82192. }
  82193. /**
  82194. * @hidden
  82195. */
  82196. export interface IViewportLike {
  82197. x: float;
  82198. y: float;
  82199. width: float;
  82200. height: float;
  82201. }
  82202. /**
  82203. * @hidden
  82204. */
  82205. export interface IPlaneLike {
  82206. normal: IVector3Like;
  82207. d: float;
  82208. normalize(): void;
  82209. }
  82210. }
  82211. declare module BABYLON {
  82212. /**
  82213. * Interface used to define common properties for effect fallbacks
  82214. */
  82215. export interface IEffectFallbacks {
  82216. /**
  82217. * Removes the defines that should be removed when falling back.
  82218. * @param currentDefines defines the current define statements for the shader.
  82219. * @param effect defines the current effect we try to compile
  82220. * @returns The resulting defines with defines of the current rank removed.
  82221. */
  82222. reduce(currentDefines: string, effect: Effect): string;
  82223. /**
  82224. * Removes the fallback from the bound mesh.
  82225. */
  82226. unBindMesh(): void;
  82227. /**
  82228. * Checks to see if more fallbacks are still availible.
  82229. */
  82230. hasMoreFallbacks: boolean;
  82231. }
  82232. }
  82233. declare module BABYLON {
  82234. /**
  82235. * Class used to evalaute queries containing `and` and `or` operators
  82236. */
  82237. export class AndOrNotEvaluator {
  82238. /**
  82239. * Evaluate a query
  82240. * @param query defines the query to evaluate
  82241. * @param evaluateCallback defines the callback used to filter result
  82242. * @returns true if the query matches
  82243. */
  82244. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  82245. private static _HandleParenthesisContent;
  82246. private static _SimplifyNegation;
  82247. }
  82248. }
  82249. declare module BABYLON {
  82250. /**
  82251. * Class used to store custom tags
  82252. */
  82253. export class Tags {
  82254. /**
  82255. * Adds support for tags on the given object
  82256. * @param obj defines the object to use
  82257. */
  82258. static EnableFor(obj: any): void;
  82259. /**
  82260. * Removes tags support
  82261. * @param obj defines the object to use
  82262. */
  82263. static DisableFor(obj: any): void;
  82264. /**
  82265. * Gets a boolean indicating if the given object has tags
  82266. * @param obj defines the object to use
  82267. * @returns a boolean
  82268. */
  82269. static HasTags(obj: any): boolean;
  82270. /**
  82271. * Gets the tags available on a given object
  82272. * @param obj defines the object to use
  82273. * @param asString defines if the tags must be returned as a string instead of an array of strings
  82274. * @returns the tags
  82275. */
  82276. static GetTags(obj: any, asString?: boolean): any;
  82277. /**
  82278. * Adds tags to an object
  82279. * @param obj defines the object to use
  82280. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  82281. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  82282. */
  82283. static AddTagsTo(obj: any, tagsString: string): void;
  82284. /**
  82285. * @hidden
  82286. */
  82287. static _AddTagTo(obj: any, tag: string): void;
  82288. /**
  82289. * Removes specific tags from a specific object
  82290. * @param obj defines the object to use
  82291. * @param tagsString defines the tags to remove
  82292. */
  82293. static RemoveTagsFrom(obj: any, tagsString: string): void;
  82294. /**
  82295. * @hidden
  82296. */
  82297. static _RemoveTagFrom(obj: any, tag: string): void;
  82298. /**
  82299. * Defines if tags hosted on an object match a given query
  82300. * @param obj defines the object to use
  82301. * @param tagsQuery defines the tag query
  82302. * @returns a boolean
  82303. */
  82304. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  82305. }
  82306. }
  82307. declare module BABYLON {
  82308. /**
  82309. * Scalar computation library
  82310. */
  82311. export class Scalar {
  82312. /**
  82313. * Two pi constants convenient for computation.
  82314. */
  82315. static TwoPi: number;
  82316. /**
  82317. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82318. * @param a number
  82319. * @param b number
  82320. * @param epsilon (default = 1.401298E-45)
  82321. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82322. */
  82323. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  82324. /**
  82325. * Returns a string : the upper case translation of the number i to hexadecimal.
  82326. * @param i number
  82327. * @returns the upper case translation of the number i to hexadecimal.
  82328. */
  82329. static ToHex(i: number): string;
  82330. /**
  82331. * Returns -1 if value is negative and +1 is value is positive.
  82332. * @param value the value
  82333. * @returns the value itself if it's equal to zero.
  82334. */
  82335. static Sign(value: number): number;
  82336. /**
  82337. * Returns the value itself if it's between min and max.
  82338. * Returns min if the value is lower than min.
  82339. * Returns max if the value is greater than max.
  82340. * @param value the value to clmap
  82341. * @param min the min value to clamp to (default: 0)
  82342. * @param max the max value to clamp to (default: 1)
  82343. * @returns the clamped value
  82344. */
  82345. static Clamp(value: number, min?: number, max?: number): number;
  82346. /**
  82347. * the log2 of value.
  82348. * @param value the value to compute log2 of
  82349. * @returns the log2 of value.
  82350. */
  82351. static Log2(value: number): number;
  82352. /**
  82353. * Loops the value, so that it is never larger than length and never smaller than 0.
  82354. *
  82355. * This is similar to the modulo operator but it works with floating point numbers.
  82356. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82357. * With t = 5 and length = 2.5, the result would be 0.0.
  82358. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82359. * @param value the value
  82360. * @param length the length
  82361. * @returns the looped value
  82362. */
  82363. static Repeat(value: number, length: number): number;
  82364. /**
  82365. * Normalize the value between 0.0 and 1.0 using min and max values
  82366. * @param value value to normalize
  82367. * @param min max to normalize between
  82368. * @param max min to normalize between
  82369. * @returns the normalized value
  82370. */
  82371. static Normalize(value: number, min: number, max: number): number;
  82372. /**
  82373. * Denormalize the value from 0.0 and 1.0 using min and max values
  82374. * @param normalized value to denormalize
  82375. * @param min max to denormalize between
  82376. * @param max min to denormalize between
  82377. * @returns the denormalized value
  82378. */
  82379. static Denormalize(normalized: number, min: number, max: number): number;
  82380. /**
  82381. * Calculates the shortest difference between two given angles given in degrees.
  82382. * @param current current angle in degrees
  82383. * @param target target angle in degrees
  82384. * @returns the delta
  82385. */
  82386. static DeltaAngle(current: number, target: number): number;
  82387. /**
  82388. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82389. * @param tx value
  82390. * @param length length
  82391. * @returns The returned value will move back and forth between 0 and length
  82392. */
  82393. static PingPong(tx: number, length: number): number;
  82394. /**
  82395. * Interpolates between min and max with smoothing at the limits.
  82396. *
  82397. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82398. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82399. * @param from from
  82400. * @param to to
  82401. * @param tx value
  82402. * @returns the smooth stepped value
  82403. */
  82404. static SmoothStep(from: number, to: number, tx: number): number;
  82405. /**
  82406. * Moves a value current towards target.
  82407. *
  82408. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82409. * Negative values of maxDelta pushes the value away from target.
  82410. * @param current current value
  82411. * @param target target value
  82412. * @param maxDelta max distance to move
  82413. * @returns resulting value
  82414. */
  82415. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82416. /**
  82417. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82418. *
  82419. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82420. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82421. * @param current current value
  82422. * @param target target value
  82423. * @param maxDelta max distance to move
  82424. * @returns resulting angle
  82425. */
  82426. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82427. /**
  82428. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82429. * @param start start value
  82430. * @param end target value
  82431. * @param amount amount to lerp between
  82432. * @returns the lerped value
  82433. */
  82434. static Lerp(start: number, end: number, amount: number): number;
  82435. /**
  82436. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82437. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82438. * @param start start value
  82439. * @param end target value
  82440. * @param amount amount to lerp between
  82441. * @returns the lerped value
  82442. */
  82443. static LerpAngle(start: number, end: number, amount: number): number;
  82444. /**
  82445. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82446. * @param a start value
  82447. * @param b target value
  82448. * @param value value between a and b
  82449. * @returns the inverseLerp value
  82450. */
  82451. static InverseLerp(a: number, b: number, value: number): number;
  82452. /**
  82453. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82454. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82455. * @param value1 spline value
  82456. * @param tangent1 spline value
  82457. * @param value2 spline value
  82458. * @param tangent2 spline value
  82459. * @param amount input value
  82460. * @returns hermite result
  82461. */
  82462. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82463. /**
  82464. * Returns a random float number between and min and max values
  82465. * @param min min value of random
  82466. * @param max max value of random
  82467. * @returns random value
  82468. */
  82469. static RandomRange(min: number, max: number): number;
  82470. /**
  82471. * This function returns percentage of a number in a given range.
  82472. *
  82473. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82474. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82475. * @param number to convert to percentage
  82476. * @param min min range
  82477. * @param max max range
  82478. * @returns the percentage
  82479. */
  82480. static RangeToPercent(number: number, min: number, max: number): number;
  82481. /**
  82482. * This function returns number that corresponds to the percentage in a given range.
  82483. *
  82484. * PercentToRange(0.34,0,100) will return 34.
  82485. * @param percent to convert to number
  82486. * @param min min range
  82487. * @param max max range
  82488. * @returns the number
  82489. */
  82490. static PercentToRange(percent: number, min: number, max: number): number;
  82491. /**
  82492. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82493. * @param angle The angle to normalize in radian.
  82494. * @return The converted angle.
  82495. */
  82496. static NormalizeRadians(angle: number): number;
  82497. }
  82498. }
  82499. declare module BABYLON {
  82500. /**
  82501. * Constant used to convert a value to gamma space
  82502. * @ignorenaming
  82503. */
  82504. export const ToGammaSpace: number;
  82505. /**
  82506. * Constant used to convert a value to linear space
  82507. * @ignorenaming
  82508. */
  82509. export const ToLinearSpace = 2.2;
  82510. /**
  82511. * Constant used to define the minimal number value in Babylon.js
  82512. * @ignorenaming
  82513. */
  82514. let Epsilon: number;
  82515. }
  82516. declare module BABYLON {
  82517. /**
  82518. * Class used to represent a viewport on screen
  82519. */
  82520. export class Viewport {
  82521. /** viewport left coordinate */
  82522. x: number;
  82523. /** viewport top coordinate */
  82524. y: number;
  82525. /**viewport width */
  82526. width: number;
  82527. /** viewport height */
  82528. height: number;
  82529. /**
  82530. * Creates a Viewport object located at (x, y) and sized (width, height)
  82531. * @param x defines viewport left coordinate
  82532. * @param y defines viewport top coordinate
  82533. * @param width defines the viewport width
  82534. * @param height defines the viewport height
  82535. */
  82536. constructor(
  82537. /** viewport left coordinate */
  82538. x: number,
  82539. /** viewport top coordinate */
  82540. y: number,
  82541. /**viewport width */
  82542. width: number,
  82543. /** viewport height */
  82544. height: number);
  82545. /**
  82546. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82547. * @param renderWidth defines the rendering width
  82548. * @param renderHeight defines the rendering height
  82549. * @returns a new Viewport
  82550. */
  82551. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82552. /**
  82553. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82554. * @param renderWidth defines the rendering width
  82555. * @param renderHeight defines the rendering height
  82556. * @param ref defines the target viewport
  82557. * @returns the current viewport
  82558. */
  82559. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82560. /**
  82561. * Returns a new Viewport copied from the current one
  82562. * @returns a new Viewport
  82563. */
  82564. clone(): Viewport;
  82565. }
  82566. }
  82567. declare module BABYLON {
  82568. /**
  82569. * Class containing a set of static utilities functions for arrays.
  82570. */
  82571. export class ArrayTools {
  82572. /**
  82573. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82574. * @param size the number of element to construct and put in the array
  82575. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82576. * @returns a new array filled with new objects
  82577. */
  82578. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82579. }
  82580. }
  82581. declare module BABYLON {
  82582. /**
  82583. * Represents a plane by the equation ax + by + cz + d = 0
  82584. */
  82585. export class Plane {
  82586. private static _TmpMatrix;
  82587. /**
  82588. * Normal of the plane (a,b,c)
  82589. */
  82590. normal: Vector3;
  82591. /**
  82592. * d component of the plane
  82593. */
  82594. d: number;
  82595. /**
  82596. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82597. * @param a a component of the plane
  82598. * @param b b component of the plane
  82599. * @param c c component of the plane
  82600. * @param d d component of the plane
  82601. */
  82602. constructor(a: number, b: number, c: number, d: number);
  82603. /**
  82604. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82605. */
  82606. asArray(): number[];
  82607. /**
  82608. * @returns a new plane copied from the current Plane.
  82609. */
  82610. clone(): Plane;
  82611. /**
  82612. * @returns the string "Plane".
  82613. */
  82614. getClassName(): string;
  82615. /**
  82616. * @returns the Plane hash code.
  82617. */
  82618. getHashCode(): number;
  82619. /**
  82620. * Normalize the current Plane in place.
  82621. * @returns the updated Plane.
  82622. */
  82623. normalize(): Plane;
  82624. /**
  82625. * Applies a transformation the plane and returns the result
  82626. * @param transformation the transformation matrix to be applied to the plane
  82627. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82628. */
  82629. transform(transformation: DeepImmutable<Matrix>): Plane;
  82630. /**
  82631. * Compute the dot product between the point and the plane normal
  82632. * @param point point to calculate the dot product with
  82633. * @returns the dot product (float) of the point coordinates and the plane normal.
  82634. */
  82635. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82636. /**
  82637. * Updates the current Plane from the plane defined by the three given points.
  82638. * @param point1 one of the points used to contruct the plane
  82639. * @param point2 one of the points used to contruct the plane
  82640. * @param point3 one of the points used to contruct the plane
  82641. * @returns the updated Plane.
  82642. */
  82643. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82644. /**
  82645. * Checks if the plane is facing a given direction
  82646. * @param direction the direction to check if the plane is facing
  82647. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82648. * @returns True is the vector "direction" is the same side than the plane normal.
  82649. */
  82650. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82651. /**
  82652. * Calculates the distance to a point
  82653. * @param point point to calculate distance to
  82654. * @returns the signed distance (float) from the given point to the Plane.
  82655. */
  82656. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82657. /**
  82658. * Creates a plane from an array
  82659. * @param array the array to create a plane from
  82660. * @returns a new Plane from the given array.
  82661. */
  82662. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82663. /**
  82664. * Creates a plane from three points
  82665. * @param point1 point used to create the plane
  82666. * @param point2 point used to create the plane
  82667. * @param point3 point used to create the plane
  82668. * @returns a new Plane defined by the three given points.
  82669. */
  82670. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82671. /**
  82672. * Creates a plane from an origin point and a normal
  82673. * @param origin origin of the plane to be constructed
  82674. * @param normal normal of the plane to be constructed
  82675. * @returns a new Plane the normal vector to this plane at the given origin point.
  82676. * Note : the vector "normal" is updated because normalized.
  82677. */
  82678. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82679. /**
  82680. * Calculates the distance from a plane and a point
  82681. * @param origin origin of the plane to be constructed
  82682. * @param normal normal of the plane to be constructed
  82683. * @param point point to calculate distance to
  82684. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82685. */
  82686. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82687. }
  82688. }
  82689. declare module BABYLON {
  82690. /** @hidden */
  82691. export class PerformanceConfigurator {
  82692. /** @hidden */
  82693. static MatrixUse64Bits: boolean;
  82694. /** @hidden */
  82695. static MatrixTrackPrecisionChange: boolean;
  82696. /** @hidden */
  82697. static MatrixCurrentType: any;
  82698. /** @hidden */
  82699. static MatrixTrackedMatrices: Array<any> | null;
  82700. /** @hidden */
  82701. static SetMatrixPrecision(use64bits: boolean): void;
  82702. }
  82703. }
  82704. declare module BABYLON {
  82705. /**
  82706. * Class representing a vector containing 2 coordinates
  82707. */
  82708. export class Vector2 {
  82709. /** defines the first coordinate */
  82710. x: number;
  82711. /** defines the second coordinate */
  82712. y: number;
  82713. /**
  82714. * Creates a new Vector2 from the given x and y coordinates
  82715. * @param x defines the first coordinate
  82716. * @param y defines the second coordinate
  82717. */
  82718. constructor(
  82719. /** defines the first coordinate */
  82720. x?: number,
  82721. /** defines the second coordinate */
  82722. y?: number);
  82723. /**
  82724. * Gets a string with the Vector2 coordinates
  82725. * @returns a string with the Vector2 coordinates
  82726. */
  82727. toString(): string;
  82728. /**
  82729. * Gets class name
  82730. * @returns the string "Vector2"
  82731. */
  82732. getClassName(): string;
  82733. /**
  82734. * Gets current vector hash code
  82735. * @returns the Vector2 hash code as a number
  82736. */
  82737. getHashCode(): number;
  82738. /**
  82739. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82740. * @param array defines the source array
  82741. * @param index defines the offset in source array
  82742. * @returns the current Vector2
  82743. */
  82744. toArray(array: FloatArray, index?: number): Vector2;
  82745. /**
  82746. * Update the current vector from an array
  82747. * @param array defines the destination array
  82748. * @param index defines the offset in the destination array
  82749. * @returns the current Vector3
  82750. */
  82751. fromArray(array: FloatArray, index?: number): Vector2;
  82752. /**
  82753. * Copy the current vector to an array
  82754. * @returns a new array with 2 elements: the Vector2 coordinates.
  82755. */
  82756. asArray(): number[];
  82757. /**
  82758. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82759. * @param source defines the source Vector2
  82760. * @returns the current updated Vector2
  82761. */
  82762. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82763. /**
  82764. * Sets the Vector2 coordinates with the given floats
  82765. * @param x defines the first coordinate
  82766. * @param y defines the second coordinate
  82767. * @returns the current updated Vector2
  82768. */
  82769. copyFromFloats(x: number, y: number): Vector2;
  82770. /**
  82771. * Sets the Vector2 coordinates with the given floats
  82772. * @param x defines the first coordinate
  82773. * @param y defines the second coordinate
  82774. * @returns the current updated Vector2
  82775. */
  82776. set(x: number, y: number): Vector2;
  82777. /**
  82778. * Add another vector with the current one
  82779. * @param otherVector defines the other vector
  82780. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82781. */
  82782. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82783. /**
  82784. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82785. * @param otherVector defines the other vector
  82786. * @param result defines the target vector
  82787. * @returns the unmodified current Vector2
  82788. */
  82789. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82790. /**
  82791. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82792. * @param otherVector defines the other vector
  82793. * @returns the current updated Vector2
  82794. */
  82795. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82796. /**
  82797. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82798. * @param otherVector defines the other vector
  82799. * @returns a new Vector2
  82800. */
  82801. addVector3(otherVector: Vector3): Vector2;
  82802. /**
  82803. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82804. * @param otherVector defines the other vector
  82805. * @returns a new Vector2
  82806. */
  82807. subtract(otherVector: Vector2): Vector2;
  82808. /**
  82809. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82810. * @param otherVector defines the other vector
  82811. * @param result defines the target vector
  82812. * @returns the unmodified current Vector2
  82813. */
  82814. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82815. /**
  82816. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82817. * @param otherVector defines the other vector
  82818. * @returns the current updated Vector2
  82819. */
  82820. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82821. /**
  82822. * Multiplies in place the current Vector2 coordinates by the given ones
  82823. * @param otherVector defines the other vector
  82824. * @returns the current updated Vector2
  82825. */
  82826. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82827. /**
  82828. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82829. * @param otherVector defines the other vector
  82830. * @returns a new Vector2
  82831. */
  82832. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82833. /**
  82834. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82835. * @param otherVector defines the other vector
  82836. * @param result defines the target vector
  82837. * @returns the unmodified current Vector2
  82838. */
  82839. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82840. /**
  82841. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82842. * @param x defines the first coordinate
  82843. * @param y defines the second coordinate
  82844. * @returns a new Vector2
  82845. */
  82846. multiplyByFloats(x: number, y: number): Vector2;
  82847. /**
  82848. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82849. * @param otherVector defines the other vector
  82850. * @returns a new Vector2
  82851. */
  82852. divide(otherVector: Vector2): Vector2;
  82853. /**
  82854. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82855. * @param otherVector defines the other vector
  82856. * @param result defines the target vector
  82857. * @returns the unmodified current Vector2
  82858. */
  82859. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82860. /**
  82861. * Divides the current Vector2 coordinates by the given ones
  82862. * @param otherVector defines the other vector
  82863. * @returns the current updated Vector2
  82864. */
  82865. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82866. /**
  82867. * Gets a new Vector2 with current Vector2 negated coordinates
  82868. * @returns a new Vector2
  82869. */
  82870. negate(): Vector2;
  82871. /**
  82872. * Negate this vector in place
  82873. * @returns this
  82874. */
  82875. negateInPlace(): Vector2;
  82876. /**
  82877. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82878. * @param result defines the Vector3 object where to store the result
  82879. * @returns the current Vector2
  82880. */
  82881. negateToRef(result: Vector2): Vector2;
  82882. /**
  82883. * Multiply the Vector2 coordinates by scale
  82884. * @param scale defines the scaling factor
  82885. * @returns the current updated Vector2
  82886. */
  82887. scaleInPlace(scale: number): Vector2;
  82888. /**
  82889. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82890. * @param scale defines the scaling factor
  82891. * @returns a new Vector2
  82892. */
  82893. scale(scale: number): Vector2;
  82894. /**
  82895. * Scale the current Vector2 values by a factor to a given Vector2
  82896. * @param scale defines the scale factor
  82897. * @param result defines the Vector2 object where to store the result
  82898. * @returns the unmodified current Vector2
  82899. */
  82900. scaleToRef(scale: number, result: Vector2): Vector2;
  82901. /**
  82902. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82903. * @param scale defines the scale factor
  82904. * @param result defines the Vector2 object where to store the result
  82905. * @returns the unmodified current Vector2
  82906. */
  82907. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82908. /**
  82909. * Gets a boolean if two vectors are equals
  82910. * @param otherVector defines the other vector
  82911. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82912. */
  82913. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82914. /**
  82915. * Gets a boolean if two vectors are equals (using an epsilon value)
  82916. * @param otherVector defines the other vector
  82917. * @param epsilon defines the minimal distance to consider equality
  82918. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82919. */
  82920. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82921. /**
  82922. * Gets a new Vector2 from current Vector2 floored values
  82923. * @returns a new Vector2
  82924. */
  82925. floor(): Vector2;
  82926. /**
  82927. * Gets a new Vector2 from current Vector2 floored values
  82928. * @returns a new Vector2
  82929. */
  82930. fract(): Vector2;
  82931. /**
  82932. * Gets the length of the vector
  82933. * @returns the vector length (float)
  82934. */
  82935. length(): number;
  82936. /**
  82937. * Gets the vector squared length
  82938. * @returns the vector squared length (float)
  82939. */
  82940. lengthSquared(): number;
  82941. /**
  82942. * Normalize the vector
  82943. * @returns the current updated Vector2
  82944. */
  82945. normalize(): Vector2;
  82946. /**
  82947. * Gets a new Vector2 copied from the Vector2
  82948. * @returns a new Vector2
  82949. */
  82950. clone(): Vector2;
  82951. /**
  82952. * Gets a new Vector2(0, 0)
  82953. * @returns a new Vector2
  82954. */
  82955. static Zero(): Vector2;
  82956. /**
  82957. * Gets a new Vector2(1, 1)
  82958. * @returns a new Vector2
  82959. */
  82960. static One(): Vector2;
  82961. /**
  82962. * Gets a new Vector2 set from the given index element of the given array
  82963. * @param array defines the data source
  82964. * @param offset defines the offset in the data source
  82965. * @returns a new Vector2
  82966. */
  82967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82968. /**
  82969. * Sets "result" from the given index element of the given array
  82970. * @param array defines the data source
  82971. * @param offset defines the offset in the data source
  82972. * @param result defines the target vector
  82973. */
  82974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82975. /**
  82976. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82977. * @param value1 defines 1st point of control
  82978. * @param value2 defines 2nd point of control
  82979. * @param value3 defines 3rd point of control
  82980. * @param value4 defines 4th point of control
  82981. * @param amount defines the interpolation factor
  82982. * @returns a new Vector2
  82983. */
  82984. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82985. /**
  82986. * 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".
  82987. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82988. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82989. * @param value defines the value to clamp
  82990. * @param min defines the lower limit
  82991. * @param max defines the upper limit
  82992. * @returns a new Vector2
  82993. */
  82994. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82995. /**
  82996. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82997. * @param value1 defines the 1st control point
  82998. * @param tangent1 defines the outgoing tangent
  82999. * @param value2 defines the 2nd control point
  83000. * @param tangent2 defines the incoming tangent
  83001. * @param amount defines the interpolation factor
  83002. * @returns a new Vector2
  83003. */
  83004. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  83005. /**
  83006. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  83007. * @param start defines the start vector
  83008. * @param end defines the end vector
  83009. * @param amount defines the interpolation factor
  83010. * @returns a new Vector2
  83011. */
  83012. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  83013. /**
  83014. * Gets the dot product of the vector "left" and the vector "right"
  83015. * @param left defines first vector
  83016. * @param right defines second vector
  83017. * @returns the dot product (float)
  83018. */
  83019. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  83020. /**
  83021. * Returns a new Vector2 equal to the normalized given vector
  83022. * @param vector defines the vector to normalize
  83023. * @returns a new Vector2
  83024. */
  83025. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  83026. /**
  83027. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  83028. * @param left defines 1st vector
  83029. * @param right defines 2nd vector
  83030. * @returns a new Vector2
  83031. */
  83032. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83033. /**
  83034. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  83035. * @param left defines 1st vector
  83036. * @param right defines 2nd vector
  83037. * @returns a new Vector2
  83038. */
  83039. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83040. /**
  83041. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  83042. * @param vector defines the vector to transform
  83043. * @param transformation defines the matrix to apply
  83044. * @returns a new Vector2
  83045. */
  83046. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  83047. /**
  83048. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  83049. * @param vector defines the vector to transform
  83050. * @param transformation defines the matrix to apply
  83051. * @param result defines the target vector
  83052. */
  83053. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  83054. /**
  83055. * Determines if a given vector is included in a triangle
  83056. * @param p defines the vector to test
  83057. * @param p0 defines 1st triangle point
  83058. * @param p1 defines 2nd triangle point
  83059. * @param p2 defines 3rd triangle point
  83060. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  83061. */
  83062. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  83063. /**
  83064. * Gets the distance between the vectors "value1" and "value2"
  83065. * @param value1 defines first vector
  83066. * @param value2 defines second vector
  83067. * @returns the distance between vectors
  83068. */
  83069. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83070. /**
  83071. * Returns the squared distance between the vectors "value1" and "value2"
  83072. * @param value1 defines first vector
  83073. * @param value2 defines second vector
  83074. * @returns the squared distance between vectors
  83075. */
  83076. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83077. /**
  83078. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  83079. * @param value1 defines first vector
  83080. * @param value2 defines second vector
  83081. * @returns a new Vector2
  83082. */
  83083. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  83084. /**
  83085. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  83086. * @param p defines the middle point
  83087. * @param segA defines one point of the segment
  83088. * @param segB defines the other point of the segment
  83089. * @returns the shortest distance
  83090. */
  83091. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  83092. }
  83093. /**
  83094. * Class used to store (x,y,z) vector representation
  83095. * A Vector3 is the main object used in 3D geometry
  83096. * It can represent etiher the coordinates of a point the space, either a direction
  83097. * Reminder: js uses a left handed forward facing system
  83098. */
  83099. export class Vector3 {
  83100. private static _UpReadOnly;
  83101. private static _ZeroReadOnly;
  83102. /** @hidden */
  83103. _x: number;
  83104. /** @hidden */
  83105. _y: number;
  83106. /** @hidden */
  83107. _z: number;
  83108. /** @hidden */
  83109. _isDirty: boolean;
  83110. /** Gets or sets the x coordinate */
  83111. get x(): number;
  83112. set x(value: number);
  83113. /** Gets or sets the y coordinate */
  83114. get y(): number;
  83115. set y(value: number);
  83116. /** Gets or sets the z coordinate */
  83117. get z(): number;
  83118. set z(value: number);
  83119. /**
  83120. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  83121. * @param x defines the first coordinates (on X axis)
  83122. * @param y defines the second coordinates (on Y axis)
  83123. * @param z defines the third coordinates (on Z axis)
  83124. */
  83125. constructor(x?: number, y?: number, z?: number);
  83126. /**
  83127. * Creates a string representation of the Vector3
  83128. * @returns a string with the Vector3 coordinates.
  83129. */
  83130. toString(): string;
  83131. /**
  83132. * Gets the class name
  83133. * @returns the string "Vector3"
  83134. */
  83135. getClassName(): string;
  83136. /**
  83137. * Creates the Vector3 hash code
  83138. * @returns a number which tends to be unique between Vector3 instances
  83139. */
  83140. getHashCode(): number;
  83141. /**
  83142. * Creates an array containing three elements : the coordinates of the Vector3
  83143. * @returns a new array of numbers
  83144. */
  83145. asArray(): number[];
  83146. /**
  83147. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  83148. * @param array defines the destination array
  83149. * @param index defines the offset in the destination array
  83150. * @returns the current Vector3
  83151. */
  83152. toArray(array: FloatArray, index?: number): Vector3;
  83153. /**
  83154. * Update the current vector from an array
  83155. * @param array defines the destination array
  83156. * @param index defines the offset in the destination array
  83157. * @returns the current Vector3
  83158. */
  83159. fromArray(array: FloatArray, index?: number): Vector3;
  83160. /**
  83161. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  83162. * @returns a new Quaternion object, computed from the Vector3 coordinates
  83163. */
  83164. toQuaternion(): Quaternion;
  83165. /**
  83166. * Adds the given vector to the current Vector3
  83167. * @param otherVector defines the second operand
  83168. * @returns the current updated Vector3
  83169. */
  83170. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83171. /**
  83172. * Adds the given coordinates to the current Vector3
  83173. * @param x defines the x coordinate of the operand
  83174. * @param y defines the y coordinate of the operand
  83175. * @param z defines the z coordinate of the operand
  83176. * @returns the current updated Vector3
  83177. */
  83178. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83179. /**
  83180. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  83181. * @param otherVector defines the second operand
  83182. * @returns the resulting Vector3
  83183. */
  83184. add(otherVector: DeepImmutable<Vector3>): Vector3;
  83185. /**
  83186. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  83187. * @param otherVector defines the second operand
  83188. * @param result defines the Vector3 object where to store the result
  83189. * @returns the current Vector3
  83190. */
  83191. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83192. /**
  83193. * Subtract the given vector from the current Vector3
  83194. * @param otherVector defines the second operand
  83195. * @returns the current updated Vector3
  83196. */
  83197. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83198. /**
  83199. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  83200. * @param otherVector defines the second operand
  83201. * @returns the resulting Vector3
  83202. */
  83203. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  83204. /**
  83205. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  83206. * @param otherVector defines the second operand
  83207. * @param result defines the Vector3 object where to store the result
  83208. * @returns the current Vector3
  83209. */
  83210. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83211. /**
  83212. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  83213. * @param x defines the x coordinate of the operand
  83214. * @param y defines the y coordinate of the operand
  83215. * @param z defines the z coordinate of the operand
  83216. * @returns the resulting Vector3
  83217. */
  83218. subtractFromFloats(x: number, y: number, z: number): Vector3;
  83219. /**
  83220. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  83221. * @param x defines the x coordinate of the operand
  83222. * @param y defines the y coordinate of the operand
  83223. * @param z defines the z coordinate of the operand
  83224. * @param result defines the Vector3 object where to store the result
  83225. * @returns the current Vector3
  83226. */
  83227. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  83228. /**
  83229. * Gets a new Vector3 set with the current Vector3 negated coordinates
  83230. * @returns a new Vector3
  83231. */
  83232. negate(): Vector3;
  83233. /**
  83234. * Negate this vector in place
  83235. * @returns this
  83236. */
  83237. negateInPlace(): Vector3;
  83238. /**
  83239. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  83240. * @param result defines the Vector3 object where to store the result
  83241. * @returns the current Vector3
  83242. */
  83243. negateToRef(result: Vector3): Vector3;
  83244. /**
  83245. * Multiplies the Vector3 coordinates by the float "scale"
  83246. * @param scale defines the multiplier factor
  83247. * @returns the current updated Vector3
  83248. */
  83249. scaleInPlace(scale: number): Vector3;
  83250. /**
  83251. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  83252. * @param scale defines the multiplier factor
  83253. * @returns a new Vector3
  83254. */
  83255. scale(scale: number): Vector3;
  83256. /**
  83257. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  83258. * @param scale defines the multiplier factor
  83259. * @param result defines the Vector3 object where to store the result
  83260. * @returns the current Vector3
  83261. */
  83262. scaleToRef(scale: number, result: Vector3): Vector3;
  83263. /**
  83264. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  83265. * @param scale defines the scale factor
  83266. * @param result defines the Vector3 object where to store the result
  83267. * @returns the unmodified current Vector3
  83268. */
  83269. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  83270. /**
  83271. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83272. * @param origin defines the origin of the projection ray
  83273. * @param plane defines the plane to project to
  83274. * @returns the projected vector3
  83275. */
  83276. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  83277. /**
  83278. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83279. * @param origin defines the origin of the projection ray
  83280. * @param plane defines the plane to project to
  83281. * @param result defines the Vector3 where to store the result
  83282. */
  83283. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  83284. /**
  83285. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  83286. * @param otherVector defines the second operand
  83287. * @returns true if both vectors are equals
  83288. */
  83289. equals(otherVector: DeepImmutable<Vector3>): boolean;
  83290. /**
  83291. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  83292. * @param otherVector defines the second operand
  83293. * @param epsilon defines the minimal distance to define values as equals
  83294. * @returns true if both vectors are distant less than epsilon
  83295. */
  83296. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  83297. /**
  83298. * Returns true if the current Vector3 coordinates equals the given floats
  83299. * @param x defines the x coordinate of the operand
  83300. * @param y defines the y coordinate of the operand
  83301. * @param z defines the z coordinate of the operand
  83302. * @returns true if both vectors are equals
  83303. */
  83304. equalsToFloats(x: number, y: number, z: number): boolean;
  83305. /**
  83306. * Multiplies the current Vector3 coordinates by the given ones
  83307. * @param otherVector defines the second operand
  83308. * @returns the current updated Vector3
  83309. */
  83310. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83311. /**
  83312. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83313. * @param otherVector defines the second operand
  83314. * @returns the new Vector3
  83315. */
  83316. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  83317. /**
  83318. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83319. * @param otherVector defines the second operand
  83320. * @param result defines the Vector3 object where to store the result
  83321. * @returns the current Vector3
  83322. */
  83323. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83324. /**
  83325. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83326. * @param x defines the x coordinate of the operand
  83327. * @param y defines the y coordinate of the operand
  83328. * @param z defines the z coordinate of the operand
  83329. * @returns the new Vector3
  83330. */
  83331. multiplyByFloats(x: number, y: number, z: number): Vector3;
  83332. /**
  83333. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83334. * @param otherVector defines the second operand
  83335. * @returns the new Vector3
  83336. */
  83337. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  83338. /**
  83339. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83340. * @param otherVector defines the second operand
  83341. * @param result defines the Vector3 object where to store the result
  83342. * @returns the current Vector3
  83343. */
  83344. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83345. /**
  83346. * Divides the current Vector3 coordinates by the given ones.
  83347. * @param otherVector defines the second operand
  83348. * @returns the current updated Vector3
  83349. */
  83350. divideInPlace(otherVector: Vector3): Vector3;
  83351. /**
  83352. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83353. * @param other defines the second operand
  83354. * @returns the current updated Vector3
  83355. */
  83356. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83357. /**
  83358. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83359. * @param other defines the second operand
  83360. * @returns the current updated Vector3
  83361. */
  83362. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83363. /**
  83364. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83365. * @param x defines the x coordinate of the operand
  83366. * @param y defines the y coordinate of the operand
  83367. * @param z defines the z coordinate of the operand
  83368. * @returns the current updated Vector3
  83369. */
  83370. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83371. /**
  83372. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83373. * @param x defines the x coordinate of the operand
  83374. * @param y defines the y coordinate of the operand
  83375. * @param z defines the z coordinate of the operand
  83376. * @returns the current updated Vector3
  83377. */
  83378. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83379. /**
  83380. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83381. * Check if is non uniform within a certain amount of decimal places to account for this
  83382. * @param epsilon the amount the values can differ
  83383. * @returns if the the vector is non uniform to a certain number of decimal places
  83384. */
  83385. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83386. /**
  83387. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83388. */
  83389. get isNonUniform(): boolean;
  83390. /**
  83391. * Gets a new Vector3 from current Vector3 floored values
  83392. * @returns a new Vector3
  83393. */
  83394. floor(): Vector3;
  83395. /**
  83396. * Gets a new Vector3 from current Vector3 floored values
  83397. * @returns a new Vector3
  83398. */
  83399. fract(): Vector3;
  83400. /**
  83401. * Gets the length of the Vector3
  83402. * @returns the length of the Vector3
  83403. */
  83404. length(): number;
  83405. /**
  83406. * Gets the squared length of the Vector3
  83407. * @returns squared length of the Vector3
  83408. */
  83409. lengthSquared(): number;
  83410. /**
  83411. * Normalize the current Vector3.
  83412. * Please note that this is an in place operation.
  83413. * @returns the current updated Vector3
  83414. */
  83415. normalize(): Vector3;
  83416. /**
  83417. * Reorders the x y z properties of the vector in place
  83418. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83419. * @returns the current updated vector
  83420. */
  83421. reorderInPlace(order: string): this;
  83422. /**
  83423. * Rotates the vector around 0,0,0 by a quaternion
  83424. * @param quaternion the rotation quaternion
  83425. * @param result vector to store the result
  83426. * @returns the resulting vector
  83427. */
  83428. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83429. /**
  83430. * Rotates a vector around a given point
  83431. * @param quaternion the rotation quaternion
  83432. * @param point the point to rotate around
  83433. * @param result vector to store the result
  83434. * @returns the resulting vector
  83435. */
  83436. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83437. /**
  83438. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83439. * The cross product is then orthogonal to both current and "other"
  83440. * @param other defines the right operand
  83441. * @returns the cross product
  83442. */
  83443. cross(other: Vector3): Vector3;
  83444. /**
  83445. * Normalize the current Vector3 with the given input length.
  83446. * Please note that this is an in place operation.
  83447. * @param len the length of the vector
  83448. * @returns the current updated Vector3
  83449. */
  83450. normalizeFromLength(len: number): Vector3;
  83451. /**
  83452. * Normalize the current Vector3 to a new vector
  83453. * @returns the new Vector3
  83454. */
  83455. normalizeToNew(): Vector3;
  83456. /**
  83457. * Normalize the current Vector3 to the reference
  83458. * @param reference define the Vector3 to update
  83459. * @returns the updated Vector3
  83460. */
  83461. normalizeToRef(reference: Vector3): Vector3;
  83462. /**
  83463. * Creates a new Vector3 copied from the current Vector3
  83464. * @returns the new Vector3
  83465. */
  83466. clone(): Vector3;
  83467. /**
  83468. * Copies the given vector coordinates to the current Vector3 ones
  83469. * @param source defines the source Vector3
  83470. * @returns the current updated Vector3
  83471. */
  83472. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83473. /**
  83474. * Copies the given floats to the current Vector3 coordinates
  83475. * @param x defines the x coordinate of the operand
  83476. * @param y defines the y coordinate of the operand
  83477. * @param z defines the z coordinate of the operand
  83478. * @returns the current updated Vector3
  83479. */
  83480. copyFromFloats(x: number, y: number, z: number): Vector3;
  83481. /**
  83482. * Copies the given floats to the current Vector3 coordinates
  83483. * @param x defines the x coordinate of the operand
  83484. * @param y defines the y coordinate of the operand
  83485. * @param z defines the z coordinate of the operand
  83486. * @returns the current updated Vector3
  83487. */
  83488. set(x: number, y: number, z: number): Vector3;
  83489. /**
  83490. * Copies the given float to the current Vector3 coordinates
  83491. * @param v defines the x, y and z coordinates of the operand
  83492. * @returns the current updated Vector3
  83493. */
  83494. setAll(v: number): Vector3;
  83495. /**
  83496. * Get the clip factor between two vectors
  83497. * @param vector0 defines the first operand
  83498. * @param vector1 defines the second operand
  83499. * @param axis defines the axis to use
  83500. * @param size defines the size along the axis
  83501. * @returns the clip factor
  83502. */
  83503. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83504. /**
  83505. * Get angle between two vectors
  83506. * @param vector0 angle between vector0 and vector1
  83507. * @param vector1 angle between vector0 and vector1
  83508. * @param normal direction of the normal
  83509. * @return the angle between vector0 and vector1
  83510. */
  83511. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83512. /**
  83513. * Returns a new Vector3 set from the index "offset" of the given array
  83514. * @param array defines the source array
  83515. * @param offset defines the offset in the source array
  83516. * @returns the new Vector3
  83517. */
  83518. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83519. /**
  83520. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83521. * @param array defines the source array
  83522. * @param offset defines the offset in the source array
  83523. * @returns the new Vector3
  83524. * @deprecated Please use FromArray instead.
  83525. */
  83526. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83527. /**
  83528. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83529. * @param array defines the source array
  83530. * @param offset defines the offset in the source array
  83531. * @param result defines the Vector3 where to store the result
  83532. */
  83533. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83534. /**
  83535. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83536. * @param array defines the source array
  83537. * @param offset defines the offset in the source array
  83538. * @param result defines the Vector3 where to store the result
  83539. * @deprecated Please use FromArrayToRef instead.
  83540. */
  83541. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83542. /**
  83543. * Sets the given vector "result" with the given floats.
  83544. * @param x defines the x coordinate of the source
  83545. * @param y defines the y coordinate of the source
  83546. * @param z defines the z coordinate of the source
  83547. * @param result defines the Vector3 where to store the result
  83548. */
  83549. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83550. /**
  83551. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83552. * @returns a new empty Vector3
  83553. */
  83554. static Zero(): Vector3;
  83555. /**
  83556. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83557. * @returns a new unit Vector3
  83558. */
  83559. static One(): Vector3;
  83560. /**
  83561. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83562. * @returns a new up Vector3
  83563. */
  83564. static Up(): Vector3;
  83565. /**
  83566. * Gets a up Vector3 that must not be updated
  83567. */
  83568. static get UpReadOnly(): DeepImmutable<Vector3>;
  83569. /**
  83570. * Gets a zero Vector3 that must not be updated
  83571. */
  83572. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83573. /**
  83574. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83575. * @returns a new down Vector3
  83576. */
  83577. static Down(): Vector3;
  83578. /**
  83579. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83580. * @param rightHandedSystem is the scene right-handed (negative z)
  83581. * @returns a new forward Vector3
  83582. */
  83583. static Forward(rightHandedSystem?: boolean): Vector3;
  83584. /**
  83585. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83586. * @param rightHandedSystem is the scene right-handed (negative-z)
  83587. * @returns a new forward Vector3
  83588. */
  83589. static Backward(rightHandedSystem?: boolean): Vector3;
  83590. /**
  83591. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83592. * @returns a new right Vector3
  83593. */
  83594. static Right(): Vector3;
  83595. /**
  83596. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83597. * @returns a new left Vector3
  83598. */
  83599. static Left(): Vector3;
  83600. /**
  83601. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83602. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83603. * @param vector defines the Vector3 to transform
  83604. * @param transformation defines the transformation matrix
  83605. * @returns the transformed Vector3
  83606. */
  83607. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83608. /**
  83609. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83610. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83611. * @param vector defines the Vector3 to transform
  83612. * @param transformation defines the transformation matrix
  83613. * @param result defines the Vector3 where to store the result
  83614. */
  83615. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83616. /**
  83617. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83618. * This method computes tranformed coordinates only, not transformed direction vectors
  83619. * @param x define the x coordinate of the source vector
  83620. * @param y define the y coordinate of the source vector
  83621. * @param z define the z coordinate of the source vector
  83622. * @param transformation defines the transformation matrix
  83623. * @param result defines the Vector3 where to store the result
  83624. */
  83625. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83626. /**
  83627. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83628. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83629. * @param vector defines the Vector3 to transform
  83630. * @param transformation defines the transformation matrix
  83631. * @returns the new Vector3
  83632. */
  83633. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83634. /**
  83635. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83636. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83637. * @param vector defines the Vector3 to transform
  83638. * @param transformation defines the transformation matrix
  83639. * @param result defines the Vector3 where to store the result
  83640. */
  83641. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83642. /**
  83643. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83644. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83645. * @param x define the x coordinate of the source vector
  83646. * @param y define the y coordinate of the source vector
  83647. * @param z define the z coordinate of the source vector
  83648. * @param transformation defines the transformation matrix
  83649. * @param result defines the Vector3 where to store the result
  83650. */
  83651. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83652. /**
  83653. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83654. * @param value1 defines the first control point
  83655. * @param value2 defines the second control point
  83656. * @param value3 defines the third control point
  83657. * @param value4 defines the fourth control point
  83658. * @param amount defines the amount on the spline to use
  83659. * @returns the new Vector3
  83660. */
  83661. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83662. /**
  83663. * 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"
  83664. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83665. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83666. * @param value defines the current value
  83667. * @param min defines the lower range value
  83668. * @param max defines the upper range value
  83669. * @returns the new Vector3
  83670. */
  83671. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83672. /**
  83673. * 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"
  83674. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83675. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83676. * @param value defines the current value
  83677. * @param min defines the lower range value
  83678. * @param max defines the upper range value
  83679. * @param result defines the Vector3 where to store the result
  83680. */
  83681. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83682. /**
  83683. * Checks if a given vector is inside a specific range
  83684. * @param v defines the vector to test
  83685. * @param min defines the minimum range
  83686. * @param max defines the maximum range
  83687. */
  83688. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83689. /**
  83690. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83691. * @param value1 defines the first control point
  83692. * @param tangent1 defines the first tangent vector
  83693. * @param value2 defines the second control point
  83694. * @param tangent2 defines the second tangent vector
  83695. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83696. * @returns the new Vector3
  83697. */
  83698. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83699. /**
  83700. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83701. * @param start defines the start value
  83702. * @param end defines the end value
  83703. * @param amount max defines amount between both (between 0 and 1)
  83704. * @returns the new Vector3
  83705. */
  83706. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83707. /**
  83708. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83709. * @param start defines the start value
  83710. * @param end defines the end value
  83711. * @param amount max defines amount between both (between 0 and 1)
  83712. * @param result defines the Vector3 where to store the result
  83713. */
  83714. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83715. /**
  83716. * Returns the dot product (float) between the vectors "left" and "right"
  83717. * @param left defines the left operand
  83718. * @param right defines the right operand
  83719. * @returns the dot product
  83720. */
  83721. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83722. /**
  83723. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83724. * The cross product is then orthogonal to both "left" and "right"
  83725. * @param left defines the left operand
  83726. * @param right defines the right operand
  83727. * @returns the cross product
  83728. */
  83729. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83730. /**
  83731. * Sets the given vector "result" with the cross product of "left" and "right"
  83732. * The cross product is then orthogonal to both "left" and "right"
  83733. * @param left defines the left operand
  83734. * @param right defines the right operand
  83735. * @param result defines the Vector3 where to store the result
  83736. */
  83737. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83738. /**
  83739. * Returns a new Vector3 as the normalization of the given vector
  83740. * @param vector defines the Vector3 to normalize
  83741. * @returns the new Vector3
  83742. */
  83743. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83744. /**
  83745. * Sets the given vector "result" with the normalization of the given first vector
  83746. * @param vector defines the Vector3 to normalize
  83747. * @param result defines the Vector3 where to store the result
  83748. */
  83749. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83750. /**
  83751. * Project a Vector3 onto screen space
  83752. * @param vector defines the Vector3 to project
  83753. * @param world defines the world matrix to use
  83754. * @param transform defines the transform (view x projection) matrix to use
  83755. * @param viewport defines the screen viewport to use
  83756. * @returns the new Vector3
  83757. */
  83758. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83759. /** @hidden */
  83760. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83761. /**
  83762. * Unproject from screen space to object space
  83763. * @param source defines the screen space Vector3 to use
  83764. * @param viewportWidth defines the current width of the viewport
  83765. * @param viewportHeight defines the current height of the viewport
  83766. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83767. * @param transform defines the transform (view x projection) matrix to use
  83768. * @returns the new Vector3
  83769. */
  83770. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83771. /**
  83772. * Unproject from screen space to object space
  83773. * @param source defines the screen space Vector3 to use
  83774. * @param viewportWidth defines the current width of the viewport
  83775. * @param viewportHeight defines the current height of the viewport
  83776. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83777. * @param view defines the view matrix to use
  83778. * @param projection defines the projection matrix to use
  83779. * @returns the new Vector3
  83780. */
  83781. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83782. /**
  83783. * Unproject from screen space to object space
  83784. * @param source defines the screen space Vector3 to use
  83785. * @param viewportWidth defines the current width of the viewport
  83786. * @param viewportHeight defines the current height of the viewport
  83787. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83788. * @param view defines the view matrix to use
  83789. * @param projection defines the projection matrix to use
  83790. * @param result defines the Vector3 where to store the result
  83791. */
  83792. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83793. /**
  83794. * Unproject from screen space to object space
  83795. * @param sourceX defines the screen space x coordinate to use
  83796. * @param sourceY defines the screen space y coordinate to use
  83797. * @param sourceZ defines the screen space z coordinate to use
  83798. * @param viewportWidth defines the current width of the viewport
  83799. * @param viewportHeight defines the current height of the viewport
  83800. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83801. * @param view defines the view matrix to use
  83802. * @param projection defines the projection matrix to use
  83803. * @param result defines the Vector3 where to store the result
  83804. */
  83805. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83806. /**
  83807. * Gets the minimal coordinate values between two Vector3
  83808. * @param left defines the first operand
  83809. * @param right defines the second operand
  83810. * @returns the new Vector3
  83811. */
  83812. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83813. /**
  83814. * Gets the maximal coordinate values between two Vector3
  83815. * @param left defines the first operand
  83816. * @param right defines the second operand
  83817. * @returns the new Vector3
  83818. */
  83819. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83820. /**
  83821. * Returns the distance between the vectors "value1" and "value2"
  83822. * @param value1 defines the first operand
  83823. * @param value2 defines the second operand
  83824. * @returns the distance
  83825. */
  83826. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83827. /**
  83828. * Returns the squared distance between the vectors "value1" and "value2"
  83829. * @param value1 defines the first operand
  83830. * @param value2 defines the second operand
  83831. * @returns the squared distance
  83832. */
  83833. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83834. /**
  83835. * Returns a new Vector3 located at the center between "value1" and "value2"
  83836. * @param value1 defines the first operand
  83837. * @param value2 defines the second operand
  83838. * @returns the new Vector3
  83839. */
  83840. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83841. /**
  83842. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83843. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83844. * to something in order to rotate it from its local system to the given target system
  83845. * Note: axis1, axis2 and axis3 are normalized during this operation
  83846. * @param axis1 defines the first axis
  83847. * @param axis2 defines the second axis
  83848. * @param axis3 defines the third axis
  83849. * @returns a new Vector3
  83850. */
  83851. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83852. /**
  83853. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83854. * @param axis1 defines the first axis
  83855. * @param axis2 defines the second axis
  83856. * @param axis3 defines the third axis
  83857. * @param ref defines the Vector3 where to store the result
  83858. */
  83859. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83860. }
  83861. /**
  83862. * Vector4 class created for EulerAngle class conversion to Quaternion
  83863. */
  83864. export class Vector4 {
  83865. /** x value of the vector */
  83866. x: number;
  83867. /** y value of the vector */
  83868. y: number;
  83869. /** z value of the vector */
  83870. z: number;
  83871. /** w value of the vector */
  83872. w: number;
  83873. /**
  83874. * Creates a Vector4 object from the given floats.
  83875. * @param x x value of the vector
  83876. * @param y y value of the vector
  83877. * @param z z value of the vector
  83878. * @param w w value of the vector
  83879. */
  83880. constructor(
  83881. /** x value of the vector */
  83882. x: number,
  83883. /** y value of the vector */
  83884. y: number,
  83885. /** z value of the vector */
  83886. z: number,
  83887. /** w value of the vector */
  83888. w: number);
  83889. /**
  83890. * Returns the string with the Vector4 coordinates.
  83891. * @returns a string containing all the vector values
  83892. */
  83893. toString(): string;
  83894. /**
  83895. * Returns the string "Vector4".
  83896. * @returns "Vector4"
  83897. */
  83898. getClassName(): string;
  83899. /**
  83900. * Returns the Vector4 hash code.
  83901. * @returns a unique hash code
  83902. */
  83903. getHashCode(): number;
  83904. /**
  83905. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83906. * @returns the resulting array
  83907. */
  83908. asArray(): number[];
  83909. /**
  83910. * Populates the given array from the given index with the Vector4 coordinates.
  83911. * @param array array to populate
  83912. * @param index index of the array to start at (default: 0)
  83913. * @returns the Vector4.
  83914. */
  83915. toArray(array: FloatArray, index?: number): Vector4;
  83916. /**
  83917. * Update the current vector from an array
  83918. * @param array defines the destination array
  83919. * @param index defines the offset in the destination array
  83920. * @returns the current Vector3
  83921. */
  83922. fromArray(array: FloatArray, index?: number): Vector4;
  83923. /**
  83924. * Adds the given vector to the current Vector4.
  83925. * @param otherVector the vector to add
  83926. * @returns the updated Vector4.
  83927. */
  83928. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83929. /**
  83930. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83931. * @param otherVector the vector to add
  83932. * @returns the resulting vector
  83933. */
  83934. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83935. /**
  83936. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83937. * @param otherVector the vector to add
  83938. * @param result the vector to store the result
  83939. * @returns the current Vector4.
  83940. */
  83941. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83942. /**
  83943. * Subtract in place the given vector from the current Vector4.
  83944. * @param otherVector the vector to subtract
  83945. * @returns the updated Vector4.
  83946. */
  83947. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83948. /**
  83949. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83950. * @param otherVector the vector to add
  83951. * @returns the new vector with the result
  83952. */
  83953. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83954. /**
  83955. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83956. * @param otherVector the vector to subtract
  83957. * @param result the vector to store the result
  83958. * @returns the current Vector4.
  83959. */
  83960. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83961. /**
  83962. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83963. */
  83964. /**
  83965. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83966. * @param x value to subtract
  83967. * @param y value to subtract
  83968. * @param z value to subtract
  83969. * @param w value to subtract
  83970. * @returns new vector containing the result
  83971. */
  83972. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83973. /**
  83974. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83975. * @param x value to subtract
  83976. * @param y value to subtract
  83977. * @param z value to subtract
  83978. * @param w value to subtract
  83979. * @param result the vector to store the result in
  83980. * @returns the current Vector4.
  83981. */
  83982. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83983. /**
  83984. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83985. * @returns a new vector with the negated values
  83986. */
  83987. negate(): Vector4;
  83988. /**
  83989. * Negate this vector in place
  83990. * @returns this
  83991. */
  83992. negateInPlace(): Vector4;
  83993. /**
  83994. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83995. * @param result defines the Vector3 object where to store the result
  83996. * @returns the current Vector4
  83997. */
  83998. negateToRef(result: Vector4): Vector4;
  83999. /**
  84000. * Multiplies the current Vector4 coordinates by scale (float).
  84001. * @param scale the number to scale with
  84002. * @returns the updated Vector4.
  84003. */
  84004. scaleInPlace(scale: number): Vector4;
  84005. /**
  84006. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  84007. * @param scale the number to scale with
  84008. * @returns a new vector with the result
  84009. */
  84010. scale(scale: number): Vector4;
  84011. /**
  84012. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  84013. * @param scale the number to scale with
  84014. * @param result a vector to store the result in
  84015. * @returns the current Vector4.
  84016. */
  84017. scaleToRef(scale: number, result: Vector4): Vector4;
  84018. /**
  84019. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  84020. * @param scale defines the scale factor
  84021. * @param result defines the Vector4 object where to store the result
  84022. * @returns the unmodified current Vector4
  84023. */
  84024. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  84025. /**
  84026. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  84027. * @param otherVector the vector to compare against
  84028. * @returns true if they are equal
  84029. */
  84030. equals(otherVector: DeepImmutable<Vector4>): boolean;
  84031. /**
  84032. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  84033. * @param otherVector vector to compare against
  84034. * @param epsilon (Default: very small number)
  84035. * @returns true if they are equal
  84036. */
  84037. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  84038. /**
  84039. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  84040. * @param x x value to compare against
  84041. * @param y y value to compare against
  84042. * @param z z value to compare against
  84043. * @param w w value to compare against
  84044. * @returns true if equal
  84045. */
  84046. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  84047. /**
  84048. * Multiplies in place the current Vector4 by the given one.
  84049. * @param otherVector vector to multiple with
  84050. * @returns the updated Vector4.
  84051. */
  84052. multiplyInPlace(otherVector: Vector4): Vector4;
  84053. /**
  84054. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  84055. * @param otherVector vector to multiple with
  84056. * @returns resulting new vector
  84057. */
  84058. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  84059. /**
  84060. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  84061. * @param otherVector vector to multiple with
  84062. * @param result vector to store the result
  84063. * @returns the current Vector4.
  84064. */
  84065. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84066. /**
  84067. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  84068. * @param x x value multiply with
  84069. * @param y y value multiply with
  84070. * @param z z value multiply with
  84071. * @param w w value multiply with
  84072. * @returns resulting new vector
  84073. */
  84074. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  84075. /**
  84076. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  84077. * @param otherVector vector to devide with
  84078. * @returns resulting new vector
  84079. */
  84080. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  84081. /**
  84082. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  84083. * @param otherVector vector to devide with
  84084. * @param result vector to store the result
  84085. * @returns the current Vector4.
  84086. */
  84087. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84088. /**
  84089. * Divides the current Vector3 coordinates by the given ones.
  84090. * @param otherVector vector to devide with
  84091. * @returns the updated Vector3.
  84092. */
  84093. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84094. /**
  84095. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  84096. * @param other defines the second operand
  84097. * @returns the current updated Vector4
  84098. */
  84099. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84100. /**
  84101. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  84102. * @param other defines the second operand
  84103. * @returns the current updated Vector4
  84104. */
  84105. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84106. /**
  84107. * Gets a new Vector4 from current Vector4 floored values
  84108. * @returns a new Vector4
  84109. */
  84110. floor(): Vector4;
  84111. /**
  84112. * Gets a new Vector4 from current Vector3 floored values
  84113. * @returns a new Vector4
  84114. */
  84115. fract(): Vector4;
  84116. /**
  84117. * Returns the Vector4 length (float).
  84118. * @returns the length
  84119. */
  84120. length(): number;
  84121. /**
  84122. * Returns the Vector4 squared length (float).
  84123. * @returns the length squared
  84124. */
  84125. lengthSquared(): number;
  84126. /**
  84127. * Normalizes in place the Vector4.
  84128. * @returns the updated Vector4.
  84129. */
  84130. normalize(): Vector4;
  84131. /**
  84132. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  84133. * @returns this converted to a new vector3
  84134. */
  84135. toVector3(): Vector3;
  84136. /**
  84137. * Returns a new Vector4 copied from the current one.
  84138. * @returns the new cloned vector
  84139. */
  84140. clone(): Vector4;
  84141. /**
  84142. * Updates the current Vector4 with the given one coordinates.
  84143. * @param source the source vector to copy from
  84144. * @returns the updated Vector4.
  84145. */
  84146. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  84147. /**
  84148. * Updates the current Vector4 coordinates with the given floats.
  84149. * @param x float to copy from
  84150. * @param y float to copy from
  84151. * @param z float to copy from
  84152. * @param w float to copy from
  84153. * @returns the updated Vector4.
  84154. */
  84155. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84156. /**
  84157. * Updates the current Vector4 coordinates with the given floats.
  84158. * @param x float to set from
  84159. * @param y float to set from
  84160. * @param z float to set from
  84161. * @param w float to set from
  84162. * @returns the updated Vector4.
  84163. */
  84164. set(x: number, y: number, z: number, w: number): Vector4;
  84165. /**
  84166. * Copies the given float to the current Vector3 coordinates
  84167. * @param v defines the x, y, z and w coordinates of the operand
  84168. * @returns the current updated Vector3
  84169. */
  84170. setAll(v: number): Vector4;
  84171. /**
  84172. * Returns a new Vector4 set from the starting index of the given array.
  84173. * @param array the array to pull values from
  84174. * @param offset the offset into the array to start at
  84175. * @returns the new vector
  84176. */
  84177. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  84178. /**
  84179. * Updates the given vector "result" from the starting index of the given array.
  84180. * @param array the array to pull values from
  84181. * @param offset the offset into the array to start at
  84182. * @param result the vector to store the result in
  84183. */
  84184. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  84185. /**
  84186. * Updates the given vector "result" from the starting index of the given Float32Array.
  84187. * @param array the array to pull values from
  84188. * @param offset the offset into the array to start at
  84189. * @param result the vector to store the result in
  84190. */
  84191. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  84192. /**
  84193. * Updates the given vector "result" coordinates from the given floats.
  84194. * @param x float to set from
  84195. * @param y float to set from
  84196. * @param z float to set from
  84197. * @param w float to set from
  84198. * @param result the vector to the floats in
  84199. */
  84200. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  84201. /**
  84202. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  84203. * @returns the new vector
  84204. */
  84205. static Zero(): Vector4;
  84206. /**
  84207. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  84208. * @returns the new vector
  84209. */
  84210. static One(): Vector4;
  84211. /**
  84212. * Returns a new normalized Vector4 from the given one.
  84213. * @param vector the vector to normalize
  84214. * @returns the vector
  84215. */
  84216. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  84217. /**
  84218. * Updates the given vector "result" from the normalization of the given one.
  84219. * @param vector the vector to normalize
  84220. * @param result the vector to store the result in
  84221. */
  84222. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  84223. /**
  84224. * Returns a vector with the minimum values from the left and right vectors
  84225. * @param left left vector to minimize
  84226. * @param right right vector to minimize
  84227. * @returns a new vector with the minimum of the left and right vector values
  84228. */
  84229. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84230. /**
  84231. * Returns a vector with the maximum values from the left and right vectors
  84232. * @param left left vector to maximize
  84233. * @param right right vector to maximize
  84234. * @returns a new vector with the maximum of the left and right vector values
  84235. */
  84236. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84237. /**
  84238. * Returns the distance (float) between the vectors "value1" and "value2".
  84239. * @param value1 value to calulate the distance between
  84240. * @param value2 value to calulate the distance between
  84241. * @return the distance between the two vectors
  84242. */
  84243. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84244. /**
  84245. * Returns the squared distance (float) between the vectors "value1" and "value2".
  84246. * @param value1 value to calulate the distance between
  84247. * @param value2 value to calulate the distance between
  84248. * @return the distance between the two vectors squared
  84249. */
  84250. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84251. /**
  84252. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  84253. * @param value1 value to calulate the center between
  84254. * @param value2 value to calulate the center between
  84255. * @return the center between the two vectors
  84256. */
  84257. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  84258. /**
  84259. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  84260. * This methods computes transformed normalized direction vectors only.
  84261. * @param vector the vector to transform
  84262. * @param transformation the transformation matrix to apply
  84263. * @returns the new vector
  84264. */
  84265. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  84266. /**
  84267. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  84268. * This methods computes transformed normalized direction vectors only.
  84269. * @param vector the vector to transform
  84270. * @param transformation the transformation matrix to apply
  84271. * @param result the vector to store the result in
  84272. */
  84273. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84274. /**
  84275. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  84276. * This methods computes transformed normalized direction vectors only.
  84277. * @param x value to transform
  84278. * @param y value to transform
  84279. * @param z value to transform
  84280. * @param w value to transform
  84281. * @param transformation the transformation matrix to apply
  84282. * @param result the vector to store the results in
  84283. */
  84284. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84285. /**
  84286. * Creates a new Vector4 from a Vector3
  84287. * @param source defines the source data
  84288. * @param w defines the 4th component (default is 0)
  84289. * @returns a new Vector4
  84290. */
  84291. static FromVector3(source: Vector3, w?: number): Vector4;
  84292. }
  84293. /**
  84294. * Class used to store quaternion data
  84295. * @see https://en.wikipedia.org/wiki/Quaternion
  84296. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  84297. */
  84298. export class Quaternion {
  84299. /** @hidden */
  84300. _x: number;
  84301. /** @hidden */
  84302. _y: number;
  84303. /** @hidden */
  84304. _z: number;
  84305. /** @hidden */
  84306. _w: number;
  84307. /** @hidden */
  84308. _isDirty: boolean;
  84309. /** Gets or sets the x coordinate */
  84310. get x(): number;
  84311. set x(value: number);
  84312. /** Gets or sets the y coordinate */
  84313. get y(): number;
  84314. set y(value: number);
  84315. /** Gets or sets the z coordinate */
  84316. get z(): number;
  84317. set z(value: number);
  84318. /** Gets or sets the w coordinate */
  84319. get w(): number;
  84320. set w(value: number);
  84321. /**
  84322. * Creates a new Quaternion from the given floats
  84323. * @param x defines the first component (0 by default)
  84324. * @param y defines the second component (0 by default)
  84325. * @param z defines the third component (0 by default)
  84326. * @param w defines the fourth component (1.0 by default)
  84327. */
  84328. constructor(x?: number, y?: number, z?: number, w?: number);
  84329. /**
  84330. * Gets a string representation for the current quaternion
  84331. * @returns a string with the Quaternion coordinates
  84332. */
  84333. toString(): string;
  84334. /**
  84335. * Gets the class name of the quaternion
  84336. * @returns the string "Quaternion"
  84337. */
  84338. getClassName(): string;
  84339. /**
  84340. * Gets a hash code for this quaternion
  84341. * @returns the quaternion hash code
  84342. */
  84343. getHashCode(): number;
  84344. /**
  84345. * Copy the quaternion to an array
  84346. * @returns a new array populated with 4 elements from the quaternion coordinates
  84347. */
  84348. asArray(): number[];
  84349. /**
  84350. * Check if two quaternions are equals
  84351. * @param otherQuaternion defines the second operand
  84352. * @return true if the current quaternion and the given one coordinates are strictly equals
  84353. */
  84354. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84355. /**
  84356. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84357. * @param otherQuaternion defines the other quaternion
  84358. * @param epsilon defines the minimal distance to consider equality
  84359. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84360. */
  84361. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84362. /**
  84363. * Clone the current quaternion
  84364. * @returns a new quaternion copied from the current one
  84365. */
  84366. clone(): Quaternion;
  84367. /**
  84368. * Copy a quaternion to the current one
  84369. * @param other defines the other quaternion
  84370. * @returns the updated current quaternion
  84371. */
  84372. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84373. /**
  84374. * Updates the current quaternion with the given float coordinates
  84375. * @param x defines the x coordinate
  84376. * @param y defines the y coordinate
  84377. * @param z defines the z coordinate
  84378. * @param w defines the w coordinate
  84379. * @returns the updated current quaternion
  84380. */
  84381. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84382. /**
  84383. * Updates the current quaternion from the given float coordinates
  84384. * @param x defines the x coordinate
  84385. * @param y defines the y coordinate
  84386. * @param z defines the z coordinate
  84387. * @param w defines the w coordinate
  84388. * @returns the updated current quaternion
  84389. */
  84390. set(x: number, y: number, z: number, w: number): Quaternion;
  84391. /**
  84392. * Adds two quaternions
  84393. * @param other defines the second operand
  84394. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84395. */
  84396. add(other: DeepImmutable<Quaternion>): Quaternion;
  84397. /**
  84398. * Add a quaternion to the current one
  84399. * @param other defines the quaternion to add
  84400. * @returns the current quaternion
  84401. */
  84402. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84403. /**
  84404. * Subtract two quaternions
  84405. * @param other defines the second operand
  84406. * @returns a new quaternion as the subtraction result of the given one from the current one
  84407. */
  84408. subtract(other: Quaternion): Quaternion;
  84409. /**
  84410. * Multiplies the current quaternion by a scale factor
  84411. * @param value defines the scale factor
  84412. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84413. */
  84414. scale(value: number): Quaternion;
  84415. /**
  84416. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84417. * @param scale defines the scale factor
  84418. * @param result defines the Quaternion object where to store the result
  84419. * @returns the unmodified current quaternion
  84420. */
  84421. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84422. /**
  84423. * Multiplies in place the current quaternion by a scale factor
  84424. * @param value defines the scale factor
  84425. * @returns the current modified quaternion
  84426. */
  84427. scaleInPlace(value: number): Quaternion;
  84428. /**
  84429. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84430. * @param scale defines the scale factor
  84431. * @param result defines the Quaternion object where to store the result
  84432. * @returns the unmodified current quaternion
  84433. */
  84434. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84435. /**
  84436. * Multiplies two quaternions
  84437. * @param q1 defines the second operand
  84438. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84439. */
  84440. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84441. /**
  84442. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84443. * @param q1 defines the second operand
  84444. * @param result defines the target quaternion
  84445. * @returns the current quaternion
  84446. */
  84447. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84448. /**
  84449. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84450. * @param q1 defines the second operand
  84451. * @returns the currentupdated quaternion
  84452. */
  84453. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84454. /**
  84455. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84456. * @param ref defines the target quaternion
  84457. * @returns the current quaternion
  84458. */
  84459. conjugateToRef(ref: Quaternion): Quaternion;
  84460. /**
  84461. * Conjugates in place (1-q) the current quaternion
  84462. * @returns the current updated quaternion
  84463. */
  84464. conjugateInPlace(): Quaternion;
  84465. /**
  84466. * Conjugates in place (1-q) the current quaternion
  84467. * @returns a new quaternion
  84468. */
  84469. conjugate(): Quaternion;
  84470. /**
  84471. * Gets length of current quaternion
  84472. * @returns the quaternion length (float)
  84473. */
  84474. length(): number;
  84475. /**
  84476. * Normalize in place the current quaternion
  84477. * @returns the current updated quaternion
  84478. */
  84479. normalize(): Quaternion;
  84480. /**
  84481. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84482. * @param order is a reserved parameter and is ignored for now
  84483. * @returns a new Vector3 containing the Euler angles
  84484. */
  84485. toEulerAngles(order?: string): Vector3;
  84486. /**
  84487. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84488. * @param result defines the vector which will be filled with the Euler angles
  84489. * @returns the current unchanged quaternion
  84490. */
  84491. toEulerAnglesToRef(result: Vector3): Quaternion;
  84492. /**
  84493. * Updates the given rotation matrix with the current quaternion values
  84494. * @param result defines the target matrix
  84495. * @returns the current unchanged quaternion
  84496. */
  84497. toRotationMatrix(result: Matrix): Quaternion;
  84498. /**
  84499. * Updates the current quaternion from the given rotation matrix values
  84500. * @param matrix defines the source matrix
  84501. * @returns the current updated quaternion
  84502. */
  84503. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84504. /**
  84505. * Creates a new quaternion from a rotation matrix
  84506. * @param matrix defines the source matrix
  84507. * @returns a new quaternion created from the given rotation matrix values
  84508. */
  84509. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84510. /**
  84511. * Updates the given quaternion with the given rotation matrix values
  84512. * @param matrix defines the source matrix
  84513. * @param result defines the target quaternion
  84514. */
  84515. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84516. /**
  84517. * Returns the dot product (float) between the quaternions "left" and "right"
  84518. * @param left defines the left operand
  84519. * @param right defines the right operand
  84520. * @returns the dot product
  84521. */
  84522. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84523. /**
  84524. * Checks if the two quaternions are close to each other
  84525. * @param quat0 defines the first quaternion to check
  84526. * @param quat1 defines the second quaternion to check
  84527. * @returns true if the two quaternions are close to each other
  84528. */
  84529. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84530. /**
  84531. * Creates an empty quaternion
  84532. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84533. */
  84534. static Zero(): Quaternion;
  84535. /**
  84536. * Inverse a given quaternion
  84537. * @param q defines the source quaternion
  84538. * @returns a new quaternion as the inverted current quaternion
  84539. */
  84540. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84541. /**
  84542. * Inverse a given quaternion
  84543. * @param q defines the source quaternion
  84544. * @param result the quaternion the result will be stored in
  84545. * @returns the result quaternion
  84546. */
  84547. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84548. /**
  84549. * Creates an identity quaternion
  84550. * @returns the identity quaternion
  84551. */
  84552. static Identity(): Quaternion;
  84553. /**
  84554. * Gets a boolean indicating if the given quaternion is identity
  84555. * @param quaternion defines the quaternion to check
  84556. * @returns true if the quaternion is identity
  84557. */
  84558. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84559. /**
  84560. * Creates a quaternion from a rotation around an axis
  84561. * @param axis defines the axis to use
  84562. * @param angle defines the angle to use
  84563. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84564. */
  84565. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84566. /**
  84567. * Creates a rotation around an axis and stores it into the given quaternion
  84568. * @param axis defines the axis to use
  84569. * @param angle defines the angle to use
  84570. * @param result defines the target quaternion
  84571. * @returns the target quaternion
  84572. */
  84573. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84574. /**
  84575. * Creates a new quaternion from data stored into an array
  84576. * @param array defines the data source
  84577. * @param offset defines the offset in the source array where the data starts
  84578. * @returns a new quaternion
  84579. */
  84580. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84581. /**
  84582. * Updates the given quaternion "result" from the starting index of the given array.
  84583. * @param array the array to pull values from
  84584. * @param offset the offset into the array to start at
  84585. * @param result the quaternion to store the result in
  84586. */
  84587. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84588. /**
  84589. * Create a quaternion from Euler rotation angles
  84590. * @param x Pitch
  84591. * @param y Yaw
  84592. * @param z Roll
  84593. * @returns the new Quaternion
  84594. */
  84595. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84596. /**
  84597. * Updates a quaternion from Euler rotation angles
  84598. * @param x Pitch
  84599. * @param y Yaw
  84600. * @param z Roll
  84601. * @param result the quaternion to store the result
  84602. * @returns the updated quaternion
  84603. */
  84604. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84605. /**
  84606. * Create a quaternion from Euler rotation vector
  84607. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84608. * @returns the new Quaternion
  84609. */
  84610. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84611. /**
  84612. * Updates a quaternion from Euler rotation vector
  84613. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84614. * @param result the quaternion to store the result
  84615. * @returns the updated quaternion
  84616. */
  84617. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84618. /**
  84619. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84620. * @param yaw defines the rotation around Y axis
  84621. * @param pitch defines the rotation around X axis
  84622. * @param roll defines the rotation around Z axis
  84623. * @returns the new quaternion
  84624. */
  84625. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84626. /**
  84627. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84628. * @param yaw defines the rotation around Y axis
  84629. * @param pitch defines the rotation around X axis
  84630. * @param roll defines the rotation around Z axis
  84631. * @param result defines the target quaternion
  84632. */
  84633. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84634. /**
  84635. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84636. * @param alpha defines the rotation around first axis
  84637. * @param beta defines the rotation around second axis
  84638. * @param gamma defines the rotation around third axis
  84639. * @returns the new quaternion
  84640. */
  84641. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84642. /**
  84643. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84644. * @param alpha defines the rotation around first axis
  84645. * @param beta defines the rotation around second axis
  84646. * @param gamma defines the rotation around third axis
  84647. * @param result defines the target quaternion
  84648. */
  84649. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84650. /**
  84651. * 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)
  84652. * @param axis1 defines the first axis
  84653. * @param axis2 defines the second axis
  84654. * @param axis3 defines the third axis
  84655. * @returns the new quaternion
  84656. */
  84657. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84658. /**
  84659. * 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
  84660. * @param axis1 defines the first axis
  84661. * @param axis2 defines the second axis
  84662. * @param axis3 defines the third axis
  84663. * @param ref defines the target quaternion
  84664. */
  84665. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84666. /**
  84667. * Interpolates between two quaternions
  84668. * @param left defines first quaternion
  84669. * @param right defines second quaternion
  84670. * @param amount defines the gradient to use
  84671. * @returns the new interpolated quaternion
  84672. */
  84673. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84674. /**
  84675. * Interpolates between two quaternions and stores it into a target quaternion
  84676. * @param left defines first quaternion
  84677. * @param right defines second quaternion
  84678. * @param amount defines the gradient to use
  84679. * @param result defines the target quaternion
  84680. */
  84681. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84682. /**
  84683. * Interpolate between two quaternions using Hermite interpolation
  84684. * @param value1 defines first quaternion
  84685. * @param tangent1 defines the incoming tangent
  84686. * @param value2 defines second quaternion
  84687. * @param tangent2 defines the outgoing tangent
  84688. * @param amount defines the target quaternion
  84689. * @returns the new interpolated quaternion
  84690. */
  84691. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84692. }
  84693. /**
  84694. * Class used to store matrix data (4x4)
  84695. */
  84696. export class Matrix {
  84697. /**
  84698. * Gets the precision of matrix computations
  84699. */
  84700. static get Use64Bits(): boolean;
  84701. private static _updateFlagSeed;
  84702. private static _identityReadOnly;
  84703. private _isIdentity;
  84704. private _isIdentityDirty;
  84705. private _isIdentity3x2;
  84706. private _isIdentity3x2Dirty;
  84707. /**
  84708. * Gets the update flag of the matrix which is an unique number for the matrix.
  84709. * It will be incremented every time the matrix data change.
  84710. * You can use it to speed the comparison between two versions of the same matrix.
  84711. */
  84712. updateFlag: number;
  84713. private readonly _m;
  84714. /**
  84715. * Gets the internal data of the matrix
  84716. */
  84717. get m(): DeepImmutable<Float32Array | Array<number>>;
  84718. /** @hidden */
  84719. _markAsUpdated(): void;
  84720. /** @hidden */
  84721. private _updateIdentityStatus;
  84722. /**
  84723. * Creates an empty matrix (filled with zeros)
  84724. */
  84725. constructor();
  84726. /**
  84727. * Check if the current matrix is identity
  84728. * @returns true is the matrix is the identity matrix
  84729. */
  84730. isIdentity(): boolean;
  84731. /**
  84732. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84733. * @returns true is the matrix is the identity matrix
  84734. */
  84735. isIdentityAs3x2(): boolean;
  84736. /**
  84737. * Gets the determinant of the matrix
  84738. * @returns the matrix determinant
  84739. */
  84740. determinant(): number;
  84741. /**
  84742. * Returns the matrix as a Float32Array or Array<number>
  84743. * @returns the matrix underlying array
  84744. */
  84745. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84746. /**
  84747. * Returns the matrix as a Float32Array or Array<number>
  84748. * @returns the matrix underlying array.
  84749. */
  84750. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84751. /**
  84752. * Inverts the current matrix in place
  84753. * @returns the current inverted matrix
  84754. */
  84755. invert(): Matrix;
  84756. /**
  84757. * Sets all the matrix elements to zero
  84758. * @returns the current matrix
  84759. */
  84760. reset(): Matrix;
  84761. /**
  84762. * Adds the current matrix with a second one
  84763. * @param other defines the matrix to add
  84764. * @returns a new matrix as the addition of the current matrix and the given one
  84765. */
  84766. add(other: DeepImmutable<Matrix>): Matrix;
  84767. /**
  84768. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84769. * @param other defines the matrix to add
  84770. * @param result defines the target matrix
  84771. * @returns the current matrix
  84772. */
  84773. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84774. /**
  84775. * Adds in place the given matrix to the current matrix
  84776. * @param other defines the second operand
  84777. * @returns the current updated matrix
  84778. */
  84779. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84780. /**
  84781. * Sets the given matrix to the current inverted Matrix
  84782. * @param other defines the target matrix
  84783. * @returns the unmodified current matrix
  84784. */
  84785. invertToRef(other: Matrix): Matrix;
  84786. /**
  84787. * add a value at the specified position in the current Matrix
  84788. * @param index the index of the value within the matrix. between 0 and 15.
  84789. * @param value the value to be added
  84790. * @returns the current updated matrix
  84791. */
  84792. addAtIndex(index: number, value: number): Matrix;
  84793. /**
  84794. * mutiply the specified position in the current Matrix by a value
  84795. * @param index the index of the value within the matrix. between 0 and 15.
  84796. * @param value the value to be added
  84797. * @returns the current updated matrix
  84798. */
  84799. multiplyAtIndex(index: number, value: number): Matrix;
  84800. /**
  84801. * Inserts the translation vector (using 3 floats) in the current matrix
  84802. * @param x defines the 1st component of the translation
  84803. * @param y defines the 2nd component of the translation
  84804. * @param z defines the 3rd component of the translation
  84805. * @returns the current updated matrix
  84806. */
  84807. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84808. /**
  84809. * Adds the translation vector (using 3 floats) in the current matrix
  84810. * @param x defines the 1st component of the translation
  84811. * @param y defines the 2nd component of the translation
  84812. * @param z defines the 3rd component of the translation
  84813. * @returns the current updated matrix
  84814. */
  84815. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84816. /**
  84817. * Inserts the translation vector in the current matrix
  84818. * @param vector3 defines the translation to insert
  84819. * @returns the current updated matrix
  84820. */
  84821. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84822. /**
  84823. * Gets the translation value of the current matrix
  84824. * @returns a new Vector3 as the extracted translation from the matrix
  84825. */
  84826. getTranslation(): Vector3;
  84827. /**
  84828. * Fill a Vector3 with the extracted translation from the matrix
  84829. * @param result defines the Vector3 where to store the translation
  84830. * @returns the current matrix
  84831. */
  84832. getTranslationToRef(result: Vector3): Matrix;
  84833. /**
  84834. * Remove rotation and scaling part from the matrix
  84835. * @returns the updated matrix
  84836. */
  84837. removeRotationAndScaling(): Matrix;
  84838. /**
  84839. * Multiply two matrices
  84840. * @param other defines the second operand
  84841. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84842. */
  84843. multiply(other: DeepImmutable<Matrix>): Matrix;
  84844. /**
  84845. * Copy the current matrix from the given one
  84846. * @param other defines the source matrix
  84847. * @returns the current updated matrix
  84848. */
  84849. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84850. /**
  84851. * Populates the given array from the starting index with the current matrix values
  84852. * @param array defines the target array
  84853. * @param offset defines the offset in the target array where to start storing values
  84854. * @returns the current matrix
  84855. */
  84856. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84857. /**
  84858. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84859. * @param other defines the second operand
  84860. * @param result defines the matrix where to store the multiplication
  84861. * @returns the current matrix
  84862. */
  84863. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84864. /**
  84865. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84866. * @param other defines the second operand
  84867. * @param result defines the array where to store the multiplication
  84868. * @param offset defines the offset in the target array where to start storing values
  84869. * @returns the current matrix
  84870. */
  84871. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84872. /**
  84873. * Check equality between this matrix and a second one
  84874. * @param value defines the second matrix to compare
  84875. * @returns true is the current matrix and the given one values are strictly equal
  84876. */
  84877. equals(value: DeepImmutable<Matrix>): boolean;
  84878. /**
  84879. * Clone the current matrix
  84880. * @returns a new matrix from the current matrix
  84881. */
  84882. clone(): Matrix;
  84883. /**
  84884. * Returns the name of the current matrix class
  84885. * @returns the string "Matrix"
  84886. */
  84887. getClassName(): string;
  84888. /**
  84889. * Gets the hash code of the current matrix
  84890. * @returns the hash code
  84891. */
  84892. getHashCode(): number;
  84893. /**
  84894. * Decomposes the current Matrix into a translation, rotation and scaling components
  84895. * @param scale defines the scale vector3 given as a reference to update
  84896. * @param rotation defines the rotation quaternion given as a reference to update
  84897. * @param translation defines the translation vector3 given as a reference to update
  84898. * @returns true if operation was successful
  84899. */
  84900. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84901. /**
  84902. * Gets specific row of the matrix
  84903. * @param index defines the number of the row to get
  84904. * @returns the index-th row of the current matrix as a new Vector4
  84905. */
  84906. getRow(index: number): Nullable<Vector4>;
  84907. /**
  84908. * Sets the index-th row of the current matrix to the vector4 values
  84909. * @param index defines the number of the row to set
  84910. * @param row defines the target vector4
  84911. * @returns the updated current matrix
  84912. */
  84913. setRow(index: number, row: Vector4): Matrix;
  84914. /**
  84915. * Compute the transpose of the matrix
  84916. * @returns the new transposed matrix
  84917. */
  84918. transpose(): Matrix;
  84919. /**
  84920. * Compute the transpose of the matrix and store it in a given matrix
  84921. * @param result defines the target matrix
  84922. * @returns the current matrix
  84923. */
  84924. transposeToRef(result: Matrix): Matrix;
  84925. /**
  84926. * Sets the index-th row of the current matrix with the given 4 x float values
  84927. * @param index defines the row index
  84928. * @param x defines the x component to set
  84929. * @param y defines the y component to set
  84930. * @param z defines the z component to set
  84931. * @param w defines the w component to set
  84932. * @returns the updated current matrix
  84933. */
  84934. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84935. /**
  84936. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84937. * @param scale defines the scale factor
  84938. * @returns a new matrix
  84939. */
  84940. scale(scale: number): Matrix;
  84941. /**
  84942. * Scale the current matrix values by a factor to a given result matrix
  84943. * @param scale defines the scale factor
  84944. * @param result defines the matrix to store the result
  84945. * @returns the current matrix
  84946. */
  84947. scaleToRef(scale: number, result: Matrix): Matrix;
  84948. /**
  84949. * Scale the current matrix values by a factor and add the result to a given matrix
  84950. * @param scale defines the scale factor
  84951. * @param result defines the Matrix to store the result
  84952. * @returns the current matrix
  84953. */
  84954. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84955. /**
  84956. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84957. * @param ref matrix to store the result
  84958. */
  84959. toNormalMatrix(ref: Matrix): void;
  84960. /**
  84961. * Gets only rotation part of the current matrix
  84962. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84963. */
  84964. getRotationMatrix(): Matrix;
  84965. /**
  84966. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84967. * @param result defines the target matrix to store data to
  84968. * @returns the current matrix
  84969. */
  84970. getRotationMatrixToRef(result: Matrix): Matrix;
  84971. /**
  84972. * Toggles model matrix from being right handed to left handed in place and vice versa
  84973. */
  84974. toggleModelMatrixHandInPlace(): void;
  84975. /**
  84976. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84977. */
  84978. toggleProjectionMatrixHandInPlace(): void;
  84979. /**
  84980. * Creates a matrix from an array
  84981. * @param array defines the source array
  84982. * @param offset defines an offset in the source array
  84983. * @returns a new Matrix set from the starting index of the given array
  84984. */
  84985. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84986. /**
  84987. * Copy the content of an array into a given matrix
  84988. * @param array defines the source array
  84989. * @param offset defines an offset in the source array
  84990. * @param result defines the target matrix
  84991. */
  84992. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84993. /**
  84994. * Stores an array into a matrix after having multiplied each component by a given factor
  84995. * @param array defines the source array
  84996. * @param offset defines the offset in the source array
  84997. * @param scale defines the scaling factor
  84998. * @param result defines the target matrix
  84999. */
  85000. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  85001. /**
  85002. * Gets an identity matrix that must not be updated
  85003. */
  85004. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  85005. /**
  85006. * Stores a list of values (16) inside a given matrix
  85007. * @param initialM11 defines 1st value of 1st row
  85008. * @param initialM12 defines 2nd value of 1st row
  85009. * @param initialM13 defines 3rd value of 1st row
  85010. * @param initialM14 defines 4th value of 1st row
  85011. * @param initialM21 defines 1st value of 2nd row
  85012. * @param initialM22 defines 2nd value of 2nd row
  85013. * @param initialM23 defines 3rd value of 2nd row
  85014. * @param initialM24 defines 4th value of 2nd row
  85015. * @param initialM31 defines 1st value of 3rd row
  85016. * @param initialM32 defines 2nd value of 3rd row
  85017. * @param initialM33 defines 3rd value of 3rd row
  85018. * @param initialM34 defines 4th value of 3rd row
  85019. * @param initialM41 defines 1st value of 4th row
  85020. * @param initialM42 defines 2nd value of 4th row
  85021. * @param initialM43 defines 3rd value of 4th row
  85022. * @param initialM44 defines 4th value of 4th row
  85023. * @param result defines the target matrix
  85024. */
  85025. 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;
  85026. /**
  85027. * Creates new matrix from a list of values (16)
  85028. * @param initialM11 defines 1st value of 1st row
  85029. * @param initialM12 defines 2nd value of 1st row
  85030. * @param initialM13 defines 3rd value of 1st row
  85031. * @param initialM14 defines 4th value of 1st row
  85032. * @param initialM21 defines 1st value of 2nd row
  85033. * @param initialM22 defines 2nd value of 2nd row
  85034. * @param initialM23 defines 3rd value of 2nd row
  85035. * @param initialM24 defines 4th value of 2nd row
  85036. * @param initialM31 defines 1st value of 3rd row
  85037. * @param initialM32 defines 2nd value of 3rd row
  85038. * @param initialM33 defines 3rd value of 3rd row
  85039. * @param initialM34 defines 4th value of 3rd row
  85040. * @param initialM41 defines 1st value of 4th row
  85041. * @param initialM42 defines 2nd value of 4th row
  85042. * @param initialM43 defines 3rd value of 4th row
  85043. * @param initialM44 defines 4th value of 4th row
  85044. * @returns the new matrix
  85045. */
  85046. 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;
  85047. /**
  85048. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85049. * @param scale defines the scale vector3
  85050. * @param rotation defines the rotation quaternion
  85051. * @param translation defines the translation vector3
  85052. * @returns a new matrix
  85053. */
  85054. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  85055. /**
  85056. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85057. * @param scale defines the scale vector3
  85058. * @param rotation defines the rotation quaternion
  85059. * @param translation defines the translation vector3
  85060. * @param result defines the target matrix
  85061. */
  85062. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  85063. /**
  85064. * Creates a new identity matrix
  85065. * @returns a new identity matrix
  85066. */
  85067. static Identity(): Matrix;
  85068. /**
  85069. * Creates a new identity matrix and stores the result in a given matrix
  85070. * @param result defines the target matrix
  85071. */
  85072. static IdentityToRef(result: Matrix): void;
  85073. /**
  85074. * Creates a new zero matrix
  85075. * @returns a new zero matrix
  85076. */
  85077. static Zero(): Matrix;
  85078. /**
  85079. * Creates a new rotation matrix for "angle" radians around the X axis
  85080. * @param angle defines the angle (in radians) to use
  85081. * @return the new matrix
  85082. */
  85083. static RotationX(angle: number): Matrix;
  85084. /**
  85085. * Creates a new matrix as the invert of a given matrix
  85086. * @param source defines the source matrix
  85087. * @returns the new matrix
  85088. */
  85089. static Invert(source: DeepImmutable<Matrix>): Matrix;
  85090. /**
  85091. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  85092. * @param angle defines the angle (in radians) to use
  85093. * @param result defines the target matrix
  85094. */
  85095. static RotationXToRef(angle: number, result: Matrix): void;
  85096. /**
  85097. * Creates a new rotation matrix for "angle" radians around the Y axis
  85098. * @param angle defines the angle (in radians) to use
  85099. * @return the new matrix
  85100. */
  85101. static RotationY(angle: number): Matrix;
  85102. /**
  85103. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  85104. * @param angle defines the angle (in radians) to use
  85105. * @param result defines the target matrix
  85106. */
  85107. static RotationYToRef(angle: number, result: Matrix): void;
  85108. /**
  85109. * Creates a new rotation matrix for "angle" radians around the Z axis
  85110. * @param angle defines the angle (in radians) to use
  85111. * @return the new matrix
  85112. */
  85113. static RotationZ(angle: number): Matrix;
  85114. /**
  85115. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  85116. * @param angle defines the angle (in radians) to use
  85117. * @param result defines the target matrix
  85118. */
  85119. static RotationZToRef(angle: number, result: Matrix): void;
  85120. /**
  85121. * Creates a new rotation matrix for "angle" radians around the given axis
  85122. * @param axis defines the axis to use
  85123. * @param angle defines the angle (in radians) to use
  85124. * @return the new matrix
  85125. */
  85126. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  85127. /**
  85128. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  85129. * @param axis defines the axis to use
  85130. * @param angle defines the angle (in radians) to use
  85131. * @param result defines the target matrix
  85132. */
  85133. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  85134. /**
  85135. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  85136. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  85137. * @param from defines the vector to align
  85138. * @param to defines the vector to align to
  85139. * @param result defines the target matrix
  85140. */
  85141. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  85142. /**
  85143. * Creates a rotation matrix
  85144. * @param yaw defines the yaw angle in radians (Y axis)
  85145. * @param pitch defines the pitch angle in radians (X axis)
  85146. * @param roll defines the roll angle in radians (Z axis)
  85147. * @returns the new rotation matrix
  85148. */
  85149. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  85150. /**
  85151. * Creates a rotation matrix and stores it in a given matrix
  85152. * @param yaw defines the yaw angle in radians (Y axis)
  85153. * @param pitch defines the pitch angle in radians (X axis)
  85154. * @param roll defines the roll angle in radians (Z axis)
  85155. * @param result defines the target matrix
  85156. */
  85157. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  85158. /**
  85159. * Creates a scaling matrix
  85160. * @param x defines the scale factor on X axis
  85161. * @param y defines the scale factor on Y axis
  85162. * @param z defines the scale factor on Z axis
  85163. * @returns the new matrix
  85164. */
  85165. static Scaling(x: number, y: number, z: number): Matrix;
  85166. /**
  85167. * Creates a scaling matrix and stores it in a given matrix
  85168. * @param x defines the scale factor on X axis
  85169. * @param y defines the scale factor on Y axis
  85170. * @param z defines the scale factor on Z axis
  85171. * @param result defines the target matrix
  85172. */
  85173. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  85174. /**
  85175. * Creates a translation matrix
  85176. * @param x defines the translation on X axis
  85177. * @param y defines the translation on Y axis
  85178. * @param z defines the translationon Z axis
  85179. * @returns the new matrix
  85180. */
  85181. static Translation(x: number, y: number, z: number): Matrix;
  85182. /**
  85183. * Creates a translation matrix and stores it in a given matrix
  85184. * @param x defines the translation on X axis
  85185. * @param y defines the translation on Y axis
  85186. * @param z defines the translationon Z axis
  85187. * @param result defines the target matrix
  85188. */
  85189. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  85190. /**
  85191. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85192. * @param startValue defines the start value
  85193. * @param endValue defines the end value
  85194. * @param gradient defines the gradient factor
  85195. * @returns the new matrix
  85196. */
  85197. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85198. /**
  85199. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85200. * @param startValue defines the start value
  85201. * @param endValue defines the end value
  85202. * @param gradient defines the gradient factor
  85203. * @param result defines the Matrix object where to store data
  85204. */
  85205. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85206. /**
  85207. * Builds a new matrix whose values are computed by:
  85208. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85209. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85210. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85211. * @param startValue defines the first matrix
  85212. * @param endValue defines the second matrix
  85213. * @param gradient defines the gradient between the two matrices
  85214. * @returns the new matrix
  85215. */
  85216. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85217. /**
  85218. * Update a matrix to values which are computed by:
  85219. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85220. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85221. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85222. * @param startValue defines the first matrix
  85223. * @param endValue defines the second matrix
  85224. * @param gradient defines the gradient between the two matrices
  85225. * @param result defines the target matrix
  85226. */
  85227. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85228. /**
  85229. * 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"
  85230. * This function works in left handed mode
  85231. * @param eye defines the final position of the entity
  85232. * @param target defines where the entity should look at
  85233. * @param up defines the up vector for the entity
  85234. * @returns the new matrix
  85235. */
  85236. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85237. /**
  85238. * 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".
  85239. * This function works in left handed mode
  85240. * @param eye defines the final position of the entity
  85241. * @param target defines where the entity should look at
  85242. * @param up defines the up vector for the entity
  85243. * @param result defines the target matrix
  85244. */
  85245. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85246. /**
  85247. * 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"
  85248. * This function works in right handed mode
  85249. * @param eye defines the final position of the entity
  85250. * @param target defines where the entity should look at
  85251. * @param up defines the up vector for the entity
  85252. * @returns the new matrix
  85253. */
  85254. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85255. /**
  85256. * 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".
  85257. * This function works in right handed mode
  85258. * @param eye defines the final position of the entity
  85259. * @param target defines where the entity should look at
  85260. * @param up defines the up vector for the entity
  85261. * @param result defines the target matrix
  85262. */
  85263. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85264. /**
  85265. * Create a left-handed orthographic projection matrix
  85266. * @param width defines the viewport width
  85267. * @param height defines the viewport height
  85268. * @param znear defines the near clip plane
  85269. * @param zfar defines the far clip plane
  85270. * @returns a new matrix as a left-handed orthographic projection matrix
  85271. */
  85272. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85273. /**
  85274. * Store a left-handed orthographic projection to a given matrix
  85275. * @param width defines the viewport width
  85276. * @param height defines the viewport height
  85277. * @param znear defines the near clip plane
  85278. * @param zfar defines the far clip plane
  85279. * @param result defines the target matrix
  85280. */
  85281. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  85282. /**
  85283. * Create a left-handed orthographic projection matrix
  85284. * @param left defines the viewport left coordinate
  85285. * @param right defines the viewport right coordinate
  85286. * @param bottom defines the viewport bottom coordinate
  85287. * @param top defines the viewport top coordinate
  85288. * @param znear defines the near clip plane
  85289. * @param zfar defines the far clip plane
  85290. * @returns a new matrix as a left-handed orthographic projection matrix
  85291. */
  85292. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85293. /**
  85294. * Stores a left-handed orthographic projection into a given matrix
  85295. * @param left defines the viewport left coordinate
  85296. * @param right defines the viewport right coordinate
  85297. * @param bottom defines the viewport bottom coordinate
  85298. * @param top defines the viewport top coordinate
  85299. * @param znear defines the near clip plane
  85300. * @param zfar defines the far clip plane
  85301. * @param result defines the target matrix
  85302. */
  85303. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85304. /**
  85305. * Creates a right-handed orthographic projection matrix
  85306. * @param left defines the viewport left coordinate
  85307. * @param right defines the viewport right coordinate
  85308. * @param bottom defines the viewport bottom coordinate
  85309. * @param top defines the viewport top coordinate
  85310. * @param znear defines the near clip plane
  85311. * @param zfar defines the far clip plane
  85312. * @returns a new matrix as a right-handed orthographic projection matrix
  85313. */
  85314. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85315. /**
  85316. * Stores a right-handed orthographic projection into a given matrix
  85317. * @param left defines the viewport left coordinate
  85318. * @param right defines the viewport right coordinate
  85319. * @param bottom defines the viewport bottom coordinate
  85320. * @param top defines the viewport top coordinate
  85321. * @param znear defines the near clip plane
  85322. * @param zfar defines the far clip plane
  85323. * @param result defines the target matrix
  85324. */
  85325. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85326. /**
  85327. * Creates a left-handed perspective projection matrix
  85328. * @param width defines the viewport width
  85329. * @param height defines the viewport height
  85330. * @param znear defines the near clip plane
  85331. * @param zfar defines the far clip plane
  85332. * @returns a new matrix as a left-handed perspective projection matrix
  85333. */
  85334. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85335. /**
  85336. * Creates a left-handed perspective projection matrix
  85337. * @param fov defines the horizontal field of view
  85338. * @param aspect defines the aspect ratio
  85339. * @param znear defines the near clip plane
  85340. * @param zfar defines the far clip plane
  85341. * @returns a new matrix as a left-handed perspective projection matrix
  85342. */
  85343. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85344. /**
  85345. * Stores a left-handed perspective projection into a given matrix
  85346. * @param fov defines the horizontal field of view
  85347. * @param aspect defines the aspect ratio
  85348. * @param znear defines the near clip plane
  85349. * @param zfar defines the far clip plane
  85350. * @param result defines the target matrix
  85351. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85352. */
  85353. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85354. /**
  85355. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85356. * @param fov defines the horizontal field of view
  85357. * @param aspect defines the aspect ratio
  85358. * @param znear defines the near clip plane
  85359. * @param zfar not used as infinity is used as far clip
  85360. * @param result defines the target matrix
  85361. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85362. */
  85363. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85364. /**
  85365. * Creates a right-handed perspective projection matrix
  85366. * @param fov defines the horizontal field of view
  85367. * @param aspect defines the aspect ratio
  85368. * @param znear defines the near clip plane
  85369. * @param zfar defines the far clip plane
  85370. * @returns a new matrix as a right-handed perspective projection matrix
  85371. */
  85372. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85373. /**
  85374. * Stores a right-handed perspective projection into a given matrix
  85375. * @param fov defines the horizontal field of view
  85376. * @param aspect defines the aspect ratio
  85377. * @param znear defines the near clip plane
  85378. * @param zfar defines the far clip plane
  85379. * @param result defines the target matrix
  85380. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85381. */
  85382. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85383. /**
  85384. * Stores a right-handed perspective projection into a given matrix
  85385. * @param fov defines the horizontal field of view
  85386. * @param aspect defines the aspect ratio
  85387. * @param znear defines the near clip plane
  85388. * @param zfar not used as infinity is used as far clip
  85389. * @param result defines the target matrix
  85390. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85391. */
  85392. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85393. /**
  85394. * Stores a perspective projection for WebVR info a given matrix
  85395. * @param fov defines the field of view
  85396. * @param znear defines the near clip plane
  85397. * @param zfar defines the far clip plane
  85398. * @param result defines the target matrix
  85399. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85400. */
  85401. static PerspectiveFovWebVRToRef(fov: {
  85402. upDegrees: number;
  85403. downDegrees: number;
  85404. leftDegrees: number;
  85405. rightDegrees: number;
  85406. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85407. /**
  85408. * Computes a complete transformation matrix
  85409. * @param viewport defines the viewport to use
  85410. * @param world defines the world matrix
  85411. * @param view defines the view matrix
  85412. * @param projection defines the projection matrix
  85413. * @param zmin defines the near clip plane
  85414. * @param zmax defines the far clip plane
  85415. * @returns the transformation matrix
  85416. */
  85417. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85418. /**
  85419. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85420. * @param matrix defines the matrix to use
  85421. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85422. */
  85423. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85424. /**
  85425. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85426. * @param matrix defines the matrix to use
  85427. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85428. */
  85429. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85430. /**
  85431. * Compute the transpose of a given matrix
  85432. * @param matrix defines the matrix to transpose
  85433. * @returns the new matrix
  85434. */
  85435. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85436. /**
  85437. * Compute the transpose of a matrix and store it in a target matrix
  85438. * @param matrix defines the matrix to transpose
  85439. * @param result defines the target matrix
  85440. */
  85441. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85442. /**
  85443. * Computes a reflection matrix from a plane
  85444. * @param plane defines the reflection plane
  85445. * @returns a new matrix
  85446. */
  85447. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85448. /**
  85449. * Computes a reflection matrix from a plane
  85450. * @param plane defines the reflection plane
  85451. * @param result defines the target matrix
  85452. */
  85453. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85454. /**
  85455. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85456. * @param xaxis defines the value of the 1st axis
  85457. * @param yaxis defines the value of the 2nd axis
  85458. * @param zaxis defines the value of the 3rd axis
  85459. * @param result defines the target matrix
  85460. */
  85461. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85462. /**
  85463. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85464. * @param quat defines the quaternion to use
  85465. * @param result defines the target matrix
  85466. */
  85467. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85468. }
  85469. /**
  85470. * @hidden
  85471. */
  85472. export class TmpVectors {
  85473. static Vector2: Vector2[];
  85474. static Vector3: Vector3[];
  85475. static Vector4: Vector4[];
  85476. static Quaternion: Quaternion[];
  85477. static Matrix: Matrix[];
  85478. }
  85479. }
  85480. declare module BABYLON {
  85481. /**
  85482. * Defines potential orientation for back face culling
  85483. */
  85484. export enum Orientation {
  85485. /**
  85486. * Clockwise
  85487. */
  85488. CW = 0,
  85489. /** Counter clockwise */
  85490. CCW = 1
  85491. }
  85492. /** Class used to represent a Bezier curve */
  85493. export class BezierCurve {
  85494. /**
  85495. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85496. * @param t defines the time
  85497. * @param x1 defines the left coordinate on X axis
  85498. * @param y1 defines the left coordinate on Y axis
  85499. * @param x2 defines the right coordinate on X axis
  85500. * @param y2 defines the right coordinate on Y axis
  85501. * @returns the interpolated value
  85502. */
  85503. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85504. }
  85505. /**
  85506. * Defines angle representation
  85507. */
  85508. export class Angle {
  85509. private _radians;
  85510. /**
  85511. * Creates an Angle object of "radians" radians (float).
  85512. * @param radians the angle in radians
  85513. */
  85514. constructor(radians: number);
  85515. /**
  85516. * Get value in degrees
  85517. * @returns the Angle value in degrees (float)
  85518. */
  85519. degrees(): number;
  85520. /**
  85521. * Get value in radians
  85522. * @returns the Angle value in radians (float)
  85523. */
  85524. radians(): number;
  85525. /**
  85526. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85527. * @param a defines first point as the origin
  85528. * @param b defines point
  85529. * @returns a new Angle
  85530. */
  85531. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85532. /**
  85533. * Gets a new Angle object from the given float in radians
  85534. * @param radians defines the angle value in radians
  85535. * @returns a new Angle
  85536. */
  85537. static FromRadians(radians: number): Angle;
  85538. /**
  85539. * Gets a new Angle object from the given float in degrees
  85540. * @param degrees defines the angle value in degrees
  85541. * @returns a new Angle
  85542. */
  85543. static FromDegrees(degrees: number): Angle;
  85544. }
  85545. /**
  85546. * This represents an arc in a 2d space.
  85547. */
  85548. export class Arc2 {
  85549. /** Defines the start point of the arc */
  85550. startPoint: Vector2;
  85551. /** Defines the mid point of the arc */
  85552. midPoint: Vector2;
  85553. /** Defines the end point of the arc */
  85554. endPoint: Vector2;
  85555. /**
  85556. * Defines the center point of the arc.
  85557. */
  85558. centerPoint: Vector2;
  85559. /**
  85560. * Defines the radius of the arc.
  85561. */
  85562. radius: number;
  85563. /**
  85564. * Defines the angle of the arc (from mid point to end point).
  85565. */
  85566. angle: Angle;
  85567. /**
  85568. * Defines the start angle of the arc (from start point to middle point).
  85569. */
  85570. startAngle: Angle;
  85571. /**
  85572. * Defines the orientation of the arc (clock wise/counter clock wise).
  85573. */
  85574. orientation: Orientation;
  85575. /**
  85576. * Creates an Arc object from the three given points : start, middle and end.
  85577. * @param startPoint Defines the start point of the arc
  85578. * @param midPoint Defines the midlle point of the arc
  85579. * @param endPoint Defines the end point of the arc
  85580. */
  85581. constructor(
  85582. /** Defines the start point of the arc */
  85583. startPoint: Vector2,
  85584. /** Defines the mid point of the arc */
  85585. midPoint: Vector2,
  85586. /** Defines the end point of the arc */
  85587. endPoint: Vector2);
  85588. }
  85589. /**
  85590. * Represents a 2D path made up of multiple 2D points
  85591. */
  85592. export class Path2 {
  85593. private _points;
  85594. private _length;
  85595. /**
  85596. * If the path start and end point are the same
  85597. */
  85598. closed: boolean;
  85599. /**
  85600. * Creates a Path2 object from the starting 2D coordinates x and y.
  85601. * @param x the starting points x value
  85602. * @param y the starting points y value
  85603. */
  85604. constructor(x: number, y: number);
  85605. /**
  85606. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85607. * @param x the added points x value
  85608. * @param y the added points y value
  85609. * @returns the updated Path2.
  85610. */
  85611. addLineTo(x: number, y: number): Path2;
  85612. /**
  85613. * 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.
  85614. * @param midX middle point x value
  85615. * @param midY middle point y value
  85616. * @param endX end point x value
  85617. * @param endY end point y value
  85618. * @param numberOfSegments (default: 36)
  85619. * @returns the updated Path2.
  85620. */
  85621. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85622. /**
  85623. * Closes the Path2.
  85624. * @returns the Path2.
  85625. */
  85626. close(): Path2;
  85627. /**
  85628. * Gets the sum of the distance between each sequential point in the path
  85629. * @returns the Path2 total length (float).
  85630. */
  85631. length(): number;
  85632. /**
  85633. * Gets the points which construct the path
  85634. * @returns the Path2 internal array of points.
  85635. */
  85636. getPoints(): Vector2[];
  85637. /**
  85638. * Retreives the point at the distance aways from the starting point
  85639. * @param normalizedLengthPosition the length along the path to retreive the point from
  85640. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85641. */
  85642. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85643. /**
  85644. * Creates a new path starting from an x and y position
  85645. * @param x starting x value
  85646. * @param y starting y value
  85647. * @returns a new Path2 starting at the coordinates (x, y).
  85648. */
  85649. static StartingAt(x: number, y: number): Path2;
  85650. }
  85651. /**
  85652. * Represents a 3D path made up of multiple 3D points
  85653. */
  85654. export class Path3D {
  85655. /**
  85656. * an array of Vector3, the curve axis of the Path3D
  85657. */
  85658. path: Vector3[];
  85659. private _curve;
  85660. private _distances;
  85661. private _tangents;
  85662. private _normals;
  85663. private _binormals;
  85664. private _raw;
  85665. private _alignTangentsWithPath;
  85666. private readonly _pointAtData;
  85667. /**
  85668. * new Path3D(path, normal, raw)
  85669. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85670. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85671. * @param path an array of Vector3, the curve axis of the Path3D
  85672. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85673. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85674. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85675. */
  85676. constructor(
  85677. /**
  85678. * an array of Vector3, the curve axis of the Path3D
  85679. */
  85680. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  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. getCurve(): Vector3[];
  85686. /**
  85687. * Returns the Path3D array of successive Vector3 designing its curve.
  85688. * @returns the Path3D array of successive Vector3 designing its curve.
  85689. */
  85690. getPoints(): Vector3[];
  85691. /**
  85692. * @returns the computed length (float) of the path.
  85693. */
  85694. length(): number;
  85695. /**
  85696. * Returns an array populated with tangent vectors on each Path3D curve point.
  85697. * @returns an array populated with tangent vectors on each Path3D curve point.
  85698. */
  85699. getTangents(): Vector3[];
  85700. /**
  85701. * Returns an array populated with normal vectors on each Path3D curve point.
  85702. * @returns an array populated with normal vectors on each Path3D curve point.
  85703. */
  85704. getNormals(): Vector3[];
  85705. /**
  85706. * Returns an array populated with binormal vectors on each Path3D curve point.
  85707. * @returns an array populated with binormal vectors on each Path3D curve point.
  85708. */
  85709. getBinormals(): Vector3[];
  85710. /**
  85711. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85712. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85713. */
  85714. getDistances(): number[];
  85715. /**
  85716. * Returns an interpolated point along this path
  85717. * @param position the position of the point along this path, from 0.0 to 1.0
  85718. * @returns a new Vector3 as the point
  85719. */
  85720. getPointAt(position: number): Vector3;
  85721. /**
  85722. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85723. * @param position the position of the point along this path, from 0.0 to 1.0
  85724. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85725. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85726. */
  85727. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85728. /**
  85729. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85730. * @param position the position of the point along this path, from 0.0 to 1.0
  85731. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85732. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85733. */
  85734. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85735. /**
  85736. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85737. * @param position the position of the point along this path, from 0.0 to 1.0
  85738. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85739. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85740. */
  85741. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85742. /**
  85743. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85744. * @param position the position of the point along this path, from 0.0 to 1.0
  85745. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85746. */
  85747. getDistanceAt(position: number): number;
  85748. /**
  85749. * Returns the array index of the previous point of an interpolated point along this path
  85750. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85751. * @returns the array index
  85752. */
  85753. getPreviousPointIndexAt(position: number): number;
  85754. /**
  85755. * 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)
  85756. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85757. * @returns the sub position
  85758. */
  85759. getSubPositionAt(position: number): number;
  85760. /**
  85761. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85762. * @param target the vector of which to get the closest position to
  85763. * @returns the position of the closest virtual point on this path to the target vector
  85764. */
  85765. getClosestPositionTo(target: Vector3): number;
  85766. /**
  85767. * Returns a sub path (slice) of this path
  85768. * @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
  85769. * @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
  85770. * @returns a sub path (slice) of this path
  85771. */
  85772. slice(start?: number, end?: number): Path3D;
  85773. /**
  85774. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85775. * @param path path which all values are copied into the curves points
  85776. * @param firstNormal which should be projected onto the curve
  85777. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85778. * @returns the same object updated.
  85779. */
  85780. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85781. private _compute;
  85782. private _getFirstNonNullVector;
  85783. private _getLastNonNullVector;
  85784. private _normalVector;
  85785. /**
  85786. * Updates the point at data for an interpolated point along this curve
  85787. * @param position the position of the point along this curve, from 0.0 to 1.0
  85788. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85789. * @returns the (updated) point at data
  85790. */
  85791. private _updatePointAtData;
  85792. /**
  85793. * Updates the point at data from the specified parameters
  85794. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85795. * @param point the interpolated point
  85796. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85797. */
  85798. private _setPointAtData;
  85799. /**
  85800. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85801. */
  85802. private _updateInterpolationMatrix;
  85803. }
  85804. /**
  85805. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85806. * A Curve3 is designed from a series of successive Vector3.
  85807. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85808. */
  85809. export class Curve3 {
  85810. private _points;
  85811. private _length;
  85812. /**
  85813. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85814. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85815. * @param v1 (Vector3) the control point
  85816. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85817. * @param nbPoints (integer) the wanted number of points in the curve
  85818. * @returns the created Curve3
  85819. */
  85820. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85821. /**
  85822. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85823. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85824. * @param v1 (Vector3) the first control point
  85825. * @param v2 (Vector3) the second control point
  85826. * @param v3 (Vector3) the end point of the Cubic Bezier
  85827. * @param nbPoints (integer) the wanted number of points in the curve
  85828. * @returns the created Curve3
  85829. */
  85830. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85831. /**
  85832. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85833. * @param p1 (Vector3) the origin point of the Hermite Spline
  85834. * @param t1 (Vector3) the tangent vector at the origin point
  85835. * @param p2 (Vector3) the end point of the Hermite Spline
  85836. * @param t2 (Vector3) the tangent vector at the end point
  85837. * @param nbPoints (integer) the wanted number of points in the curve
  85838. * @returns the created Curve3
  85839. */
  85840. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85841. /**
  85842. * Returns a Curve3 object along a CatmullRom Spline curve :
  85843. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85844. * @param nbPoints (integer) the wanted number of points between each curve control points
  85845. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85846. * @returns the created Curve3
  85847. */
  85848. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85849. /**
  85850. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85851. * A Curve3 is designed from a series of successive Vector3.
  85852. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85853. * @param points points which make up the curve
  85854. */
  85855. constructor(points: Vector3[]);
  85856. /**
  85857. * @returns the Curve3 stored array of successive Vector3
  85858. */
  85859. getPoints(): Vector3[];
  85860. /**
  85861. * @returns the computed length (float) of the curve.
  85862. */
  85863. length(): number;
  85864. /**
  85865. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85866. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85867. * curveA and curveB keep unchanged.
  85868. * @param curve the curve to continue from this curve
  85869. * @returns the newly constructed curve
  85870. */
  85871. continue(curve: DeepImmutable<Curve3>): Curve3;
  85872. private _computeLength;
  85873. }
  85874. }
  85875. declare module BABYLON {
  85876. /**
  85877. * This represents the main contract an easing function should follow.
  85878. * Easing functions are used throughout the animation system.
  85879. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85880. */
  85881. export interface IEasingFunction {
  85882. /**
  85883. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85884. * of the easing function.
  85885. * The link below provides some of the most common examples of easing functions.
  85886. * @see https://easings.net/
  85887. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85888. * @returns the corresponding value on the curve defined by the easing function
  85889. */
  85890. ease(gradient: number): number;
  85891. }
  85892. /**
  85893. * Base class used for every default easing function.
  85894. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85895. */
  85896. export class EasingFunction implements IEasingFunction {
  85897. /**
  85898. * Interpolation follows the mathematical formula associated with the easing function.
  85899. */
  85900. static readonly EASINGMODE_EASEIN: number;
  85901. /**
  85902. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85903. */
  85904. static readonly EASINGMODE_EASEOUT: number;
  85905. /**
  85906. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85907. */
  85908. static readonly EASINGMODE_EASEINOUT: number;
  85909. private _easingMode;
  85910. /**
  85911. * Sets the easing mode of the current function.
  85912. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85913. */
  85914. setEasingMode(easingMode: number): void;
  85915. /**
  85916. * Gets the current easing mode.
  85917. * @returns the easing mode
  85918. */
  85919. getEasingMode(): number;
  85920. /**
  85921. * @hidden
  85922. */
  85923. easeInCore(gradient: number): number;
  85924. /**
  85925. * Given an input gradient between 0 and 1, this returns the corresponding value
  85926. * of the easing function.
  85927. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85928. * @returns the corresponding value on the curve defined by the easing function
  85929. */
  85930. ease(gradient: number): number;
  85931. }
  85932. /**
  85933. * Easing function with a circle shape (see link below).
  85934. * @see https://easings.net/#easeInCirc
  85935. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85936. */
  85937. export class CircleEase extends EasingFunction implements IEasingFunction {
  85938. /** @hidden */
  85939. easeInCore(gradient: number): number;
  85940. }
  85941. /**
  85942. * Easing function with a ease back shape (see link below).
  85943. * @see https://easings.net/#easeInBack
  85944. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85945. */
  85946. export class BackEase extends EasingFunction implements IEasingFunction {
  85947. /** Defines the amplitude of the function */
  85948. amplitude: number;
  85949. /**
  85950. * Instantiates a back ease easing
  85951. * @see https://easings.net/#easeInBack
  85952. * @param amplitude Defines the amplitude of the function
  85953. */
  85954. constructor(
  85955. /** Defines the amplitude of the function */
  85956. amplitude?: number);
  85957. /** @hidden */
  85958. easeInCore(gradient: number): number;
  85959. }
  85960. /**
  85961. * Easing function with a bouncing shape (see link below).
  85962. * @see https://easings.net/#easeInBounce
  85963. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85964. */
  85965. export class BounceEase extends EasingFunction implements IEasingFunction {
  85966. /** Defines the number of bounces */
  85967. bounces: number;
  85968. /** Defines the amplitude of the bounce */
  85969. bounciness: number;
  85970. /**
  85971. * Instantiates a bounce easing
  85972. * @see https://easings.net/#easeInBounce
  85973. * @param bounces Defines the number of bounces
  85974. * @param bounciness Defines the amplitude of the bounce
  85975. */
  85976. constructor(
  85977. /** Defines the number of bounces */
  85978. bounces?: number,
  85979. /** Defines the amplitude of the bounce */
  85980. bounciness?: number);
  85981. /** @hidden */
  85982. easeInCore(gradient: number): number;
  85983. }
  85984. /**
  85985. * Easing function with a power of 3 shape (see link below).
  85986. * @see https://easings.net/#easeInCubic
  85987. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85988. */
  85989. export class CubicEase extends EasingFunction implements IEasingFunction {
  85990. /** @hidden */
  85991. easeInCore(gradient: number): number;
  85992. }
  85993. /**
  85994. * Easing function with an elastic shape (see link below).
  85995. * @see https://easings.net/#easeInElastic
  85996. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85997. */
  85998. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85999. /** Defines the number of oscillations*/
  86000. oscillations: number;
  86001. /** Defines the amplitude of the oscillations*/
  86002. springiness: number;
  86003. /**
  86004. * Instantiates an elastic easing function
  86005. * @see https://easings.net/#easeInElastic
  86006. * @param oscillations Defines the number of oscillations
  86007. * @param springiness Defines the amplitude of the oscillations
  86008. */
  86009. constructor(
  86010. /** Defines the number of oscillations*/
  86011. oscillations?: number,
  86012. /** Defines the amplitude of the oscillations*/
  86013. springiness?: number);
  86014. /** @hidden */
  86015. easeInCore(gradient: number): number;
  86016. }
  86017. /**
  86018. * Easing function with an exponential shape (see link below).
  86019. * @see https://easings.net/#easeInExpo
  86020. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86021. */
  86022. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  86023. /** Defines the exponent of the function */
  86024. exponent: number;
  86025. /**
  86026. * Instantiates an exponential easing function
  86027. * @see https://easings.net/#easeInExpo
  86028. * @param exponent Defines the exponent of the function
  86029. */
  86030. constructor(
  86031. /** Defines the exponent of the function */
  86032. exponent?: number);
  86033. /** @hidden */
  86034. easeInCore(gradient: number): number;
  86035. }
  86036. /**
  86037. * Easing function with a power shape (see link below).
  86038. * @see https://easings.net/#easeInQuad
  86039. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86040. */
  86041. export class PowerEase extends EasingFunction implements IEasingFunction {
  86042. /** Defines the power of the function */
  86043. power: number;
  86044. /**
  86045. * Instantiates an power base easing function
  86046. * @see https://easings.net/#easeInQuad
  86047. * @param power Defines the power of the function
  86048. */
  86049. constructor(
  86050. /** Defines the power of the function */
  86051. power?: number);
  86052. /** @hidden */
  86053. easeInCore(gradient: number): number;
  86054. }
  86055. /**
  86056. * Easing function with a power of 2 shape (see link below).
  86057. * @see https://easings.net/#easeInQuad
  86058. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86059. */
  86060. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  86061. /** @hidden */
  86062. easeInCore(gradient: number): number;
  86063. }
  86064. /**
  86065. * Easing function with a power of 4 shape (see link below).
  86066. * @see https://easings.net/#easeInQuart
  86067. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86068. */
  86069. export class QuarticEase extends EasingFunction implements IEasingFunction {
  86070. /** @hidden */
  86071. easeInCore(gradient: number): number;
  86072. }
  86073. /**
  86074. * Easing function with a power of 5 shape (see link below).
  86075. * @see https://easings.net/#easeInQuint
  86076. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86077. */
  86078. export class QuinticEase extends EasingFunction implements IEasingFunction {
  86079. /** @hidden */
  86080. easeInCore(gradient: number): number;
  86081. }
  86082. /**
  86083. * Easing function with a sin shape (see link below).
  86084. * @see https://easings.net/#easeInSine
  86085. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86086. */
  86087. export class SineEase extends EasingFunction implements IEasingFunction {
  86088. /** @hidden */
  86089. easeInCore(gradient: number): number;
  86090. }
  86091. /**
  86092. * Easing function with a bezier shape (see link below).
  86093. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86094. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86095. */
  86096. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  86097. /** Defines the x component of the start tangent in the bezier curve */
  86098. x1: number;
  86099. /** Defines the y component of the start tangent in the bezier curve */
  86100. y1: number;
  86101. /** Defines the x component of the end tangent in the bezier curve */
  86102. x2: number;
  86103. /** Defines the y component of the end tangent in the bezier curve */
  86104. y2: number;
  86105. /**
  86106. * Instantiates a bezier function
  86107. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86108. * @param x1 Defines the x component of the start tangent in the bezier curve
  86109. * @param y1 Defines the y component of the start tangent in the bezier curve
  86110. * @param x2 Defines the x component of the end tangent in the bezier curve
  86111. * @param y2 Defines the y component of the end tangent in the bezier curve
  86112. */
  86113. constructor(
  86114. /** Defines the x component of the start tangent in the bezier curve */
  86115. x1?: number,
  86116. /** Defines the y component of the start tangent in the bezier curve */
  86117. y1?: number,
  86118. /** Defines the x component of the end tangent in the bezier curve */
  86119. x2?: number,
  86120. /** Defines the y component of the end tangent in the bezier curve */
  86121. y2?: number);
  86122. /** @hidden */
  86123. easeInCore(gradient: number): number;
  86124. }
  86125. }
  86126. declare module BABYLON {
  86127. /**
  86128. * Class used to hold a RBG color
  86129. */
  86130. export class Color3 {
  86131. /**
  86132. * Defines the red component (between 0 and 1, default is 0)
  86133. */
  86134. r: number;
  86135. /**
  86136. * Defines the green component (between 0 and 1, default is 0)
  86137. */
  86138. g: number;
  86139. /**
  86140. * Defines the blue component (between 0 and 1, default is 0)
  86141. */
  86142. b: number;
  86143. /**
  86144. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  86145. * @param r defines the red component (between 0 and 1, default is 0)
  86146. * @param g defines the green component (between 0 and 1, default is 0)
  86147. * @param b defines the blue component (between 0 and 1, default is 0)
  86148. */
  86149. constructor(
  86150. /**
  86151. * Defines the red component (between 0 and 1, default is 0)
  86152. */
  86153. r?: number,
  86154. /**
  86155. * Defines the green component (between 0 and 1, default is 0)
  86156. */
  86157. g?: number,
  86158. /**
  86159. * Defines the blue component (between 0 and 1, default is 0)
  86160. */
  86161. b?: number);
  86162. /**
  86163. * Creates a string with the Color3 current values
  86164. * @returns the string representation of the Color3 object
  86165. */
  86166. toString(): string;
  86167. /**
  86168. * Returns the string "Color3"
  86169. * @returns "Color3"
  86170. */
  86171. getClassName(): string;
  86172. /**
  86173. * Compute the Color3 hash code
  86174. * @returns an unique number that can be used to hash Color3 objects
  86175. */
  86176. getHashCode(): number;
  86177. /**
  86178. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  86179. * @param array defines the array where to store the r,g,b components
  86180. * @param index defines an optional index in the target array to define where to start storing values
  86181. * @returns the current Color3 object
  86182. */
  86183. toArray(array: FloatArray, index?: number): Color3;
  86184. /**
  86185. * Update the current color with values stored in an array from the starting index of the given array
  86186. * @param array defines the source array
  86187. * @param offset defines an offset in the source array
  86188. * @returns the current Color3 object
  86189. */
  86190. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86191. /**
  86192. * Returns a new Color4 object from the current Color3 and the given alpha
  86193. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  86194. * @returns a new Color4 object
  86195. */
  86196. toColor4(alpha?: number): Color4;
  86197. /**
  86198. * Returns a new array populated with 3 numeric elements : red, green and blue values
  86199. * @returns the new array
  86200. */
  86201. asArray(): number[];
  86202. /**
  86203. * Returns the luminance value
  86204. * @returns a float value
  86205. */
  86206. toLuminance(): number;
  86207. /**
  86208. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  86209. * @param otherColor defines the second operand
  86210. * @returns the new Color3 object
  86211. */
  86212. multiply(otherColor: DeepImmutable<Color3>): Color3;
  86213. /**
  86214. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  86215. * @param otherColor defines the second operand
  86216. * @param result defines the Color3 object where to store the result
  86217. * @returns the current Color3
  86218. */
  86219. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86220. /**
  86221. * Determines equality between Color3 objects
  86222. * @param otherColor defines the second operand
  86223. * @returns true if the rgb values are equal to the given ones
  86224. */
  86225. equals(otherColor: DeepImmutable<Color3>): boolean;
  86226. /**
  86227. * Determines equality between the current Color3 object and a set of r,b,g values
  86228. * @param r defines the red component to check
  86229. * @param g defines the green component to check
  86230. * @param b defines the blue component to check
  86231. * @returns true if the rgb values are equal to the given ones
  86232. */
  86233. equalsFloats(r: number, g: number, b: number): boolean;
  86234. /**
  86235. * Multiplies in place each rgb value by scale
  86236. * @param scale defines the scaling factor
  86237. * @returns the updated Color3
  86238. */
  86239. scale(scale: number): Color3;
  86240. /**
  86241. * Multiplies the rgb values by scale and stores the result into "result"
  86242. * @param scale defines the scaling factor
  86243. * @param result defines the Color3 object where to store the result
  86244. * @returns the unmodified current Color3
  86245. */
  86246. scaleToRef(scale: number, result: Color3): Color3;
  86247. /**
  86248. * Scale the current Color3 values by a factor and add the result to a given Color3
  86249. * @param scale defines the scale factor
  86250. * @param result defines color to store the result into
  86251. * @returns the unmodified current Color3
  86252. */
  86253. scaleAndAddToRef(scale: number, result: Color3): Color3;
  86254. /**
  86255. * Clamps the rgb values by the min and max values and stores the result into "result"
  86256. * @param min defines minimum clamping value (default is 0)
  86257. * @param max defines maximum clamping value (default is 1)
  86258. * @param result defines color to store the result into
  86259. * @returns the original Color3
  86260. */
  86261. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  86262. /**
  86263. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  86264. * @param otherColor defines the second operand
  86265. * @returns the new Color3
  86266. */
  86267. add(otherColor: DeepImmutable<Color3>): Color3;
  86268. /**
  86269. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  86270. * @param otherColor defines the second operand
  86271. * @param result defines Color3 object to store the result into
  86272. * @returns the unmodified current Color3
  86273. */
  86274. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86275. /**
  86276. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  86277. * @param otherColor defines the second operand
  86278. * @returns the new Color3
  86279. */
  86280. subtract(otherColor: DeepImmutable<Color3>): Color3;
  86281. /**
  86282. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  86283. * @param otherColor defines the second operand
  86284. * @param result defines Color3 object to store the result into
  86285. * @returns the unmodified current Color3
  86286. */
  86287. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86288. /**
  86289. * Copy the current object
  86290. * @returns a new Color3 copied the current one
  86291. */
  86292. clone(): Color3;
  86293. /**
  86294. * Copies the rgb values from the source in the current Color3
  86295. * @param source defines the source Color3 object
  86296. * @returns the updated Color3 object
  86297. */
  86298. copyFrom(source: DeepImmutable<Color3>): Color3;
  86299. /**
  86300. * Updates the Color3 rgb values from the given floats
  86301. * @param r defines the red component to read from
  86302. * @param g defines the green component to read from
  86303. * @param b defines the blue component to read from
  86304. * @returns the current Color3 object
  86305. */
  86306. copyFromFloats(r: number, g: number, b: number): Color3;
  86307. /**
  86308. * Updates the Color3 rgb values from the given floats
  86309. * @param r defines the red component to read from
  86310. * @param g defines the green component to read from
  86311. * @param b defines the blue component to read from
  86312. * @returns the current Color3 object
  86313. */
  86314. set(r: number, g: number, b: number): Color3;
  86315. /**
  86316. * Compute the Color3 hexadecimal code as a string
  86317. * @returns a string containing the hexadecimal representation of the Color3 object
  86318. */
  86319. toHexString(): string;
  86320. /**
  86321. * Computes a new Color3 converted from the current one to linear space
  86322. * @returns a new Color3 object
  86323. */
  86324. toLinearSpace(): Color3;
  86325. /**
  86326. * Converts current color in rgb space to HSV values
  86327. * @returns a new color3 representing the HSV values
  86328. */
  86329. toHSV(): Color3;
  86330. /**
  86331. * Converts current color in rgb space to HSV values
  86332. * @param result defines the Color3 where to store the HSV values
  86333. */
  86334. toHSVToRef(result: Color3): void;
  86335. /**
  86336. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  86337. * @param convertedColor defines the Color3 object where to store the linear space version
  86338. * @returns the unmodified Color3
  86339. */
  86340. toLinearSpaceToRef(convertedColor: Color3): Color3;
  86341. /**
  86342. * Computes a new Color3 converted from the current one to gamma space
  86343. * @returns a new Color3 object
  86344. */
  86345. toGammaSpace(): Color3;
  86346. /**
  86347. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86348. * @param convertedColor defines the Color3 object where to store the gamma space version
  86349. * @returns the unmodified Color3
  86350. */
  86351. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86352. private static _BlackReadOnly;
  86353. /**
  86354. * Convert Hue, saturation and value to a Color3 (RGB)
  86355. * @param hue defines the hue
  86356. * @param saturation defines the saturation
  86357. * @param value defines the value
  86358. * @param result defines the Color3 where to store the RGB values
  86359. */
  86360. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86361. /**
  86362. * Creates a new Color3 from the string containing valid hexadecimal values
  86363. * @param hex defines a string containing valid hexadecimal values
  86364. * @returns a new Color3 object
  86365. */
  86366. static FromHexString(hex: string): Color3;
  86367. /**
  86368. * Creates a new Color3 from the starting index of the given array
  86369. * @param array defines the source array
  86370. * @param offset defines an offset in the source array
  86371. * @returns a new Color3 object
  86372. */
  86373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86374. /**
  86375. * Creates a new Color3 from the starting index element of the given array
  86376. * @param array defines the source array to read from
  86377. * @param offset defines the offset in the source array
  86378. * @param result defines the target Color3 object
  86379. */
  86380. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86381. /**
  86382. * Creates a new Color3 from integer values (< 256)
  86383. * @param r defines the red component to read from (value between 0 and 255)
  86384. * @param g defines the green component to read from (value between 0 and 255)
  86385. * @param b defines the blue component to read from (value between 0 and 255)
  86386. * @returns a new Color3 object
  86387. */
  86388. static FromInts(r: number, g: number, b: number): Color3;
  86389. /**
  86390. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86391. * @param start defines the start Color3 value
  86392. * @param end defines the end Color3 value
  86393. * @param amount defines the gradient value between start and end
  86394. * @returns a new Color3 object
  86395. */
  86396. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86397. /**
  86398. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86399. * @param left defines the start value
  86400. * @param right defines the end value
  86401. * @param amount defines the gradient factor
  86402. * @param result defines the Color3 object where to store the result
  86403. */
  86404. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86405. /**
  86406. * Returns a Color3 value containing a red color
  86407. * @returns a new Color3 object
  86408. */
  86409. static Red(): Color3;
  86410. /**
  86411. * Returns a Color3 value containing a green color
  86412. * @returns a new Color3 object
  86413. */
  86414. static Green(): Color3;
  86415. /**
  86416. * Returns a Color3 value containing a blue color
  86417. * @returns a new Color3 object
  86418. */
  86419. static Blue(): Color3;
  86420. /**
  86421. * Returns a Color3 value containing a black color
  86422. * @returns a new Color3 object
  86423. */
  86424. static Black(): Color3;
  86425. /**
  86426. * Gets a Color3 value containing a black color that must not be updated
  86427. */
  86428. static get BlackReadOnly(): DeepImmutable<Color3>;
  86429. /**
  86430. * Returns a Color3 value containing a white color
  86431. * @returns a new Color3 object
  86432. */
  86433. static White(): Color3;
  86434. /**
  86435. * Returns a Color3 value containing a purple color
  86436. * @returns a new Color3 object
  86437. */
  86438. static Purple(): Color3;
  86439. /**
  86440. * Returns a Color3 value containing a magenta color
  86441. * @returns a new Color3 object
  86442. */
  86443. static Magenta(): Color3;
  86444. /**
  86445. * Returns a Color3 value containing a yellow color
  86446. * @returns a new Color3 object
  86447. */
  86448. static Yellow(): Color3;
  86449. /**
  86450. * Returns a Color3 value containing a gray color
  86451. * @returns a new Color3 object
  86452. */
  86453. static Gray(): Color3;
  86454. /**
  86455. * Returns a Color3 value containing a teal color
  86456. * @returns a new Color3 object
  86457. */
  86458. static Teal(): Color3;
  86459. /**
  86460. * Returns a Color3 value containing a random color
  86461. * @returns a new Color3 object
  86462. */
  86463. static Random(): Color3;
  86464. }
  86465. /**
  86466. * Class used to hold a RBGA color
  86467. */
  86468. export class Color4 {
  86469. /**
  86470. * Defines the red component (between 0 and 1, default is 0)
  86471. */
  86472. r: number;
  86473. /**
  86474. * Defines the green component (between 0 and 1, default is 0)
  86475. */
  86476. g: number;
  86477. /**
  86478. * Defines the blue component (between 0 and 1, default is 0)
  86479. */
  86480. b: number;
  86481. /**
  86482. * Defines the alpha component (between 0 and 1, default is 1)
  86483. */
  86484. a: number;
  86485. /**
  86486. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86487. * @param r defines the red component (between 0 and 1, default is 0)
  86488. * @param g defines the green component (between 0 and 1, default is 0)
  86489. * @param b defines the blue component (between 0 and 1, default is 0)
  86490. * @param a defines the alpha component (between 0 and 1, default is 1)
  86491. */
  86492. constructor(
  86493. /**
  86494. * Defines the red component (between 0 and 1, default is 0)
  86495. */
  86496. r?: number,
  86497. /**
  86498. * Defines the green component (between 0 and 1, default is 0)
  86499. */
  86500. g?: number,
  86501. /**
  86502. * Defines the blue component (between 0 and 1, default is 0)
  86503. */
  86504. b?: number,
  86505. /**
  86506. * Defines the alpha component (between 0 and 1, default is 1)
  86507. */
  86508. a?: number);
  86509. /**
  86510. * Adds in place the given Color4 values to the current Color4 object
  86511. * @param right defines the second operand
  86512. * @returns the current updated Color4 object
  86513. */
  86514. addInPlace(right: DeepImmutable<Color4>): Color4;
  86515. /**
  86516. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86517. * @returns the new array
  86518. */
  86519. asArray(): number[];
  86520. /**
  86521. * Stores from the starting index in the given array the Color4 successive values
  86522. * @param array defines the array where to store the r,g,b components
  86523. * @param index defines an optional index in the target array to define where to start storing values
  86524. * @returns the current Color4 object
  86525. */
  86526. toArray(array: number[], index?: number): Color4;
  86527. /**
  86528. * Update the current color with values stored in an array from the starting index of the given array
  86529. * @param array defines the source array
  86530. * @param offset defines an offset in the source array
  86531. * @returns the current Color4 object
  86532. */
  86533. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86534. /**
  86535. * Determines equality between Color4 objects
  86536. * @param otherColor defines the second operand
  86537. * @returns true if the rgba values are equal to the given ones
  86538. */
  86539. equals(otherColor: DeepImmutable<Color4>): boolean;
  86540. /**
  86541. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86542. * @param right defines the second operand
  86543. * @returns a new Color4 object
  86544. */
  86545. add(right: DeepImmutable<Color4>): Color4;
  86546. /**
  86547. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86548. * @param right defines the second operand
  86549. * @returns a new Color4 object
  86550. */
  86551. subtract(right: DeepImmutable<Color4>): Color4;
  86552. /**
  86553. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86554. * @param right defines the second operand
  86555. * @param result defines the Color4 object where to store the result
  86556. * @returns the current Color4 object
  86557. */
  86558. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86559. /**
  86560. * Creates a new Color4 with the current Color4 values multiplied by scale
  86561. * @param scale defines the scaling factor to apply
  86562. * @returns a new Color4 object
  86563. */
  86564. scale(scale: number): Color4;
  86565. /**
  86566. * Multiplies the current Color4 values by scale and stores the result in "result"
  86567. * @param scale defines the scaling factor to apply
  86568. * @param result defines the Color4 object where to store the result
  86569. * @returns the current unmodified Color4
  86570. */
  86571. scaleToRef(scale: number, result: Color4): Color4;
  86572. /**
  86573. * Scale the current Color4 values by a factor and add the result to a given Color4
  86574. * @param scale defines the scale factor
  86575. * @param result defines the Color4 object where to store the result
  86576. * @returns the unmodified current Color4
  86577. */
  86578. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86579. /**
  86580. * Clamps the rgb values by the min and max values and stores the result into "result"
  86581. * @param min defines minimum clamping value (default is 0)
  86582. * @param max defines maximum clamping value (default is 1)
  86583. * @param result defines color to store the result into.
  86584. * @returns the cuurent Color4
  86585. */
  86586. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86587. /**
  86588. * Multipy an Color4 value by another and return a new Color4 object
  86589. * @param color defines the Color4 value to multiply by
  86590. * @returns a new Color4 object
  86591. */
  86592. multiply(color: Color4): Color4;
  86593. /**
  86594. * Multipy a Color4 value by another and push the result in a reference value
  86595. * @param color defines the Color4 value to multiply by
  86596. * @param result defines the Color4 to fill the result in
  86597. * @returns the result Color4
  86598. */
  86599. multiplyToRef(color: Color4, result: Color4): Color4;
  86600. /**
  86601. * Creates a string with the Color4 current values
  86602. * @returns the string representation of the Color4 object
  86603. */
  86604. toString(): string;
  86605. /**
  86606. * Returns the string "Color4"
  86607. * @returns "Color4"
  86608. */
  86609. getClassName(): string;
  86610. /**
  86611. * Compute the Color4 hash code
  86612. * @returns an unique number that can be used to hash Color4 objects
  86613. */
  86614. getHashCode(): number;
  86615. /**
  86616. * Creates a new Color4 copied from the current one
  86617. * @returns a new Color4 object
  86618. */
  86619. clone(): Color4;
  86620. /**
  86621. * Copies the given Color4 values into the current one
  86622. * @param source defines the source Color4 object
  86623. * @returns the current updated Color4 object
  86624. */
  86625. copyFrom(source: Color4): Color4;
  86626. /**
  86627. * Copies the given float values into the current one
  86628. * @param r defines the red component to read from
  86629. * @param g defines the green component to read from
  86630. * @param b defines the blue component to read from
  86631. * @param a defines the alpha component to read from
  86632. * @returns the current updated Color4 object
  86633. */
  86634. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86635. /**
  86636. * Copies the given float values into the current one
  86637. * @param r defines the red component to read from
  86638. * @param g defines the green component to read from
  86639. * @param b defines the blue component to read from
  86640. * @param a defines the alpha component to read from
  86641. * @returns the current updated Color4 object
  86642. */
  86643. set(r: number, g: number, b: number, a: number): Color4;
  86644. /**
  86645. * Compute the Color4 hexadecimal code as a string
  86646. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86647. * @returns a string containing the hexadecimal representation of the Color4 object
  86648. */
  86649. toHexString(returnAsColor3?: boolean): string;
  86650. /**
  86651. * Computes a new Color4 converted from the current one to linear space
  86652. * @returns a new Color4 object
  86653. */
  86654. toLinearSpace(): Color4;
  86655. /**
  86656. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86657. * @param convertedColor defines the Color4 object where to store the linear space version
  86658. * @returns the unmodified Color4
  86659. */
  86660. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86661. /**
  86662. * Computes a new Color4 converted from the current one to gamma space
  86663. * @returns a new Color4 object
  86664. */
  86665. toGammaSpace(): Color4;
  86666. /**
  86667. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86668. * @param convertedColor defines the Color4 object where to store the gamma space version
  86669. * @returns the unmodified Color4
  86670. */
  86671. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86672. /**
  86673. * Creates a new Color4 from the string containing valid hexadecimal values
  86674. * @param hex defines a string containing valid hexadecimal values
  86675. * @returns a new Color4 object
  86676. */
  86677. static FromHexString(hex: string): Color4;
  86678. /**
  86679. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86680. * @param left defines the start value
  86681. * @param right defines the end value
  86682. * @param amount defines the gradient factor
  86683. * @returns a new Color4 object
  86684. */
  86685. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86686. /**
  86687. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86688. * @param left defines the start value
  86689. * @param right defines the end value
  86690. * @param amount defines the gradient factor
  86691. * @param result defines the Color4 object where to store data
  86692. */
  86693. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86694. /**
  86695. * Creates a new Color4 from a Color3 and an alpha value
  86696. * @param color3 defines the source Color3 to read from
  86697. * @param alpha defines the alpha component (1.0 by default)
  86698. * @returns a new Color4 object
  86699. */
  86700. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86701. /**
  86702. * Creates a new Color4 from the starting index element of the given array
  86703. * @param array defines the source array to read from
  86704. * @param offset defines the offset in the source array
  86705. * @returns a new Color4 object
  86706. */
  86707. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86708. /**
  86709. * Creates a new Color4 from the starting index element of the given array
  86710. * @param array defines the source array to read from
  86711. * @param offset defines the offset in the source array
  86712. * @param result defines the target Color4 object
  86713. */
  86714. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86715. /**
  86716. * Creates a new Color3 from integer values (< 256)
  86717. * @param r defines the red component to read from (value between 0 and 255)
  86718. * @param g defines the green component to read from (value between 0 and 255)
  86719. * @param b defines the blue component to read from (value between 0 and 255)
  86720. * @param a defines the alpha component to read from (value between 0 and 255)
  86721. * @returns a new Color3 object
  86722. */
  86723. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86724. /**
  86725. * Check the content of a given array and convert it to an array containing RGBA data
  86726. * If the original array was already containing count * 4 values then it is returned directly
  86727. * @param colors defines the array to check
  86728. * @param count defines the number of RGBA data to expect
  86729. * @returns an array containing count * 4 values (RGBA)
  86730. */
  86731. static CheckColors4(colors: number[], count: number): number[];
  86732. }
  86733. /**
  86734. * @hidden
  86735. */
  86736. export class TmpColors {
  86737. static Color3: Color3[];
  86738. static Color4: Color4[];
  86739. }
  86740. }
  86741. declare module BABYLON {
  86742. /**
  86743. * Defines an interface which represents an animation key frame
  86744. */
  86745. export interface IAnimationKey {
  86746. /**
  86747. * Frame of the key frame
  86748. */
  86749. frame: number;
  86750. /**
  86751. * Value at the specifies key frame
  86752. */
  86753. value: any;
  86754. /**
  86755. * The input tangent for the cubic hermite spline
  86756. */
  86757. inTangent?: any;
  86758. /**
  86759. * The output tangent for the cubic hermite spline
  86760. */
  86761. outTangent?: any;
  86762. /**
  86763. * The animation interpolation type
  86764. */
  86765. interpolation?: AnimationKeyInterpolation;
  86766. }
  86767. /**
  86768. * Enum for the animation key frame interpolation type
  86769. */
  86770. export enum AnimationKeyInterpolation {
  86771. /**
  86772. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86773. */
  86774. STEP = 1
  86775. }
  86776. }
  86777. declare module BABYLON {
  86778. /**
  86779. * Represents the range of an animation
  86780. */
  86781. export class AnimationRange {
  86782. /**The name of the animation range**/
  86783. name: string;
  86784. /**The starting frame of the animation */
  86785. from: number;
  86786. /**The ending frame of the animation*/
  86787. to: number;
  86788. /**
  86789. * Initializes the range of an animation
  86790. * @param name The name of the animation range
  86791. * @param from The starting frame of the animation
  86792. * @param to The ending frame of the animation
  86793. */
  86794. constructor(
  86795. /**The name of the animation range**/
  86796. name: string,
  86797. /**The starting frame of the animation */
  86798. from: number,
  86799. /**The ending frame of the animation*/
  86800. to: number);
  86801. /**
  86802. * Makes a copy of the animation range
  86803. * @returns A copy of the animation range
  86804. */
  86805. clone(): AnimationRange;
  86806. }
  86807. }
  86808. declare module BABYLON {
  86809. /**
  86810. * Composed of a frame, and an action function
  86811. */
  86812. export class AnimationEvent {
  86813. /** The frame for which the event is triggered **/
  86814. frame: number;
  86815. /** The event to perform when triggered **/
  86816. action: (currentFrame: number) => void;
  86817. /** Specifies if the event should be triggered only once**/
  86818. onlyOnce?: boolean | undefined;
  86819. /**
  86820. * Specifies if the animation event is done
  86821. */
  86822. isDone: boolean;
  86823. /**
  86824. * Initializes the animation event
  86825. * @param frame The frame for which the event is triggered
  86826. * @param action The event to perform when triggered
  86827. * @param onlyOnce Specifies if the event should be triggered only once
  86828. */
  86829. constructor(
  86830. /** The frame for which the event is triggered **/
  86831. frame: number,
  86832. /** The event to perform when triggered **/
  86833. action: (currentFrame: number) => void,
  86834. /** Specifies if the event should be triggered only once**/
  86835. onlyOnce?: boolean | undefined);
  86836. /** @hidden */
  86837. _clone(): AnimationEvent;
  86838. }
  86839. }
  86840. declare module BABYLON {
  86841. /**
  86842. * Interface used to define a behavior
  86843. */
  86844. export interface Behavior<T> {
  86845. /** gets or sets behavior's name */
  86846. name: string;
  86847. /**
  86848. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86849. */
  86850. init(): void;
  86851. /**
  86852. * Called when the behavior is attached to a target
  86853. * @param target defines the target where the behavior is attached to
  86854. */
  86855. attach(target: T): void;
  86856. /**
  86857. * Called when the behavior is detached from its target
  86858. */
  86859. detach(): void;
  86860. }
  86861. /**
  86862. * Interface implemented by classes supporting behaviors
  86863. */
  86864. export interface IBehaviorAware<T> {
  86865. /**
  86866. * Attach a behavior
  86867. * @param behavior defines the behavior to attach
  86868. * @returns the current host
  86869. */
  86870. addBehavior(behavior: Behavior<T>): T;
  86871. /**
  86872. * Remove a behavior from the current object
  86873. * @param behavior defines the behavior to detach
  86874. * @returns the current host
  86875. */
  86876. removeBehavior(behavior: Behavior<T>): T;
  86877. /**
  86878. * Gets a behavior using its name to search
  86879. * @param name defines the name to search
  86880. * @returns the behavior or null if not found
  86881. */
  86882. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86883. }
  86884. }
  86885. declare module BABYLON {
  86886. /**
  86887. * Defines an array and its length.
  86888. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86889. */
  86890. export interface ISmartArrayLike<T> {
  86891. /**
  86892. * The data of the array.
  86893. */
  86894. data: Array<T>;
  86895. /**
  86896. * The active length of the array.
  86897. */
  86898. length: number;
  86899. }
  86900. /**
  86901. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86902. */
  86903. export class SmartArray<T> implements ISmartArrayLike<T> {
  86904. /**
  86905. * The full set of data from the array.
  86906. */
  86907. data: Array<T>;
  86908. /**
  86909. * The active length of the array.
  86910. */
  86911. length: number;
  86912. protected _id: number;
  86913. /**
  86914. * Instantiates a Smart Array.
  86915. * @param capacity defines the default capacity of the array.
  86916. */
  86917. constructor(capacity: number);
  86918. /**
  86919. * Pushes a value at the end of the active data.
  86920. * @param value defines the object to push in the array.
  86921. */
  86922. push(value: T): void;
  86923. /**
  86924. * Iterates over the active data and apply the lambda to them.
  86925. * @param func defines the action to apply on each value.
  86926. */
  86927. forEach(func: (content: T) => void): void;
  86928. /**
  86929. * Sorts the full sets of data.
  86930. * @param compareFn defines the comparison function to apply.
  86931. */
  86932. sort(compareFn: (a: T, b: T) => number): void;
  86933. /**
  86934. * Resets the active data to an empty array.
  86935. */
  86936. reset(): void;
  86937. /**
  86938. * Releases all the data from the array as well as the array.
  86939. */
  86940. dispose(): void;
  86941. /**
  86942. * Concats the active data with a given array.
  86943. * @param array defines the data to concatenate with.
  86944. */
  86945. concat(array: any): void;
  86946. /**
  86947. * Returns the position of a value in the active data.
  86948. * @param value defines the value to find the index for
  86949. * @returns the index if found in the active data otherwise -1
  86950. */
  86951. indexOf(value: T): number;
  86952. /**
  86953. * Returns whether an element is part of the active data.
  86954. * @param value defines the value to look for
  86955. * @returns true if found in the active data otherwise false
  86956. */
  86957. contains(value: T): boolean;
  86958. private static _GlobalId;
  86959. }
  86960. /**
  86961. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86962. * The data in this array can only be present once
  86963. */
  86964. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86965. private _duplicateId;
  86966. /**
  86967. * Pushes a value at the end of the active data.
  86968. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86969. * @param value defines the object to push in the array.
  86970. */
  86971. push(value: T): void;
  86972. /**
  86973. * Pushes a value at the end of the active data.
  86974. * If the data is already present, it won t be added again
  86975. * @param value defines the object to push in the array.
  86976. * @returns true if added false if it was already present
  86977. */
  86978. pushNoDuplicate(value: T): boolean;
  86979. /**
  86980. * Resets the active data to an empty array.
  86981. */
  86982. reset(): void;
  86983. /**
  86984. * Concats the active data with a given array.
  86985. * This ensures no dupplicate will be present in the result.
  86986. * @param array defines the data to concatenate with.
  86987. */
  86988. concatWithNoDuplicate(array: any): void;
  86989. }
  86990. }
  86991. declare module BABYLON {
  86992. /**
  86993. * @ignore
  86994. * This is a list of all the different input types that are available in the application.
  86995. * Fo instance: ArcRotateCameraGamepadInput...
  86996. */
  86997. export var CameraInputTypes: {};
  86998. /**
  86999. * This is the contract to implement in order to create a new input class.
  87000. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  87001. */
  87002. export interface ICameraInput<TCamera extends Camera> {
  87003. /**
  87004. * Defines the camera the input is attached to.
  87005. */
  87006. camera: Nullable<TCamera>;
  87007. /**
  87008. * Gets the class name of the current intput.
  87009. * @returns the class name
  87010. */
  87011. getClassName(): string;
  87012. /**
  87013. * Get the friendly name associated with the input class.
  87014. * @returns the input friendly name
  87015. */
  87016. getSimpleName(): string;
  87017. /**
  87018. * Attach the input controls to a specific dom element to get the input from.
  87019. * @param element Defines the element the controls should be listened from
  87020. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87021. */
  87022. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87023. /**
  87024. * Detach the current controls from the specified dom element.
  87025. * @param element Defines the element to stop listening the inputs from
  87026. */
  87027. detachControl(element: Nullable<HTMLElement>): void;
  87028. /**
  87029. * Update the current camera state depending on the inputs that have been used this frame.
  87030. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87031. */
  87032. checkInputs?: () => void;
  87033. }
  87034. /**
  87035. * Represents a map of input types to input instance or input index to input instance.
  87036. */
  87037. export interface CameraInputsMap<TCamera extends Camera> {
  87038. /**
  87039. * Accessor to the input by input type.
  87040. */
  87041. [name: string]: ICameraInput<TCamera>;
  87042. /**
  87043. * Accessor to the input by input index.
  87044. */
  87045. [idx: number]: ICameraInput<TCamera>;
  87046. }
  87047. /**
  87048. * This represents the input manager used within a camera.
  87049. * It helps dealing with all the different kind of input attached to a camera.
  87050. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87051. */
  87052. export class CameraInputsManager<TCamera extends Camera> {
  87053. /**
  87054. * Defines the list of inputs attahed to the camera.
  87055. */
  87056. attached: CameraInputsMap<TCamera>;
  87057. /**
  87058. * Defines the dom element the camera is collecting inputs from.
  87059. * This is null if the controls have not been attached.
  87060. */
  87061. attachedElement: Nullable<HTMLElement>;
  87062. /**
  87063. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87064. */
  87065. noPreventDefault: boolean;
  87066. /**
  87067. * Defined the camera the input manager belongs to.
  87068. */
  87069. camera: TCamera;
  87070. /**
  87071. * Update the current camera state depending on the inputs that have been used this frame.
  87072. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87073. */
  87074. checkInputs: () => void;
  87075. /**
  87076. * Instantiate a new Camera Input Manager.
  87077. * @param camera Defines the camera the input manager blongs to
  87078. */
  87079. constructor(camera: TCamera);
  87080. /**
  87081. * Add an input method to a camera
  87082. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87083. * @param input camera input method
  87084. */
  87085. add(input: ICameraInput<TCamera>): void;
  87086. /**
  87087. * Remove a specific input method from a camera
  87088. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  87089. * @param inputToRemove camera input method
  87090. */
  87091. remove(inputToRemove: ICameraInput<TCamera>): void;
  87092. /**
  87093. * Remove a specific input type from a camera
  87094. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  87095. * @param inputType the type of the input to remove
  87096. */
  87097. removeByType(inputType: string): void;
  87098. private _addCheckInputs;
  87099. /**
  87100. * Attach the input controls to the currently attached dom element to listen the events from.
  87101. * @param input Defines the input to attach
  87102. */
  87103. attachInput(input: ICameraInput<TCamera>): void;
  87104. /**
  87105. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  87106. * @param element Defines the dom element to collect the events from
  87107. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87108. */
  87109. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  87110. /**
  87111. * Detach the current manager inputs controls from a specific dom element.
  87112. * @param element Defines the dom element to collect the events from
  87113. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  87114. */
  87115. detachElement(element: HTMLElement, disconnect?: boolean): void;
  87116. /**
  87117. * Rebuild the dynamic inputCheck function from the current list of
  87118. * defined inputs in the manager.
  87119. */
  87120. rebuildInputCheck(): void;
  87121. /**
  87122. * Remove all attached input methods from a camera
  87123. */
  87124. clear(): void;
  87125. /**
  87126. * Serialize the current input manager attached to a camera.
  87127. * This ensures than once parsed,
  87128. * the input associated to the camera will be identical to the current ones
  87129. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  87130. */
  87131. serialize(serializedCamera: any): void;
  87132. /**
  87133. * Parses an input manager serialized JSON to restore the previous list of inputs
  87134. * and states associated to a camera.
  87135. * @param parsedCamera Defines the JSON to parse
  87136. */
  87137. parse(parsedCamera: any): void;
  87138. }
  87139. }
  87140. declare module BABYLON {
  87141. /**
  87142. * Class used to store data that will be store in GPU memory
  87143. */
  87144. export class Buffer {
  87145. private _engine;
  87146. private _buffer;
  87147. /** @hidden */
  87148. _data: Nullable<DataArray>;
  87149. private _updatable;
  87150. private _instanced;
  87151. private _divisor;
  87152. /**
  87153. * Gets the byte stride.
  87154. */
  87155. readonly byteStride: number;
  87156. /**
  87157. * Constructor
  87158. * @param engine the engine
  87159. * @param data the data to use for this buffer
  87160. * @param updatable whether the data is updatable
  87161. * @param stride the stride (optional)
  87162. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87163. * @param instanced whether the buffer is instanced (optional)
  87164. * @param useBytes set to true if the stride in in bytes (optional)
  87165. * @param divisor sets an optional divisor for instances (1 by default)
  87166. */
  87167. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  87168. /**
  87169. * Create a new VertexBuffer based on the current buffer
  87170. * @param kind defines the vertex buffer kind (position, normal, etc.)
  87171. * @param offset defines offset in the buffer (0 by default)
  87172. * @param size defines the size in floats of attributes (position is 3 for instance)
  87173. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  87174. * @param instanced defines if the vertex buffer contains indexed data
  87175. * @param useBytes defines if the offset and stride are in bytes *
  87176. * @param divisor sets an optional divisor for instances (1 by default)
  87177. * @returns the new vertex buffer
  87178. */
  87179. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  87180. /**
  87181. * Gets a boolean indicating if the Buffer is updatable?
  87182. * @returns true if the buffer is updatable
  87183. */
  87184. isUpdatable(): boolean;
  87185. /**
  87186. * Gets current buffer's data
  87187. * @returns a DataArray or null
  87188. */
  87189. getData(): Nullable<DataArray>;
  87190. /**
  87191. * Gets underlying native buffer
  87192. * @returns underlying native buffer
  87193. */
  87194. getBuffer(): Nullable<DataBuffer>;
  87195. /**
  87196. * Gets the stride in float32 units (i.e. byte stride / 4).
  87197. * May not be an integer if the byte stride is not divisible by 4.
  87198. * @returns the stride in float32 units
  87199. * @deprecated Please use byteStride instead.
  87200. */
  87201. getStrideSize(): number;
  87202. /**
  87203. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87204. * @param data defines the data to store
  87205. */
  87206. create(data?: Nullable<DataArray>): void;
  87207. /** @hidden */
  87208. _rebuild(): void;
  87209. /**
  87210. * Update current buffer data
  87211. * @param data defines the data to store
  87212. */
  87213. update(data: DataArray): void;
  87214. /**
  87215. * Updates the data directly.
  87216. * @param data the new data
  87217. * @param offset the new offset
  87218. * @param vertexCount the vertex count (optional)
  87219. * @param useBytes set to true if the offset is in bytes
  87220. */
  87221. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  87222. /**
  87223. * Release all resources
  87224. */
  87225. dispose(): void;
  87226. }
  87227. /**
  87228. * Specialized buffer used to store vertex data
  87229. */
  87230. export class VertexBuffer {
  87231. /** @hidden */
  87232. _buffer: Buffer;
  87233. private _kind;
  87234. private _size;
  87235. private _ownsBuffer;
  87236. private _instanced;
  87237. private _instanceDivisor;
  87238. /**
  87239. * The byte type.
  87240. */
  87241. static readonly BYTE: number;
  87242. /**
  87243. * The unsigned byte type.
  87244. */
  87245. static readonly UNSIGNED_BYTE: number;
  87246. /**
  87247. * The short type.
  87248. */
  87249. static readonly SHORT: number;
  87250. /**
  87251. * The unsigned short type.
  87252. */
  87253. static readonly UNSIGNED_SHORT: number;
  87254. /**
  87255. * The integer type.
  87256. */
  87257. static readonly INT: number;
  87258. /**
  87259. * The unsigned integer type.
  87260. */
  87261. static readonly UNSIGNED_INT: number;
  87262. /**
  87263. * The float type.
  87264. */
  87265. static readonly FLOAT: number;
  87266. /**
  87267. * Gets or sets the instance divisor when in instanced mode
  87268. */
  87269. get instanceDivisor(): number;
  87270. set instanceDivisor(value: number);
  87271. /**
  87272. * Gets the byte stride.
  87273. */
  87274. readonly byteStride: number;
  87275. /**
  87276. * Gets the byte offset.
  87277. */
  87278. readonly byteOffset: number;
  87279. /**
  87280. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  87281. */
  87282. readonly normalized: boolean;
  87283. /**
  87284. * Gets the data type of each component in the array.
  87285. */
  87286. readonly type: number;
  87287. /**
  87288. * Constructor
  87289. * @param engine the engine
  87290. * @param data the data to use for this vertex buffer
  87291. * @param kind the vertex buffer kind
  87292. * @param updatable whether the data is updatable
  87293. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87294. * @param stride the stride (optional)
  87295. * @param instanced whether the buffer is instanced (optional)
  87296. * @param offset the offset of the data (optional)
  87297. * @param size the number of components (optional)
  87298. * @param type the type of the component (optional)
  87299. * @param normalized whether the data contains normalized data (optional)
  87300. * @param useBytes set to true if stride and offset are in bytes (optional)
  87301. * @param divisor defines the instance divisor to use (1 by default)
  87302. */
  87303. 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);
  87304. /** @hidden */
  87305. _rebuild(): void;
  87306. /**
  87307. * Returns the kind of the VertexBuffer (string)
  87308. * @returns a string
  87309. */
  87310. getKind(): string;
  87311. /**
  87312. * Gets a boolean indicating if the VertexBuffer is updatable?
  87313. * @returns true if the buffer is updatable
  87314. */
  87315. isUpdatable(): boolean;
  87316. /**
  87317. * Gets current buffer's data
  87318. * @returns a DataArray or null
  87319. */
  87320. getData(): Nullable<DataArray>;
  87321. /**
  87322. * Gets underlying native buffer
  87323. * @returns underlying native buffer
  87324. */
  87325. getBuffer(): Nullable<DataBuffer>;
  87326. /**
  87327. * Gets the stride in float32 units (i.e. byte stride / 4).
  87328. * May not be an integer if the byte stride is not divisible by 4.
  87329. * @returns the stride in float32 units
  87330. * @deprecated Please use byteStride instead.
  87331. */
  87332. getStrideSize(): number;
  87333. /**
  87334. * Returns the offset as a multiple of the type byte length.
  87335. * @returns the offset in bytes
  87336. * @deprecated Please use byteOffset instead.
  87337. */
  87338. getOffset(): number;
  87339. /**
  87340. * Returns the number of components per vertex attribute (integer)
  87341. * @returns the size in float
  87342. */
  87343. getSize(): number;
  87344. /**
  87345. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87346. * @returns true if this buffer is instanced
  87347. */
  87348. getIsInstanced(): boolean;
  87349. /**
  87350. * Returns the instancing divisor, zero for non-instanced (integer).
  87351. * @returns a number
  87352. */
  87353. getInstanceDivisor(): number;
  87354. /**
  87355. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87356. * @param data defines the data to store
  87357. */
  87358. create(data?: DataArray): void;
  87359. /**
  87360. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87361. * This function will create a new buffer if the current one is not updatable
  87362. * @param data defines the data to store
  87363. */
  87364. update(data: DataArray): void;
  87365. /**
  87366. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87367. * Returns the directly updated WebGLBuffer.
  87368. * @param data the new data
  87369. * @param offset the new offset
  87370. * @param useBytes set to true if the offset is in bytes
  87371. */
  87372. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87373. /**
  87374. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87375. */
  87376. dispose(): void;
  87377. /**
  87378. * Enumerates each value of this vertex buffer as numbers.
  87379. * @param count the number of values to enumerate
  87380. * @param callback the callback function called for each value
  87381. */
  87382. forEach(count: number, callback: (value: number, index: number) => void): void;
  87383. /**
  87384. * Positions
  87385. */
  87386. static readonly PositionKind: string;
  87387. /**
  87388. * Normals
  87389. */
  87390. static readonly NormalKind: string;
  87391. /**
  87392. * Tangents
  87393. */
  87394. static readonly TangentKind: string;
  87395. /**
  87396. * Texture coordinates
  87397. */
  87398. static readonly UVKind: string;
  87399. /**
  87400. * Texture coordinates 2
  87401. */
  87402. static readonly UV2Kind: string;
  87403. /**
  87404. * Texture coordinates 3
  87405. */
  87406. static readonly UV3Kind: string;
  87407. /**
  87408. * Texture coordinates 4
  87409. */
  87410. static readonly UV4Kind: string;
  87411. /**
  87412. * Texture coordinates 5
  87413. */
  87414. static readonly UV5Kind: string;
  87415. /**
  87416. * Texture coordinates 6
  87417. */
  87418. static readonly UV6Kind: string;
  87419. /**
  87420. * Colors
  87421. */
  87422. static readonly ColorKind: string;
  87423. /**
  87424. * Matrix indices (for bones)
  87425. */
  87426. static readonly MatricesIndicesKind: string;
  87427. /**
  87428. * Matrix weights (for bones)
  87429. */
  87430. static readonly MatricesWeightsKind: string;
  87431. /**
  87432. * Additional matrix indices (for bones)
  87433. */
  87434. static readonly MatricesIndicesExtraKind: string;
  87435. /**
  87436. * Additional matrix weights (for bones)
  87437. */
  87438. static readonly MatricesWeightsExtraKind: string;
  87439. /**
  87440. * Deduces the stride given a kind.
  87441. * @param kind The kind string to deduce
  87442. * @returns The deduced stride
  87443. */
  87444. static DeduceStride(kind: string): number;
  87445. /**
  87446. * Gets the byte length of the given type.
  87447. * @param type the type
  87448. * @returns the number of bytes
  87449. */
  87450. static GetTypeByteLength(type: number): number;
  87451. /**
  87452. * Enumerates each value of the given parameters as numbers.
  87453. * @param data the data to enumerate
  87454. * @param byteOffset the byte offset of the data
  87455. * @param byteStride the byte stride of the data
  87456. * @param componentCount the number of components per element
  87457. * @param componentType the type of the component
  87458. * @param count the number of values to enumerate
  87459. * @param normalized whether the data is normalized
  87460. * @param callback the callback function called for each value
  87461. */
  87462. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87463. private static _GetFloatValue;
  87464. }
  87465. }
  87466. declare module BABYLON {
  87467. /**
  87468. * The options Interface for creating a Capsule Mesh
  87469. */
  87470. export interface ICreateCapsuleOptions {
  87471. /** The Orientation of the capsule. Default : Vector3.Up() */
  87472. orientation?: Vector3;
  87473. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87474. subdivisions: number;
  87475. /** Number of cylindrical segments on the capsule. */
  87476. tessellation: number;
  87477. /** Height or Length of the capsule. */
  87478. height: number;
  87479. /** Radius of the capsule. */
  87480. radius: number;
  87481. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  87482. capSubdivisions: number;
  87483. /** Overwrite for the top radius. */
  87484. radiusTop?: number;
  87485. /** Overwrite for the bottom radius. */
  87486. radiusBottom?: number;
  87487. /** Overwrite for the top capSubdivisions. */
  87488. topCapSubdivisions?: number;
  87489. /** Overwrite for the bottom capSubdivisions. */
  87490. bottomCapSubdivisions?: number;
  87491. }
  87492. /**
  87493. * Class containing static functions to help procedurally build meshes
  87494. */
  87495. export class CapsuleBuilder {
  87496. /**
  87497. * Creates a capsule or a pill mesh
  87498. * @param name defines the name of the mesh
  87499. * @param options The constructors options.
  87500. * @param scene The scene the mesh is scoped to.
  87501. * @returns Capsule Mesh
  87502. */
  87503. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87504. }
  87505. }
  87506. declare module BABYLON {
  87507. /**
  87508. * @hidden
  87509. */
  87510. export class IntersectionInfo {
  87511. bu: Nullable<number>;
  87512. bv: Nullable<number>;
  87513. distance: number;
  87514. faceId: number;
  87515. subMeshId: number;
  87516. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87517. }
  87518. }
  87519. declare module BABYLON {
  87520. /**
  87521. * Class used to store bounding sphere information
  87522. */
  87523. export class BoundingSphere {
  87524. /**
  87525. * Gets the center of the bounding sphere in local space
  87526. */
  87527. readonly center: Vector3;
  87528. /**
  87529. * Radius of the bounding sphere in local space
  87530. */
  87531. radius: number;
  87532. /**
  87533. * Gets the center of the bounding sphere in world space
  87534. */
  87535. readonly centerWorld: Vector3;
  87536. /**
  87537. * Radius of the bounding sphere in world space
  87538. */
  87539. radiusWorld: number;
  87540. /**
  87541. * Gets the minimum vector in local space
  87542. */
  87543. readonly minimum: Vector3;
  87544. /**
  87545. * Gets the maximum vector in local space
  87546. */
  87547. readonly maximum: Vector3;
  87548. private _worldMatrix;
  87549. private static readonly TmpVector3;
  87550. /**
  87551. * Creates a new bounding sphere
  87552. * @param min defines the minimum vector (in local space)
  87553. * @param max defines the maximum vector (in local space)
  87554. * @param worldMatrix defines the new world matrix
  87555. */
  87556. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87557. /**
  87558. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87559. * @param min defines the new minimum vector (in local space)
  87560. * @param max defines the new maximum vector (in local space)
  87561. * @param worldMatrix defines the new world matrix
  87562. */
  87563. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87564. /**
  87565. * Scale the current bounding sphere by applying a scale factor
  87566. * @param factor defines the scale factor to apply
  87567. * @returns the current bounding box
  87568. */
  87569. scale(factor: number): BoundingSphere;
  87570. /**
  87571. * Gets the world matrix of the bounding box
  87572. * @returns a matrix
  87573. */
  87574. getWorldMatrix(): DeepImmutable<Matrix>;
  87575. /** @hidden */
  87576. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87577. /**
  87578. * Tests if the bounding sphere is intersecting the frustum planes
  87579. * @param frustumPlanes defines the frustum planes to test
  87580. * @returns true if there is an intersection
  87581. */
  87582. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87583. /**
  87584. * Tests if the bounding sphere center is in between the frustum planes.
  87585. * Used for optimistic fast inclusion.
  87586. * @param frustumPlanes defines the frustum planes to test
  87587. * @returns true if the sphere center is in between the frustum planes
  87588. */
  87589. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87590. /**
  87591. * Tests if a point is inside the bounding sphere
  87592. * @param point defines the point to test
  87593. * @returns true if the point is inside the bounding sphere
  87594. */
  87595. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87596. /**
  87597. * Checks if two sphere intersct
  87598. * @param sphere0 sphere 0
  87599. * @param sphere1 sphere 1
  87600. * @returns true if the speres intersect
  87601. */
  87602. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87603. }
  87604. }
  87605. declare module BABYLON {
  87606. /**
  87607. * Class used to store bounding box information
  87608. */
  87609. export class BoundingBox implements ICullable {
  87610. /**
  87611. * Gets the 8 vectors representing the bounding box in local space
  87612. */
  87613. readonly vectors: Vector3[];
  87614. /**
  87615. * Gets the center of the bounding box in local space
  87616. */
  87617. readonly center: Vector3;
  87618. /**
  87619. * Gets the center of the bounding box in world space
  87620. */
  87621. readonly centerWorld: Vector3;
  87622. /**
  87623. * Gets the extend size in local space
  87624. */
  87625. readonly extendSize: Vector3;
  87626. /**
  87627. * Gets the extend size in world space
  87628. */
  87629. readonly extendSizeWorld: Vector3;
  87630. /**
  87631. * Gets the OBB (object bounding box) directions
  87632. */
  87633. readonly directions: Vector3[];
  87634. /**
  87635. * Gets the 8 vectors representing the bounding box in world space
  87636. */
  87637. readonly vectorsWorld: Vector3[];
  87638. /**
  87639. * Gets the minimum vector in world space
  87640. */
  87641. readonly minimumWorld: Vector3;
  87642. /**
  87643. * Gets the maximum vector in world space
  87644. */
  87645. readonly maximumWorld: Vector3;
  87646. /**
  87647. * Gets the minimum vector in local space
  87648. */
  87649. readonly minimum: Vector3;
  87650. /**
  87651. * Gets the maximum vector in local space
  87652. */
  87653. readonly maximum: Vector3;
  87654. private _worldMatrix;
  87655. private static readonly TmpVector3;
  87656. /**
  87657. * @hidden
  87658. */
  87659. _tag: number;
  87660. /**
  87661. * Creates a new bounding box
  87662. * @param min defines the minimum vector (in local space)
  87663. * @param max defines the maximum vector (in local space)
  87664. * @param worldMatrix defines the new world matrix
  87665. */
  87666. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87667. /**
  87668. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87669. * @param min defines the new minimum vector (in local space)
  87670. * @param max defines the new maximum vector (in local space)
  87671. * @param worldMatrix defines the new world matrix
  87672. */
  87673. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87674. /**
  87675. * Scale the current bounding box by applying a scale factor
  87676. * @param factor defines the scale factor to apply
  87677. * @returns the current bounding box
  87678. */
  87679. scale(factor: number): BoundingBox;
  87680. /**
  87681. * Gets the world matrix of the bounding box
  87682. * @returns a matrix
  87683. */
  87684. getWorldMatrix(): DeepImmutable<Matrix>;
  87685. /** @hidden */
  87686. _update(world: DeepImmutable<Matrix>): void;
  87687. /**
  87688. * Tests if the bounding box is intersecting the frustum planes
  87689. * @param frustumPlanes defines the frustum planes to test
  87690. * @returns true if there is an intersection
  87691. */
  87692. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87693. /**
  87694. * Tests if the bounding box is entirely inside the frustum planes
  87695. * @param frustumPlanes defines the frustum planes to test
  87696. * @returns true if there is an inclusion
  87697. */
  87698. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87699. /**
  87700. * Tests if a point is inside the bounding box
  87701. * @param point defines the point to test
  87702. * @returns true if the point is inside the bounding box
  87703. */
  87704. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87705. /**
  87706. * Tests if the bounding box intersects with a bounding sphere
  87707. * @param sphere defines the sphere to test
  87708. * @returns true if there is an intersection
  87709. */
  87710. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87711. /**
  87712. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87713. * @param min defines the min vector to use
  87714. * @param max defines the max vector to use
  87715. * @returns true if there is an intersection
  87716. */
  87717. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87718. /**
  87719. * Tests if two bounding boxes are intersections
  87720. * @param box0 defines the first box to test
  87721. * @param box1 defines the second box to test
  87722. * @returns true if there is an intersection
  87723. */
  87724. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87725. /**
  87726. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87727. * @param minPoint defines the minimum vector of the bounding box
  87728. * @param maxPoint defines the maximum vector of the bounding box
  87729. * @param sphereCenter defines the sphere center
  87730. * @param sphereRadius defines the sphere radius
  87731. * @returns true if there is an intersection
  87732. */
  87733. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87734. /**
  87735. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87736. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87737. * @param frustumPlanes defines the frustum planes to test
  87738. * @return true if there is an inclusion
  87739. */
  87740. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87741. /**
  87742. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87743. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87744. * @param frustumPlanes defines the frustum planes to test
  87745. * @return true if there is an intersection
  87746. */
  87747. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87748. }
  87749. }
  87750. declare module BABYLON {
  87751. /** @hidden */
  87752. export class Collider {
  87753. /** Define if a collision was found */
  87754. collisionFound: boolean;
  87755. /**
  87756. * Define last intersection point in local space
  87757. */
  87758. intersectionPoint: Vector3;
  87759. /**
  87760. * Define last collided mesh
  87761. */
  87762. collidedMesh: Nullable<AbstractMesh>;
  87763. private _collisionPoint;
  87764. private _planeIntersectionPoint;
  87765. private _tempVector;
  87766. private _tempVector2;
  87767. private _tempVector3;
  87768. private _tempVector4;
  87769. private _edge;
  87770. private _baseToVertex;
  87771. private _destinationPoint;
  87772. private _slidePlaneNormal;
  87773. private _displacementVector;
  87774. /** @hidden */
  87775. _radius: Vector3;
  87776. /** @hidden */
  87777. _retry: number;
  87778. private _velocity;
  87779. private _basePoint;
  87780. private _epsilon;
  87781. /** @hidden */
  87782. _velocityWorldLength: number;
  87783. /** @hidden */
  87784. _basePointWorld: Vector3;
  87785. private _velocityWorld;
  87786. private _normalizedVelocity;
  87787. /** @hidden */
  87788. _initialVelocity: Vector3;
  87789. /** @hidden */
  87790. _initialPosition: Vector3;
  87791. private _nearestDistance;
  87792. private _collisionMask;
  87793. get collisionMask(): number;
  87794. set collisionMask(mask: number);
  87795. /**
  87796. * Gets the plane normal used to compute the sliding response (in local space)
  87797. */
  87798. get slidePlaneNormal(): Vector3;
  87799. /** @hidden */
  87800. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87801. /** @hidden */
  87802. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87803. /** @hidden */
  87804. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87805. /** @hidden */
  87806. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87807. /** @hidden */
  87808. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87809. /** @hidden */
  87810. _getResponse(pos: Vector3, vel: Vector3): void;
  87811. }
  87812. }
  87813. declare module BABYLON {
  87814. /**
  87815. * Interface for cullable objects
  87816. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87817. */
  87818. export interface ICullable {
  87819. /**
  87820. * Checks if the object or part of the object is in the frustum
  87821. * @param frustumPlanes Camera near/planes
  87822. * @returns true if the object is in frustum otherwise false
  87823. */
  87824. isInFrustum(frustumPlanes: Plane[]): boolean;
  87825. /**
  87826. * Checks if a cullable object (mesh...) is in the camera frustum
  87827. * Unlike isInFrustum this cheks the full bounding box
  87828. * @param frustumPlanes Camera near/planes
  87829. * @returns true if the object is in frustum otherwise false
  87830. */
  87831. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87832. }
  87833. /**
  87834. * Info for a bounding data of a mesh
  87835. */
  87836. export class BoundingInfo implements ICullable {
  87837. /**
  87838. * Bounding box for the mesh
  87839. */
  87840. readonly boundingBox: BoundingBox;
  87841. /**
  87842. * Bounding sphere for the mesh
  87843. */
  87844. readonly boundingSphere: BoundingSphere;
  87845. private _isLocked;
  87846. private static readonly TmpVector3;
  87847. /**
  87848. * Constructs bounding info
  87849. * @param minimum min vector of the bounding box/sphere
  87850. * @param maximum max vector of the bounding box/sphere
  87851. * @param worldMatrix defines the new world matrix
  87852. */
  87853. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87854. /**
  87855. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87856. * @param min defines the new minimum vector (in local space)
  87857. * @param max defines the new maximum vector (in local space)
  87858. * @param worldMatrix defines the new world matrix
  87859. */
  87860. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87861. /**
  87862. * min vector of the bounding box/sphere
  87863. */
  87864. get minimum(): Vector3;
  87865. /**
  87866. * max vector of the bounding box/sphere
  87867. */
  87868. get maximum(): Vector3;
  87869. /**
  87870. * If the info is locked and won't be updated to avoid perf overhead
  87871. */
  87872. get isLocked(): boolean;
  87873. set isLocked(value: boolean);
  87874. /**
  87875. * Updates the bounding sphere and box
  87876. * @param world world matrix to be used to update
  87877. */
  87878. update(world: DeepImmutable<Matrix>): void;
  87879. /**
  87880. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87881. * @param center New center of the bounding info
  87882. * @param extend New extend of the bounding info
  87883. * @returns the current bounding info
  87884. */
  87885. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87886. /**
  87887. * Scale the current bounding info by applying a scale factor
  87888. * @param factor defines the scale factor to apply
  87889. * @returns the current bounding info
  87890. */
  87891. scale(factor: number): BoundingInfo;
  87892. /**
  87893. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87894. * @param frustumPlanes defines the frustum to test
  87895. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87896. * @returns true if the bounding info is in the frustum planes
  87897. */
  87898. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87899. /**
  87900. * Gets the world distance between the min and max points of the bounding box
  87901. */
  87902. get diagonalLength(): number;
  87903. /**
  87904. * Checks if a cullable object (mesh...) is in the camera frustum
  87905. * Unlike isInFrustum this cheks the full bounding box
  87906. * @param frustumPlanes Camera near/planes
  87907. * @returns true if the object is in frustum otherwise false
  87908. */
  87909. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87910. /** @hidden */
  87911. _checkCollision(collider: Collider): boolean;
  87912. /**
  87913. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87914. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87915. * @param point the point to check intersection with
  87916. * @returns if the point intersects
  87917. */
  87918. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87919. /**
  87920. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87921. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87922. * @param boundingInfo the bounding info to check intersection with
  87923. * @param precise if the intersection should be done using OBB
  87924. * @returns if the bounding info intersects
  87925. */
  87926. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87927. }
  87928. }
  87929. declare module BABYLON {
  87930. /**
  87931. * Extracts minimum and maximum values from a list of indexed positions
  87932. * @param positions defines the positions to use
  87933. * @param indices defines the indices to the positions
  87934. * @param indexStart defines the start index
  87935. * @param indexCount defines the end index
  87936. * @param bias defines bias value to add to the result
  87937. * @return minimum and maximum values
  87938. */
  87939. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87940. minimum: Vector3;
  87941. maximum: Vector3;
  87942. };
  87943. /**
  87944. * Extracts minimum and maximum values from a list of positions
  87945. * @param positions defines the positions to use
  87946. * @param start defines the start index in the positions array
  87947. * @param count defines the number of positions to handle
  87948. * @param bias defines bias value to add to the result
  87949. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87950. * @return minimum and maximum values
  87951. */
  87952. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87953. minimum: Vector3;
  87954. maximum: Vector3;
  87955. };
  87956. }
  87957. declare module BABYLON {
  87958. /** @hidden */
  87959. export class WebGLDataBuffer extends DataBuffer {
  87960. private _buffer;
  87961. constructor(resource: WebGLBuffer);
  87962. get underlyingResource(): any;
  87963. }
  87964. }
  87965. declare module BABYLON {
  87966. /** @hidden */
  87967. export class WebGLPipelineContext implements IPipelineContext {
  87968. engine: ThinEngine;
  87969. program: Nullable<WebGLProgram>;
  87970. context?: WebGLRenderingContext;
  87971. vertexShader?: WebGLShader;
  87972. fragmentShader?: WebGLShader;
  87973. isParallelCompiled: boolean;
  87974. onCompiled?: () => void;
  87975. transformFeedback?: WebGLTransformFeedback | null;
  87976. vertexCompilationError: Nullable<string>;
  87977. fragmentCompilationError: Nullable<string>;
  87978. programLinkError: Nullable<string>;
  87979. programValidationError: Nullable<string>;
  87980. get isAsync(): boolean;
  87981. get isReady(): boolean;
  87982. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  87983. _getVertexShaderCode(): string | null;
  87984. _getFragmentShaderCode(): string | null;
  87985. }
  87986. }
  87987. declare module BABYLON {
  87988. interface ThinEngine {
  87989. /**
  87990. * Create an uniform buffer
  87991. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87992. * @param elements defines the content of the uniform buffer
  87993. * @returns the webGL uniform buffer
  87994. */
  87995. createUniformBuffer(elements: FloatArray): DataBuffer;
  87996. /**
  87997. * Create a dynamic uniform buffer
  87998. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87999. * @param elements defines the content of the uniform buffer
  88000. * @returns the webGL uniform buffer
  88001. */
  88002. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88003. /**
  88004. * Update an existing uniform buffer
  88005. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88006. * @param uniformBuffer defines the target uniform buffer
  88007. * @param elements defines the content to update
  88008. * @param offset defines the offset in the uniform buffer where update should start
  88009. * @param count defines the size of the data to update
  88010. */
  88011. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88012. /**
  88013. * Bind an uniform buffer to the current webGL context
  88014. * @param buffer defines the buffer to bind
  88015. */
  88016. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88017. /**
  88018. * Bind a buffer to the current webGL context at a given location
  88019. * @param buffer defines the buffer to bind
  88020. * @param location defines the index where to bind the buffer
  88021. */
  88022. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88023. /**
  88024. * Bind a specific block at a given index in a specific shader program
  88025. * @param pipelineContext defines the pipeline context to use
  88026. * @param blockName defines the block name
  88027. * @param index defines the index where to bind the block
  88028. */
  88029. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88030. }
  88031. }
  88032. declare module BABYLON {
  88033. /**
  88034. * Uniform buffer objects.
  88035. *
  88036. * Handles blocks of uniform on the GPU.
  88037. *
  88038. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88039. *
  88040. * For more information, please refer to :
  88041. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88042. */
  88043. export class UniformBuffer {
  88044. private _engine;
  88045. private _buffer;
  88046. private _data;
  88047. private _bufferData;
  88048. private _dynamic?;
  88049. private _uniformLocations;
  88050. private _uniformSizes;
  88051. private _uniformLocationPointer;
  88052. private _needSync;
  88053. private _noUBO;
  88054. private _currentEffect;
  88055. /** @hidden */
  88056. _alreadyBound: boolean;
  88057. private static _MAX_UNIFORM_SIZE;
  88058. private static _tempBuffer;
  88059. /**
  88060. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88061. * This is dynamic to allow compat with webgl 1 and 2.
  88062. * You will need to pass the name of the uniform as well as the value.
  88063. */
  88064. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88065. /**
  88066. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88067. * This is dynamic to allow compat with webgl 1 and 2.
  88068. * You will need to pass the name of the uniform as well as the value.
  88069. */
  88070. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88071. /**
  88072. * Lambda to Update a single float in a uniform buffer.
  88073. * This is dynamic to allow compat with webgl 1 and 2.
  88074. * You will need to pass the name of the uniform as well as the value.
  88075. */
  88076. updateFloat: (name: string, x: number) => void;
  88077. /**
  88078. * Lambda to Update a vec2 of float in a uniform buffer.
  88079. * This is dynamic to allow compat with webgl 1 and 2.
  88080. * You will need to pass the name of the uniform as well as the value.
  88081. */
  88082. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88083. /**
  88084. * Lambda to Update a vec3 of float in a uniform buffer.
  88085. * This is dynamic to allow compat with webgl 1 and 2.
  88086. * You will need to pass the name of the uniform as well as the value.
  88087. */
  88088. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88089. /**
  88090. * Lambda to Update a vec4 of float in a uniform buffer.
  88091. * This is dynamic to allow compat with webgl 1 and 2.
  88092. * You will need to pass the name of the uniform as well as the value.
  88093. */
  88094. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88095. /**
  88096. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88097. * This is dynamic to allow compat with webgl 1 and 2.
  88098. * You will need to pass the name of the uniform as well as the value.
  88099. */
  88100. updateMatrix: (name: string, mat: Matrix) => void;
  88101. /**
  88102. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88103. * This is dynamic to allow compat with webgl 1 and 2.
  88104. * You will need to pass the name of the uniform as well as the value.
  88105. */
  88106. updateVector3: (name: string, vector: Vector3) => void;
  88107. /**
  88108. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88109. * This is dynamic to allow compat with webgl 1 and 2.
  88110. * You will need to pass the name of the uniform as well as the value.
  88111. */
  88112. updateVector4: (name: string, vector: Vector4) => void;
  88113. /**
  88114. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88115. * This is dynamic to allow compat with webgl 1 and 2.
  88116. * You will need to pass the name of the uniform as well as the value.
  88117. */
  88118. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88119. /**
  88120. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88121. * This is dynamic to allow compat with webgl 1 and 2.
  88122. * You will need to pass the name of the uniform as well as the value.
  88123. */
  88124. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88125. /**
  88126. * Instantiates a new Uniform buffer objects.
  88127. *
  88128. * Handles blocks of uniform on the GPU.
  88129. *
  88130. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88131. *
  88132. * For more information, please refer to :
  88133. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88134. * @param engine Define the engine the buffer is associated with
  88135. * @param data Define the data contained in the buffer
  88136. * @param dynamic Define if the buffer is updatable
  88137. */
  88138. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88139. /**
  88140. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88141. * or just falling back on setUniformXXX calls.
  88142. */
  88143. get useUbo(): boolean;
  88144. /**
  88145. * Indicates if the WebGL underlying uniform buffer is in sync
  88146. * with the javascript cache data.
  88147. */
  88148. get isSync(): boolean;
  88149. /**
  88150. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88151. * Also, a dynamic UniformBuffer will disable cache verification and always
  88152. * update the underlying WebGL uniform buffer to the GPU.
  88153. * @returns if Dynamic, otherwise false
  88154. */
  88155. isDynamic(): boolean;
  88156. /**
  88157. * The data cache on JS side.
  88158. * @returns the underlying data as a float array
  88159. */
  88160. getData(): Float32Array;
  88161. /**
  88162. * The underlying WebGL Uniform buffer.
  88163. * @returns the webgl buffer
  88164. */
  88165. getBuffer(): Nullable<DataBuffer>;
  88166. /**
  88167. * std140 layout specifies how to align data within an UBO structure.
  88168. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88169. * for specs.
  88170. */
  88171. private _fillAlignment;
  88172. /**
  88173. * Adds an uniform in the buffer.
  88174. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88175. * for the layout to be correct !
  88176. * @param name Name of the uniform, as used in the uniform block in the shader.
  88177. * @param size Data size, or data directly.
  88178. */
  88179. addUniform(name: string, size: number | number[]): void;
  88180. /**
  88181. * Adds a Matrix 4x4 to the uniform buffer.
  88182. * @param name Name of the uniform, as used in the uniform block in the shader.
  88183. * @param mat A 4x4 matrix.
  88184. */
  88185. addMatrix(name: string, mat: Matrix): void;
  88186. /**
  88187. * Adds a vec2 to the uniform buffer.
  88188. * @param name Name of the uniform, as used in the uniform block in the shader.
  88189. * @param x Define the x component value of the vec2
  88190. * @param y Define the y component value of the vec2
  88191. */
  88192. addFloat2(name: string, x: number, y: number): void;
  88193. /**
  88194. * Adds a vec3 to the uniform buffer.
  88195. * @param name Name of the uniform, as used in the uniform block in the shader.
  88196. * @param x Define the x component value of the vec3
  88197. * @param y Define the y component value of the vec3
  88198. * @param z Define the z component value of the vec3
  88199. */
  88200. addFloat3(name: string, x: number, y: number, z: number): void;
  88201. /**
  88202. * Adds a vec3 to the uniform buffer.
  88203. * @param name Name of the uniform, as used in the uniform block in the shader.
  88204. * @param color Define the vec3 from a Color
  88205. */
  88206. addColor3(name: string, color: Color3): void;
  88207. /**
  88208. * Adds a vec4 to the uniform buffer.
  88209. * @param name Name of the uniform, as used in the uniform block in the shader.
  88210. * @param color Define the rgb components from a Color
  88211. * @param alpha Define the a component of the vec4
  88212. */
  88213. addColor4(name: string, color: Color3, alpha: number): void;
  88214. /**
  88215. * Adds a vec3 to the uniform buffer.
  88216. * @param name Name of the uniform, as used in the uniform block in the shader.
  88217. * @param vector Define the vec3 components from a Vector
  88218. */
  88219. addVector3(name: string, vector: Vector3): void;
  88220. /**
  88221. * Adds a Matrix 3x3 to the uniform buffer.
  88222. * @param name Name of the uniform, as used in the uniform block in the shader.
  88223. */
  88224. addMatrix3x3(name: string): void;
  88225. /**
  88226. * Adds a Matrix 2x2 to the uniform buffer.
  88227. * @param name Name of the uniform, as used in the uniform block in the shader.
  88228. */
  88229. addMatrix2x2(name: string): void;
  88230. /**
  88231. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88232. */
  88233. create(): void;
  88234. /** @hidden */
  88235. _rebuild(): void;
  88236. /**
  88237. * Updates the WebGL Uniform Buffer on the GPU.
  88238. * If the `dynamic` flag is set to true, no cache comparison is done.
  88239. * Otherwise, the buffer will be updated only if the cache differs.
  88240. */
  88241. update(): void;
  88242. /**
  88243. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88244. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88245. * @param data Define the flattened data
  88246. * @param size Define the size of the data.
  88247. */
  88248. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88249. private _valueCache;
  88250. private _cacheMatrix;
  88251. private _updateMatrix3x3ForUniform;
  88252. private _updateMatrix3x3ForEffect;
  88253. private _updateMatrix2x2ForEffect;
  88254. private _updateMatrix2x2ForUniform;
  88255. private _updateFloatForEffect;
  88256. private _updateFloatForUniform;
  88257. private _updateFloat2ForEffect;
  88258. private _updateFloat2ForUniform;
  88259. private _updateFloat3ForEffect;
  88260. private _updateFloat3ForUniform;
  88261. private _updateFloat4ForEffect;
  88262. private _updateFloat4ForUniform;
  88263. private _updateMatrixForEffect;
  88264. private _updateMatrixForUniform;
  88265. private _updateVector3ForEffect;
  88266. private _updateVector3ForUniform;
  88267. private _updateVector4ForEffect;
  88268. private _updateVector4ForUniform;
  88269. private _updateColor3ForEffect;
  88270. private _updateColor3ForUniform;
  88271. private _updateColor4ForEffect;
  88272. private _updateColor4ForUniform;
  88273. /**
  88274. * Sets a sampler uniform on the effect.
  88275. * @param name Define the name of the sampler.
  88276. * @param texture Define the texture to set in the sampler
  88277. */
  88278. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88279. /**
  88280. * Directly updates the value of the uniform in the cache AND on the GPU.
  88281. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88282. * @param data Define the flattened data
  88283. */
  88284. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88285. /**
  88286. * Binds this uniform buffer to an effect.
  88287. * @param effect Define the effect to bind the buffer to
  88288. * @param name Name of the uniform block in the shader.
  88289. */
  88290. bindToEffect(effect: Effect, name: string): void;
  88291. /**
  88292. * Disposes the uniform buffer.
  88293. */
  88294. dispose(): void;
  88295. }
  88296. }
  88297. declare module BABYLON {
  88298. /**
  88299. * Enum that determines the text-wrapping mode to use.
  88300. */
  88301. export enum InspectableType {
  88302. /**
  88303. * Checkbox for booleans
  88304. */
  88305. Checkbox = 0,
  88306. /**
  88307. * Sliders for numbers
  88308. */
  88309. Slider = 1,
  88310. /**
  88311. * Vector3
  88312. */
  88313. Vector3 = 2,
  88314. /**
  88315. * Quaternions
  88316. */
  88317. Quaternion = 3,
  88318. /**
  88319. * Color3
  88320. */
  88321. Color3 = 4,
  88322. /**
  88323. * String
  88324. */
  88325. String = 5
  88326. }
  88327. /**
  88328. * Interface used to define custom inspectable properties.
  88329. * This interface is used by the inspector to display custom property grids
  88330. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88331. */
  88332. export interface IInspectable {
  88333. /**
  88334. * Gets the label to display
  88335. */
  88336. label: string;
  88337. /**
  88338. * Gets the name of the property to edit
  88339. */
  88340. propertyName: string;
  88341. /**
  88342. * Gets the type of the editor to use
  88343. */
  88344. type: InspectableType;
  88345. /**
  88346. * Gets the minimum value of the property when using in "slider" mode
  88347. */
  88348. min?: number;
  88349. /**
  88350. * Gets the maximum value of the property when using in "slider" mode
  88351. */
  88352. max?: number;
  88353. /**
  88354. * Gets the setp to use when using in "slider" mode
  88355. */
  88356. step?: number;
  88357. }
  88358. }
  88359. declare module BABYLON {
  88360. /**
  88361. * Class used to provide helper for timing
  88362. */
  88363. export class TimingTools {
  88364. /**
  88365. * Polyfill for setImmediate
  88366. * @param action defines the action to execute after the current execution block
  88367. */
  88368. static SetImmediate(action: () => void): void;
  88369. }
  88370. }
  88371. declare module BABYLON {
  88372. /**
  88373. * Class used to enable instatition of objects by class name
  88374. */
  88375. export class InstantiationTools {
  88376. /**
  88377. * Use this object to register external classes like custom textures or material
  88378. * to allow the laoders to instantiate them
  88379. */
  88380. static RegisteredExternalClasses: {
  88381. [key: string]: Object;
  88382. };
  88383. /**
  88384. * Tries to instantiate a new object from a given class name
  88385. * @param className defines the class name to instantiate
  88386. * @returns the new object or null if the system was not able to do the instantiation
  88387. */
  88388. static Instantiate(className: string): any;
  88389. }
  88390. }
  88391. declare module BABYLON {
  88392. /**
  88393. * Define options used to create a depth texture
  88394. */
  88395. export class DepthTextureCreationOptions {
  88396. /** Specifies whether or not a stencil should be allocated in the texture */
  88397. generateStencil?: boolean;
  88398. /** Specifies whether or not bilinear filtering is enable on the texture */
  88399. bilinearFiltering?: boolean;
  88400. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88401. comparisonFunction?: number;
  88402. /** Specifies if the created texture is a cube texture */
  88403. isCube?: boolean;
  88404. }
  88405. }
  88406. declare module BABYLON {
  88407. interface ThinEngine {
  88408. /**
  88409. * Creates a depth stencil cube texture.
  88410. * This is only available in WebGL 2.
  88411. * @param size The size of face edge in the cube texture.
  88412. * @param options The options defining the cube texture.
  88413. * @returns The cube texture
  88414. */
  88415. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88416. /**
  88417. * Creates a cube texture
  88418. * @param rootUrl defines the url where the files to load is located
  88419. * @param scene defines the current scene
  88420. * @param files defines the list of files to load (1 per face)
  88421. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88422. * @param onLoad defines an optional callback raised when the texture is loaded
  88423. * @param onError defines an optional callback raised if there is an issue to load the texture
  88424. * @param format defines the format of the data
  88425. * @param forcedExtension defines the extension to use to pick the right loader
  88426. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88427. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88428. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88429. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88430. * @returns the cube texture as an InternalTexture
  88431. */
  88432. 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;
  88433. /**
  88434. * Creates a cube texture
  88435. * @param rootUrl defines the url where the files to load is located
  88436. * @param scene defines the current scene
  88437. * @param files defines the list of files to load (1 per face)
  88438. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88439. * @param onLoad defines an optional callback raised when the texture is loaded
  88440. * @param onError defines an optional callback raised if there is an issue to load the texture
  88441. * @param format defines the format of the data
  88442. * @param forcedExtension defines the extension to use to pick the right loader
  88443. * @returns the cube texture as an InternalTexture
  88444. */
  88445. 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;
  88446. /**
  88447. * Creates a cube texture
  88448. * @param rootUrl defines the url where the files to load is located
  88449. * @param scene defines the current scene
  88450. * @param files defines the list of files to load (1 per face)
  88451. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88452. * @param onLoad defines an optional callback raised when the texture is loaded
  88453. * @param onError defines an optional callback raised if there is an issue to load the texture
  88454. * @param format defines the format of the data
  88455. * @param forcedExtension defines the extension to use to pick the right loader
  88456. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88457. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88458. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88459. * @returns the cube texture as an InternalTexture
  88460. */
  88461. 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;
  88462. /** @hidden */
  88463. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88464. /** @hidden */
  88465. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88466. /** @hidden */
  88467. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88468. /** @hidden */
  88469. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88470. /**
  88471. * @hidden
  88472. */
  88473. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88474. }
  88475. }
  88476. declare module BABYLON {
  88477. /**
  88478. * Class for creating a cube texture
  88479. */
  88480. export class CubeTexture extends BaseTexture {
  88481. private _delayedOnLoad;
  88482. /**
  88483. * Observable triggered once the texture has been loaded.
  88484. */
  88485. onLoadObservable: Observable<CubeTexture>;
  88486. /**
  88487. * The url of the texture
  88488. */
  88489. url: string;
  88490. /**
  88491. * Gets or sets the center of the bounding box associated with the cube texture.
  88492. * It must define where the camera used to render the texture was set
  88493. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88494. */
  88495. boundingBoxPosition: Vector3;
  88496. private _boundingBoxSize;
  88497. /**
  88498. * Gets or sets the size of the bounding box associated with the cube texture
  88499. * When defined, the cubemap will switch to local mode
  88500. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88501. * @example https://www.babylonjs-playground.com/#RNASML
  88502. */
  88503. set boundingBoxSize(value: Vector3);
  88504. /**
  88505. * Returns the bounding box size
  88506. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88507. */
  88508. get boundingBoxSize(): Vector3;
  88509. protected _rotationY: number;
  88510. /**
  88511. * Sets texture matrix rotation angle around Y axis in radians.
  88512. */
  88513. set rotationY(value: number);
  88514. /**
  88515. * Gets texture matrix rotation angle around Y axis radians.
  88516. */
  88517. get rotationY(): number;
  88518. /**
  88519. * Are mip maps generated for this texture or not.
  88520. */
  88521. get noMipmap(): boolean;
  88522. private _noMipmap;
  88523. private _files;
  88524. protected _forcedExtension: Nullable<string>;
  88525. private _extensions;
  88526. private _textureMatrix;
  88527. private _format;
  88528. private _createPolynomials;
  88529. /**
  88530. * Creates a cube texture from an array of image urls
  88531. * @param files defines an array of image urls
  88532. * @param scene defines the hosting scene
  88533. * @param noMipmap specifies if mip maps are not used
  88534. * @returns a cube texture
  88535. */
  88536. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88537. /**
  88538. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88539. * @param url defines the url of the prefiltered texture
  88540. * @param scene defines the scene the texture is attached to
  88541. * @param forcedExtension defines the extension of the file if different from the url
  88542. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88543. * @return the prefiltered texture
  88544. */
  88545. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88546. /**
  88547. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88548. * as prefiltered data.
  88549. * @param rootUrl defines the url of the texture or the root name of the six images
  88550. * @param null defines the scene or engine the texture is attached to
  88551. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88552. * @param noMipmap defines if mipmaps should be created or not
  88553. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88554. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88555. * @param onError defines a callback triggered in case of error during load
  88556. * @param format defines the internal format to use for the texture once loaded
  88557. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88558. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88559. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88560. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88561. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88562. * @return the cube texture
  88563. */
  88564. 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);
  88565. /**
  88566. * Get the current class name of the texture useful for serialization or dynamic coding.
  88567. * @returns "CubeTexture"
  88568. */
  88569. getClassName(): string;
  88570. /**
  88571. * Update the url (and optional buffer) of this texture if url was null during construction.
  88572. * @param url the url of the texture
  88573. * @param forcedExtension defines the extension to use
  88574. * @param onLoad callback called when the texture is loaded (defaults to null)
  88575. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88576. */
  88577. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88578. /**
  88579. * Delays loading of the cube texture
  88580. * @param forcedExtension defines the extension to use
  88581. */
  88582. delayLoad(forcedExtension?: string): void;
  88583. /**
  88584. * Returns the reflection texture matrix
  88585. * @returns the reflection texture matrix
  88586. */
  88587. getReflectionTextureMatrix(): Matrix;
  88588. /**
  88589. * Sets the reflection texture matrix
  88590. * @param value Reflection texture matrix
  88591. */
  88592. setReflectionTextureMatrix(value: Matrix): void;
  88593. /**
  88594. * Parses text to create a cube texture
  88595. * @param parsedTexture define the serialized text to read from
  88596. * @param scene defines the hosting scene
  88597. * @param rootUrl defines the root url of the cube texture
  88598. * @returns a cube texture
  88599. */
  88600. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88601. /**
  88602. * Makes a clone, or deep copy, of the cube texture
  88603. * @returns a new cube texture
  88604. */
  88605. clone(): CubeTexture;
  88606. }
  88607. }
  88608. declare module BABYLON {
  88609. /**
  88610. * Manages the defines for the Material
  88611. */
  88612. export class MaterialDefines {
  88613. /** @hidden */
  88614. protected _keys: string[];
  88615. private _isDirty;
  88616. /** @hidden */
  88617. _renderId: number;
  88618. /** @hidden */
  88619. _areLightsDirty: boolean;
  88620. /** @hidden */
  88621. _areLightsDisposed: boolean;
  88622. /** @hidden */
  88623. _areAttributesDirty: boolean;
  88624. /** @hidden */
  88625. _areTexturesDirty: boolean;
  88626. /** @hidden */
  88627. _areFresnelDirty: boolean;
  88628. /** @hidden */
  88629. _areMiscDirty: boolean;
  88630. /** @hidden */
  88631. _arePrePassDirty: boolean;
  88632. /** @hidden */
  88633. _areImageProcessingDirty: boolean;
  88634. /** @hidden */
  88635. _normals: boolean;
  88636. /** @hidden */
  88637. _uvs: boolean;
  88638. /** @hidden */
  88639. _needNormals: boolean;
  88640. /** @hidden */
  88641. _needUVs: boolean;
  88642. [id: string]: any;
  88643. /**
  88644. * Specifies if the material needs to be re-calculated
  88645. */
  88646. get isDirty(): boolean;
  88647. /**
  88648. * Marks the material to indicate that it has been re-calculated
  88649. */
  88650. markAsProcessed(): void;
  88651. /**
  88652. * Marks the material to indicate that it needs to be re-calculated
  88653. */
  88654. markAsUnprocessed(): void;
  88655. /**
  88656. * Marks the material to indicate all of its defines need to be re-calculated
  88657. */
  88658. markAllAsDirty(): void;
  88659. /**
  88660. * Marks the material to indicate that image processing needs to be re-calculated
  88661. */
  88662. markAsImageProcessingDirty(): void;
  88663. /**
  88664. * Marks the material to indicate the lights need to be re-calculated
  88665. * @param disposed Defines whether the light is dirty due to dispose or not
  88666. */
  88667. markAsLightDirty(disposed?: boolean): void;
  88668. /**
  88669. * Marks the attribute state as changed
  88670. */
  88671. markAsAttributesDirty(): void;
  88672. /**
  88673. * Marks the texture state as changed
  88674. */
  88675. markAsTexturesDirty(): void;
  88676. /**
  88677. * Marks the fresnel state as changed
  88678. */
  88679. markAsFresnelDirty(): void;
  88680. /**
  88681. * Marks the misc state as changed
  88682. */
  88683. markAsMiscDirty(): void;
  88684. /**
  88685. * Marks the prepass state as changed
  88686. */
  88687. markAsPrePassDirty(): void;
  88688. /**
  88689. * Rebuilds the material defines
  88690. */
  88691. rebuild(): void;
  88692. /**
  88693. * Specifies if two material defines are equal
  88694. * @param other - A material define instance to compare to
  88695. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88696. */
  88697. isEqual(other: MaterialDefines): boolean;
  88698. /**
  88699. * Clones this instance's defines to another instance
  88700. * @param other - material defines to clone values to
  88701. */
  88702. cloneTo(other: MaterialDefines): void;
  88703. /**
  88704. * Resets the material define values
  88705. */
  88706. reset(): void;
  88707. /**
  88708. * Converts the material define values to a string
  88709. * @returns - String of material define information
  88710. */
  88711. toString(): string;
  88712. }
  88713. }
  88714. declare module BABYLON {
  88715. /**
  88716. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88717. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88718. * 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;
  88719. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88720. */
  88721. export class ColorCurves {
  88722. private _dirty;
  88723. private _tempColor;
  88724. private _globalCurve;
  88725. private _highlightsCurve;
  88726. private _midtonesCurve;
  88727. private _shadowsCurve;
  88728. private _positiveCurve;
  88729. private _negativeCurve;
  88730. private _globalHue;
  88731. private _globalDensity;
  88732. private _globalSaturation;
  88733. private _globalExposure;
  88734. /**
  88735. * Gets 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. get globalHue(): number;
  88739. /**
  88740. * Sets the global Hue value.
  88741. * 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).
  88742. */
  88743. set globalHue(value: number);
  88744. /**
  88745. * Gets the global Density value.
  88746. * 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.
  88747. * Values less than zero provide a filter of opposite hue.
  88748. */
  88749. get globalDensity(): number;
  88750. /**
  88751. * Sets the global Density value.
  88752. * 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.
  88753. * Values less than zero provide a filter of opposite hue.
  88754. */
  88755. set globalDensity(value: number);
  88756. /**
  88757. * Gets 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. get globalSaturation(): number;
  88761. /**
  88762. * Sets the global Saturation 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 saturation and negative values decrease saturation.
  88764. */
  88765. set globalSaturation(value: number);
  88766. /**
  88767. * Gets 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. get globalExposure(): number;
  88771. /**
  88772. * Sets the global Exposure value.
  88773. * 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.
  88774. */
  88775. set globalExposure(value: number);
  88776. private _highlightsHue;
  88777. private _highlightsDensity;
  88778. private _highlightsSaturation;
  88779. private _highlightsExposure;
  88780. /**
  88781. * Gets 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. get highlightsHue(): number;
  88785. /**
  88786. * Sets the highlights Hue value.
  88787. * 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).
  88788. */
  88789. set highlightsHue(value: number);
  88790. /**
  88791. * Gets the highlights Density value.
  88792. * 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.
  88793. * Values less than zero provide a filter of opposite hue.
  88794. */
  88795. get highlightsDensity(): number;
  88796. /**
  88797. * Sets the highlights Density value.
  88798. * 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.
  88799. * Values less than zero provide a filter of opposite hue.
  88800. */
  88801. set highlightsDensity(value: number);
  88802. /**
  88803. * Gets 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. get highlightsSaturation(): number;
  88807. /**
  88808. * Sets the highlights Saturation 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 saturation and negative values decrease saturation.
  88810. */
  88811. set highlightsSaturation(value: number);
  88812. /**
  88813. * Gets 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. get highlightsExposure(): number;
  88817. /**
  88818. * Sets the highlights Exposure value.
  88819. * 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.
  88820. */
  88821. set highlightsExposure(value: number);
  88822. private _midtonesHue;
  88823. private _midtonesDensity;
  88824. private _midtonesSaturation;
  88825. private _midtonesExposure;
  88826. /**
  88827. * Gets 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. get midtonesHue(): number;
  88831. /**
  88832. * Sets the midtones Hue value.
  88833. * 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).
  88834. */
  88835. set midtonesHue(value: number);
  88836. /**
  88837. * Gets the midtones Density value.
  88838. * 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.
  88839. * Values less than zero provide a filter of opposite hue.
  88840. */
  88841. get midtonesDensity(): number;
  88842. /**
  88843. * Sets the midtones Density value.
  88844. * 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.
  88845. * Values less than zero provide a filter of opposite hue.
  88846. */
  88847. set midtonesDensity(value: number);
  88848. /**
  88849. * Gets 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. get midtonesSaturation(): number;
  88853. /**
  88854. * Sets the midtones Saturation 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 saturation and negative values decrease saturation.
  88856. */
  88857. set midtonesSaturation(value: number);
  88858. /**
  88859. * Gets 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. get midtonesExposure(): number;
  88863. /**
  88864. * Sets the midtones Exposure value.
  88865. * 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.
  88866. */
  88867. set midtonesExposure(value: number);
  88868. private _shadowsHue;
  88869. private _shadowsDensity;
  88870. private _shadowsSaturation;
  88871. private _shadowsExposure;
  88872. /**
  88873. * Gets 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. get shadowsHue(): number;
  88877. /**
  88878. * Sets the shadows Hue value.
  88879. * 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).
  88880. */
  88881. set shadowsHue(value: number);
  88882. /**
  88883. * Gets the shadows Density value.
  88884. * 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.
  88885. * Values less than zero provide a filter of opposite hue.
  88886. */
  88887. get shadowsDensity(): number;
  88888. /**
  88889. * Sets the shadows Density value.
  88890. * 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.
  88891. * Values less than zero provide a filter of opposite hue.
  88892. */
  88893. set shadowsDensity(value: number);
  88894. /**
  88895. * Gets 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. get shadowsSaturation(): number;
  88899. /**
  88900. * Sets the shadows Saturation 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 saturation and negative values decrease saturation.
  88902. */
  88903. set shadowsSaturation(value: number);
  88904. /**
  88905. * Gets 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. get shadowsExposure(): number;
  88909. /**
  88910. * Sets the shadows Exposure value.
  88911. * 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.
  88912. */
  88913. set shadowsExposure(value: number);
  88914. /**
  88915. * Returns the class name
  88916. * @returns The class name
  88917. */
  88918. getClassName(): string;
  88919. /**
  88920. * Binds the color curves to the shader.
  88921. * @param colorCurves The color curve to bind
  88922. * @param effect The effect to bind to
  88923. * @param positiveUniform The positive uniform shader parameter
  88924. * @param neutralUniform The neutral uniform shader parameter
  88925. * @param negativeUniform The negative uniform shader parameter
  88926. */
  88927. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88928. /**
  88929. * Prepare the list of uniforms associated with the ColorCurves effects.
  88930. * @param uniformsList The list of uniforms used in the effect
  88931. */
  88932. static PrepareUniforms(uniformsList: string[]): void;
  88933. /**
  88934. * Returns color grading data based on a hue, density, saturation and exposure value.
  88935. * @param filterHue The hue of the color filter.
  88936. * @param filterDensity The density of the color filter.
  88937. * @param saturation The saturation.
  88938. * @param exposure The exposure.
  88939. * @param result The result data container.
  88940. */
  88941. private getColorGradingDataToRef;
  88942. /**
  88943. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88944. * @param value The input slider value in range [-100,100].
  88945. * @returns Adjusted value.
  88946. */
  88947. private static applyColorGradingSliderNonlinear;
  88948. /**
  88949. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88950. * @param hue The hue (H) input.
  88951. * @param saturation The saturation (S) input.
  88952. * @param brightness The brightness (B) input.
  88953. * @result An RGBA color represented as Vector4.
  88954. */
  88955. private static fromHSBToRef;
  88956. /**
  88957. * Returns a value clamped between min and max
  88958. * @param value The value to clamp
  88959. * @param min The minimum of value
  88960. * @param max The maximum of value
  88961. * @returns The clamped value.
  88962. */
  88963. private static clamp;
  88964. /**
  88965. * Clones the current color curve instance.
  88966. * @return The cloned curves
  88967. */
  88968. clone(): ColorCurves;
  88969. /**
  88970. * Serializes the current color curve instance to a json representation.
  88971. * @return a JSON representation
  88972. */
  88973. serialize(): any;
  88974. /**
  88975. * Parses the color curve from a json representation.
  88976. * @param source the JSON source to parse
  88977. * @return The parsed curves
  88978. */
  88979. static Parse(source: any): ColorCurves;
  88980. }
  88981. }
  88982. declare module BABYLON {
  88983. /**
  88984. * Interface to follow in your material defines to integrate easily the
  88985. * Image proccessing functions.
  88986. * @hidden
  88987. */
  88988. export interface IImageProcessingConfigurationDefines {
  88989. IMAGEPROCESSING: boolean;
  88990. VIGNETTE: boolean;
  88991. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88992. VIGNETTEBLENDMODEOPAQUE: boolean;
  88993. TONEMAPPING: boolean;
  88994. TONEMAPPING_ACES: boolean;
  88995. CONTRAST: boolean;
  88996. EXPOSURE: boolean;
  88997. COLORCURVES: boolean;
  88998. COLORGRADING: boolean;
  88999. COLORGRADING3D: boolean;
  89000. SAMPLER3DGREENDEPTH: boolean;
  89001. SAMPLER3DBGRMAP: boolean;
  89002. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89003. }
  89004. /**
  89005. * @hidden
  89006. */
  89007. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89008. IMAGEPROCESSING: boolean;
  89009. VIGNETTE: boolean;
  89010. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89011. VIGNETTEBLENDMODEOPAQUE: boolean;
  89012. TONEMAPPING: boolean;
  89013. TONEMAPPING_ACES: boolean;
  89014. CONTRAST: boolean;
  89015. COLORCURVES: boolean;
  89016. COLORGRADING: boolean;
  89017. COLORGRADING3D: boolean;
  89018. SAMPLER3DGREENDEPTH: boolean;
  89019. SAMPLER3DBGRMAP: boolean;
  89020. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89021. EXPOSURE: boolean;
  89022. constructor();
  89023. }
  89024. /**
  89025. * This groups together the common properties used for image processing either in direct forward pass
  89026. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89027. * or not.
  89028. */
  89029. export class ImageProcessingConfiguration {
  89030. /**
  89031. * Default tone mapping applied in BabylonJS.
  89032. */
  89033. static readonly TONEMAPPING_STANDARD: number;
  89034. /**
  89035. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89036. * to other engines rendering to increase portability.
  89037. */
  89038. static readonly TONEMAPPING_ACES: number;
  89039. /**
  89040. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89041. */
  89042. colorCurves: Nullable<ColorCurves>;
  89043. private _colorCurvesEnabled;
  89044. /**
  89045. * Gets wether the color curves effect is enabled.
  89046. */
  89047. get colorCurvesEnabled(): boolean;
  89048. /**
  89049. * Sets wether the color curves effect is enabled.
  89050. */
  89051. set colorCurvesEnabled(value: boolean);
  89052. private _colorGradingTexture;
  89053. /**
  89054. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89055. */
  89056. get colorGradingTexture(): Nullable<BaseTexture>;
  89057. /**
  89058. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89059. */
  89060. set colorGradingTexture(value: Nullable<BaseTexture>);
  89061. private _colorGradingEnabled;
  89062. /**
  89063. * Gets wether the color grading effect is enabled.
  89064. */
  89065. get colorGradingEnabled(): boolean;
  89066. /**
  89067. * Sets wether the color grading effect is enabled.
  89068. */
  89069. set colorGradingEnabled(value: boolean);
  89070. private _colorGradingWithGreenDepth;
  89071. /**
  89072. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89073. */
  89074. get colorGradingWithGreenDepth(): boolean;
  89075. /**
  89076. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89077. */
  89078. set colorGradingWithGreenDepth(value: boolean);
  89079. private _colorGradingBGR;
  89080. /**
  89081. * Gets wether the color grading texture contains BGR values.
  89082. */
  89083. get colorGradingBGR(): boolean;
  89084. /**
  89085. * Sets wether the color grading texture contains BGR values.
  89086. */
  89087. set colorGradingBGR(value: boolean);
  89088. /** @hidden */
  89089. _exposure: number;
  89090. /**
  89091. * Gets the Exposure used in the effect.
  89092. */
  89093. get exposure(): number;
  89094. /**
  89095. * Sets the Exposure used in the effect.
  89096. */
  89097. set exposure(value: number);
  89098. private _toneMappingEnabled;
  89099. /**
  89100. * Gets wether the tone mapping effect is enabled.
  89101. */
  89102. get toneMappingEnabled(): boolean;
  89103. /**
  89104. * Sets wether the tone mapping effect is enabled.
  89105. */
  89106. set toneMappingEnabled(value: boolean);
  89107. private _toneMappingType;
  89108. /**
  89109. * Gets the type of tone mapping effect.
  89110. */
  89111. get toneMappingType(): number;
  89112. /**
  89113. * Sets the type of tone mapping effect used in BabylonJS.
  89114. */
  89115. set toneMappingType(value: number);
  89116. protected _contrast: number;
  89117. /**
  89118. * Gets the contrast used in the effect.
  89119. */
  89120. get contrast(): number;
  89121. /**
  89122. * Sets the contrast used in the effect.
  89123. */
  89124. set contrast(value: number);
  89125. /**
  89126. * Vignette stretch size.
  89127. */
  89128. vignetteStretch: number;
  89129. /**
  89130. * Vignette centre X Offset.
  89131. */
  89132. vignetteCentreX: number;
  89133. /**
  89134. * Vignette centre Y Offset.
  89135. */
  89136. vignetteCentreY: number;
  89137. /**
  89138. * Vignette weight or intensity of the vignette effect.
  89139. */
  89140. vignetteWeight: number;
  89141. /**
  89142. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89143. * if vignetteEnabled is set to true.
  89144. */
  89145. vignetteColor: Color4;
  89146. /**
  89147. * Camera field of view used by the Vignette effect.
  89148. */
  89149. vignetteCameraFov: number;
  89150. private _vignetteBlendMode;
  89151. /**
  89152. * Gets the vignette blend mode allowing different kind of effect.
  89153. */
  89154. get vignetteBlendMode(): number;
  89155. /**
  89156. * Sets the vignette blend mode allowing different kind of effect.
  89157. */
  89158. set vignetteBlendMode(value: number);
  89159. private _vignetteEnabled;
  89160. /**
  89161. * Gets wether the vignette effect is enabled.
  89162. */
  89163. get vignetteEnabled(): boolean;
  89164. /**
  89165. * Sets wether the vignette effect is enabled.
  89166. */
  89167. set vignetteEnabled(value: boolean);
  89168. private _applyByPostProcess;
  89169. /**
  89170. * Gets wether the image processing is applied through a post process or not.
  89171. */
  89172. get applyByPostProcess(): boolean;
  89173. /**
  89174. * Sets wether the image processing is applied through a post process or not.
  89175. */
  89176. set applyByPostProcess(value: boolean);
  89177. private _isEnabled;
  89178. /**
  89179. * Gets wether the image processing is enabled or not.
  89180. */
  89181. get isEnabled(): boolean;
  89182. /**
  89183. * Sets wether the image processing is enabled or not.
  89184. */
  89185. set isEnabled(value: boolean);
  89186. /**
  89187. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89188. */
  89189. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89190. /**
  89191. * Method called each time the image processing information changes requires to recompile the effect.
  89192. */
  89193. protected _updateParameters(): void;
  89194. /**
  89195. * Gets the current class name.
  89196. * @return "ImageProcessingConfiguration"
  89197. */
  89198. getClassName(): string;
  89199. /**
  89200. * Prepare the list of uniforms associated with the Image Processing effects.
  89201. * @param uniforms The list of uniforms used in the effect
  89202. * @param defines the list of defines currently in use
  89203. */
  89204. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89205. /**
  89206. * Prepare the list of samplers associated with the Image Processing effects.
  89207. * @param samplersList The list of uniforms used in the effect
  89208. * @param defines the list of defines currently in use
  89209. */
  89210. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89211. /**
  89212. * Prepare the list of defines associated to the shader.
  89213. * @param defines the list of defines to complete
  89214. * @param forPostProcess Define if we are currently in post process mode or not
  89215. */
  89216. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89217. /**
  89218. * Returns true if all the image processing information are ready.
  89219. * @returns True if ready, otherwise, false
  89220. */
  89221. isReady(): boolean;
  89222. /**
  89223. * Binds the image processing to the shader.
  89224. * @param effect The effect to bind to
  89225. * @param overrideAspectRatio Override the aspect ratio of the effect
  89226. */
  89227. bind(effect: Effect, overrideAspectRatio?: number): void;
  89228. /**
  89229. * Clones the current image processing instance.
  89230. * @return The cloned image processing
  89231. */
  89232. clone(): ImageProcessingConfiguration;
  89233. /**
  89234. * Serializes the current image processing instance to a json representation.
  89235. * @return a JSON representation
  89236. */
  89237. serialize(): any;
  89238. /**
  89239. * Parses the image processing from a json representation.
  89240. * @param source the JSON source to parse
  89241. * @return The parsed image processing
  89242. */
  89243. static Parse(source: any): ImageProcessingConfiguration;
  89244. private static _VIGNETTEMODE_MULTIPLY;
  89245. private static _VIGNETTEMODE_OPAQUE;
  89246. /**
  89247. * Used to apply the vignette as a mix with the pixel color.
  89248. */
  89249. static get VIGNETTEMODE_MULTIPLY(): number;
  89250. /**
  89251. * Used to apply the vignette as a replacement of the pixel color.
  89252. */
  89253. static get VIGNETTEMODE_OPAQUE(): number;
  89254. }
  89255. }
  89256. declare module BABYLON {
  89257. /** @hidden */
  89258. export var postprocessVertexShader: {
  89259. name: string;
  89260. shader: string;
  89261. };
  89262. }
  89263. declare module BABYLON {
  89264. /**
  89265. * Type used to define a render target texture size (either with a number or with a rect width and height)
  89266. */
  89267. export type RenderTargetTextureSize = number | {
  89268. width: number;
  89269. height: number;
  89270. layers?: number;
  89271. };
  89272. interface ThinEngine {
  89273. /**
  89274. * Creates a new render target texture
  89275. * @param size defines the size of the texture
  89276. * @param options defines the options used to create the texture
  89277. * @returns a new render target texture stored in an InternalTexture
  89278. */
  89279. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  89280. /**
  89281. * Creates a depth stencil texture.
  89282. * This is only available in WebGL 2 or with the depth texture extension available.
  89283. * @param size The size of face edge in the texture.
  89284. * @param options The options defining the texture.
  89285. * @returns The texture
  89286. */
  89287. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89288. /** @hidden */
  89289. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89290. }
  89291. }
  89292. declare module BABYLON {
  89293. /**
  89294. * Defines the kind of connection point for node based material
  89295. */
  89296. export enum NodeMaterialBlockConnectionPointTypes {
  89297. /** Float */
  89298. Float = 1,
  89299. /** Int */
  89300. Int = 2,
  89301. /** Vector2 */
  89302. Vector2 = 4,
  89303. /** Vector3 */
  89304. Vector3 = 8,
  89305. /** Vector4 */
  89306. Vector4 = 16,
  89307. /** Color3 */
  89308. Color3 = 32,
  89309. /** Color4 */
  89310. Color4 = 64,
  89311. /** Matrix */
  89312. Matrix = 128,
  89313. /** Custom object */
  89314. Object = 256,
  89315. /** Detect type based on connection */
  89316. AutoDetect = 1024,
  89317. /** Output type that will be defined by input type */
  89318. BasedOnInput = 2048
  89319. }
  89320. }
  89321. declare module BABYLON {
  89322. /**
  89323. * Enum used to define the target of a block
  89324. */
  89325. export enum NodeMaterialBlockTargets {
  89326. /** Vertex shader */
  89327. Vertex = 1,
  89328. /** Fragment shader */
  89329. Fragment = 2,
  89330. /** Neutral */
  89331. Neutral = 4,
  89332. /** Vertex and Fragment */
  89333. VertexAndFragment = 3
  89334. }
  89335. }
  89336. declare module BABYLON {
  89337. /**
  89338. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  89339. */
  89340. export enum NodeMaterialBlockConnectionPointMode {
  89341. /** Value is an uniform */
  89342. Uniform = 0,
  89343. /** Value is a mesh attribute */
  89344. Attribute = 1,
  89345. /** Value is a varying between vertex and fragment shaders */
  89346. Varying = 2,
  89347. /** Mode is undefined */
  89348. Undefined = 3
  89349. }
  89350. }
  89351. declare module BABYLON {
  89352. /**
  89353. * Enum used to define system values e.g. values automatically provided by the system
  89354. */
  89355. export enum NodeMaterialSystemValues {
  89356. /** World */
  89357. World = 1,
  89358. /** View */
  89359. View = 2,
  89360. /** Projection */
  89361. Projection = 3,
  89362. /** ViewProjection */
  89363. ViewProjection = 4,
  89364. /** WorldView */
  89365. WorldView = 5,
  89366. /** WorldViewProjection */
  89367. WorldViewProjection = 6,
  89368. /** CameraPosition */
  89369. CameraPosition = 7,
  89370. /** Fog Color */
  89371. FogColor = 8,
  89372. /** Delta time */
  89373. DeltaTime = 9
  89374. }
  89375. }
  89376. declare module BABYLON {
  89377. /** Defines supported spaces */
  89378. export enum Space {
  89379. /** Local (object) space */
  89380. LOCAL = 0,
  89381. /** World space */
  89382. WORLD = 1,
  89383. /** Bone space */
  89384. BONE = 2
  89385. }
  89386. /** Defines the 3 main axes */
  89387. export class Axis {
  89388. /** X axis */
  89389. static X: Vector3;
  89390. /** Y axis */
  89391. static Y: Vector3;
  89392. /** Z axis */
  89393. static Z: Vector3;
  89394. }
  89395. }
  89396. declare module BABYLON {
  89397. /**
  89398. * Represents a camera frustum
  89399. */
  89400. export class Frustum {
  89401. /**
  89402. * Gets the planes representing the frustum
  89403. * @param transform matrix to be applied to the returned planes
  89404. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89405. */
  89406. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89407. /**
  89408. * Gets the near frustum plane transformed by the transform matrix
  89409. * @param transform transformation matrix to be applied to the resulting frustum plane
  89410. * @param frustumPlane the resuling frustum plane
  89411. */
  89412. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89413. /**
  89414. * Gets the far frustum plane transformed by the transform matrix
  89415. * @param transform transformation matrix to be applied to the resulting frustum plane
  89416. * @param frustumPlane the resuling frustum plane
  89417. */
  89418. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89419. /**
  89420. * Gets the left frustum plane transformed by the transform matrix
  89421. * @param transform transformation matrix to be applied to the resulting frustum plane
  89422. * @param frustumPlane the resuling frustum plane
  89423. */
  89424. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89425. /**
  89426. * Gets the right frustum plane transformed by the transform matrix
  89427. * @param transform transformation matrix to be applied to the resulting frustum plane
  89428. * @param frustumPlane the resuling frustum plane
  89429. */
  89430. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89431. /**
  89432. * Gets the top frustum plane transformed by the transform matrix
  89433. * @param transform transformation matrix to be applied to the resulting frustum plane
  89434. * @param frustumPlane the resuling frustum plane
  89435. */
  89436. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89437. /**
  89438. * Gets the bottom frustum plane transformed by the transform matrix
  89439. * @param transform transformation matrix to be applied to the resulting frustum plane
  89440. * @param frustumPlane the resuling frustum plane
  89441. */
  89442. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89443. /**
  89444. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89445. * @param transform transformation matrix to be applied to the resulting frustum planes
  89446. * @param frustumPlanes the resuling frustum planes
  89447. */
  89448. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89449. }
  89450. }
  89451. declare module BABYLON {
  89452. /**
  89453. * Interface for the size containing width and height
  89454. */
  89455. export interface ISize {
  89456. /**
  89457. * Width
  89458. */
  89459. width: number;
  89460. /**
  89461. * Heighht
  89462. */
  89463. height: number;
  89464. }
  89465. /**
  89466. * Size containing widht and height
  89467. */
  89468. export class Size implements ISize {
  89469. /**
  89470. * Width
  89471. */
  89472. width: number;
  89473. /**
  89474. * Height
  89475. */
  89476. height: number;
  89477. /**
  89478. * Creates a Size object from the given width and height (floats).
  89479. * @param width width of the new size
  89480. * @param height height of the new size
  89481. */
  89482. constructor(width: number, height: number);
  89483. /**
  89484. * Returns a string with the Size width and height
  89485. * @returns a string with the Size width and height
  89486. */
  89487. toString(): string;
  89488. /**
  89489. * "Size"
  89490. * @returns the string "Size"
  89491. */
  89492. getClassName(): string;
  89493. /**
  89494. * Returns the Size hash code.
  89495. * @returns a hash code for a unique width and height
  89496. */
  89497. getHashCode(): number;
  89498. /**
  89499. * Updates the current size from the given one.
  89500. * @param src the given size
  89501. */
  89502. copyFrom(src: Size): void;
  89503. /**
  89504. * Updates in place the current Size from the given floats.
  89505. * @param width width of the new size
  89506. * @param height height of the new size
  89507. * @returns the updated Size.
  89508. */
  89509. copyFromFloats(width: number, height: number): Size;
  89510. /**
  89511. * Updates in place the current Size from the given floats.
  89512. * @param width width to set
  89513. * @param height height to set
  89514. * @returns the updated Size.
  89515. */
  89516. set(width: number, height: number): Size;
  89517. /**
  89518. * Multiplies the width and height by numbers
  89519. * @param w factor to multiple the width by
  89520. * @param h factor to multiple the height by
  89521. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89522. */
  89523. multiplyByFloats(w: number, h: number): Size;
  89524. /**
  89525. * Clones the size
  89526. * @returns a new Size copied from the given one.
  89527. */
  89528. clone(): Size;
  89529. /**
  89530. * True if the current Size and the given one width and height are strictly equal.
  89531. * @param other the other size to compare against
  89532. * @returns True if the current Size and the given one width and height are strictly equal.
  89533. */
  89534. equals(other: Size): boolean;
  89535. /**
  89536. * The surface of the Size : width * height (float).
  89537. */
  89538. get surface(): number;
  89539. /**
  89540. * Create a new size of zero
  89541. * @returns a new Size set to (0.0, 0.0)
  89542. */
  89543. static Zero(): Size;
  89544. /**
  89545. * Sums the width and height of two sizes
  89546. * @param otherSize size to add to this size
  89547. * @returns a new Size set as the addition result of the current Size and the given one.
  89548. */
  89549. add(otherSize: Size): Size;
  89550. /**
  89551. * Subtracts the width and height of two
  89552. * @param otherSize size to subtract to this size
  89553. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89554. */
  89555. subtract(otherSize: Size): Size;
  89556. /**
  89557. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89558. * @param start starting size to lerp between
  89559. * @param end end size to lerp between
  89560. * @param amount amount to lerp between the start and end values
  89561. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89562. */
  89563. static Lerp(start: Size, end: Size, amount: number): Size;
  89564. }
  89565. }
  89566. declare module BABYLON {
  89567. /**
  89568. * Contains position and normal vectors for a vertex
  89569. */
  89570. export class PositionNormalVertex {
  89571. /** the position of the vertex (defaut: 0,0,0) */
  89572. position: Vector3;
  89573. /** the normal of the vertex (defaut: 0,1,0) */
  89574. normal: Vector3;
  89575. /**
  89576. * Creates a PositionNormalVertex
  89577. * @param position the position of the vertex (defaut: 0,0,0)
  89578. * @param normal the normal of the vertex (defaut: 0,1,0)
  89579. */
  89580. constructor(
  89581. /** the position of the vertex (defaut: 0,0,0) */
  89582. position?: Vector3,
  89583. /** the normal of the vertex (defaut: 0,1,0) */
  89584. normal?: Vector3);
  89585. /**
  89586. * Clones the PositionNormalVertex
  89587. * @returns the cloned PositionNormalVertex
  89588. */
  89589. clone(): PositionNormalVertex;
  89590. }
  89591. /**
  89592. * Contains position, normal and uv vectors for a vertex
  89593. */
  89594. export class PositionNormalTextureVertex {
  89595. /** the position of the vertex (defaut: 0,0,0) */
  89596. position: Vector3;
  89597. /** the normal of the vertex (defaut: 0,1,0) */
  89598. normal: Vector3;
  89599. /** the uv of the vertex (default: 0,0) */
  89600. uv: Vector2;
  89601. /**
  89602. * Creates a PositionNormalTextureVertex
  89603. * @param position the position of the vertex (defaut: 0,0,0)
  89604. * @param normal the normal of the vertex (defaut: 0,1,0)
  89605. * @param uv the uv of the vertex (default: 0,0)
  89606. */
  89607. constructor(
  89608. /** the position of the vertex (defaut: 0,0,0) */
  89609. position?: Vector3,
  89610. /** the normal of the vertex (defaut: 0,1,0) */
  89611. normal?: Vector3,
  89612. /** the uv of the vertex (default: 0,0) */
  89613. uv?: Vector2);
  89614. /**
  89615. * Clones the PositionNormalTextureVertex
  89616. * @returns the cloned PositionNormalTextureVertex
  89617. */
  89618. clone(): PositionNormalTextureVertex;
  89619. }
  89620. }
  89621. declare module BABYLON {
  89622. /**
  89623. * Enum defining the type of animations supported by InputBlock
  89624. */
  89625. export enum AnimatedInputBlockTypes {
  89626. /** No animation */
  89627. None = 0,
  89628. /** Time based animation. Will only work for floats */
  89629. Time = 1
  89630. }
  89631. }
  89632. declare module BABYLON {
  89633. /**
  89634. * Interface describing all the common properties and methods a shadow light needs to implement.
  89635. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89636. * as well as binding the different shadow properties to the effects.
  89637. */
  89638. export interface IShadowLight extends Light {
  89639. /**
  89640. * The light id in the scene (used in scene.findLighById for instance)
  89641. */
  89642. id: string;
  89643. /**
  89644. * The position the shdow will be casted from.
  89645. */
  89646. position: Vector3;
  89647. /**
  89648. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89649. */
  89650. direction: Vector3;
  89651. /**
  89652. * The transformed position. Position of the light in world space taking parenting in account.
  89653. */
  89654. transformedPosition: Vector3;
  89655. /**
  89656. * The transformed direction. Direction of the light in world space taking parenting in account.
  89657. */
  89658. transformedDirection: Vector3;
  89659. /**
  89660. * The friendly name of the light in the scene.
  89661. */
  89662. name: string;
  89663. /**
  89664. * Defines the shadow projection clipping minimum z value.
  89665. */
  89666. shadowMinZ: number;
  89667. /**
  89668. * Defines the shadow projection clipping maximum z value.
  89669. */
  89670. shadowMaxZ: number;
  89671. /**
  89672. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89673. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89674. */
  89675. computeTransformedInformation(): boolean;
  89676. /**
  89677. * Gets the scene the light belongs to.
  89678. * @returns The scene
  89679. */
  89680. getScene(): Scene;
  89681. /**
  89682. * Callback defining a custom Projection Matrix Builder.
  89683. * This can be used to override the default projection matrix computation.
  89684. */
  89685. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89686. /**
  89687. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89688. * @param matrix The materix to updated with the projection information
  89689. * @param viewMatrix The transform matrix of the light
  89690. * @param renderList The list of mesh to render in the map
  89691. * @returns The current light
  89692. */
  89693. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89694. /**
  89695. * Gets the current depth scale used in ESM.
  89696. * @returns The scale
  89697. */
  89698. getDepthScale(): number;
  89699. /**
  89700. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89701. * @returns true if a cube texture needs to be use
  89702. */
  89703. needCube(): boolean;
  89704. /**
  89705. * Detects if the projection matrix requires to be recomputed this frame.
  89706. * @returns true if it requires to be recomputed otherwise, false.
  89707. */
  89708. needProjectionMatrixCompute(): boolean;
  89709. /**
  89710. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89711. */
  89712. forceProjectionMatrixCompute(): void;
  89713. /**
  89714. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89715. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89716. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89717. */
  89718. getShadowDirection(faceIndex?: number): Vector3;
  89719. /**
  89720. * Gets the minZ used for shadow according to both the scene and the light.
  89721. * @param activeCamera The camera we are returning the min for
  89722. * @returns the depth min z
  89723. */
  89724. getDepthMinZ(activeCamera: Camera): number;
  89725. /**
  89726. * Gets the maxZ used for shadow according to both the scene and the light.
  89727. * @param activeCamera The camera we are returning the max for
  89728. * @returns the depth max z
  89729. */
  89730. getDepthMaxZ(activeCamera: Camera): number;
  89731. }
  89732. /**
  89733. * Base implementation IShadowLight
  89734. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89735. */
  89736. export abstract class ShadowLight extends Light implements IShadowLight {
  89737. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89738. protected _position: Vector3;
  89739. protected _setPosition(value: Vector3): void;
  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. get position(): Vector3;
  89745. /**
  89746. * Sets the position the shadow will be casted from. Also use as the light position for both
  89747. * point and spot lights.
  89748. */
  89749. set position(value: Vector3);
  89750. protected _direction: Vector3;
  89751. protected _setDirection(value: Vector3): void;
  89752. /**
  89753. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89754. * Also use as the light direction on spot and directional lights.
  89755. */
  89756. get direction(): Vector3;
  89757. /**
  89758. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89759. * Also use as the light direction on spot and directional lights.
  89760. */
  89761. set direction(value: Vector3);
  89762. protected _shadowMinZ: number;
  89763. /**
  89764. * Gets the shadow projection clipping minimum z value.
  89765. */
  89766. get shadowMinZ(): number;
  89767. /**
  89768. * Sets the shadow projection clipping minimum z value.
  89769. */
  89770. set shadowMinZ(value: number);
  89771. protected _shadowMaxZ: number;
  89772. /**
  89773. * Sets the shadow projection clipping maximum z value.
  89774. */
  89775. get shadowMaxZ(): number;
  89776. /**
  89777. * Gets the shadow projection clipping maximum z value.
  89778. */
  89779. set shadowMaxZ(value: number);
  89780. /**
  89781. * Callback defining a custom Projection Matrix Builder.
  89782. * This can be used to override the default projection matrix computation.
  89783. */
  89784. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89785. /**
  89786. * The transformed position. Position of the light in world space taking parenting in account.
  89787. */
  89788. transformedPosition: Vector3;
  89789. /**
  89790. * The transformed direction. Direction of the light in world space taking parenting in account.
  89791. */
  89792. transformedDirection: Vector3;
  89793. private _needProjectionMatrixCompute;
  89794. /**
  89795. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89796. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89797. */
  89798. computeTransformedInformation(): boolean;
  89799. /**
  89800. * Return the depth scale used for the shadow map.
  89801. * @returns the depth scale.
  89802. */
  89803. getDepthScale(): number;
  89804. /**
  89805. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89806. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89807. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89808. */
  89809. getShadowDirection(faceIndex?: number): Vector3;
  89810. /**
  89811. * Returns the ShadowLight absolute position in the World.
  89812. * @returns the position vector in world space
  89813. */
  89814. getAbsolutePosition(): Vector3;
  89815. /**
  89816. * Sets the ShadowLight direction toward the passed target.
  89817. * @param target The point to target in local space
  89818. * @returns the updated ShadowLight direction
  89819. */
  89820. setDirectionToTarget(target: Vector3): Vector3;
  89821. /**
  89822. * Returns the light rotation in euler definition.
  89823. * @returns the x y z rotation in local space.
  89824. */
  89825. getRotation(): Vector3;
  89826. /**
  89827. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89828. * @returns true if a cube texture needs to be use
  89829. */
  89830. needCube(): boolean;
  89831. /**
  89832. * Detects if the projection matrix requires to be recomputed this frame.
  89833. * @returns true if it requires to be recomputed otherwise, false.
  89834. */
  89835. needProjectionMatrixCompute(): boolean;
  89836. /**
  89837. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89838. */
  89839. forceProjectionMatrixCompute(): void;
  89840. /** @hidden */
  89841. _initCache(): void;
  89842. /** @hidden */
  89843. _isSynchronized(): boolean;
  89844. /**
  89845. * Computes the world matrix of the node
  89846. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89847. * @returns the world matrix
  89848. */
  89849. computeWorldMatrix(force?: boolean): Matrix;
  89850. /**
  89851. * Gets the minZ used for shadow according to both the scene and the light.
  89852. * @param activeCamera The camera we are returning the min for
  89853. * @returns the depth min z
  89854. */
  89855. getDepthMinZ(activeCamera: Camera): number;
  89856. /**
  89857. * Gets the maxZ used for shadow according to both the scene and the light.
  89858. * @param activeCamera The camera we are returning the max for
  89859. * @returns the depth max z
  89860. */
  89861. getDepthMaxZ(activeCamera: Camera): number;
  89862. /**
  89863. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89864. * @param matrix The materix to updated with the projection information
  89865. * @param viewMatrix The transform matrix of the light
  89866. * @param renderList The list of mesh to render in the map
  89867. * @returns The current light
  89868. */
  89869. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89870. }
  89871. }
  89872. declare module BABYLON {
  89873. /** @hidden */
  89874. export var packingFunctions: {
  89875. name: string;
  89876. shader: string;
  89877. };
  89878. }
  89879. declare module BABYLON {
  89880. /** @hidden */
  89881. export var bayerDitherFunctions: {
  89882. name: string;
  89883. shader: string;
  89884. };
  89885. }
  89886. declare module BABYLON {
  89887. /** @hidden */
  89888. export var shadowMapFragmentDeclaration: {
  89889. name: string;
  89890. shader: string;
  89891. };
  89892. }
  89893. declare module BABYLON {
  89894. /** @hidden */
  89895. export var clipPlaneFragmentDeclaration: {
  89896. name: string;
  89897. shader: string;
  89898. };
  89899. }
  89900. declare module BABYLON {
  89901. /** @hidden */
  89902. export var clipPlaneFragment: {
  89903. name: string;
  89904. shader: string;
  89905. };
  89906. }
  89907. declare module BABYLON {
  89908. /** @hidden */
  89909. export var shadowMapFragment: {
  89910. name: string;
  89911. shader: string;
  89912. };
  89913. }
  89914. declare module BABYLON {
  89915. /** @hidden */
  89916. export var shadowMapPixelShader: {
  89917. name: string;
  89918. shader: string;
  89919. };
  89920. }
  89921. declare module BABYLON {
  89922. /** @hidden */
  89923. export var bonesDeclaration: {
  89924. name: string;
  89925. shader: string;
  89926. };
  89927. }
  89928. declare module BABYLON {
  89929. /** @hidden */
  89930. export var morphTargetsVertexGlobalDeclaration: {
  89931. name: string;
  89932. shader: string;
  89933. };
  89934. }
  89935. declare module BABYLON {
  89936. /** @hidden */
  89937. export var morphTargetsVertexDeclaration: {
  89938. name: string;
  89939. shader: string;
  89940. };
  89941. }
  89942. declare module BABYLON {
  89943. /** @hidden */
  89944. export var instancesDeclaration: {
  89945. name: string;
  89946. shader: string;
  89947. };
  89948. }
  89949. declare module BABYLON {
  89950. /** @hidden */
  89951. export var helperFunctions: {
  89952. name: string;
  89953. shader: string;
  89954. };
  89955. }
  89956. declare module BABYLON {
  89957. /** @hidden */
  89958. export var shadowMapVertexDeclaration: {
  89959. name: string;
  89960. shader: string;
  89961. };
  89962. }
  89963. declare module BABYLON {
  89964. /** @hidden */
  89965. export var clipPlaneVertexDeclaration: {
  89966. name: string;
  89967. shader: string;
  89968. };
  89969. }
  89970. declare module BABYLON {
  89971. /** @hidden */
  89972. export var morphTargetsVertex: {
  89973. name: string;
  89974. shader: string;
  89975. };
  89976. }
  89977. declare module BABYLON {
  89978. /** @hidden */
  89979. export var instancesVertex: {
  89980. name: string;
  89981. shader: string;
  89982. };
  89983. }
  89984. declare module BABYLON {
  89985. /** @hidden */
  89986. export var bonesVertex: {
  89987. name: string;
  89988. shader: string;
  89989. };
  89990. }
  89991. declare module BABYLON {
  89992. /** @hidden */
  89993. export var shadowMapVertexNormalBias: {
  89994. name: string;
  89995. shader: string;
  89996. };
  89997. }
  89998. declare module BABYLON {
  89999. /** @hidden */
  90000. export var shadowMapVertexMetric: {
  90001. name: string;
  90002. shader: string;
  90003. };
  90004. }
  90005. declare module BABYLON {
  90006. /** @hidden */
  90007. export var clipPlaneVertex: {
  90008. name: string;
  90009. shader: string;
  90010. };
  90011. }
  90012. declare module BABYLON {
  90013. /** @hidden */
  90014. export var shadowMapVertexShader: {
  90015. name: string;
  90016. shader: string;
  90017. };
  90018. }
  90019. declare module BABYLON {
  90020. /** @hidden */
  90021. export var depthBoxBlurPixelShader: {
  90022. name: string;
  90023. shader: string;
  90024. };
  90025. }
  90026. declare module BABYLON {
  90027. /** @hidden */
  90028. export var shadowMapFragmentSoftTransparentShadow: {
  90029. name: string;
  90030. shader: string;
  90031. };
  90032. }
  90033. declare module BABYLON {
  90034. /**
  90035. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  90036. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  90037. */
  90038. export class EffectFallbacks implements IEffectFallbacks {
  90039. private _defines;
  90040. private _currentRank;
  90041. private _maxRank;
  90042. private _mesh;
  90043. /**
  90044. * Removes the fallback from the bound mesh.
  90045. */
  90046. unBindMesh(): void;
  90047. /**
  90048. * Adds a fallback on the specified property.
  90049. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90050. * @param define The name of the define in the shader
  90051. */
  90052. addFallback(rank: number, define: string): void;
  90053. /**
  90054. * Sets the mesh to use CPU skinning when needing to fallback.
  90055. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90056. * @param mesh The mesh to use the fallbacks.
  90057. */
  90058. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  90059. /**
  90060. * Checks to see if more fallbacks are still availible.
  90061. */
  90062. get hasMoreFallbacks(): boolean;
  90063. /**
  90064. * Removes the defines that should be removed when falling back.
  90065. * @param currentDefines defines the current define statements for the shader.
  90066. * @param effect defines the current effect we try to compile
  90067. * @returns The resulting defines with defines of the current rank removed.
  90068. */
  90069. reduce(currentDefines: string, effect: Effect): string;
  90070. }
  90071. }
  90072. declare module BABYLON {
  90073. /**
  90074. * Interface used to define Action
  90075. */
  90076. export interface IAction {
  90077. /**
  90078. * Trigger for the action
  90079. */
  90080. trigger: number;
  90081. /** Options of the trigger */
  90082. triggerOptions: any;
  90083. /**
  90084. * Gets the trigger parameters
  90085. * @returns the trigger parameters
  90086. */
  90087. getTriggerParameter(): any;
  90088. /**
  90089. * Internal only - executes current action event
  90090. * @hidden
  90091. */
  90092. _executeCurrent(evt?: ActionEvent): void;
  90093. /**
  90094. * Serialize placeholder for child classes
  90095. * @param parent of child
  90096. * @returns the serialized object
  90097. */
  90098. serialize(parent: any): any;
  90099. /**
  90100. * Internal only
  90101. * @hidden
  90102. */
  90103. _prepare(): void;
  90104. /**
  90105. * Internal only - manager for action
  90106. * @hidden
  90107. */
  90108. _actionManager: Nullable<AbstractActionManager>;
  90109. /**
  90110. * Adds action to chain of actions, may be a DoNothingAction
  90111. * @param action defines the next action to execute
  90112. * @returns The action passed in
  90113. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90114. */
  90115. then(action: IAction): IAction;
  90116. }
  90117. /**
  90118. * The action to be carried out following a trigger
  90119. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90120. */
  90121. export class Action implements IAction {
  90122. /** the trigger, with or without parameters, for the action */
  90123. triggerOptions: any;
  90124. /**
  90125. * Trigger for the action
  90126. */
  90127. trigger: number;
  90128. /**
  90129. * Internal only - manager for action
  90130. * @hidden
  90131. */
  90132. _actionManager: ActionManager;
  90133. private _nextActiveAction;
  90134. private _child;
  90135. private _condition?;
  90136. private _triggerParameter;
  90137. /**
  90138. * An event triggered prior to action being executed.
  90139. */
  90140. onBeforeExecuteObservable: Observable<Action>;
  90141. /**
  90142. * Creates a new Action
  90143. * @param triggerOptions the trigger, with or without parameters, for the action
  90144. * @param condition an optional determinant of action
  90145. */
  90146. constructor(
  90147. /** the trigger, with or without parameters, for the action */
  90148. triggerOptions: any, condition?: Condition);
  90149. /**
  90150. * Internal only
  90151. * @hidden
  90152. */
  90153. _prepare(): void;
  90154. /**
  90155. * Gets the trigger parameters
  90156. * @returns the trigger parameters
  90157. */
  90158. getTriggerParameter(): any;
  90159. /**
  90160. * Internal only - executes current action event
  90161. * @hidden
  90162. */
  90163. _executeCurrent(evt?: ActionEvent): void;
  90164. /**
  90165. * Execute placeholder for child classes
  90166. * @param evt optional action event
  90167. */
  90168. execute(evt?: ActionEvent): void;
  90169. /**
  90170. * Skips to next active action
  90171. */
  90172. skipToNextActiveAction(): void;
  90173. /**
  90174. * Adds action to chain of actions, may be a DoNothingAction
  90175. * @param action defines the next action to execute
  90176. * @returns The action passed in
  90177. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90178. */
  90179. then(action: Action): Action;
  90180. /**
  90181. * Internal only
  90182. * @hidden
  90183. */
  90184. _getProperty(propertyPath: string): string;
  90185. /**
  90186. * Internal only
  90187. * @hidden
  90188. */
  90189. _getEffectiveTarget(target: any, propertyPath: string): any;
  90190. /**
  90191. * Serialize placeholder for child classes
  90192. * @param parent of child
  90193. * @returns the serialized object
  90194. */
  90195. serialize(parent: any): any;
  90196. /**
  90197. * Internal only called by serialize
  90198. * @hidden
  90199. */
  90200. protected _serialize(serializedAction: any, parent?: any): any;
  90201. /**
  90202. * Internal only
  90203. * @hidden
  90204. */
  90205. static _SerializeValueAsString: (value: any) => string;
  90206. /**
  90207. * Internal only
  90208. * @hidden
  90209. */
  90210. static _GetTargetProperty: (target: Scene | Node) => {
  90211. name: string;
  90212. targetType: string;
  90213. value: string;
  90214. };
  90215. }
  90216. }
  90217. declare module BABYLON {
  90218. /**
  90219. * A Condition applied to an Action
  90220. */
  90221. export class Condition {
  90222. /**
  90223. * Internal only - manager for action
  90224. * @hidden
  90225. */
  90226. _actionManager: ActionManager;
  90227. /**
  90228. * Internal only
  90229. * @hidden
  90230. */
  90231. _evaluationId: number;
  90232. /**
  90233. * Internal only
  90234. * @hidden
  90235. */
  90236. _currentResult: boolean;
  90237. /**
  90238. * Creates a new Condition
  90239. * @param actionManager the manager of the action the condition is applied to
  90240. */
  90241. constructor(actionManager: ActionManager);
  90242. /**
  90243. * Check if the current condition is valid
  90244. * @returns a boolean
  90245. */
  90246. isValid(): boolean;
  90247. /**
  90248. * Internal only
  90249. * @hidden
  90250. */
  90251. _getProperty(propertyPath: string): string;
  90252. /**
  90253. * Internal only
  90254. * @hidden
  90255. */
  90256. _getEffectiveTarget(target: any, propertyPath: string): any;
  90257. /**
  90258. * Serialize placeholder for child classes
  90259. * @returns the serialized object
  90260. */
  90261. serialize(): any;
  90262. /**
  90263. * Internal only
  90264. * @hidden
  90265. */
  90266. protected _serialize(serializedCondition: any): any;
  90267. }
  90268. /**
  90269. * Defines specific conditional operators as extensions of Condition
  90270. */
  90271. export class ValueCondition extends Condition {
  90272. /** path to specify the property of the target the conditional operator uses */
  90273. propertyPath: string;
  90274. /** the value compared by the conditional operator against the current value of the property */
  90275. value: any;
  90276. /** the conditional operator, default ValueCondition.IsEqual */
  90277. operator: number;
  90278. /**
  90279. * Internal only
  90280. * @hidden
  90281. */
  90282. private static _IsEqual;
  90283. /**
  90284. * Internal only
  90285. * @hidden
  90286. */
  90287. private static _IsDifferent;
  90288. /**
  90289. * Internal only
  90290. * @hidden
  90291. */
  90292. private static _IsGreater;
  90293. /**
  90294. * Internal only
  90295. * @hidden
  90296. */
  90297. private static _IsLesser;
  90298. /**
  90299. * returns the number for IsEqual
  90300. */
  90301. static get IsEqual(): number;
  90302. /**
  90303. * Returns the number for IsDifferent
  90304. */
  90305. static get IsDifferent(): number;
  90306. /**
  90307. * Returns the number for IsGreater
  90308. */
  90309. static get IsGreater(): number;
  90310. /**
  90311. * Returns the number for IsLesser
  90312. */
  90313. static get IsLesser(): number;
  90314. /**
  90315. * Internal only The action manager for the condition
  90316. * @hidden
  90317. */
  90318. _actionManager: ActionManager;
  90319. /**
  90320. * Internal only
  90321. * @hidden
  90322. */
  90323. private _target;
  90324. /**
  90325. * Internal only
  90326. * @hidden
  90327. */
  90328. private _effectiveTarget;
  90329. /**
  90330. * Internal only
  90331. * @hidden
  90332. */
  90333. private _property;
  90334. /**
  90335. * Creates a new ValueCondition
  90336. * @param actionManager manager for the action the condition applies to
  90337. * @param target for the action
  90338. * @param propertyPath path to specify the property of the target the conditional operator uses
  90339. * @param value the value compared by the conditional operator against the current value of the property
  90340. * @param operator the conditional operator, default ValueCondition.IsEqual
  90341. */
  90342. constructor(actionManager: ActionManager, target: any,
  90343. /** path to specify the property of the target the conditional operator uses */
  90344. propertyPath: string,
  90345. /** the value compared by the conditional operator against the current value of the property */
  90346. value: any,
  90347. /** the conditional operator, default ValueCondition.IsEqual */
  90348. operator?: number);
  90349. /**
  90350. * Compares the given value with the property value for the specified conditional operator
  90351. * @returns the result of the comparison
  90352. */
  90353. isValid(): boolean;
  90354. /**
  90355. * Serialize the ValueCondition into a JSON compatible object
  90356. * @returns serialization object
  90357. */
  90358. serialize(): any;
  90359. /**
  90360. * Gets the name of the conditional operator for the ValueCondition
  90361. * @param operator the conditional operator
  90362. * @returns the name
  90363. */
  90364. static GetOperatorName(operator: number): string;
  90365. }
  90366. /**
  90367. * Defines a predicate condition as an extension of Condition
  90368. */
  90369. export class PredicateCondition extends Condition {
  90370. /** defines the predicate function used to validate the condition */
  90371. predicate: () => boolean;
  90372. /**
  90373. * Internal only - manager for action
  90374. * @hidden
  90375. */
  90376. _actionManager: ActionManager;
  90377. /**
  90378. * Creates a new PredicateCondition
  90379. * @param actionManager manager for the action the condition applies to
  90380. * @param predicate defines the predicate function used to validate the condition
  90381. */
  90382. constructor(actionManager: ActionManager,
  90383. /** defines the predicate function used to validate the condition */
  90384. predicate: () => boolean);
  90385. /**
  90386. * @returns the validity of the predicate condition
  90387. */
  90388. isValid(): boolean;
  90389. }
  90390. /**
  90391. * Defines a state condition as an extension of Condition
  90392. */
  90393. export class StateCondition extends Condition {
  90394. /** Value to compare with target state */
  90395. value: string;
  90396. /**
  90397. * Internal only - manager for action
  90398. * @hidden
  90399. */
  90400. _actionManager: ActionManager;
  90401. /**
  90402. * Internal only
  90403. * @hidden
  90404. */
  90405. private _target;
  90406. /**
  90407. * Creates a new StateCondition
  90408. * @param actionManager manager for the action the condition applies to
  90409. * @param target of the condition
  90410. * @param value to compare with target state
  90411. */
  90412. constructor(actionManager: ActionManager, target: any,
  90413. /** Value to compare with target state */
  90414. value: string);
  90415. /**
  90416. * Gets a boolean indicating if the current condition is met
  90417. * @returns the validity of the state
  90418. */
  90419. isValid(): boolean;
  90420. /**
  90421. * Serialize the StateCondition into a JSON compatible object
  90422. * @returns serialization object
  90423. */
  90424. serialize(): any;
  90425. }
  90426. }
  90427. declare module BABYLON {
  90428. /**
  90429. * This defines an action responsible to toggle a boolean once triggered.
  90430. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90431. */
  90432. export class SwitchBooleanAction extends Action {
  90433. /**
  90434. * The path to the boolean property in the target object
  90435. */
  90436. propertyPath: string;
  90437. private _target;
  90438. private _effectiveTarget;
  90439. private _property;
  90440. /**
  90441. * Instantiate the action
  90442. * @param triggerOptions defines the trigger options
  90443. * @param target defines the object containing the boolean
  90444. * @param propertyPath defines the path to the boolean property in the target object
  90445. * @param condition defines the trigger related conditions
  90446. */
  90447. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90448. /** @hidden */
  90449. _prepare(): void;
  90450. /**
  90451. * Execute the action toggle the boolean value.
  90452. */
  90453. execute(): void;
  90454. /**
  90455. * Serializes the actions and its related information.
  90456. * @param parent defines the object to serialize in
  90457. * @returns the serialized object
  90458. */
  90459. serialize(parent: any): any;
  90460. }
  90461. /**
  90462. * This defines an action responsible to set a the state field of the target
  90463. * to a desired value once triggered.
  90464. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90465. */
  90466. export class SetStateAction extends Action {
  90467. /**
  90468. * The value to store in the state field.
  90469. */
  90470. value: string;
  90471. private _target;
  90472. /**
  90473. * Instantiate the action
  90474. * @param triggerOptions defines the trigger options
  90475. * @param target defines the object containing the state property
  90476. * @param value defines the value to store in the state field
  90477. * @param condition defines the trigger related conditions
  90478. */
  90479. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90480. /**
  90481. * Execute the action and store the value on the target state property.
  90482. */
  90483. execute(): void;
  90484. /**
  90485. * Serializes the actions and its related information.
  90486. * @param parent defines the object to serialize in
  90487. * @returns the serialized object
  90488. */
  90489. serialize(parent: any): any;
  90490. }
  90491. /**
  90492. * This defines an action responsible to set a property of the target
  90493. * to a desired value once triggered.
  90494. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90495. */
  90496. export class SetValueAction extends Action {
  90497. /**
  90498. * The path of the property to set in the target.
  90499. */
  90500. propertyPath: string;
  90501. /**
  90502. * The value to set in the property
  90503. */
  90504. value: any;
  90505. private _target;
  90506. private _effectiveTarget;
  90507. private _property;
  90508. /**
  90509. * Instantiate the action
  90510. * @param triggerOptions defines the trigger options
  90511. * @param target defines the object containing the property
  90512. * @param propertyPath defines the path of the property to set in the target
  90513. * @param value defines the value to set in the property
  90514. * @param condition defines the trigger related conditions
  90515. */
  90516. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90517. /** @hidden */
  90518. _prepare(): void;
  90519. /**
  90520. * Execute the action and set the targetted property to the desired value.
  90521. */
  90522. execute(): void;
  90523. /**
  90524. * Serializes the actions and its related information.
  90525. * @param parent defines the object to serialize in
  90526. * @returns the serialized object
  90527. */
  90528. serialize(parent: any): any;
  90529. }
  90530. /**
  90531. * This defines an action responsible to increment the target value
  90532. * to a desired value once triggered.
  90533. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90534. */
  90535. export class IncrementValueAction extends Action {
  90536. /**
  90537. * The path of the property to increment in the target.
  90538. */
  90539. propertyPath: string;
  90540. /**
  90541. * The value we should increment the property by.
  90542. */
  90543. value: any;
  90544. private _target;
  90545. private _effectiveTarget;
  90546. private _property;
  90547. /**
  90548. * Instantiate the action
  90549. * @param triggerOptions defines the trigger options
  90550. * @param target defines the object containing the property
  90551. * @param propertyPath defines the path of the property to increment in the target
  90552. * @param value defines the value value we should increment the property by
  90553. * @param condition defines the trigger related conditions
  90554. */
  90555. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90556. /** @hidden */
  90557. _prepare(): void;
  90558. /**
  90559. * Execute the action and increment the target of the value amount.
  90560. */
  90561. execute(): void;
  90562. /**
  90563. * Serializes the actions and its related information.
  90564. * @param parent defines the object to serialize in
  90565. * @returns the serialized object
  90566. */
  90567. serialize(parent: any): any;
  90568. }
  90569. /**
  90570. * This defines an action responsible to start an animation once triggered.
  90571. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90572. */
  90573. export class PlayAnimationAction extends Action {
  90574. /**
  90575. * Where the animation should start (animation frame)
  90576. */
  90577. from: number;
  90578. /**
  90579. * Where the animation should stop (animation frame)
  90580. */
  90581. to: number;
  90582. /**
  90583. * Define if the animation should loop or stop after the first play.
  90584. */
  90585. loop?: boolean;
  90586. private _target;
  90587. /**
  90588. * Instantiate the action
  90589. * @param triggerOptions defines the trigger options
  90590. * @param target defines the target animation or animation name
  90591. * @param from defines from where the animation should start (animation frame)
  90592. * @param end defines where the animation should stop (animation frame)
  90593. * @param loop defines if the animation should loop or stop after the first play
  90594. * @param condition defines the trigger related conditions
  90595. */
  90596. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90597. /** @hidden */
  90598. _prepare(): void;
  90599. /**
  90600. * Execute the action and play the animation.
  90601. */
  90602. execute(): void;
  90603. /**
  90604. * Serializes the actions and its related information.
  90605. * @param parent defines the object to serialize in
  90606. * @returns the serialized object
  90607. */
  90608. serialize(parent: any): any;
  90609. }
  90610. /**
  90611. * This defines an action responsible to stop an animation once triggered.
  90612. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90613. */
  90614. export class StopAnimationAction extends Action {
  90615. private _target;
  90616. /**
  90617. * Instantiate the action
  90618. * @param triggerOptions defines the trigger options
  90619. * @param target defines the target animation or animation name
  90620. * @param condition defines the trigger related conditions
  90621. */
  90622. constructor(triggerOptions: any, target: any, condition?: Condition);
  90623. /** @hidden */
  90624. _prepare(): void;
  90625. /**
  90626. * Execute the action and stop the animation.
  90627. */
  90628. execute(): void;
  90629. /**
  90630. * Serializes the actions and its related information.
  90631. * @param parent defines the object to serialize in
  90632. * @returns the serialized object
  90633. */
  90634. serialize(parent: any): any;
  90635. }
  90636. /**
  90637. * This defines an action responsible that does nothing once triggered.
  90638. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90639. */
  90640. export class DoNothingAction extends Action {
  90641. /**
  90642. * Instantiate the action
  90643. * @param triggerOptions defines the trigger options
  90644. * @param condition defines the trigger related conditions
  90645. */
  90646. constructor(triggerOptions?: any, condition?: Condition);
  90647. /**
  90648. * Execute the action and do nothing.
  90649. */
  90650. execute(): void;
  90651. /**
  90652. * Serializes the actions and its related information.
  90653. * @param parent defines the object to serialize in
  90654. * @returns the serialized object
  90655. */
  90656. serialize(parent: any): any;
  90657. }
  90658. /**
  90659. * This defines an action responsible to trigger several actions once triggered.
  90660. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90661. */
  90662. export class CombineAction extends Action {
  90663. /**
  90664. * The list of aggregated animations to run.
  90665. */
  90666. children: Action[];
  90667. /**
  90668. * Instantiate the action
  90669. * @param triggerOptions defines the trigger options
  90670. * @param children defines the list of aggregated animations to run
  90671. * @param condition defines the trigger related conditions
  90672. */
  90673. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90674. /** @hidden */
  90675. _prepare(): void;
  90676. /**
  90677. * Execute the action and executes all the aggregated actions.
  90678. */
  90679. execute(evt: ActionEvent): void;
  90680. /**
  90681. * Serializes the actions and its related information.
  90682. * @param parent defines the object to serialize in
  90683. * @returns the serialized object
  90684. */
  90685. serialize(parent: any): any;
  90686. }
  90687. /**
  90688. * This defines an action responsible to run code (external event) once triggered.
  90689. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90690. */
  90691. export class ExecuteCodeAction extends Action {
  90692. /**
  90693. * The callback function to run.
  90694. */
  90695. func: (evt: ActionEvent) => void;
  90696. /**
  90697. * Instantiate the action
  90698. * @param triggerOptions defines the trigger options
  90699. * @param func defines the callback function to run
  90700. * @param condition defines the trigger related conditions
  90701. */
  90702. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90703. /**
  90704. * Execute the action and run the attached code.
  90705. */
  90706. execute(evt: ActionEvent): void;
  90707. }
  90708. /**
  90709. * This defines an action responsible to set the parent property of the target once triggered.
  90710. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90711. */
  90712. export class SetParentAction extends Action {
  90713. private _parent;
  90714. private _target;
  90715. /**
  90716. * Instantiate the action
  90717. * @param triggerOptions defines the trigger options
  90718. * @param target defines the target containing the parent property
  90719. * @param parent defines from where the animation should start (animation frame)
  90720. * @param condition defines the trigger related conditions
  90721. */
  90722. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90723. /** @hidden */
  90724. _prepare(): void;
  90725. /**
  90726. * Execute the action and set the parent property.
  90727. */
  90728. execute(): void;
  90729. /**
  90730. * Serializes the actions and its related information.
  90731. * @param parent defines the object to serialize in
  90732. * @returns the serialized object
  90733. */
  90734. serialize(parent: any): any;
  90735. }
  90736. }
  90737. declare module BABYLON {
  90738. /**
  90739. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90740. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90741. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90742. */
  90743. export class ActionManager extends AbstractActionManager {
  90744. /**
  90745. * Nothing
  90746. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90747. */
  90748. static readonly NothingTrigger: number;
  90749. /**
  90750. * On pick
  90751. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90752. */
  90753. static readonly OnPickTrigger: number;
  90754. /**
  90755. * On left pick
  90756. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90757. */
  90758. static readonly OnLeftPickTrigger: number;
  90759. /**
  90760. * On right pick
  90761. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90762. */
  90763. static readonly OnRightPickTrigger: number;
  90764. /**
  90765. * On center pick
  90766. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90767. */
  90768. static readonly OnCenterPickTrigger: number;
  90769. /**
  90770. * On pick down
  90771. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90772. */
  90773. static readonly OnPickDownTrigger: number;
  90774. /**
  90775. * On double pick
  90776. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90777. */
  90778. static readonly OnDoublePickTrigger: number;
  90779. /**
  90780. * On pick up
  90781. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90782. */
  90783. static readonly OnPickUpTrigger: number;
  90784. /**
  90785. * On pick out.
  90786. * This trigger will only be raised if you also declared a OnPickDown
  90787. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90788. */
  90789. static readonly OnPickOutTrigger: number;
  90790. /**
  90791. * On long press
  90792. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90793. */
  90794. static readonly OnLongPressTrigger: number;
  90795. /**
  90796. * On pointer over
  90797. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90798. */
  90799. static readonly OnPointerOverTrigger: number;
  90800. /**
  90801. * On pointer out
  90802. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90803. */
  90804. static readonly OnPointerOutTrigger: number;
  90805. /**
  90806. * On every frame
  90807. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90808. */
  90809. static readonly OnEveryFrameTrigger: number;
  90810. /**
  90811. * On intersection enter
  90812. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90813. */
  90814. static readonly OnIntersectionEnterTrigger: number;
  90815. /**
  90816. * On intersection exit
  90817. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90818. */
  90819. static readonly OnIntersectionExitTrigger: number;
  90820. /**
  90821. * On key down
  90822. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90823. */
  90824. static readonly OnKeyDownTrigger: number;
  90825. /**
  90826. * On key up
  90827. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90828. */
  90829. static readonly OnKeyUpTrigger: number;
  90830. private _scene;
  90831. /**
  90832. * Creates a new action manager
  90833. * @param scene defines the hosting scene
  90834. */
  90835. constructor(scene: Scene);
  90836. /**
  90837. * Releases all associated resources
  90838. */
  90839. dispose(): void;
  90840. /**
  90841. * Gets hosting scene
  90842. * @returns the hosting scene
  90843. */
  90844. getScene(): Scene;
  90845. /**
  90846. * Does this action manager handles actions of any of the given triggers
  90847. * @param triggers defines the triggers to be tested
  90848. * @return a boolean indicating whether one (or more) of the triggers is handled
  90849. */
  90850. hasSpecificTriggers(triggers: number[]): boolean;
  90851. /**
  90852. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90853. * speed.
  90854. * @param triggerA defines the trigger to be tested
  90855. * @param triggerB defines the trigger to be tested
  90856. * @return a boolean indicating whether one (or more) of the triggers is handled
  90857. */
  90858. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90859. /**
  90860. * Does this action manager handles actions of a given trigger
  90861. * @param trigger defines the trigger to be tested
  90862. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90863. * @return whether the trigger is handled
  90864. */
  90865. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90866. /**
  90867. * Does this action manager has pointer triggers
  90868. */
  90869. get hasPointerTriggers(): boolean;
  90870. /**
  90871. * Does this action manager has pick triggers
  90872. */
  90873. get hasPickTriggers(): boolean;
  90874. /**
  90875. * Registers an action to this action manager
  90876. * @param action defines the action to be registered
  90877. * @return the action amended (prepared) after registration
  90878. */
  90879. registerAction(action: IAction): Nullable<IAction>;
  90880. /**
  90881. * Unregisters an action to this action manager
  90882. * @param action defines the action to be unregistered
  90883. * @return a boolean indicating whether the action has been unregistered
  90884. */
  90885. unregisterAction(action: IAction): Boolean;
  90886. /**
  90887. * Process a specific trigger
  90888. * @param trigger defines the trigger to process
  90889. * @param evt defines the event details to be processed
  90890. */
  90891. processTrigger(trigger: number, evt?: IActionEvent): void;
  90892. /** @hidden */
  90893. _getEffectiveTarget(target: any, propertyPath: string): any;
  90894. /** @hidden */
  90895. _getProperty(propertyPath: string): string;
  90896. /**
  90897. * Serialize this manager to a JSON object
  90898. * @param name defines the property name to store this manager
  90899. * @returns a JSON representation of this manager
  90900. */
  90901. serialize(name: string): any;
  90902. /**
  90903. * Creates a new ActionManager from a JSON data
  90904. * @param parsedActions defines the JSON data to read from
  90905. * @param object defines the hosting mesh
  90906. * @param scene defines the hosting scene
  90907. */
  90908. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90909. /**
  90910. * Get a trigger name by index
  90911. * @param trigger defines the trigger index
  90912. * @returns a trigger name
  90913. */
  90914. static GetTriggerName(trigger: number): string;
  90915. }
  90916. }
  90917. declare module BABYLON {
  90918. /**
  90919. * Class used to represent a sprite
  90920. * @see https://doc.babylonjs.com/babylon101/sprites
  90921. */
  90922. export class Sprite implements IAnimatable {
  90923. /** defines the name */
  90924. name: string;
  90925. /** Gets or sets the current world position */
  90926. position: Vector3;
  90927. /** Gets or sets the main color */
  90928. color: Color4;
  90929. /** Gets or sets the width */
  90930. width: number;
  90931. /** Gets or sets the height */
  90932. height: number;
  90933. /** Gets or sets rotation angle */
  90934. angle: number;
  90935. /** Gets or sets the cell index in the sprite sheet */
  90936. cellIndex: number;
  90937. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90938. cellRef: string;
  90939. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90940. invertU: boolean;
  90941. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90942. invertV: boolean;
  90943. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90944. disposeWhenFinishedAnimating: boolean;
  90945. /** Gets the list of attached animations */
  90946. animations: Nullable<Array<Animation>>;
  90947. /** Gets or sets a boolean indicating if the sprite can be picked */
  90948. isPickable: boolean;
  90949. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90950. useAlphaForPicking: boolean;
  90951. /** @hidden */
  90952. _xOffset: number;
  90953. /** @hidden */
  90954. _yOffset: number;
  90955. /** @hidden */
  90956. _xSize: number;
  90957. /** @hidden */
  90958. _ySize: number;
  90959. /**
  90960. * Gets or sets the associated action manager
  90961. */
  90962. actionManager: Nullable<ActionManager>;
  90963. /**
  90964. * An event triggered when the control has been disposed
  90965. */
  90966. onDisposeObservable: Observable<Sprite>;
  90967. private _animationStarted;
  90968. private _loopAnimation;
  90969. private _fromIndex;
  90970. private _toIndex;
  90971. private _delay;
  90972. private _direction;
  90973. private _manager;
  90974. private _time;
  90975. private _onAnimationEnd;
  90976. /**
  90977. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  90978. */
  90979. isVisible: boolean;
  90980. /**
  90981. * Gets or sets the sprite size
  90982. */
  90983. get size(): number;
  90984. set size(value: number);
  90985. /**
  90986. * Returns a boolean indicating if the animation is started
  90987. */
  90988. get animationStarted(): boolean;
  90989. /**
  90990. * Gets or sets the unique id of the sprite
  90991. */
  90992. uniqueId: number;
  90993. /**
  90994. * Gets the manager of this sprite
  90995. */
  90996. get manager(): ISpriteManager;
  90997. /**
  90998. * Creates a new Sprite
  90999. * @param name defines the name
  91000. * @param manager defines the manager
  91001. */
  91002. constructor(
  91003. /** defines the name */
  91004. name: string, manager: ISpriteManager);
  91005. /**
  91006. * Returns the string "Sprite"
  91007. * @returns "Sprite"
  91008. */
  91009. getClassName(): string;
  91010. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  91011. get fromIndex(): number;
  91012. set fromIndex(value: number);
  91013. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  91014. get toIndex(): number;
  91015. set toIndex(value: number);
  91016. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  91017. get loopAnimation(): boolean;
  91018. set loopAnimation(value: boolean);
  91019. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  91020. get delay(): number;
  91021. set delay(value: number);
  91022. /**
  91023. * Starts an animation
  91024. * @param from defines the initial key
  91025. * @param to defines the end key
  91026. * @param loop defines if the animation must loop
  91027. * @param delay defines the start delay (in ms)
  91028. * @param onAnimationEnd defines a callback to call when animation ends
  91029. */
  91030. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  91031. /** Stops current animation (if any) */
  91032. stopAnimation(): void;
  91033. /** @hidden */
  91034. _animate(deltaTime: number): void;
  91035. /** Release associated resources */
  91036. dispose(): void;
  91037. /**
  91038. * Serializes the sprite to a JSON object
  91039. * @returns the JSON object
  91040. */
  91041. serialize(): any;
  91042. /**
  91043. * Parses a JSON object to create a new sprite
  91044. * @param parsedSprite The JSON object to parse
  91045. * @param manager defines the hosting manager
  91046. * @returns the new sprite
  91047. */
  91048. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  91049. }
  91050. }
  91051. declare module BABYLON {
  91052. /**
  91053. * Information about the result of picking within a scene
  91054. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91055. */
  91056. export class PickingInfo {
  91057. /** @hidden */
  91058. _pickingUnavailable: boolean;
  91059. /**
  91060. * If the pick collided with an object
  91061. */
  91062. hit: boolean;
  91063. /**
  91064. * Distance away where the pick collided
  91065. */
  91066. distance: number;
  91067. /**
  91068. * The location of pick collision
  91069. */
  91070. pickedPoint: Nullable<Vector3>;
  91071. /**
  91072. * The mesh corresponding the the pick collision
  91073. */
  91074. pickedMesh: Nullable<AbstractMesh>;
  91075. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91076. bu: number;
  91077. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91078. bv: number;
  91079. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91080. faceId: number;
  91081. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91082. subMeshFaceId: number;
  91083. /** Id of the the submesh that was picked */
  91084. subMeshId: number;
  91085. /** If a sprite was picked, this will be the sprite the pick collided with */
  91086. pickedSprite: Nullable<Sprite>;
  91087. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  91088. thinInstanceIndex: number;
  91089. /**
  91090. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91091. */
  91092. originMesh: Nullable<AbstractMesh>;
  91093. /**
  91094. * The ray that was used to perform the picking.
  91095. */
  91096. ray: Nullable<Ray>;
  91097. /**
  91098. * Gets the normal correspodning to the face the pick collided with
  91099. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91100. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91101. * @returns The normal correspodning to the face the pick collided with
  91102. */
  91103. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91104. /**
  91105. * Gets the texture coordinates of where the pick occured
  91106. * @returns the vector containing the coordnates of the texture
  91107. */
  91108. getTextureCoordinates(): Nullable<Vector2>;
  91109. }
  91110. }
  91111. declare module BABYLON {
  91112. /**
  91113. * Class representing a ray with position and direction
  91114. */
  91115. export class Ray {
  91116. /** origin point */
  91117. origin: Vector3;
  91118. /** direction */
  91119. direction: Vector3;
  91120. /** length of the ray */
  91121. length: number;
  91122. private static readonly _TmpVector3;
  91123. private _tmpRay;
  91124. /**
  91125. * Creates a new ray
  91126. * @param origin origin point
  91127. * @param direction direction
  91128. * @param length length of the ray
  91129. */
  91130. constructor(
  91131. /** origin point */
  91132. origin: Vector3,
  91133. /** direction */
  91134. direction: Vector3,
  91135. /** length of the ray */
  91136. length?: number);
  91137. /**
  91138. * Checks if the ray intersects a box
  91139. * This does not account for the ray lenght by design to improve perfs.
  91140. * @param minimum bound of the box
  91141. * @param maximum bound of the box
  91142. * @param intersectionTreshold extra extend to be added to the box in all direction
  91143. * @returns if the box was hit
  91144. */
  91145. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91146. /**
  91147. * Checks if the ray intersects a box
  91148. * This does not account for the ray lenght by design to improve perfs.
  91149. * @param box the bounding box to check
  91150. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91151. * @returns if the box was hit
  91152. */
  91153. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91154. /**
  91155. * If the ray hits a sphere
  91156. * @param sphere the bounding sphere to check
  91157. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91158. * @returns true if it hits the sphere
  91159. */
  91160. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91161. /**
  91162. * If the ray hits a triange
  91163. * @param vertex0 triangle vertex
  91164. * @param vertex1 triangle vertex
  91165. * @param vertex2 triangle vertex
  91166. * @returns intersection information if hit
  91167. */
  91168. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91169. /**
  91170. * Checks if ray intersects a plane
  91171. * @param plane the plane to check
  91172. * @returns the distance away it was hit
  91173. */
  91174. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91175. /**
  91176. * Calculate the intercept of a ray on a given axis
  91177. * @param axis to check 'x' | 'y' | 'z'
  91178. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91179. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91180. */
  91181. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91182. /**
  91183. * Checks if ray intersects a mesh
  91184. * @param mesh the mesh to check
  91185. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91186. * @returns picking info of the intersecton
  91187. */
  91188. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91189. /**
  91190. * Checks if ray intersects a mesh
  91191. * @param meshes the meshes to check
  91192. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91193. * @param results array to store result in
  91194. * @returns Array of picking infos
  91195. */
  91196. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91197. private _comparePickingInfo;
  91198. private static smallnum;
  91199. private static rayl;
  91200. /**
  91201. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91202. * @param sega the first point of the segment to test the intersection against
  91203. * @param segb the second point of the segment to test the intersection against
  91204. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91205. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91206. */
  91207. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91208. /**
  91209. * Update the ray from viewport position
  91210. * @param x position
  91211. * @param y y position
  91212. * @param viewportWidth viewport width
  91213. * @param viewportHeight viewport height
  91214. * @param world world matrix
  91215. * @param view view matrix
  91216. * @param projection projection matrix
  91217. * @returns this ray updated
  91218. */
  91219. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91220. /**
  91221. * Creates a ray with origin and direction of 0,0,0
  91222. * @returns the new ray
  91223. */
  91224. static Zero(): Ray;
  91225. /**
  91226. * Creates a new ray from screen space and viewport
  91227. * @param x position
  91228. * @param y y position
  91229. * @param viewportWidth viewport width
  91230. * @param viewportHeight viewport height
  91231. * @param world world matrix
  91232. * @param view view matrix
  91233. * @param projection projection matrix
  91234. * @returns new ray
  91235. */
  91236. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91237. /**
  91238. * 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
  91239. * transformed to the given world matrix.
  91240. * @param origin The origin point
  91241. * @param end The end point
  91242. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91243. * @returns the new ray
  91244. */
  91245. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91246. /**
  91247. * Transforms a ray by a matrix
  91248. * @param ray ray to transform
  91249. * @param matrix matrix to apply
  91250. * @returns the resulting new ray
  91251. */
  91252. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91253. /**
  91254. * Transforms a ray by a matrix
  91255. * @param ray ray to transform
  91256. * @param matrix matrix to apply
  91257. * @param result ray to store result in
  91258. */
  91259. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91260. /**
  91261. * Unproject a ray from screen space to object space
  91262. * @param sourceX defines the screen space x coordinate to use
  91263. * @param sourceY defines the screen space y coordinate to use
  91264. * @param viewportWidth defines the current width of the viewport
  91265. * @param viewportHeight defines the current height of the viewport
  91266. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91267. * @param view defines the view matrix to use
  91268. * @param projection defines the projection matrix to use
  91269. */
  91270. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91271. }
  91272. /**
  91273. * Type used to define predicate used to select faces when a mesh intersection is detected
  91274. */
  91275. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91276. interface Scene {
  91277. /** @hidden */
  91278. _tempPickingRay: Nullable<Ray>;
  91279. /** @hidden */
  91280. _cachedRayForTransform: Ray;
  91281. /** @hidden */
  91282. _pickWithRayInverseMatrix: Matrix;
  91283. /** @hidden */
  91284. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91285. /** @hidden */
  91286. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91287. /** @hidden */
  91288. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91289. }
  91290. }
  91291. declare module BABYLON {
  91292. /**
  91293. * Groups all the scene component constants in one place to ease maintenance.
  91294. * @hidden
  91295. */
  91296. export class SceneComponentConstants {
  91297. static readonly NAME_EFFECTLAYER: string;
  91298. static readonly NAME_LAYER: string;
  91299. static readonly NAME_LENSFLARESYSTEM: string;
  91300. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91301. static readonly NAME_PARTICLESYSTEM: string;
  91302. static readonly NAME_GAMEPAD: string;
  91303. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91304. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91305. static readonly NAME_PREPASSRENDERER: string;
  91306. static readonly NAME_DEPTHRENDERER: string;
  91307. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91308. static readonly NAME_SPRITE: string;
  91309. static readonly NAME_SUBSURFACE: string;
  91310. static readonly NAME_OUTLINERENDERER: string;
  91311. static readonly NAME_PROCEDURALTEXTURE: string;
  91312. static readonly NAME_SHADOWGENERATOR: string;
  91313. static readonly NAME_OCTREE: string;
  91314. static readonly NAME_PHYSICSENGINE: string;
  91315. static readonly NAME_AUDIO: string;
  91316. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91317. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91318. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91319. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91320. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91321. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91322. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91323. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91324. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91325. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91326. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91327. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91328. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91329. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91330. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91331. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91332. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91333. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91334. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91335. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91336. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91337. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91338. static readonly STEP_AFTERRENDER_AUDIO: number;
  91339. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91340. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91341. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91342. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91343. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91344. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91345. static readonly STEP_POINTERMOVE_SPRITE: number;
  91346. static readonly STEP_POINTERDOWN_SPRITE: number;
  91347. static readonly STEP_POINTERUP_SPRITE: number;
  91348. }
  91349. /**
  91350. * This represents a scene component.
  91351. *
  91352. * This is used to decouple the dependency the scene is having on the different workloads like
  91353. * layers, post processes...
  91354. */
  91355. export interface ISceneComponent {
  91356. /**
  91357. * The name of the component. Each component must have a unique name.
  91358. */
  91359. name: string;
  91360. /**
  91361. * The scene the component belongs to.
  91362. */
  91363. scene: Scene;
  91364. /**
  91365. * Register the component to one instance of a scene.
  91366. */
  91367. register(): void;
  91368. /**
  91369. * Rebuilds the elements related to this component in case of
  91370. * context lost for instance.
  91371. */
  91372. rebuild(): void;
  91373. /**
  91374. * Disposes the component and the associated ressources.
  91375. */
  91376. dispose(): void;
  91377. }
  91378. /**
  91379. * This represents a SERIALIZABLE scene component.
  91380. *
  91381. * This extends Scene Component to add Serialization methods on top.
  91382. */
  91383. export interface ISceneSerializableComponent extends ISceneComponent {
  91384. /**
  91385. * Adds all the elements from the container to the scene
  91386. * @param container the container holding the elements
  91387. */
  91388. addFromContainer(container: AbstractScene): void;
  91389. /**
  91390. * Removes all the elements in the container from the scene
  91391. * @param container contains the elements to remove
  91392. * @param dispose if the removed element should be disposed (default: false)
  91393. */
  91394. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91395. /**
  91396. * Serializes the component data to the specified json object
  91397. * @param serializationObject The object to serialize to
  91398. */
  91399. serialize(serializationObject: any): void;
  91400. }
  91401. /**
  91402. * Strong typing of a Mesh related stage step action
  91403. */
  91404. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91405. /**
  91406. * Strong typing of a Evaluate Sub Mesh related stage step action
  91407. */
  91408. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91409. /**
  91410. * Strong typing of a Active Mesh related stage step action
  91411. */
  91412. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91413. /**
  91414. * Strong typing of a Camera related stage step action
  91415. */
  91416. export type CameraStageAction = (camera: Camera) => void;
  91417. /**
  91418. * Strong typing of a Camera Frame buffer related stage step action
  91419. */
  91420. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91421. /**
  91422. * Strong typing of a Render Target related stage step action
  91423. */
  91424. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91425. /**
  91426. * Strong typing of a RenderingGroup related stage step action
  91427. */
  91428. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91429. /**
  91430. * Strong typing of a Mesh Render related stage step action
  91431. */
  91432. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91433. /**
  91434. * Strong typing of a simple stage step action
  91435. */
  91436. export type SimpleStageAction = () => void;
  91437. /**
  91438. * Strong typing of a render target action.
  91439. */
  91440. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91441. /**
  91442. * Strong typing of a pointer move action.
  91443. */
  91444. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91445. /**
  91446. * Strong typing of a pointer up/down action.
  91447. */
  91448. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91449. /**
  91450. * Representation of a stage in the scene (Basically a list of ordered steps)
  91451. * @hidden
  91452. */
  91453. export class Stage<T extends Function> extends Array<{
  91454. index: number;
  91455. component: ISceneComponent;
  91456. action: T;
  91457. }> {
  91458. /**
  91459. * Hide ctor from the rest of the world.
  91460. * @param items The items to add.
  91461. */
  91462. private constructor();
  91463. /**
  91464. * Creates a new Stage.
  91465. * @returns A new instance of a Stage
  91466. */
  91467. static Create<T extends Function>(): Stage<T>;
  91468. /**
  91469. * Registers a step in an ordered way in the targeted stage.
  91470. * @param index Defines the position to register the step in
  91471. * @param component Defines the component attached to the step
  91472. * @param action Defines the action to launch during the step
  91473. */
  91474. registerStep(index: number, component: ISceneComponent, action: T): void;
  91475. /**
  91476. * Clears all the steps from the stage.
  91477. */
  91478. clear(): void;
  91479. }
  91480. }
  91481. declare module BABYLON {
  91482. interface Scene {
  91483. /** @hidden */
  91484. _pointerOverSprite: Nullable<Sprite>;
  91485. /** @hidden */
  91486. _pickedDownSprite: Nullable<Sprite>;
  91487. /** @hidden */
  91488. _tempSpritePickingRay: Nullable<Ray>;
  91489. /**
  91490. * All of the sprite managers added to this scene
  91491. * @see https://doc.babylonjs.com/babylon101/sprites
  91492. */
  91493. spriteManagers: Array<ISpriteManager>;
  91494. /**
  91495. * An event triggered when sprites rendering is about to start
  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. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91499. /**
  91500. * An event triggered when sprites rendering is done
  91501. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91502. */
  91503. onAfterSpritesRenderingObservable: Observable<Scene>;
  91504. /** @hidden */
  91505. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91506. /** Launch a ray to try to pick a sprite in the scene
  91507. * @param x position on screen
  91508. * @param y position on screen
  91509. * @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
  91510. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91511. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91512. * @returns a PickingInfo
  91513. */
  91514. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91515. /** Use the given ray to pick a sprite in the scene
  91516. * @param ray The ray (in world space) to use to pick meshes
  91517. * @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
  91518. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91519. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91520. * @returns a PickingInfo
  91521. */
  91522. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91523. /** @hidden */
  91524. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91525. /** Launch a ray to try to pick sprites in the scene
  91526. * @param x position on screen
  91527. * @param y position on screen
  91528. * @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
  91529. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91530. * @returns a PickingInfo array
  91531. */
  91532. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91533. /** Use the given ray to pick sprites in the scene
  91534. * @param ray The ray (in world space) to use to pick meshes
  91535. * @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
  91536. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91537. * @returns a PickingInfo array
  91538. */
  91539. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91540. /**
  91541. * Force the sprite under the pointer
  91542. * @param sprite defines the sprite to use
  91543. */
  91544. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91545. /**
  91546. * Gets the sprite under the pointer
  91547. * @returns a Sprite or null if no sprite is under the pointer
  91548. */
  91549. getPointerOverSprite(): Nullable<Sprite>;
  91550. }
  91551. /**
  91552. * Defines the sprite scene component responsible to manage sprites
  91553. * in a given scene.
  91554. */
  91555. export class SpriteSceneComponent implements ISceneComponent {
  91556. /**
  91557. * The component name helpfull to identify the component in the list of scene components.
  91558. */
  91559. readonly name: string;
  91560. /**
  91561. * The scene the component belongs to.
  91562. */
  91563. scene: Scene;
  91564. /** @hidden */
  91565. private _spritePredicate;
  91566. /**
  91567. * Creates a new instance of the component for the given scene
  91568. * @param scene Defines the scene to register the component in
  91569. */
  91570. constructor(scene: Scene);
  91571. /**
  91572. * Registers the component in a given scene
  91573. */
  91574. register(): void;
  91575. /**
  91576. * Rebuilds the elements related to this component in case of
  91577. * context lost for instance.
  91578. */
  91579. rebuild(): void;
  91580. /**
  91581. * Disposes the component and the associated ressources.
  91582. */
  91583. dispose(): void;
  91584. private _pickSpriteButKeepRay;
  91585. private _pointerMove;
  91586. private _pointerDown;
  91587. private _pointerUp;
  91588. }
  91589. }
  91590. declare module BABYLON {
  91591. /** @hidden */
  91592. export var fogFragmentDeclaration: {
  91593. name: string;
  91594. shader: string;
  91595. };
  91596. }
  91597. declare module BABYLON {
  91598. /** @hidden */
  91599. export var fogFragment: {
  91600. name: string;
  91601. shader: string;
  91602. };
  91603. }
  91604. declare module BABYLON {
  91605. /** @hidden */
  91606. export var imageProcessingCompatibility: {
  91607. name: string;
  91608. shader: string;
  91609. };
  91610. }
  91611. declare module BABYLON {
  91612. /** @hidden */
  91613. export var spritesPixelShader: {
  91614. name: string;
  91615. shader: string;
  91616. };
  91617. }
  91618. declare module BABYLON {
  91619. /** @hidden */
  91620. export var fogVertexDeclaration: {
  91621. name: string;
  91622. shader: string;
  91623. };
  91624. }
  91625. declare module BABYLON {
  91626. /** @hidden */
  91627. export var spritesVertexShader: {
  91628. name: string;
  91629. shader: string;
  91630. };
  91631. }
  91632. declare module BABYLON {
  91633. /**
  91634. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91635. */
  91636. export interface ISpriteManager extends IDisposable {
  91637. /**
  91638. * Gets manager's name
  91639. */
  91640. name: string;
  91641. /**
  91642. * Restricts the camera to viewing objects with the same layerMask.
  91643. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91644. */
  91645. layerMask: number;
  91646. /**
  91647. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91648. */
  91649. isPickable: boolean;
  91650. /**
  91651. * Gets the hosting scene
  91652. */
  91653. scene: Scene;
  91654. /**
  91655. * Specifies the rendering group id for this mesh (0 by default)
  91656. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91657. */
  91658. renderingGroupId: number;
  91659. /**
  91660. * Defines the list of sprites managed by the manager.
  91661. */
  91662. sprites: Array<Sprite>;
  91663. /**
  91664. * Gets or sets the spritesheet texture
  91665. */
  91666. texture: Texture;
  91667. /** Defines the default width of a cell in the spritesheet */
  91668. cellWidth: number;
  91669. /** Defines the default height of a cell in the spritesheet */
  91670. cellHeight: number;
  91671. /**
  91672. * Tests the intersection of a sprite with a specific ray.
  91673. * @param ray The ray we are sending to test the collision
  91674. * @param camera The camera space we are sending rays in
  91675. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91676. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91677. * @returns picking info or null.
  91678. */
  91679. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91680. /**
  91681. * Intersects the sprites with a ray
  91682. * @param ray defines the ray to intersect with
  91683. * @param camera defines the current active camera
  91684. * @param predicate defines a predicate used to select candidate sprites
  91685. * @returns null if no hit or a PickingInfo array
  91686. */
  91687. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91688. /**
  91689. * Renders the list of sprites on screen.
  91690. */
  91691. render(): void;
  91692. }
  91693. /**
  91694. * Class used to manage multiple sprites on the same spritesheet
  91695. * @see https://doc.babylonjs.com/babylon101/sprites
  91696. */
  91697. export class SpriteManager implements ISpriteManager {
  91698. /** defines the manager's name */
  91699. name: string;
  91700. /** Define the Url to load snippets */
  91701. static SnippetUrl: string;
  91702. /** Snippet ID if the manager was created from the snippet server */
  91703. snippetId: string;
  91704. /** Gets the list of sprites */
  91705. sprites: Sprite[];
  91706. /** Gets or sets the rendering group id (0 by default) */
  91707. renderingGroupId: number;
  91708. /** Gets or sets camera layer mask */
  91709. layerMask: number;
  91710. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91711. fogEnabled: boolean;
  91712. /** Gets or sets a boolean indicating if the sprites are pickable */
  91713. isPickable: boolean;
  91714. /** Defines the default width of a cell in the spritesheet */
  91715. cellWidth: number;
  91716. /** Defines the default height of a cell in the spritesheet */
  91717. cellHeight: number;
  91718. /** Associative array from JSON sprite data file */
  91719. private _cellData;
  91720. /** Array of sprite names from JSON sprite data file */
  91721. private _spriteMap;
  91722. /** True when packed cell data from JSON file is ready*/
  91723. private _packedAndReady;
  91724. private _textureContent;
  91725. private _useInstancing;
  91726. /**
  91727. * An event triggered when the manager is disposed.
  91728. */
  91729. onDisposeObservable: Observable<SpriteManager>;
  91730. private _onDisposeObserver;
  91731. /**
  91732. * Callback called when the manager is disposed
  91733. */
  91734. set onDispose(callback: () => void);
  91735. private _capacity;
  91736. private _fromPacked;
  91737. private _spriteTexture;
  91738. private _epsilon;
  91739. private _scene;
  91740. private _vertexData;
  91741. private _buffer;
  91742. private _vertexBuffers;
  91743. private _spriteBuffer;
  91744. private _indexBuffer;
  91745. private _effectBase;
  91746. private _effectFog;
  91747. private _vertexBufferSize;
  91748. /**
  91749. * Gets or sets the unique id of the sprite
  91750. */
  91751. uniqueId: number;
  91752. /**
  91753. * Gets the array of sprites
  91754. */
  91755. get children(): Sprite[];
  91756. /**
  91757. * Gets the hosting scene
  91758. */
  91759. get scene(): Scene;
  91760. /**
  91761. * Gets the capacity of the manager
  91762. */
  91763. get capacity(): number;
  91764. /**
  91765. * Gets or sets the spritesheet texture
  91766. */
  91767. get texture(): Texture;
  91768. set texture(value: Texture);
  91769. private _blendMode;
  91770. /**
  91771. * Blend mode use to render the particle, it can be any of
  91772. * the static Constants.ALPHA_x properties provided in this class.
  91773. * Default value is Constants.ALPHA_COMBINE
  91774. */
  91775. get blendMode(): number;
  91776. set blendMode(blendMode: number);
  91777. /** Disables writing to the depth buffer when rendering the sprites.
  91778. * It can be handy to disable depth writing when using textures without alpha channel
  91779. * and setting some specific blend modes.
  91780. */
  91781. disableDepthWrite: boolean;
  91782. /**
  91783. * Creates a new sprite manager
  91784. * @param name defines the manager's name
  91785. * @param imgUrl defines the sprite sheet url
  91786. * @param capacity defines the maximum allowed number of sprites
  91787. * @param cellSize defines the size of a sprite cell
  91788. * @param scene defines the hosting scene
  91789. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91790. * @param samplingMode defines the smapling mode to use with spritesheet
  91791. * @param fromPacked set to false; do not alter
  91792. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91793. */
  91794. constructor(
  91795. /** defines the manager's name */
  91796. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91797. /**
  91798. * Returns the string "SpriteManager"
  91799. * @returns "SpriteManager"
  91800. */
  91801. getClassName(): string;
  91802. private _makePacked;
  91803. private _appendSpriteVertex;
  91804. private _checkTextureAlpha;
  91805. /**
  91806. * Intersects the sprites with a ray
  91807. * @param ray defines the ray to intersect with
  91808. * @param camera defines the current active camera
  91809. * @param predicate defines a predicate used to select candidate sprites
  91810. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91811. * @returns null if no hit or a PickingInfo
  91812. */
  91813. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91814. /**
  91815. * Intersects the sprites with a ray
  91816. * @param ray defines the ray to intersect with
  91817. * @param camera defines the current active camera
  91818. * @param predicate defines a predicate used to select candidate sprites
  91819. * @returns null if no hit or a PickingInfo array
  91820. */
  91821. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91822. /**
  91823. * Render all child sprites
  91824. */
  91825. render(): void;
  91826. /**
  91827. * Release associated resources
  91828. */
  91829. dispose(): void;
  91830. /**
  91831. * Serializes the sprite manager to a JSON object
  91832. * @param serializeTexture defines if the texture must be serialized as well
  91833. * @returns the JSON object
  91834. */
  91835. serialize(serializeTexture?: boolean): any;
  91836. /**
  91837. * Parses a JSON object to create a new sprite manager.
  91838. * @param parsedManager The JSON object to parse
  91839. * @param scene The scene to create the sprite managerin
  91840. * @param rootUrl The root url to use to load external dependencies like texture
  91841. * @returns the new sprite manager
  91842. */
  91843. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91844. /**
  91845. * Creates a sprite manager from a snippet saved in a remote file
  91846. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91847. * @param url defines the url to load from
  91848. * @param scene defines the hosting scene
  91849. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91850. * @returns a promise that will resolve to the new sprite manager
  91851. */
  91852. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91853. /**
  91854. * Creates a sprite manager from a snippet saved by the sprite editor
  91855. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91856. * @param scene defines the hosting scene
  91857. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91858. * @returns a promise that will resolve to the new sprite manager
  91859. */
  91860. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91861. }
  91862. }
  91863. declare module BABYLON {
  91864. /** Interface used by value gradients (color, factor, ...) */
  91865. export interface IValueGradient {
  91866. /**
  91867. * Gets or sets the gradient value (between 0 and 1)
  91868. */
  91869. gradient: number;
  91870. }
  91871. /** Class used to store color4 gradient */
  91872. export class ColorGradient implements IValueGradient {
  91873. /**
  91874. * Gets or sets the gradient value (between 0 and 1)
  91875. */
  91876. gradient: number;
  91877. /**
  91878. * Gets or sets first associated color
  91879. */
  91880. color1: Color4;
  91881. /**
  91882. * Gets or sets second associated color
  91883. */
  91884. color2?: Color4 | undefined;
  91885. /**
  91886. * Creates a new color4 gradient
  91887. * @param gradient gets or sets the gradient value (between 0 and 1)
  91888. * @param color1 gets or sets first associated color
  91889. * @param color2 gets or sets first second color
  91890. */
  91891. constructor(
  91892. /**
  91893. * Gets or sets the gradient value (between 0 and 1)
  91894. */
  91895. gradient: number,
  91896. /**
  91897. * Gets or sets first associated color
  91898. */
  91899. color1: Color4,
  91900. /**
  91901. * Gets or sets second associated color
  91902. */
  91903. color2?: Color4 | undefined);
  91904. /**
  91905. * Will get a color picked randomly between color1 and color2.
  91906. * If color2 is undefined then color1 will be used
  91907. * @param result defines the target Color4 to store the result in
  91908. */
  91909. getColorToRef(result: Color4): void;
  91910. }
  91911. /** Class used to store color 3 gradient */
  91912. export class Color3Gradient implements IValueGradient {
  91913. /**
  91914. * Gets or sets the gradient value (between 0 and 1)
  91915. */
  91916. gradient: number;
  91917. /**
  91918. * Gets or sets the associated color
  91919. */
  91920. color: Color3;
  91921. /**
  91922. * Creates a new color3 gradient
  91923. * @param gradient gets or sets the gradient value (between 0 and 1)
  91924. * @param color gets or sets associated color
  91925. */
  91926. constructor(
  91927. /**
  91928. * Gets or sets the gradient value (between 0 and 1)
  91929. */
  91930. gradient: number,
  91931. /**
  91932. * Gets or sets the associated color
  91933. */
  91934. color: Color3);
  91935. }
  91936. /** Class used to store factor gradient */
  91937. export class FactorGradient implements IValueGradient {
  91938. /**
  91939. * Gets or sets the gradient value (between 0 and 1)
  91940. */
  91941. gradient: number;
  91942. /**
  91943. * Gets or sets first associated factor
  91944. */
  91945. factor1: number;
  91946. /**
  91947. * Gets or sets second associated factor
  91948. */
  91949. factor2?: number | undefined;
  91950. /**
  91951. * Creates a new factor gradient
  91952. * @param gradient gets or sets the gradient value (between 0 and 1)
  91953. * @param factor1 gets or sets first associated factor
  91954. * @param factor2 gets or sets second associated factor
  91955. */
  91956. constructor(
  91957. /**
  91958. * Gets or sets the gradient value (between 0 and 1)
  91959. */
  91960. gradient: number,
  91961. /**
  91962. * Gets or sets first associated factor
  91963. */
  91964. factor1: number,
  91965. /**
  91966. * Gets or sets second associated factor
  91967. */
  91968. factor2?: number | undefined);
  91969. /**
  91970. * Will get a number picked randomly between factor1 and factor2.
  91971. * If factor2 is undefined then factor1 will be used
  91972. * @returns the picked number
  91973. */
  91974. getFactor(): number;
  91975. }
  91976. /**
  91977. * Helper used to simplify some generic gradient tasks
  91978. */
  91979. export class GradientHelper {
  91980. /**
  91981. * Gets the current gradient from an array of IValueGradient
  91982. * @param ratio defines the current ratio to get
  91983. * @param gradients defines the array of IValueGradient
  91984. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91985. */
  91986. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91987. }
  91988. }
  91989. declare module BABYLON {
  91990. interface ThinEngine {
  91991. /**
  91992. * Creates a raw texture
  91993. * @param data defines the data to store in the texture
  91994. * @param width defines the width of the texture
  91995. * @param height defines the height of the texture
  91996. * @param format defines the format of the data
  91997. * @param generateMipMaps defines if the engine should generate the mip levels
  91998. * @param invertY defines if data must be stored with Y axis inverted
  91999. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  92000. * @param compression defines the compression used (null by default)
  92001. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92002. * @returns the raw texture inside an InternalTexture
  92003. */
  92004. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  92005. /**
  92006. * Update a raw texture
  92007. * @param texture defines the texture to update
  92008. * @param data defines the data to store in the texture
  92009. * @param format defines the format of the data
  92010. * @param invertY defines if data must be stored with Y axis inverted
  92011. */
  92012. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92013. /**
  92014. * Update a raw texture
  92015. * @param texture defines the texture to update
  92016. * @param data defines the data to store in the texture
  92017. * @param format defines the format of the data
  92018. * @param invertY defines if data must be stored with Y axis inverted
  92019. * @param compression defines the compression used (null by default)
  92020. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92021. */
  92022. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  92023. /**
  92024. * Creates a new raw cube texture
  92025. * @param data defines the array of data to use to create each face
  92026. * @param size defines the size of the textures
  92027. * @param format defines the format of the data
  92028. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92029. * @param generateMipMaps defines if the engine should generate the mip levels
  92030. * @param invertY defines if data must be stored with Y axis inverted
  92031. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92032. * @param compression defines the compression used (null by default)
  92033. * @returns the cube texture as an InternalTexture
  92034. */
  92035. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  92036. /**
  92037. * Update a raw cube texture
  92038. * @param texture defines the texture to udpdate
  92039. * @param data defines the data to store
  92040. * @param format defines the data format
  92041. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92042. * @param invertY defines if data must be stored with Y axis inverted
  92043. */
  92044. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  92045. /**
  92046. * Update a raw cube texture
  92047. * @param texture defines the texture to udpdate
  92048. * @param data defines the data to store
  92049. * @param format defines the data format
  92050. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92051. * @param invertY defines if data must be stored with Y axis inverted
  92052. * @param compression defines the compression used (null by default)
  92053. */
  92054. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  92055. /**
  92056. * Update a raw cube texture
  92057. * @param texture defines the texture to udpdate
  92058. * @param data defines the data to store
  92059. * @param format defines the data format
  92060. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92061. * @param invertY defines if data must be stored with Y axis inverted
  92062. * @param compression defines the compression used (null by default)
  92063. * @param level defines which level of the texture to update
  92064. */
  92065. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  92066. /**
  92067. * Creates a new raw cube texture from a specified url
  92068. * @param url defines the url where the data is located
  92069. * @param scene defines the current scene
  92070. * @param size defines the size of the textures
  92071. * @param format defines the format of the data
  92072. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92073. * @param noMipmap defines if the engine should avoid generating the mip levels
  92074. * @param callback defines a callback used to extract texture data from loaded data
  92075. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92076. * @param onLoad defines a callback called when texture is loaded
  92077. * @param onError defines a callback called if there is an error
  92078. * @returns the cube texture as an InternalTexture
  92079. */
  92080. 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;
  92081. /**
  92082. * Creates a new raw cube texture from a specified url
  92083. * @param url defines the url where the data is located
  92084. * @param scene defines the current scene
  92085. * @param size defines the size of the textures
  92086. * @param format defines the format of the data
  92087. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92088. * @param noMipmap defines if the engine should avoid generating the mip levels
  92089. * @param callback defines a callback used to extract texture data from loaded data
  92090. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92091. * @param onLoad defines a callback called when texture is loaded
  92092. * @param onError defines a callback called if there is an error
  92093. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92094. * @param invertY defines if data must be stored with Y axis inverted
  92095. * @returns the cube texture as an InternalTexture
  92096. */
  92097. 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;
  92098. /**
  92099. * Creates a new raw 3D texture
  92100. * @param data defines the data used to create the texture
  92101. * @param width defines the width of the texture
  92102. * @param height defines the height of the texture
  92103. * @param depth defines the depth of the texture
  92104. * @param format defines the format of the texture
  92105. * @param generateMipMaps defines if the engine must generate mip levels
  92106. * @param invertY defines if data must be stored with Y axis inverted
  92107. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92108. * @param compression defines the compressed used (can be null)
  92109. * @param textureType defines the compressed used (can be null)
  92110. * @returns a new raw 3D texture (stored in an InternalTexture)
  92111. */
  92112. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92113. /**
  92114. * Update a raw 3D texture
  92115. * @param texture defines the texture to update
  92116. * @param data defines the data to store
  92117. * @param format defines the data format
  92118. * @param invertY defines if data must be stored with Y axis inverted
  92119. */
  92120. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92121. /**
  92122. * Update a raw 3D texture
  92123. * @param texture defines the texture to update
  92124. * @param data defines the data to store
  92125. * @param format defines the data format
  92126. * @param invertY defines if data must be stored with Y axis inverted
  92127. * @param compression defines the used compression (can be null)
  92128. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92129. */
  92130. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92131. /**
  92132. * Creates a new raw 2D array texture
  92133. * @param data defines the data used to create the texture
  92134. * @param width defines the width of the texture
  92135. * @param height defines the height of the texture
  92136. * @param depth defines the number of layers of the texture
  92137. * @param format defines the format of the texture
  92138. * @param generateMipMaps defines if the engine must generate mip levels
  92139. * @param invertY defines if data must be stored with Y axis inverted
  92140. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92141. * @param compression defines the compressed used (can be null)
  92142. * @param textureType defines the compressed used (can be null)
  92143. * @returns a new raw 2D array texture (stored in an InternalTexture)
  92144. */
  92145. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92146. /**
  92147. * Update a raw 2D array texture
  92148. * @param texture defines the texture to update
  92149. * @param data defines the data to store
  92150. * @param format defines the data format
  92151. * @param invertY defines if data must be stored with Y axis inverted
  92152. */
  92153. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92154. /**
  92155. * Update a raw 2D array texture
  92156. * @param texture defines the texture to update
  92157. * @param data defines the data to store
  92158. * @param format defines the data format
  92159. * @param invertY defines if data must be stored with Y axis inverted
  92160. * @param compression defines the used compression (can be null)
  92161. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92162. */
  92163. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92164. }
  92165. }
  92166. declare module BABYLON {
  92167. /**
  92168. * Raw texture can help creating a texture directly from an array of data.
  92169. * This can be super useful if you either get the data from an uncompressed source or
  92170. * if you wish to create your texture pixel by pixel.
  92171. */
  92172. export class RawTexture extends Texture {
  92173. /**
  92174. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92175. */
  92176. format: number;
  92177. /**
  92178. * Instantiates a new RawTexture.
  92179. * Raw texture can help creating a texture directly from an array of data.
  92180. * This can be super useful if you either get the data from an uncompressed source or
  92181. * if you wish to create your texture pixel by pixel.
  92182. * @param data define the array of data to use to create the texture
  92183. * @param width define the width of the texture
  92184. * @param height define the height of the texture
  92185. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92186. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92187. * @param generateMipMaps define whether mip maps should be generated or not
  92188. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92189. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92190. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92191. */
  92192. constructor(data: ArrayBufferView, width: number, height: number,
  92193. /**
  92194. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92195. */
  92196. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  92197. /**
  92198. * Updates the texture underlying data.
  92199. * @param data Define the new data of the texture
  92200. */
  92201. update(data: ArrayBufferView): void;
  92202. /**
  92203. * Creates a luminance texture from some data.
  92204. * @param data Define the texture data
  92205. * @param width Define the width of the texture
  92206. * @param height Define the height of the texture
  92207. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92208. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92209. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92210. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92211. * @returns the luminance texture
  92212. */
  92213. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92214. /**
  92215. * Creates a luminance alpha texture from some data.
  92216. * @param data Define the texture data
  92217. * @param width Define the width of the texture
  92218. * @param height Define the height of the texture
  92219. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92220. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92221. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92222. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92223. * @returns the luminance alpha texture
  92224. */
  92225. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92226. /**
  92227. * Creates an alpha texture from some data.
  92228. * @param data Define the texture data
  92229. * @param width Define the width of the texture
  92230. * @param height Define the height of the texture
  92231. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92232. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92233. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92234. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92235. * @returns the alpha texture
  92236. */
  92237. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92238. /**
  92239. * Creates a RGB texture from some data.
  92240. * @param data Define the texture data
  92241. * @param width Define the width of the texture
  92242. * @param height Define the height of the texture
  92243. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92244. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92245. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92246. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92247. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92248. * @returns the RGB alpha texture
  92249. */
  92250. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92251. /**
  92252. * Creates a RGBA texture from some data.
  92253. * @param data Define the texture data
  92254. * @param width Define the width of the texture
  92255. * @param height Define the height of the texture
  92256. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92257. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92258. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92259. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92260. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92261. * @returns the RGBA texture
  92262. */
  92263. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92264. /**
  92265. * Creates a R texture from some data.
  92266. * @param data Define the texture data
  92267. * @param width Define the width of the texture
  92268. * @param height Define the height of the texture
  92269. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92270. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92271. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92272. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92273. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92274. * @returns the R texture
  92275. */
  92276. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92277. }
  92278. }
  92279. declare module BABYLON {
  92280. interface ThinEngine {
  92281. /**
  92282. * Update a dynamic index buffer
  92283. * @param indexBuffer defines the target index buffer
  92284. * @param indices defines the data to update
  92285. * @param offset defines the offset in the target index buffer where update should start
  92286. */
  92287. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  92288. /**
  92289. * Updates a dynamic vertex buffer.
  92290. * @param vertexBuffer the vertex buffer to update
  92291. * @param data the data used to update the vertex buffer
  92292. * @param byteOffset the byte offset of the data
  92293. * @param byteLength the byte length of the data
  92294. */
  92295. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  92296. }
  92297. }
  92298. declare module BABYLON {
  92299. interface AbstractScene {
  92300. /**
  92301. * The list of procedural textures added to the scene
  92302. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92303. */
  92304. proceduralTextures: Array<ProceduralTexture>;
  92305. }
  92306. /**
  92307. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  92308. * in a given scene.
  92309. */
  92310. export class ProceduralTextureSceneComponent implements ISceneComponent {
  92311. /**
  92312. * The component name helpfull to identify the component in the list of scene components.
  92313. */
  92314. readonly name: string;
  92315. /**
  92316. * The scene the component belongs to.
  92317. */
  92318. scene: Scene;
  92319. /**
  92320. * Creates a new instance of the component for the given scene
  92321. * @param scene Defines the scene to register the component in
  92322. */
  92323. constructor(scene: Scene);
  92324. /**
  92325. * Registers the component in a given scene
  92326. */
  92327. register(): void;
  92328. /**
  92329. * Rebuilds the elements related to this component in case of
  92330. * context lost for instance.
  92331. */
  92332. rebuild(): void;
  92333. /**
  92334. * Disposes the component and the associated ressources.
  92335. */
  92336. dispose(): void;
  92337. private _beforeClear;
  92338. }
  92339. }
  92340. declare module BABYLON {
  92341. interface ThinEngine {
  92342. /**
  92343. * Creates a new render target cube texture
  92344. * @param size defines the size of the texture
  92345. * @param options defines the options used to create the texture
  92346. * @returns a new render target cube texture stored in an InternalTexture
  92347. */
  92348. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  92349. }
  92350. }
  92351. declare module BABYLON {
  92352. /** @hidden */
  92353. export var proceduralVertexShader: {
  92354. name: string;
  92355. shader: string;
  92356. };
  92357. }
  92358. declare module BABYLON {
  92359. /**
  92360. * 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.
  92361. * This is the base class of any Procedural texture and contains most of the shareable code.
  92362. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92363. */
  92364. export class ProceduralTexture extends Texture {
  92365. /**
  92366. * Define if the texture is enabled or not (disabled texture will not render)
  92367. */
  92368. isEnabled: boolean;
  92369. /**
  92370. * Define if the texture must be cleared before rendering (default is true)
  92371. */
  92372. autoClear: boolean;
  92373. /**
  92374. * Callback called when the texture is generated
  92375. */
  92376. onGenerated: () => void;
  92377. /**
  92378. * Event raised when the texture is generated
  92379. */
  92380. onGeneratedObservable: Observable<ProceduralTexture>;
  92381. /**
  92382. * Event raised before the texture is generated
  92383. */
  92384. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92385. /**
  92386. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92387. */
  92388. nodeMaterialSource: Nullable<NodeMaterial>;
  92389. /** @hidden */
  92390. _generateMipMaps: boolean;
  92391. /** @hidden **/
  92392. _effect: Effect;
  92393. /** @hidden */
  92394. _textures: {
  92395. [key: string]: Texture;
  92396. };
  92397. /** @hidden */
  92398. protected _fallbackTexture: Nullable<Texture>;
  92399. private _size;
  92400. private _currentRefreshId;
  92401. private _frameId;
  92402. private _refreshRate;
  92403. private _vertexBuffers;
  92404. private _indexBuffer;
  92405. private _uniforms;
  92406. private _samplers;
  92407. private _fragment;
  92408. private _floats;
  92409. private _ints;
  92410. private _floatsArrays;
  92411. private _colors3;
  92412. private _colors4;
  92413. private _vectors2;
  92414. private _vectors3;
  92415. private _matrices;
  92416. private _fallbackTextureUsed;
  92417. private _fullEngine;
  92418. private _cachedDefines;
  92419. private _contentUpdateId;
  92420. private _contentData;
  92421. /**
  92422. * Instantiates a new procedural texture.
  92423. * 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.
  92424. * This is the base class of any Procedural texture and contains most of the shareable code.
  92425. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92426. * @param name Define the name of the texture
  92427. * @param size Define the size of the texture to create
  92428. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92429. * @param scene Define the scene the texture belongs to
  92430. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92431. * @param generateMipMaps Define if the texture should creates mip maps or not
  92432. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92433. * @param textureType The FBO internal texture type
  92434. */
  92435. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  92436. /**
  92437. * The effect that is created when initializing the post process.
  92438. * @returns The created effect corresponding the the postprocess.
  92439. */
  92440. getEffect(): Effect;
  92441. /**
  92442. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92443. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92444. */
  92445. getContent(): Nullable<ArrayBufferView>;
  92446. private _createIndexBuffer;
  92447. /** @hidden */
  92448. _rebuild(): void;
  92449. /**
  92450. * Resets the texture in order to recreate its associated resources.
  92451. * This can be called in case of context loss
  92452. */
  92453. reset(): void;
  92454. protected _getDefines(): string;
  92455. /**
  92456. * Is the texture ready to be used ? (rendered at least once)
  92457. * @returns true if ready, otherwise, false.
  92458. */
  92459. isReady(): boolean;
  92460. /**
  92461. * Resets the refresh counter of the texture and start bak from scratch.
  92462. * Could be useful to regenerate the texture if it is setup to render only once.
  92463. */
  92464. resetRefreshCounter(): void;
  92465. /**
  92466. * Set the fragment shader to use in order to render the texture.
  92467. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92468. */
  92469. setFragment(fragment: any): void;
  92470. /**
  92471. * Define the refresh rate of the texture or the rendering frequency.
  92472. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92473. */
  92474. get refreshRate(): number;
  92475. set refreshRate(value: number);
  92476. /** @hidden */
  92477. _shouldRender(): boolean;
  92478. /**
  92479. * Get the size the texture is rendering at.
  92480. * @returns the size (on cube texture it is always squared)
  92481. */
  92482. getRenderSize(): RenderTargetTextureSize;
  92483. /**
  92484. * Resize the texture to new value.
  92485. * @param size Define the new size the texture should have
  92486. * @param generateMipMaps Define whether the new texture should create mip maps
  92487. */
  92488. resize(size: number, generateMipMaps: boolean): void;
  92489. private _checkUniform;
  92490. /**
  92491. * Set a texture in the shader program used to render.
  92492. * @param name Define the name of the uniform samplers as defined in the shader
  92493. * @param texture Define the texture to bind to this sampler
  92494. * @return the texture itself allowing "fluent" like uniform updates
  92495. */
  92496. setTexture(name: string, texture: Texture): ProceduralTexture;
  92497. /**
  92498. * Set a float in the shader.
  92499. * @param name Define the name of the uniform as defined in the shader
  92500. * @param value Define the value to give to the uniform
  92501. * @return the texture itself allowing "fluent" like uniform updates
  92502. */
  92503. setFloat(name: string, value: number): ProceduralTexture;
  92504. /**
  92505. * Set a int in the shader.
  92506. * @param name Define the name of the uniform as defined in the shader
  92507. * @param value Define the value to give to the uniform
  92508. * @return the texture itself allowing "fluent" like uniform updates
  92509. */
  92510. setInt(name: string, value: number): ProceduralTexture;
  92511. /**
  92512. * Set an array of floats in the shader.
  92513. * @param name Define the name of the uniform as defined in the shader
  92514. * @param value Define the value to give to the uniform
  92515. * @return the texture itself allowing "fluent" like uniform updates
  92516. */
  92517. setFloats(name: string, value: number[]): ProceduralTexture;
  92518. /**
  92519. * Set a vec3 in the shader from a Color3.
  92520. * @param name Define the name of the uniform as defined in the shader
  92521. * @param value Define the value to give to the uniform
  92522. * @return the texture itself allowing "fluent" like uniform updates
  92523. */
  92524. setColor3(name: string, value: Color3): ProceduralTexture;
  92525. /**
  92526. * Set a vec4 in the shader from a Color4.
  92527. * @param name Define the name of the uniform as defined in the shader
  92528. * @param value Define the value to give to the uniform
  92529. * @return the texture itself allowing "fluent" like uniform updates
  92530. */
  92531. setColor4(name: string, value: Color4): ProceduralTexture;
  92532. /**
  92533. * Set a vec2 in the shader from a Vector2.
  92534. * @param name Define the name of the uniform as defined in the shader
  92535. * @param value Define the value to give to the uniform
  92536. * @return the texture itself allowing "fluent" like uniform updates
  92537. */
  92538. setVector2(name: string, value: Vector2): ProceduralTexture;
  92539. /**
  92540. * Set a vec3 in the shader from a Vector3.
  92541. * @param name Define the name of the uniform as defined in the shader
  92542. * @param value Define the value to give to the uniform
  92543. * @return the texture itself allowing "fluent" like uniform updates
  92544. */
  92545. setVector3(name: string, value: Vector3): ProceduralTexture;
  92546. /**
  92547. * Set a mat4 in the shader from a MAtrix.
  92548. * @param name Define the name of the uniform as defined in the shader
  92549. * @param value Define the value to give to the uniform
  92550. * @return the texture itself allowing "fluent" like uniform updates
  92551. */
  92552. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92553. /**
  92554. * Render the texture to its associated render target.
  92555. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92556. */
  92557. render(useCameraPostProcess?: boolean): void;
  92558. /**
  92559. * Clone the texture.
  92560. * @returns the cloned texture
  92561. */
  92562. clone(): ProceduralTexture;
  92563. /**
  92564. * Dispose the texture and release its asoociated resources.
  92565. */
  92566. dispose(): void;
  92567. }
  92568. }
  92569. declare module BABYLON {
  92570. /**
  92571. * This represents the base class for particle system in Babylon.
  92572. * 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.
  92573. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92574. * @example https://doc.babylonjs.com/babylon101/particles
  92575. */
  92576. export class BaseParticleSystem {
  92577. /**
  92578. * Source color is added to the destination color without alpha affecting the result
  92579. */
  92580. static BLENDMODE_ONEONE: number;
  92581. /**
  92582. * Blend current color and particle color using particle’s alpha
  92583. */
  92584. static BLENDMODE_STANDARD: number;
  92585. /**
  92586. * Add current color and particle color multiplied by particle’s alpha
  92587. */
  92588. static BLENDMODE_ADD: number;
  92589. /**
  92590. * Multiply current color with particle color
  92591. */
  92592. static BLENDMODE_MULTIPLY: number;
  92593. /**
  92594. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92595. */
  92596. static BLENDMODE_MULTIPLYADD: number;
  92597. /**
  92598. * List of animations used by the particle system.
  92599. */
  92600. animations: Animation[];
  92601. /**
  92602. * Gets or sets the unique id of the particle system
  92603. */
  92604. uniqueId: number;
  92605. /**
  92606. * The id of the Particle system.
  92607. */
  92608. id: string;
  92609. /**
  92610. * The friendly name of the Particle system.
  92611. */
  92612. name: string;
  92613. /**
  92614. * Snippet ID if the particle system was created from the snippet server
  92615. */
  92616. snippetId: string;
  92617. /**
  92618. * The rendering group used by the Particle system to chose when to render.
  92619. */
  92620. renderingGroupId: number;
  92621. /**
  92622. * The emitter represents the Mesh or position we are attaching the particle system to.
  92623. */
  92624. emitter: Nullable<AbstractMesh | Vector3>;
  92625. /**
  92626. * The maximum number of particles to emit per frame
  92627. */
  92628. emitRate: number;
  92629. /**
  92630. * If you want to launch only a few particles at once, that can be done, as well.
  92631. */
  92632. manualEmitCount: number;
  92633. /**
  92634. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92635. */
  92636. updateSpeed: number;
  92637. /**
  92638. * The amount of time the particle system is running (depends of the overall update speed).
  92639. */
  92640. targetStopDuration: number;
  92641. /**
  92642. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92643. */
  92644. disposeOnStop: boolean;
  92645. /**
  92646. * Minimum power of emitting particles.
  92647. */
  92648. minEmitPower: number;
  92649. /**
  92650. * Maximum power of emitting particles.
  92651. */
  92652. maxEmitPower: number;
  92653. /**
  92654. * Minimum life time of emitting particles.
  92655. */
  92656. minLifeTime: number;
  92657. /**
  92658. * Maximum life time of emitting particles.
  92659. */
  92660. maxLifeTime: number;
  92661. /**
  92662. * Minimum Size of emitting particles.
  92663. */
  92664. minSize: number;
  92665. /**
  92666. * Maximum Size of emitting particles.
  92667. */
  92668. maxSize: number;
  92669. /**
  92670. * Minimum scale of emitting particles on X axis.
  92671. */
  92672. minScaleX: number;
  92673. /**
  92674. * Maximum scale of emitting particles on X axis.
  92675. */
  92676. maxScaleX: number;
  92677. /**
  92678. * Minimum scale of emitting particles on Y axis.
  92679. */
  92680. minScaleY: number;
  92681. /**
  92682. * Maximum scale of emitting particles on Y axis.
  92683. */
  92684. maxScaleY: number;
  92685. /**
  92686. * Gets or sets the minimal initial rotation in radians.
  92687. */
  92688. minInitialRotation: number;
  92689. /**
  92690. * Gets or sets the maximal initial rotation in radians.
  92691. */
  92692. maxInitialRotation: number;
  92693. /**
  92694. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92695. */
  92696. minAngularSpeed: number;
  92697. /**
  92698. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92699. */
  92700. maxAngularSpeed: number;
  92701. /**
  92702. * The texture used to render each particle. (this can be a spritesheet)
  92703. */
  92704. particleTexture: Nullable<BaseTexture>;
  92705. /**
  92706. * The layer mask we are rendering the particles through.
  92707. */
  92708. layerMask: number;
  92709. /**
  92710. * This can help using your own shader to render the particle system.
  92711. * The according effect will be created
  92712. */
  92713. customShader: any;
  92714. /**
  92715. * By default particle system starts as soon as they are created. This prevents the
  92716. * automatic start to happen and let you decide when to start emitting particles.
  92717. */
  92718. preventAutoStart: boolean;
  92719. private _noiseTexture;
  92720. /**
  92721. * Gets or sets a texture used to add random noise to particle positions
  92722. */
  92723. get noiseTexture(): Nullable<ProceduralTexture>;
  92724. set noiseTexture(value: Nullable<ProceduralTexture>);
  92725. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92726. noiseStrength: Vector3;
  92727. /**
  92728. * Callback triggered when the particle animation is ending.
  92729. */
  92730. onAnimationEnd: Nullable<() => void>;
  92731. /**
  92732. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92733. */
  92734. blendMode: number;
  92735. /**
  92736. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92737. * to override the particles.
  92738. */
  92739. forceDepthWrite: boolean;
  92740. /** 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 */
  92741. preWarmCycles: number;
  92742. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92743. preWarmStepOffset: number;
  92744. /**
  92745. * 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)
  92746. */
  92747. spriteCellChangeSpeed: number;
  92748. /**
  92749. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92750. */
  92751. startSpriteCellID: number;
  92752. /**
  92753. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92754. */
  92755. endSpriteCellID: number;
  92756. /**
  92757. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92758. */
  92759. spriteCellWidth: number;
  92760. /**
  92761. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92762. */
  92763. spriteCellHeight: number;
  92764. /**
  92765. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92766. */
  92767. spriteRandomStartCell: boolean;
  92768. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92769. translationPivot: Vector2;
  92770. /** @hidden */
  92771. protected _isAnimationSheetEnabled: boolean;
  92772. /**
  92773. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92774. */
  92775. beginAnimationOnStart: boolean;
  92776. /**
  92777. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92778. */
  92779. beginAnimationFrom: number;
  92780. /**
  92781. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92782. */
  92783. beginAnimationTo: number;
  92784. /**
  92785. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92786. */
  92787. beginAnimationLoop: boolean;
  92788. /**
  92789. * Gets or sets a world offset applied to all particles
  92790. */
  92791. worldOffset: Vector3;
  92792. /**
  92793. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92794. */
  92795. get isAnimationSheetEnabled(): boolean;
  92796. set isAnimationSheetEnabled(value: boolean);
  92797. /**
  92798. * Get hosting scene
  92799. * @returns the scene
  92800. */
  92801. getScene(): Nullable<Scene>;
  92802. /**
  92803. * You can use gravity if you want to give an orientation to your particles.
  92804. */
  92805. gravity: Vector3;
  92806. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92807. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92808. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92809. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92810. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92811. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92812. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92813. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92814. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92815. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92816. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92817. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92818. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92819. /**
  92820. * Defines the delay in milliseconds before starting the system (0 by default)
  92821. */
  92822. startDelay: number;
  92823. /**
  92824. * Gets the current list of drag gradients.
  92825. * You must use addDragGradient and removeDragGradient to udpate this list
  92826. * @returns the list of drag gradients
  92827. */
  92828. getDragGradients(): Nullable<Array<FactorGradient>>;
  92829. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92830. limitVelocityDamping: number;
  92831. /**
  92832. * Gets the current list of limit velocity gradients.
  92833. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92834. * @returns the list of limit velocity gradients
  92835. */
  92836. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92837. /**
  92838. * Gets the current list of color gradients.
  92839. * You must use addColorGradient and removeColorGradient to udpate this list
  92840. * @returns the list of color gradients
  92841. */
  92842. getColorGradients(): Nullable<Array<ColorGradient>>;
  92843. /**
  92844. * Gets the current list of size gradients.
  92845. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92846. * @returns the list of size gradients
  92847. */
  92848. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92849. /**
  92850. * Gets the current list of color remap gradients.
  92851. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92852. * @returns the list of color remap gradients
  92853. */
  92854. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92855. /**
  92856. * Gets the current list of alpha remap gradients.
  92857. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92858. * @returns the list of alpha remap gradients
  92859. */
  92860. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92861. /**
  92862. * Gets the current list of life time gradients.
  92863. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92864. * @returns the list of life time gradients
  92865. */
  92866. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92867. /**
  92868. * Gets the current list of angular speed gradients.
  92869. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92870. * @returns the list of angular speed gradients
  92871. */
  92872. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92873. /**
  92874. * Gets the current list of velocity gradients.
  92875. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92876. * @returns the list of velocity gradients
  92877. */
  92878. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92879. /**
  92880. * Gets the current list of start size gradients.
  92881. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92882. * @returns the list of start size gradients
  92883. */
  92884. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92885. /**
  92886. * Gets the current list of emit rate gradients.
  92887. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92888. * @returns the list of emit rate gradients
  92889. */
  92890. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92891. /**
  92892. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92893. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92894. */
  92895. get direction1(): Vector3;
  92896. set direction1(value: Vector3);
  92897. /**
  92898. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92899. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92900. */
  92901. get direction2(): Vector3;
  92902. set direction2(value: Vector3);
  92903. /**
  92904. * 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.
  92905. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92906. */
  92907. get minEmitBox(): Vector3;
  92908. set minEmitBox(value: Vector3);
  92909. /**
  92910. * 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.
  92911. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92912. */
  92913. get maxEmitBox(): Vector3;
  92914. set maxEmitBox(value: Vector3);
  92915. /**
  92916. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92917. */
  92918. color1: Color4;
  92919. /**
  92920. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92921. */
  92922. color2: Color4;
  92923. /**
  92924. * Color the particle will have at the end of its lifetime
  92925. */
  92926. colorDead: Color4;
  92927. /**
  92928. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92929. */
  92930. textureMask: Color4;
  92931. /**
  92932. * The particle emitter type defines the emitter used by the particle system.
  92933. * It can be for example box, sphere, or cone...
  92934. */
  92935. particleEmitterType: IParticleEmitterType;
  92936. /** @hidden */
  92937. _isSubEmitter: boolean;
  92938. /**
  92939. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92940. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92941. */
  92942. billboardMode: number;
  92943. protected _isBillboardBased: boolean;
  92944. /**
  92945. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92946. */
  92947. get isBillboardBased(): boolean;
  92948. set isBillboardBased(value: boolean);
  92949. /**
  92950. * The scene the particle system belongs to.
  92951. */
  92952. protected _scene: Nullable<Scene>;
  92953. /**
  92954. * The engine the particle system belongs to.
  92955. */
  92956. protected _engine: ThinEngine;
  92957. /**
  92958. * Local cache of defines for image processing.
  92959. */
  92960. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92961. /**
  92962. * Default configuration related to image processing available in the standard Material.
  92963. */
  92964. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92965. /**
  92966. * Gets the image processing configuration used either in this material.
  92967. */
  92968. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92969. /**
  92970. * Sets the Default image processing configuration used either in the this material.
  92971. *
  92972. * If sets to null, the scene one is in use.
  92973. */
  92974. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92975. /**
  92976. * Attaches a new image processing configuration to the Standard Material.
  92977. * @param configuration
  92978. */
  92979. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  92980. /** @hidden */
  92981. protected _reset(): void;
  92982. /** @hidden */
  92983. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  92984. /**
  92985. * Instantiates a particle system.
  92986. * 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.
  92987. * @param name The name of the particle system
  92988. */
  92989. constructor(name: string);
  92990. /**
  92991. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92992. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92993. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92994. * @returns the emitter
  92995. */
  92996. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92997. /**
  92998. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92999. * @param radius The radius of the hemisphere to emit from
  93000. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93001. * @returns the emitter
  93002. */
  93003. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  93004. /**
  93005. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93006. * @param radius The radius of the sphere to emit from
  93007. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93008. * @returns the emitter
  93009. */
  93010. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  93011. /**
  93012. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93013. * @param radius The radius of the sphere to emit from
  93014. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93015. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93016. * @returns the emitter
  93017. */
  93018. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  93019. /**
  93020. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93021. * @param radius The radius of the emission cylinder
  93022. * @param height The height of the emission cylinder
  93023. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93024. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93025. * @returns the emitter
  93026. */
  93027. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  93028. /**
  93029. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93030. * @param radius The radius of the cylinder to emit from
  93031. * @param height The height of the emission cylinder
  93032. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93033. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93034. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93035. * @returns the emitter
  93036. */
  93037. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  93038. /**
  93039. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93040. * @param radius The radius of the cone to emit from
  93041. * @param angle The base angle of the cone
  93042. * @returns the emitter
  93043. */
  93044. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  93045. /**
  93046. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93047. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93048. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93049. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93050. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93051. * @returns the emitter
  93052. */
  93053. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93054. }
  93055. }
  93056. declare module BABYLON {
  93057. /**
  93058. * Type of sub emitter
  93059. */
  93060. export enum SubEmitterType {
  93061. /**
  93062. * Attached to the particle over it's lifetime
  93063. */
  93064. ATTACHED = 0,
  93065. /**
  93066. * Created when the particle dies
  93067. */
  93068. END = 1
  93069. }
  93070. /**
  93071. * Sub emitter class used to emit particles from an existing particle
  93072. */
  93073. export class SubEmitter {
  93074. /**
  93075. * the particle system to be used by the sub emitter
  93076. */
  93077. particleSystem: ParticleSystem;
  93078. /**
  93079. * Type of the submitter (Default: END)
  93080. */
  93081. type: SubEmitterType;
  93082. /**
  93083. * 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)
  93084. * Note: This only is supported when using an emitter of type Mesh
  93085. */
  93086. inheritDirection: boolean;
  93087. /**
  93088. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  93089. */
  93090. inheritedVelocityAmount: number;
  93091. /**
  93092. * Creates a sub emitter
  93093. * @param particleSystem the particle system to be used by the sub emitter
  93094. */
  93095. constructor(
  93096. /**
  93097. * the particle system to be used by the sub emitter
  93098. */
  93099. particleSystem: ParticleSystem);
  93100. /**
  93101. * Clones the sub emitter
  93102. * @returns the cloned sub emitter
  93103. */
  93104. clone(): SubEmitter;
  93105. /**
  93106. * Serialize current object to a JSON object
  93107. * @returns the serialized object
  93108. */
  93109. serialize(): any;
  93110. /** @hidden */
  93111. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  93112. /**
  93113. * Creates a new SubEmitter from a serialized JSON version
  93114. * @param serializationObject defines the JSON object to read from
  93115. * @param sceneOrEngine defines the hosting scene or the hosting engine
  93116. * @param rootUrl defines the rootUrl for data loading
  93117. * @returns a new SubEmitter
  93118. */
  93119. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  93120. /** Release associated resources */
  93121. dispose(): void;
  93122. }
  93123. }
  93124. declare module BABYLON {
  93125. /** @hidden */
  93126. export var imageProcessingDeclaration: {
  93127. name: string;
  93128. shader: string;
  93129. };
  93130. }
  93131. declare module BABYLON {
  93132. /** @hidden */
  93133. export var imageProcessingFunctions: {
  93134. name: string;
  93135. shader: string;
  93136. };
  93137. }
  93138. declare module BABYLON {
  93139. /** @hidden */
  93140. export var particlesPixelShader: {
  93141. name: string;
  93142. shader: string;
  93143. };
  93144. }
  93145. declare module BABYLON {
  93146. /** @hidden */
  93147. export var particlesVertexShader: {
  93148. name: string;
  93149. shader: string;
  93150. };
  93151. }
  93152. declare module BABYLON {
  93153. /**
  93154. * Interface used to define entities containing multiple clip planes
  93155. */
  93156. export interface IClipPlanesHolder {
  93157. /**
  93158. * Gets or sets the active clipplane 1
  93159. */
  93160. clipPlane: Nullable<Plane>;
  93161. /**
  93162. * Gets or sets the active clipplane 2
  93163. */
  93164. clipPlane2: Nullable<Plane>;
  93165. /**
  93166. * Gets or sets the active clipplane 3
  93167. */
  93168. clipPlane3: Nullable<Plane>;
  93169. /**
  93170. * Gets or sets the active clipplane 4
  93171. */
  93172. clipPlane4: Nullable<Plane>;
  93173. /**
  93174. * Gets or sets the active clipplane 5
  93175. */
  93176. clipPlane5: Nullable<Plane>;
  93177. /**
  93178. * Gets or sets the active clipplane 6
  93179. */
  93180. clipPlane6: Nullable<Plane>;
  93181. }
  93182. }
  93183. declare module BABYLON {
  93184. /**
  93185. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  93186. *
  93187. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  93188. *
  93189. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  93190. */
  93191. export class ThinMaterialHelper {
  93192. /**
  93193. * Binds the clip plane information from the holder to the effect.
  93194. * @param effect The effect we are binding the data to
  93195. * @param holder The entity containing the clip plane information
  93196. */
  93197. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  93198. }
  93199. }
  93200. declare module BABYLON {
  93201. interface ThinEngine {
  93202. /**
  93203. * Sets alpha constants used by some alpha blending modes
  93204. * @param r defines the red component
  93205. * @param g defines the green component
  93206. * @param b defines the blue component
  93207. * @param a defines the alpha component
  93208. */
  93209. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  93210. /**
  93211. * Sets the current alpha mode
  93212. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  93213. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  93214. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93215. */
  93216. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  93217. /**
  93218. * Gets the current alpha mode
  93219. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93220. * @returns the current alpha mode
  93221. */
  93222. getAlphaMode(): number;
  93223. /**
  93224. * Sets the current alpha equation
  93225. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  93226. */
  93227. setAlphaEquation(equation: number): void;
  93228. /**
  93229. * Gets the current alpha equation.
  93230. * @returns the current alpha equation
  93231. */
  93232. getAlphaEquation(): number;
  93233. }
  93234. }
  93235. declare module BABYLON {
  93236. /**
  93237. * This represents a particle system in Babylon.
  93238. * 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.
  93239. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93240. * @example https://doc.babylonjs.com/babylon101/particles
  93241. */
  93242. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  93243. /**
  93244. * Billboard mode will only apply to Y axis
  93245. */
  93246. static readonly BILLBOARDMODE_Y: number;
  93247. /**
  93248. * Billboard mode will apply to all axes
  93249. */
  93250. static readonly BILLBOARDMODE_ALL: number;
  93251. /**
  93252. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  93253. */
  93254. static readonly BILLBOARDMODE_STRETCHED: number;
  93255. /**
  93256. * This function can be defined to provide custom update for active particles.
  93257. * This function will be called instead of regular update (age, position, color, etc.).
  93258. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  93259. */
  93260. updateFunction: (particles: Particle[]) => void;
  93261. private _emitterWorldMatrix;
  93262. /**
  93263. * This function can be defined to specify initial direction for every new particle.
  93264. * It by default use the emitterType defined function
  93265. */
  93266. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93267. /**
  93268. * This function can be defined to specify initial position for every new particle.
  93269. * It by default use the emitterType defined function
  93270. */
  93271. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93272. /**
  93273. * @hidden
  93274. */
  93275. _inheritedVelocityOffset: Vector3;
  93276. /**
  93277. * An event triggered when the system is disposed
  93278. */
  93279. onDisposeObservable: Observable<IParticleSystem>;
  93280. /**
  93281. * An event triggered when the system is stopped
  93282. */
  93283. onStoppedObservable: Observable<IParticleSystem>;
  93284. private _onDisposeObserver;
  93285. /**
  93286. * Sets a callback that will be triggered when the system is disposed
  93287. */
  93288. set onDispose(callback: () => void);
  93289. private _particles;
  93290. private _epsilon;
  93291. private _capacity;
  93292. private _stockParticles;
  93293. private _newPartsExcess;
  93294. private _vertexData;
  93295. private _vertexBuffer;
  93296. private _vertexBuffers;
  93297. private _spriteBuffer;
  93298. private _indexBuffer;
  93299. private _effect;
  93300. private _customEffect;
  93301. private _cachedDefines;
  93302. private _scaledColorStep;
  93303. private _colorDiff;
  93304. private _scaledDirection;
  93305. private _scaledGravity;
  93306. private _currentRenderId;
  93307. private _alive;
  93308. private _useInstancing;
  93309. private _started;
  93310. private _stopped;
  93311. private _actualFrame;
  93312. private _scaledUpdateSpeed;
  93313. private _vertexBufferSize;
  93314. /** @hidden */
  93315. _currentEmitRateGradient: Nullable<FactorGradient>;
  93316. /** @hidden */
  93317. _currentEmitRate1: number;
  93318. /** @hidden */
  93319. _currentEmitRate2: number;
  93320. /** @hidden */
  93321. _currentStartSizeGradient: Nullable<FactorGradient>;
  93322. /** @hidden */
  93323. _currentStartSize1: number;
  93324. /** @hidden */
  93325. _currentStartSize2: number;
  93326. private readonly _rawTextureWidth;
  93327. private _rampGradientsTexture;
  93328. private _useRampGradients;
  93329. /** Gets or sets a matrix to use to compute projection */
  93330. defaultProjectionMatrix: Matrix;
  93331. /** Gets or sets a matrix to use to compute view */
  93332. defaultViewMatrix: Matrix;
  93333. /** Gets or sets a boolean indicating that ramp gradients must be used
  93334. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93335. */
  93336. get useRampGradients(): boolean;
  93337. set useRampGradients(value: boolean);
  93338. /**
  93339. * 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.
  93340. * 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: [])
  93341. */
  93342. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  93343. private _subEmitters;
  93344. /**
  93345. * @hidden
  93346. * If the particle systems emitter should be disposed when the particle system is disposed
  93347. */
  93348. _disposeEmitterOnDispose: boolean;
  93349. /**
  93350. * The current active Sub-systems, this property is used by the root particle system only.
  93351. */
  93352. activeSubSystems: Array<ParticleSystem>;
  93353. /**
  93354. * Specifies if the particles are updated in emitter local space or world space
  93355. */
  93356. isLocal: boolean;
  93357. private _rootParticleSystem;
  93358. /**
  93359. * Gets the current list of active particles
  93360. */
  93361. get particles(): Particle[];
  93362. /**
  93363. * Gets the number of particles active at the same time.
  93364. * @returns The number of active particles.
  93365. */
  93366. getActiveCount(): number;
  93367. /**
  93368. * Returns the string "ParticleSystem"
  93369. * @returns a string containing the class name
  93370. */
  93371. getClassName(): string;
  93372. /**
  93373. * Gets a boolean indicating that the system is stopping
  93374. * @returns true if the system is currently stopping
  93375. */
  93376. isStopping(): boolean;
  93377. /**
  93378. * Gets the custom effect used to render the particles
  93379. * @param blendMode Blend mode for which the effect should be retrieved
  93380. * @returns The effect
  93381. */
  93382. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93383. /**
  93384. * Sets the custom effect used to render the particles
  93385. * @param effect The effect to set
  93386. * @param blendMode Blend mode for which the effect should be set
  93387. */
  93388. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93389. /** @hidden */
  93390. private _onBeforeDrawParticlesObservable;
  93391. /**
  93392. * Observable that will be called just before the particles are drawn
  93393. */
  93394. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93395. /**
  93396. * Gets the name of the particle vertex shader
  93397. */
  93398. get vertexShaderName(): string;
  93399. /**
  93400. * Instantiates a particle system.
  93401. * 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.
  93402. * @param name The name of the particle system
  93403. * @param capacity The max number of particles alive at the same time
  93404. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93405. * @param customEffect a custom effect used to change the way particles are rendered by default
  93406. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93407. * @param epsilon Offset used to render the particles
  93408. */
  93409. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93410. private _addFactorGradient;
  93411. private _removeFactorGradient;
  93412. /**
  93413. * Adds a new life time gradient
  93414. * @param gradient defines the gradient to use (between 0 and 1)
  93415. * @param factor defines the life time factor to affect to the specified gradient
  93416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93417. * @returns the current particle system
  93418. */
  93419. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93420. /**
  93421. * Remove a specific life time gradient
  93422. * @param gradient defines the gradient to remove
  93423. * @returns the current particle system
  93424. */
  93425. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93426. /**
  93427. * Adds a new size gradient
  93428. * @param gradient defines the gradient to use (between 0 and 1)
  93429. * @param factor defines the size factor to affect to the specified gradient
  93430. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93431. * @returns the current particle system
  93432. */
  93433. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93434. /**
  93435. * Remove a specific size gradient
  93436. * @param gradient defines the gradient to remove
  93437. * @returns the current particle system
  93438. */
  93439. removeSizeGradient(gradient: number): IParticleSystem;
  93440. /**
  93441. * Adds a new color remap gradient
  93442. * @param gradient defines the gradient to use (between 0 and 1)
  93443. * @param min defines the color remap minimal range
  93444. * @param max defines the color remap maximal range
  93445. * @returns the current particle system
  93446. */
  93447. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93448. /**
  93449. * Remove a specific color remap gradient
  93450. * @param gradient defines the gradient to remove
  93451. * @returns the current particle system
  93452. */
  93453. removeColorRemapGradient(gradient: number): IParticleSystem;
  93454. /**
  93455. * Adds a new alpha remap gradient
  93456. * @param gradient defines the gradient to use (between 0 and 1)
  93457. * @param min defines the alpha remap minimal range
  93458. * @param max defines the alpha remap maximal range
  93459. * @returns the current particle system
  93460. */
  93461. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93462. /**
  93463. * Remove a specific alpha remap gradient
  93464. * @param gradient defines the gradient to remove
  93465. * @returns the current particle system
  93466. */
  93467. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93468. /**
  93469. * Adds a new angular speed gradient
  93470. * @param gradient defines the gradient to use (between 0 and 1)
  93471. * @param factor defines the angular speed to affect to the specified gradient
  93472. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93473. * @returns the current particle system
  93474. */
  93475. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93476. /**
  93477. * Remove a specific angular speed gradient
  93478. * @param gradient defines the gradient to remove
  93479. * @returns the current particle system
  93480. */
  93481. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93482. /**
  93483. * Adds a new velocity gradient
  93484. * @param gradient defines the gradient to use (between 0 and 1)
  93485. * @param factor defines the velocity to affect to the specified gradient
  93486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93487. * @returns the current particle system
  93488. */
  93489. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93490. /**
  93491. * Remove a specific velocity gradient
  93492. * @param gradient defines the gradient to remove
  93493. * @returns the current particle system
  93494. */
  93495. removeVelocityGradient(gradient: number): IParticleSystem;
  93496. /**
  93497. * Adds a new limit velocity gradient
  93498. * @param gradient defines the gradient to use (between 0 and 1)
  93499. * @param factor defines the limit velocity value to affect to the specified gradient
  93500. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93501. * @returns the current particle system
  93502. */
  93503. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93504. /**
  93505. * Remove a specific limit velocity gradient
  93506. * @param gradient defines the gradient to remove
  93507. * @returns the current particle system
  93508. */
  93509. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93510. /**
  93511. * Adds a new drag gradient
  93512. * @param gradient defines the gradient to use (between 0 and 1)
  93513. * @param factor defines the drag value to affect to the specified gradient
  93514. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93515. * @returns the current particle system
  93516. */
  93517. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93518. /**
  93519. * Remove a specific drag gradient
  93520. * @param gradient defines the gradient to remove
  93521. * @returns the current particle system
  93522. */
  93523. removeDragGradient(gradient: number): IParticleSystem;
  93524. /**
  93525. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93526. * @param gradient defines the gradient to use (between 0 and 1)
  93527. * @param factor defines the emit rate value to affect to the specified gradient
  93528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93529. * @returns the current particle system
  93530. */
  93531. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93532. /**
  93533. * Remove a specific emit rate gradient
  93534. * @param gradient defines the gradient to remove
  93535. * @returns the current particle system
  93536. */
  93537. removeEmitRateGradient(gradient: number): IParticleSystem;
  93538. /**
  93539. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93540. * @param gradient defines the gradient to use (between 0 and 1)
  93541. * @param factor defines the start size value to affect to the specified gradient
  93542. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93543. * @returns the current particle system
  93544. */
  93545. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93546. /**
  93547. * Remove a specific start size gradient
  93548. * @param gradient defines the gradient to remove
  93549. * @returns the current particle system
  93550. */
  93551. removeStartSizeGradient(gradient: number): IParticleSystem;
  93552. private _createRampGradientTexture;
  93553. /**
  93554. * Gets the current list of ramp gradients.
  93555. * You must use addRampGradient and removeRampGradient to udpate this list
  93556. * @returns the list of ramp gradients
  93557. */
  93558. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93559. /** Force the system to rebuild all gradients that need to be resync */
  93560. forceRefreshGradients(): void;
  93561. private _syncRampGradientTexture;
  93562. /**
  93563. * Adds a new ramp gradient used to remap particle colors
  93564. * @param gradient defines the gradient to use (between 0 and 1)
  93565. * @param color defines the color to affect to the specified gradient
  93566. * @returns the current particle system
  93567. */
  93568. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93569. /**
  93570. * Remove a specific ramp gradient
  93571. * @param gradient defines the gradient to remove
  93572. * @returns the current particle system
  93573. */
  93574. removeRampGradient(gradient: number): ParticleSystem;
  93575. /**
  93576. * Adds a new color gradient
  93577. * @param gradient defines the gradient to use (between 0 and 1)
  93578. * @param color1 defines the color to affect to the specified gradient
  93579. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93580. * @returns this particle system
  93581. */
  93582. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93583. /**
  93584. * Remove a specific color gradient
  93585. * @param gradient defines the gradient to remove
  93586. * @returns this particle system
  93587. */
  93588. removeColorGradient(gradient: number): IParticleSystem;
  93589. private _fetchR;
  93590. protected _reset(): void;
  93591. private _resetEffect;
  93592. private _createVertexBuffers;
  93593. private _createIndexBuffer;
  93594. /**
  93595. * Gets the maximum number of particles active at the same time.
  93596. * @returns The max number of active particles.
  93597. */
  93598. getCapacity(): number;
  93599. /**
  93600. * Gets whether there are still active particles in the system.
  93601. * @returns True if it is alive, otherwise false.
  93602. */
  93603. isAlive(): boolean;
  93604. /**
  93605. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93606. * @returns True if it has been started, otherwise false.
  93607. */
  93608. isStarted(): boolean;
  93609. private _prepareSubEmitterInternalArray;
  93610. /**
  93611. * Starts the particle system and begins to emit
  93612. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93613. */
  93614. start(delay?: number): void;
  93615. /**
  93616. * Stops the particle system.
  93617. * @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.
  93618. */
  93619. stop(stopSubEmitters?: boolean): void;
  93620. /**
  93621. * Remove all active particles
  93622. */
  93623. reset(): void;
  93624. /**
  93625. * @hidden (for internal use only)
  93626. */
  93627. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93628. /**
  93629. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93630. * Its lifetime will start back at 0.
  93631. */
  93632. recycleParticle: (particle: Particle) => void;
  93633. private _stopSubEmitters;
  93634. private _createParticle;
  93635. private _removeFromRoot;
  93636. private _emitFromParticle;
  93637. private _update;
  93638. /** @hidden */
  93639. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93640. /** @hidden */
  93641. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93642. /**
  93643. * Fill the defines array according to the current settings of the particle system
  93644. * @param defines Array to be updated
  93645. * @param blendMode blend mode to take into account when updating the array
  93646. */
  93647. fillDefines(defines: Array<string>, blendMode: number): void;
  93648. /**
  93649. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93650. * @param uniforms Uniforms array to fill
  93651. * @param attributes Attributes array to fill
  93652. * @param samplers Samplers array to fill
  93653. */
  93654. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93655. /** @hidden */
  93656. private _getEffect;
  93657. /**
  93658. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93659. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93660. */
  93661. animate(preWarmOnly?: boolean): void;
  93662. private _appendParticleVertices;
  93663. /**
  93664. * Rebuilds the particle system.
  93665. */
  93666. rebuild(): void;
  93667. /**
  93668. * Is this system ready to be used/rendered
  93669. * @return true if the system is ready
  93670. */
  93671. isReady(): boolean;
  93672. private _render;
  93673. /**
  93674. * Renders the particle system in its current state.
  93675. * @returns the current number of particles
  93676. */
  93677. render(): number;
  93678. /**
  93679. * Disposes the particle system and free the associated resources
  93680. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93681. */
  93682. dispose(disposeTexture?: boolean): void;
  93683. /**
  93684. * Clones the particle system.
  93685. * @param name The name of the cloned object
  93686. * @param newEmitter The new emitter to use
  93687. * @returns the cloned particle system
  93688. */
  93689. clone(name: string, newEmitter: any): ParticleSystem;
  93690. /**
  93691. * Serializes the particle system to a JSON object
  93692. * @param serializeTexture defines if the texture must be serialized as well
  93693. * @returns the JSON object
  93694. */
  93695. serialize(serializeTexture?: boolean): any;
  93696. /** @hidden */
  93697. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93698. /** @hidden */
  93699. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93700. /**
  93701. * Parses a JSON object to create a particle system.
  93702. * @param parsedParticleSystem The JSON object to parse
  93703. * @param sceneOrEngine The scene or the engine to create the particle system in
  93704. * @param rootUrl The root url to use to load external dependencies like texture
  93705. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93706. * @returns the Parsed particle system
  93707. */
  93708. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93709. }
  93710. }
  93711. declare module BABYLON {
  93712. /**
  93713. * A particle represents one of the element emitted by a particle system.
  93714. * This is mainly define by its coordinates, direction, velocity and age.
  93715. */
  93716. export class Particle {
  93717. /**
  93718. * The particle system the particle belongs to.
  93719. */
  93720. particleSystem: ParticleSystem;
  93721. private static _Count;
  93722. /**
  93723. * Unique ID of the particle
  93724. */
  93725. id: number;
  93726. /**
  93727. * The world position of the particle in the scene.
  93728. */
  93729. position: Vector3;
  93730. /**
  93731. * The world direction of the particle in the scene.
  93732. */
  93733. direction: Vector3;
  93734. /**
  93735. * The color of the particle.
  93736. */
  93737. color: Color4;
  93738. /**
  93739. * The color change of the particle per step.
  93740. */
  93741. colorStep: Color4;
  93742. /**
  93743. * Defines how long will the life of the particle be.
  93744. */
  93745. lifeTime: number;
  93746. /**
  93747. * The current age of the particle.
  93748. */
  93749. age: number;
  93750. /**
  93751. * The current size of the particle.
  93752. */
  93753. size: number;
  93754. /**
  93755. * The current scale of the particle.
  93756. */
  93757. scale: Vector2;
  93758. /**
  93759. * The current angle of the particle.
  93760. */
  93761. angle: number;
  93762. /**
  93763. * Defines how fast is the angle changing.
  93764. */
  93765. angularSpeed: number;
  93766. /**
  93767. * Defines the cell index used by the particle to be rendered from a sprite.
  93768. */
  93769. cellIndex: number;
  93770. /**
  93771. * The information required to support color remapping
  93772. */
  93773. remapData: Vector4;
  93774. /** @hidden */
  93775. _randomCellOffset?: number;
  93776. /** @hidden */
  93777. _initialDirection: Nullable<Vector3>;
  93778. /** @hidden */
  93779. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93780. /** @hidden */
  93781. _initialStartSpriteCellID: number;
  93782. /** @hidden */
  93783. _initialEndSpriteCellID: number;
  93784. /** @hidden */
  93785. _currentColorGradient: Nullable<ColorGradient>;
  93786. /** @hidden */
  93787. _currentColor1: Color4;
  93788. /** @hidden */
  93789. _currentColor2: Color4;
  93790. /** @hidden */
  93791. _currentSizeGradient: Nullable<FactorGradient>;
  93792. /** @hidden */
  93793. _currentSize1: number;
  93794. /** @hidden */
  93795. _currentSize2: number;
  93796. /** @hidden */
  93797. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93798. /** @hidden */
  93799. _currentAngularSpeed1: number;
  93800. /** @hidden */
  93801. _currentAngularSpeed2: number;
  93802. /** @hidden */
  93803. _currentVelocityGradient: Nullable<FactorGradient>;
  93804. /** @hidden */
  93805. _currentVelocity1: number;
  93806. /** @hidden */
  93807. _currentVelocity2: number;
  93808. /** @hidden */
  93809. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93810. /** @hidden */
  93811. _currentLimitVelocity1: number;
  93812. /** @hidden */
  93813. _currentLimitVelocity2: number;
  93814. /** @hidden */
  93815. _currentDragGradient: Nullable<FactorGradient>;
  93816. /** @hidden */
  93817. _currentDrag1: number;
  93818. /** @hidden */
  93819. _currentDrag2: number;
  93820. /** @hidden */
  93821. _randomNoiseCoordinates1: Vector3;
  93822. /** @hidden */
  93823. _randomNoiseCoordinates2: Vector3;
  93824. /** @hidden */
  93825. _localPosition?: Vector3;
  93826. /**
  93827. * Creates a new instance Particle
  93828. * @param particleSystem the particle system the particle belongs to
  93829. */
  93830. constructor(
  93831. /**
  93832. * The particle system the particle belongs to.
  93833. */
  93834. particleSystem: ParticleSystem);
  93835. private updateCellInfoFromSystem;
  93836. /**
  93837. * Defines how the sprite cell index is updated for the particle
  93838. */
  93839. updateCellIndex(): void;
  93840. /** @hidden */
  93841. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93842. /** @hidden */
  93843. _inheritParticleInfoToSubEmitters(): void;
  93844. /** @hidden */
  93845. _reset(): void;
  93846. /**
  93847. * Copy the properties of particle to another one.
  93848. * @param other the particle to copy the information to.
  93849. */
  93850. copyTo(other: Particle): void;
  93851. }
  93852. }
  93853. declare module BABYLON {
  93854. /**
  93855. * Particle emitter represents a volume emitting particles.
  93856. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93857. */
  93858. export interface IParticleEmitterType {
  93859. /**
  93860. * Called by the particle System when the direction is computed for the created particle.
  93861. * @param worldMatrix is the world matrix of the particle system
  93862. * @param directionToUpdate is the direction vector to update with the result
  93863. * @param particle is the particle we are computed the direction for
  93864. * @param isLocal defines if the direction should be set in local space
  93865. */
  93866. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93867. /**
  93868. * Called by the particle System when the position is computed for the created particle.
  93869. * @param worldMatrix is the world matrix of the particle system
  93870. * @param positionToUpdate is the position vector to update with the result
  93871. * @param particle is the particle we are computed the position for
  93872. * @param isLocal defines if the position should be set in local space
  93873. */
  93874. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93875. /**
  93876. * Clones the current emitter and returns a copy of it
  93877. * @returns the new emitter
  93878. */
  93879. clone(): IParticleEmitterType;
  93880. /**
  93881. * Called by the GPUParticleSystem to setup the update shader
  93882. * @param effect defines the update shader
  93883. */
  93884. applyToShader(effect: Effect): void;
  93885. /**
  93886. * Returns a string to use to update the GPU particles update shader
  93887. * @returns the effect defines string
  93888. */
  93889. getEffectDefines(): string;
  93890. /**
  93891. * Returns a string representing the class name
  93892. * @returns a string containing the class name
  93893. */
  93894. getClassName(): string;
  93895. /**
  93896. * Serializes the particle system to a JSON object.
  93897. * @returns the JSON object
  93898. */
  93899. serialize(): any;
  93900. /**
  93901. * Parse properties from a JSON object
  93902. * @param serializationObject defines the JSON object
  93903. * @param scene defines the hosting scene
  93904. */
  93905. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93906. }
  93907. }
  93908. declare module BABYLON {
  93909. /**
  93910. * Particle emitter emitting particles from the inside of a box.
  93911. * It emits the particles randomly between 2 given directions.
  93912. */
  93913. export class BoxParticleEmitter implements IParticleEmitterType {
  93914. /**
  93915. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93916. */
  93917. direction1: Vector3;
  93918. /**
  93919. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93920. */
  93921. direction2: Vector3;
  93922. /**
  93923. * 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.
  93924. */
  93925. minEmitBox: Vector3;
  93926. /**
  93927. * 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.
  93928. */
  93929. maxEmitBox: Vector3;
  93930. /**
  93931. * Creates a new instance BoxParticleEmitter
  93932. */
  93933. constructor();
  93934. /**
  93935. * Called by the particle System when the direction is computed for the created particle.
  93936. * @param worldMatrix is the world matrix of the particle system
  93937. * @param directionToUpdate is the direction vector to update with the result
  93938. * @param particle is the particle we are computed the direction for
  93939. * @param isLocal defines if the direction should be set in local space
  93940. */
  93941. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93942. /**
  93943. * Called by the particle System when the position is computed for the created particle.
  93944. * @param worldMatrix is the world matrix of the particle system
  93945. * @param positionToUpdate is the position vector to update with the result
  93946. * @param particle is the particle we are computed the position for
  93947. * @param isLocal defines if the position should be set in local space
  93948. */
  93949. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93950. /**
  93951. * Clones the current emitter and returns a copy of it
  93952. * @returns the new emitter
  93953. */
  93954. clone(): BoxParticleEmitter;
  93955. /**
  93956. * Called by the GPUParticleSystem to setup the update shader
  93957. * @param effect defines the update shader
  93958. */
  93959. applyToShader(effect: Effect): void;
  93960. /**
  93961. * Returns a string to use to update the GPU particles update shader
  93962. * @returns a string containng the defines string
  93963. */
  93964. getEffectDefines(): string;
  93965. /**
  93966. * Returns the string "BoxParticleEmitter"
  93967. * @returns a string containing the class name
  93968. */
  93969. getClassName(): string;
  93970. /**
  93971. * Serializes the particle system to a JSON object.
  93972. * @returns the JSON object
  93973. */
  93974. serialize(): any;
  93975. /**
  93976. * Parse properties from a JSON object
  93977. * @param serializationObject defines the JSON object
  93978. */
  93979. parse(serializationObject: any): void;
  93980. }
  93981. }
  93982. declare module BABYLON {
  93983. /**
  93984. * Particle emitter emitting particles from the inside of a cone.
  93985. * It emits the particles alongside the cone volume from the base to the particle.
  93986. * The emission direction might be randomized.
  93987. */
  93988. export class ConeParticleEmitter implements IParticleEmitterType {
  93989. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93990. directionRandomizer: number;
  93991. private _radius;
  93992. private _angle;
  93993. private _height;
  93994. /**
  93995. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  93996. */
  93997. radiusRange: number;
  93998. /**
  93999. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  94000. */
  94001. heightRange: number;
  94002. /**
  94003. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  94004. */
  94005. emitFromSpawnPointOnly: boolean;
  94006. /**
  94007. * Gets or sets the radius of the emission cone
  94008. */
  94009. get radius(): number;
  94010. set radius(value: number);
  94011. /**
  94012. * Gets or sets the angle of the emission cone
  94013. */
  94014. get angle(): number;
  94015. set angle(value: number);
  94016. private _buildHeight;
  94017. /**
  94018. * Creates a new instance ConeParticleEmitter
  94019. * @param radius the radius of the emission cone (1 by default)
  94020. * @param angle the cone base angle (PI by default)
  94021. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  94022. */
  94023. constructor(radius?: number, angle?: number,
  94024. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94025. directionRandomizer?: number);
  94026. /**
  94027. * Called by the particle System when the direction is computed for the created particle.
  94028. * @param worldMatrix is the world matrix of the particle system
  94029. * @param directionToUpdate is the direction vector to update with the result
  94030. * @param particle is the particle we are computed the direction for
  94031. * @param isLocal defines if the direction should be set in local space
  94032. */
  94033. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94034. /**
  94035. * Called by the particle System when the position is computed for the created particle.
  94036. * @param worldMatrix is the world matrix of the particle system
  94037. * @param positionToUpdate is the position vector to update with the result
  94038. * @param particle is the particle we are computed the position for
  94039. * @param isLocal defines if the position should be set in local space
  94040. */
  94041. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94042. /**
  94043. * Clones the current emitter and returns a copy of it
  94044. * @returns the new emitter
  94045. */
  94046. clone(): ConeParticleEmitter;
  94047. /**
  94048. * Called by the GPUParticleSystem to setup the update shader
  94049. * @param effect defines the update shader
  94050. */
  94051. applyToShader(effect: Effect): void;
  94052. /**
  94053. * Returns a string to use to update the GPU particles update shader
  94054. * @returns a string containng the defines string
  94055. */
  94056. getEffectDefines(): string;
  94057. /**
  94058. * Returns the string "ConeParticleEmitter"
  94059. * @returns a string containing the class name
  94060. */
  94061. getClassName(): string;
  94062. /**
  94063. * Serializes the particle system to a JSON object.
  94064. * @returns the JSON object
  94065. */
  94066. serialize(): any;
  94067. /**
  94068. * Parse properties from a JSON object
  94069. * @param serializationObject defines the JSON object
  94070. */
  94071. parse(serializationObject: any): void;
  94072. }
  94073. }
  94074. declare module BABYLON {
  94075. /**
  94076. * Particle emitter emitting particles from the inside of a cylinder.
  94077. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  94078. */
  94079. export class CylinderParticleEmitter implements IParticleEmitterType {
  94080. /**
  94081. * The radius of the emission cylinder.
  94082. */
  94083. radius: number;
  94084. /**
  94085. * The height of the emission cylinder.
  94086. */
  94087. height: number;
  94088. /**
  94089. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94090. */
  94091. radiusRange: number;
  94092. /**
  94093. * How much to randomize the particle direction [0-1].
  94094. */
  94095. directionRandomizer: number;
  94096. /**
  94097. * Creates a new instance CylinderParticleEmitter
  94098. * @param radius the radius of the emission cylinder (1 by default)
  94099. * @param height the height of the emission cylinder (1 by default)
  94100. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94101. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94102. */
  94103. constructor(
  94104. /**
  94105. * The radius of the emission cylinder.
  94106. */
  94107. radius?: number,
  94108. /**
  94109. * The height of the emission cylinder.
  94110. */
  94111. height?: number,
  94112. /**
  94113. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94114. */
  94115. radiusRange?: number,
  94116. /**
  94117. * How much to randomize the particle direction [0-1].
  94118. */
  94119. directionRandomizer?: number);
  94120. /**
  94121. * Called by the particle System when the direction is computed for the created particle.
  94122. * @param worldMatrix is the world matrix of the particle system
  94123. * @param directionToUpdate is the direction vector to update with the result
  94124. * @param particle is the particle we are computed the direction for
  94125. * @param isLocal defines if the direction should be set in local space
  94126. */
  94127. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94128. /**
  94129. * Called by the particle System when the position is computed for the created particle.
  94130. * @param worldMatrix is the world matrix of the particle system
  94131. * @param positionToUpdate is the position vector to update with the result
  94132. * @param particle is the particle we are computed the position for
  94133. * @param isLocal defines if the position should be set in local space
  94134. */
  94135. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94136. /**
  94137. * Clones the current emitter and returns a copy of it
  94138. * @returns the new emitter
  94139. */
  94140. clone(): CylinderParticleEmitter;
  94141. /**
  94142. * Called by the GPUParticleSystem to setup the update shader
  94143. * @param effect defines the update shader
  94144. */
  94145. applyToShader(effect: Effect): void;
  94146. /**
  94147. * Returns a string to use to update the GPU particles update shader
  94148. * @returns a string containng the defines string
  94149. */
  94150. getEffectDefines(): string;
  94151. /**
  94152. * Returns the string "CylinderParticleEmitter"
  94153. * @returns a string containing the class name
  94154. */
  94155. getClassName(): string;
  94156. /**
  94157. * Serializes the particle system to a JSON object.
  94158. * @returns the JSON object
  94159. */
  94160. serialize(): any;
  94161. /**
  94162. * Parse properties from a JSON object
  94163. * @param serializationObject defines the JSON object
  94164. */
  94165. parse(serializationObject: any): void;
  94166. }
  94167. /**
  94168. * Particle emitter emitting particles from the inside of a cylinder.
  94169. * It emits the particles randomly between two vectors.
  94170. */
  94171. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  94172. /**
  94173. * The min limit of the emission direction.
  94174. */
  94175. direction1: Vector3;
  94176. /**
  94177. * The max limit of the emission direction.
  94178. */
  94179. direction2: Vector3;
  94180. /**
  94181. * Creates a new instance CylinderDirectedParticleEmitter
  94182. * @param radius the radius of the emission cylinder (1 by default)
  94183. * @param height the height of the emission cylinder (1 by default)
  94184. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94185. * @param direction1 the min limit of the emission direction (up vector by default)
  94186. * @param direction2 the max limit of the emission direction (up vector by default)
  94187. */
  94188. constructor(radius?: number, height?: number, radiusRange?: number,
  94189. /**
  94190. * The min limit of the emission direction.
  94191. */
  94192. direction1?: Vector3,
  94193. /**
  94194. * The max limit of the emission direction.
  94195. */
  94196. direction2?: Vector3);
  94197. /**
  94198. * Called by the particle System when the direction is computed for the created particle.
  94199. * @param worldMatrix is the world matrix of the particle system
  94200. * @param directionToUpdate is the direction vector to update with the result
  94201. * @param particle is the particle we are computed the direction for
  94202. */
  94203. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94204. /**
  94205. * Clones the current emitter and returns a copy of it
  94206. * @returns the new emitter
  94207. */
  94208. clone(): CylinderDirectedParticleEmitter;
  94209. /**
  94210. * Called by the GPUParticleSystem to setup the update shader
  94211. * @param effect defines the update shader
  94212. */
  94213. applyToShader(effect: Effect): void;
  94214. /**
  94215. * Returns a string to use to update the GPU particles update shader
  94216. * @returns a string containng the defines string
  94217. */
  94218. getEffectDefines(): string;
  94219. /**
  94220. * Returns the string "CylinderDirectedParticleEmitter"
  94221. * @returns a string containing the class name
  94222. */
  94223. getClassName(): string;
  94224. /**
  94225. * Serializes the particle system to a JSON object.
  94226. * @returns the JSON object
  94227. */
  94228. serialize(): any;
  94229. /**
  94230. * Parse properties from a JSON object
  94231. * @param serializationObject defines the JSON object
  94232. */
  94233. parse(serializationObject: any): void;
  94234. }
  94235. }
  94236. declare module BABYLON {
  94237. /**
  94238. * Particle emitter emitting particles from the inside of a hemisphere.
  94239. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  94240. */
  94241. export class HemisphericParticleEmitter implements IParticleEmitterType {
  94242. /**
  94243. * The radius of the emission hemisphere.
  94244. */
  94245. radius: number;
  94246. /**
  94247. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94248. */
  94249. radiusRange: number;
  94250. /**
  94251. * How much to randomize the particle direction [0-1].
  94252. */
  94253. directionRandomizer: number;
  94254. /**
  94255. * Creates a new instance HemisphericParticleEmitter
  94256. * @param radius the radius of the emission hemisphere (1 by default)
  94257. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94258. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94259. */
  94260. constructor(
  94261. /**
  94262. * The radius of the emission hemisphere.
  94263. */
  94264. radius?: number,
  94265. /**
  94266. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94267. */
  94268. radiusRange?: number,
  94269. /**
  94270. * How much to randomize the particle direction [0-1].
  94271. */
  94272. directionRandomizer?: number);
  94273. /**
  94274. * Called by the particle System when the direction is computed for the created particle.
  94275. * @param worldMatrix is the world matrix of the particle system
  94276. * @param directionToUpdate is the direction vector to update with the result
  94277. * @param particle is the particle we are computed the direction for
  94278. * @param isLocal defines if the direction should be set in local space
  94279. */
  94280. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94281. /**
  94282. * Called by the particle System when the position is computed for the created particle.
  94283. * @param worldMatrix is the world matrix of the particle system
  94284. * @param positionToUpdate is the position vector to update with the result
  94285. * @param particle is the particle we are computed the position for
  94286. * @param isLocal defines if the position should be set in local space
  94287. */
  94288. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94289. /**
  94290. * Clones the current emitter and returns a copy of it
  94291. * @returns the new emitter
  94292. */
  94293. clone(): HemisphericParticleEmitter;
  94294. /**
  94295. * Called by the GPUParticleSystem to setup the update shader
  94296. * @param effect defines the update shader
  94297. */
  94298. applyToShader(effect: Effect): void;
  94299. /**
  94300. * Returns a string to use to update the GPU particles update shader
  94301. * @returns a string containng the defines string
  94302. */
  94303. getEffectDefines(): string;
  94304. /**
  94305. * Returns the string "HemisphericParticleEmitter"
  94306. * @returns a string containing the class name
  94307. */
  94308. getClassName(): string;
  94309. /**
  94310. * Serializes the particle system to a JSON object.
  94311. * @returns the JSON object
  94312. */
  94313. serialize(): any;
  94314. /**
  94315. * Parse properties from a JSON object
  94316. * @param serializationObject defines the JSON object
  94317. */
  94318. parse(serializationObject: any): void;
  94319. }
  94320. }
  94321. declare module BABYLON {
  94322. /**
  94323. * Particle emitter emitting particles from a point.
  94324. * It emits the particles randomly between 2 given directions.
  94325. */
  94326. export class PointParticleEmitter implements IParticleEmitterType {
  94327. /**
  94328. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94329. */
  94330. direction1: Vector3;
  94331. /**
  94332. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94333. */
  94334. direction2: Vector3;
  94335. /**
  94336. * Creates a new instance PointParticleEmitter
  94337. */
  94338. constructor();
  94339. /**
  94340. * Called by the particle System when the direction is computed for the created particle.
  94341. * @param worldMatrix is the world matrix of the particle system
  94342. * @param directionToUpdate is the direction vector to update with the result
  94343. * @param particle is the particle we are computed the direction for
  94344. * @param isLocal defines if the direction should be set in local space
  94345. */
  94346. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94347. /**
  94348. * Called by the particle System when the position is computed for the created particle.
  94349. * @param worldMatrix is the world matrix of the particle system
  94350. * @param positionToUpdate is the position vector to update with the result
  94351. * @param particle is the particle we are computed the position for
  94352. * @param isLocal defines if the position should be set in local space
  94353. */
  94354. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94355. /**
  94356. * Clones the current emitter and returns a copy of it
  94357. * @returns the new emitter
  94358. */
  94359. clone(): PointParticleEmitter;
  94360. /**
  94361. * Called by the GPUParticleSystem to setup the update shader
  94362. * @param effect defines the update shader
  94363. */
  94364. applyToShader(effect: Effect): void;
  94365. /**
  94366. * Returns a string to use to update the GPU particles update shader
  94367. * @returns a string containng the defines string
  94368. */
  94369. getEffectDefines(): string;
  94370. /**
  94371. * Returns the string "PointParticleEmitter"
  94372. * @returns a string containing the class name
  94373. */
  94374. getClassName(): string;
  94375. /**
  94376. * Serializes the particle system to a JSON object.
  94377. * @returns the JSON object
  94378. */
  94379. serialize(): any;
  94380. /**
  94381. * Parse properties from a JSON object
  94382. * @param serializationObject defines the JSON object
  94383. */
  94384. parse(serializationObject: any): void;
  94385. }
  94386. }
  94387. declare module BABYLON {
  94388. /**
  94389. * Particle emitter emitting particles from the inside of a sphere.
  94390. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94391. */
  94392. export class SphereParticleEmitter implements IParticleEmitterType {
  94393. /**
  94394. * The radius of the emission sphere.
  94395. */
  94396. radius: number;
  94397. /**
  94398. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94399. */
  94400. radiusRange: number;
  94401. /**
  94402. * How much to randomize the particle direction [0-1].
  94403. */
  94404. directionRandomizer: number;
  94405. /**
  94406. * Creates a new instance SphereParticleEmitter
  94407. * @param radius the radius of the emission sphere (1 by default)
  94408. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94409. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94410. */
  94411. constructor(
  94412. /**
  94413. * The radius of the emission sphere.
  94414. */
  94415. radius?: number,
  94416. /**
  94417. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94418. */
  94419. radiusRange?: number,
  94420. /**
  94421. * How much to randomize the particle direction [0-1].
  94422. */
  94423. directionRandomizer?: number);
  94424. /**
  94425. * Called by the particle System when the direction is computed for the created particle.
  94426. * @param worldMatrix is the world matrix of the particle system
  94427. * @param directionToUpdate is the direction vector to update with the result
  94428. * @param particle is the particle we are computed the direction for
  94429. * @param isLocal defines if the direction should be set in local space
  94430. */
  94431. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94432. /**
  94433. * Called by the particle System when the position is computed for the created particle.
  94434. * @param worldMatrix is the world matrix of the particle system
  94435. * @param positionToUpdate is the position vector to update with the result
  94436. * @param particle is the particle we are computed the position for
  94437. * @param isLocal defines if the position should be set in local space
  94438. */
  94439. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94440. /**
  94441. * Clones the current emitter and returns a copy of it
  94442. * @returns the new emitter
  94443. */
  94444. clone(): SphereParticleEmitter;
  94445. /**
  94446. * Called by the GPUParticleSystem to setup the update shader
  94447. * @param effect defines the update shader
  94448. */
  94449. applyToShader(effect: Effect): void;
  94450. /**
  94451. * Returns a string to use to update the GPU particles update shader
  94452. * @returns a string containng the defines string
  94453. */
  94454. getEffectDefines(): string;
  94455. /**
  94456. * Returns the string "SphereParticleEmitter"
  94457. * @returns a string containing the class name
  94458. */
  94459. getClassName(): string;
  94460. /**
  94461. * Serializes the particle system to a JSON object.
  94462. * @returns the JSON object
  94463. */
  94464. serialize(): any;
  94465. /**
  94466. * Parse properties from a JSON object
  94467. * @param serializationObject defines the JSON object
  94468. */
  94469. parse(serializationObject: any): void;
  94470. }
  94471. /**
  94472. * Particle emitter emitting particles from the inside of a sphere.
  94473. * It emits the particles randomly between two vectors.
  94474. */
  94475. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94476. /**
  94477. * The min limit of the emission direction.
  94478. */
  94479. direction1: Vector3;
  94480. /**
  94481. * The max limit of the emission direction.
  94482. */
  94483. direction2: Vector3;
  94484. /**
  94485. * Creates a new instance SphereDirectedParticleEmitter
  94486. * @param radius the radius of the emission sphere (1 by default)
  94487. * @param direction1 the min limit of the emission direction (up vector by default)
  94488. * @param direction2 the max limit of the emission direction (up vector by default)
  94489. */
  94490. constructor(radius?: number,
  94491. /**
  94492. * The min limit of the emission direction.
  94493. */
  94494. direction1?: Vector3,
  94495. /**
  94496. * The max limit of the emission direction.
  94497. */
  94498. direction2?: Vector3);
  94499. /**
  94500. * Called by the particle System when the direction is computed for the created particle.
  94501. * @param worldMatrix is the world matrix of the particle system
  94502. * @param directionToUpdate is the direction vector to update with the result
  94503. * @param particle is the particle we are computed the direction for
  94504. */
  94505. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94506. /**
  94507. * Clones the current emitter and returns a copy of it
  94508. * @returns the new emitter
  94509. */
  94510. clone(): SphereDirectedParticleEmitter;
  94511. /**
  94512. * Called by the GPUParticleSystem to setup the update shader
  94513. * @param effect defines the update shader
  94514. */
  94515. applyToShader(effect: Effect): void;
  94516. /**
  94517. * Returns a string to use to update the GPU particles update shader
  94518. * @returns a string containng the defines string
  94519. */
  94520. getEffectDefines(): string;
  94521. /**
  94522. * Returns the string "SphereDirectedParticleEmitter"
  94523. * @returns a string containing the class name
  94524. */
  94525. getClassName(): string;
  94526. /**
  94527. * Serializes the particle system to a JSON object.
  94528. * @returns the JSON object
  94529. */
  94530. serialize(): any;
  94531. /**
  94532. * Parse properties from a JSON object
  94533. * @param serializationObject defines the JSON object
  94534. */
  94535. parse(serializationObject: any): void;
  94536. }
  94537. }
  94538. declare module BABYLON {
  94539. /**
  94540. * Particle emitter emitting particles from a custom list of positions.
  94541. */
  94542. export class CustomParticleEmitter implements IParticleEmitterType {
  94543. /**
  94544. * Gets or sets the position generator that will create the inital position of each particle.
  94545. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94546. */
  94547. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94548. /**
  94549. * Gets or sets the destination generator that will create the final destination of each particle.
  94550. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94551. */
  94552. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94553. /**
  94554. * Creates a new instance CustomParticleEmitter
  94555. */
  94556. constructor();
  94557. /**
  94558. * Called by the particle System when the direction is computed for the created particle.
  94559. * @param worldMatrix is the world matrix of the particle system
  94560. * @param directionToUpdate is the direction vector to update with the result
  94561. * @param particle is the particle we are computed the direction for
  94562. * @param isLocal defines if the direction should be set in local space
  94563. */
  94564. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94565. /**
  94566. * Called by the particle System when the position is computed for the created particle.
  94567. * @param worldMatrix is the world matrix of the particle system
  94568. * @param positionToUpdate is the position vector to update with the result
  94569. * @param particle is the particle we are computed the position for
  94570. * @param isLocal defines if the position should be set in local space
  94571. */
  94572. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94573. /**
  94574. * Clones the current emitter and returns a copy of it
  94575. * @returns the new emitter
  94576. */
  94577. clone(): CustomParticleEmitter;
  94578. /**
  94579. * Called by the GPUParticleSystem to setup the update shader
  94580. * @param effect defines the update shader
  94581. */
  94582. applyToShader(effect: Effect): void;
  94583. /**
  94584. * Returns a string to use to update the GPU particles update shader
  94585. * @returns a string containng the defines string
  94586. */
  94587. getEffectDefines(): string;
  94588. /**
  94589. * Returns the string "PointParticleEmitter"
  94590. * @returns a string containing the class name
  94591. */
  94592. getClassName(): string;
  94593. /**
  94594. * Serializes the particle system to a JSON object.
  94595. * @returns the JSON object
  94596. */
  94597. serialize(): any;
  94598. /**
  94599. * Parse properties from a JSON object
  94600. * @param serializationObject defines the JSON object
  94601. */
  94602. parse(serializationObject: any): void;
  94603. }
  94604. }
  94605. declare module BABYLON {
  94606. /**
  94607. * Particle emitter emitting particles from the inside of a box.
  94608. * It emits the particles randomly between 2 given directions.
  94609. */
  94610. export class MeshParticleEmitter implements IParticleEmitterType {
  94611. private _indices;
  94612. private _positions;
  94613. private _normals;
  94614. private _storedNormal;
  94615. private _mesh;
  94616. /**
  94617. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94618. */
  94619. direction1: Vector3;
  94620. /**
  94621. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94622. */
  94623. direction2: Vector3;
  94624. /**
  94625. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94626. */
  94627. useMeshNormalsForDirection: boolean;
  94628. /** Defines the mesh to use as source */
  94629. get mesh(): Nullable<AbstractMesh>;
  94630. set mesh(value: Nullable<AbstractMesh>);
  94631. /**
  94632. * Creates a new instance MeshParticleEmitter
  94633. * @param mesh defines the mesh to use as source
  94634. */
  94635. constructor(mesh?: Nullable<AbstractMesh>);
  94636. /**
  94637. * Called by the particle System when the direction is computed for the created particle.
  94638. * @param worldMatrix is the world matrix of the particle system
  94639. * @param directionToUpdate is the direction vector to update with the result
  94640. * @param particle is the particle we are computed the direction for
  94641. * @param isLocal defines if the direction should be set in local space
  94642. */
  94643. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94644. /**
  94645. * Called by the particle System when the position is computed for the created particle.
  94646. * @param worldMatrix is the world matrix of the particle system
  94647. * @param positionToUpdate is the position vector to update with the result
  94648. * @param particle is the particle we are computed the position for
  94649. * @param isLocal defines if the position should be set in local space
  94650. */
  94651. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94652. /**
  94653. * Clones the current emitter and returns a copy of it
  94654. * @returns the new emitter
  94655. */
  94656. clone(): MeshParticleEmitter;
  94657. /**
  94658. * Called by the GPUParticleSystem to setup the update shader
  94659. * @param effect defines the update shader
  94660. */
  94661. applyToShader(effect: Effect): void;
  94662. /**
  94663. * Returns a string to use to update the GPU particles update shader
  94664. * @returns a string containng the defines string
  94665. */
  94666. getEffectDefines(): string;
  94667. /**
  94668. * Returns the string "BoxParticleEmitter"
  94669. * @returns a string containing the class name
  94670. */
  94671. getClassName(): string;
  94672. /**
  94673. * Serializes the particle system to a JSON object.
  94674. * @returns the JSON object
  94675. */
  94676. serialize(): any;
  94677. /**
  94678. * Parse properties from a JSON object
  94679. * @param serializationObject defines the JSON object
  94680. * @param scene defines the hosting scene
  94681. */
  94682. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94683. }
  94684. }
  94685. declare module BABYLON {
  94686. /**
  94687. * Interface representing a particle system in Babylon.js.
  94688. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94689. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94690. */
  94691. export interface IParticleSystem {
  94692. /**
  94693. * List of animations used by the particle system.
  94694. */
  94695. animations: Animation[];
  94696. /**
  94697. * The id of the Particle system.
  94698. */
  94699. id: string;
  94700. /**
  94701. * The name of the Particle system.
  94702. */
  94703. name: string;
  94704. /**
  94705. * The emitter represents the Mesh or position we are attaching the particle system to.
  94706. */
  94707. emitter: Nullable<AbstractMesh | Vector3>;
  94708. /**
  94709. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94710. */
  94711. isBillboardBased: boolean;
  94712. /**
  94713. * The rendering group used by the Particle system to chose when to render.
  94714. */
  94715. renderingGroupId: number;
  94716. /**
  94717. * The layer mask we are rendering the particles through.
  94718. */
  94719. layerMask: number;
  94720. /**
  94721. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94722. */
  94723. updateSpeed: number;
  94724. /**
  94725. * The amount of time the particle system is running (depends of the overall update speed).
  94726. */
  94727. targetStopDuration: number;
  94728. /**
  94729. * The texture used to render each particle. (this can be a spritesheet)
  94730. */
  94731. particleTexture: Nullable<BaseTexture>;
  94732. /**
  94733. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94734. */
  94735. blendMode: number;
  94736. /**
  94737. * Minimum life time of emitting particles.
  94738. */
  94739. minLifeTime: number;
  94740. /**
  94741. * Maximum life time of emitting particles.
  94742. */
  94743. maxLifeTime: number;
  94744. /**
  94745. * Minimum Size of emitting particles.
  94746. */
  94747. minSize: number;
  94748. /**
  94749. * Maximum Size of emitting particles.
  94750. */
  94751. maxSize: number;
  94752. /**
  94753. * Minimum scale of emitting particles on X axis.
  94754. */
  94755. minScaleX: number;
  94756. /**
  94757. * Maximum scale of emitting particles on X axis.
  94758. */
  94759. maxScaleX: number;
  94760. /**
  94761. * Minimum scale of emitting particles on Y axis.
  94762. */
  94763. minScaleY: number;
  94764. /**
  94765. * Maximum scale of emitting particles on Y axis.
  94766. */
  94767. maxScaleY: number;
  94768. /**
  94769. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94770. */
  94771. color1: Color4;
  94772. /**
  94773. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94774. */
  94775. color2: Color4;
  94776. /**
  94777. * Color the particle will have at the end of its lifetime.
  94778. */
  94779. colorDead: Color4;
  94780. /**
  94781. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94782. */
  94783. emitRate: number;
  94784. /**
  94785. * You can use gravity if you want to give an orientation to your particles.
  94786. */
  94787. gravity: Vector3;
  94788. /**
  94789. * Minimum power of emitting particles.
  94790. */
  94791. minEmitPower: number;
  94792. /**
  94793. * Maximum power of emitting particles.
  94794. */
  94795. maxEmitPower: number;
  94796. /**
  94797. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94798. */
  94799. minAngularSpeed: number;
  94800. /**
  94801. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94802. */
  94803. maxAngularSpeed: number;
  94804. /**
  94805. * Gets or sets the minimal initial rotation in radians.
  94806. */
  94807. minInitialRotation: number;
  94808. /**
  94809. * Gets or sets the maximal initial rotation in radians.
  94810. */
  94811. maxInitialRotation: number;
  94812. /**
  94813. * The particle emitter type defines the emitter used by the particle system.
  94814. * It can be for example box, sphere, or cone...
  94815. */
  94816. particleEmitterType: Nullable<IParticleEmitterType>;
  94817. /**
  94818. * Defines the delay in milliseconds before starting the system (0 by default)
  94819. */
  94820. startDelay: number;
  94821. /**
  94822. * 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
  94823. */
  94824. preWarmCycles: number;
  94825. /**
  94826. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94827. */
  94828. preWarmStepOffset: number;
  94829. /**
  94830. * 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)
  94831. */
  94832. spriteCellChangeSpeed: number;
  94833. /**
  94834. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94835. */
  94836. startSpriteCellID: number;
  94837. /**
  94838. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94839. */
  94840. endSpriteCellID: number;
  94841. /**
  94842. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94843. */
  94844. spriteCellWidth: number;
  94845. /**
  94846. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94847. */
  94848. spriteCellHeight: number;
  94849. /**
  94850. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94851. */
  94852. spriteRandomStartCell: boolean;
  94853. /**
  94854. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94855. */
  94856. isAnimationSheetEnabled: boolean;
  94857. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94858. translationPivot: Vector2;
  94859. /**
  94860. * Gets or sets a texture used to add random noise to particle positions
  94861. */
  94862. noiseTexture: Nullable<BaseTexture>;
  94863. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94864. noiseStrength: Vector3;
  94865. /**
  94866. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94867. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94868. */
  94869. billboardMode: number;
  94870. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94871. limitVelocityDamping: number;
  94872. /**
  94873. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94874. */
  94875. beginAnimationOnStart: boolean;
  94876. /**
  94877. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94878. */
  94879. beginAnimationFrom: number;
  94880. /**
  94881. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94882. */
  94883. beginAnimationTo: number;
  94884. /**
  94885. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94886. */
  94887. beginAnimationLoop: boolean;
  94888. /**
  94889. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94890. */
  94891. disposeOnStop: boolean;
  94892. /**
  94893. * Specifies if the particles are updated in emitter local space or world space
  94894. */
  94895. isLocal: boolean;
  94896. /** Snippet ID if the particle system was created from the snippet server */
  94897. snippetId: string;
  94898. /** Gets or sets a matrix to use to compute projection */
  94899. defaultProjectionMatrix: Matrix;
  94900. /**
  94901. * Gets the maximum number of particles active at the same time.
  94902. * @returns The max number of active particles.
  94903. */
  94904. getCapacity(): number;
  94905. /**
  94906. * Gets the number of particles active at the same time.
  94907. * @returns The number of active particles.
  94908. */
  94909. getActiveCount(): number;
  94910. /**
  94911. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94912. * @returns True if it has been started, otherwise false.
  94913. */
  94914. isStarted(): boolean;
  94915. /**
  94916. * Animates the particle system for this frame.
  94917. */
  94918. animate(): void;
  94919. /**
  94920. * Renders the particle system in its current state.
  94921. * @returns the current number of particles
  94922. */
  94923. render(): number;
  94924. /**
  94925. * Dispose the particle system and frees its associated resources.
  94926. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94927. */
  94928. dispose(disposeTexture?: boolean): void;
  94929. /**
  94930. * An event triggered when the system is disposed
  94931. */
  94932. onDisposeObservable: Observable<IParticleSystem>;
  94933. /**
  94934. * An event triggered when the system is stopped
  94935. */
  94936. onStoppedObservable: Observable<IParticleSystem>;
  94937. /**
  94938. * Clones the particle system.
  94939. * @param name The name of the cloned object
  94940. * @param newEmitter The new emitter to use
  94941. * @returns the cloned particle system
  94942. */
  94943. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94944. /**
  94945. * Serializes the particle system to a JSON object
  94946. * @param serializeTexture defines if the texture must be serialized as well
  94947. * @returns the JSON object
  94948. */
  94949. serialize(serializeTexture: boolean): any;
  94950. /**
  94951. * Rebuild the particle system
  94952. */
  94953. rebuild(): void;
  94954. /** Force the system to rebuild all gradients that need to be resync */
  94955. forceRefreshGradients(): void;
  94956. /**
  94957. * Starts the particle system and begins to emit
  94958. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94959. */
  94960. start(delay?: number): void;
  94961. /**
  94962. * Stops the particle system.
  94963. */
  94964. stop(): void;
  94965. /**
  94966. * Remove all active particles
  94967. */
  94968. reset(): void;
  94969. /**
  94970. * Gets a boolean indicating that the system is stopping
  94971. * @returns true if the system is currently stopping
  94972. */
  94973. isStopping(): boolean;
  94974. /**
  94975. * Is this system ready to be used/rendered
  94976. * @return true if the system is ready
  94977. */
  94978. isReady(): boolean;
  94979. /**
  94980. * Returns the string "ParticleSystem"
  94981. * @returns a string containing the class name
  94982. */
  94983. getClassName(): string;
  94984. /**
  94985. * Gets the custom effect used to render the particles
  94986. * @param blendMode Blend mode for which the effect should be retrieved
  94987. * @returns The effect
  94988. */
  94989. getCustomEffect(blendMode: number): Nullable<Effect>;
  94990. /**
  94991. * Sets the custom effect used to render the particles
  94992. * @param effect The effect to set
  94993. * @param blendMode Blend mode for which the effect should be set
  94994. */
  94995. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  94996. /**
  94997. * Fill the defines array according to the current settings of the particle system
  94998. * @param defines Array to be updated
  94999. * @param blendMode blend mode to take into account when updating the array
  95000. */
  95001. fillDefines(defines: Array<string>, blendMode: number): void;
  95002. /**
  95003. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  95004. * @param uniforms Uniforms array to fill
  95005. * @param attributes Attributes array to fill
  95006. * @param samplers Samplers array to fill
  95007. */
  95008. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  95009. /**
  95010. * Observable that will be called just before the particles are drawn
  95011. */
  95012. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  95013. /**
  95014. * Gets the name of the particle vertex shader
  95015. */
  95016. vertexShaderName: string;
  95017. /**
  95018. * Adds a new color gradient
  95019. * @param gradient defines the gradient to use (between 0 and 1)
  95020. * @param color1 defines the color to affect to the specified gradient
  95021. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  95022. * @returns the current particle system
  95023. */
  95024. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  95025. /**
  95026. * Remove a specific color gradient
  95027. * @param gradient defines the gradient to remove
  95028. * @returns the current particle system
  95029. */
  95030. removeColorGradient(gradient: number): IParticleSystem;
  95031. /**
  95032. * Adds a new size gradient
  95033. * @param gradient defines the gradient to use (between 0 and 1)
  95034. * @param factor defines the size factor to affect to the specified gradient
  95035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95036. * @returns the current particle system
  95037. */
  95038. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95039. /**
  95040. * Remove a specific size gradient
  95041. * @param gradient defines the gradient to remove
  95042. * @returns the current particle system
  95043. */
  95044. removeSizeGradient(gradient: number): IParticleSystem;
  95045. /**
  95046. * Gets the current list of color gradients.
  95047. * You must use addColorGradient and removeColorGradient to udpate this list
  95048. * @returns the list of color gradients
  95049. */
  95050. getColorGradients(): Nullable<Array<ColorGradient>>;
  95051. /**
  95052. * Gets the current list of size gradients.
  95053. * You must use addSizeGradient and removeSizeGradient to udpate this list
  95054. * @returns the list of size gradients
  95055. */
  95056. getSizeGradients(): Nullable<Array<FactorGradient>>;
  95057. /**
  95058. * Gets the current list of angular speed gradients.
  95059. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  95060. * @returns the list of angular speed gradients
  95061. */
  95062. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  95063. /**
  95064. * Adds a new angular speed gradient
  95065. * @param gradient defines the gradient to use (between 0 and 1)
  95066. * @param factor defines the angular speed to affect to the specified gradient
  95067. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95068. * @returns the current particle system
  95069. */
  95070. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95071. /**
  95072. * Remove a specific angular speed gradient
  95073. * @param gradient defines the gradient to remove
  95074. * @returns the current particle system
  95075. */
  95076. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  95077. /**
  95078. * Gets the current list of velocity gradients.
  95079. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  95080. * @returns the list of velocity gradients
  95081. */
  95082. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  95083. /**
  95084. * Adds a new velocity gradient
  95085. * @param gradient defines the gradient to use (between 0 and 1)
  95086. * @param factor defines the velocity to affect to the specified gradient
  95087. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95088. * @returns the current particle system
  95089. */
  95090. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95091. /**
  95092. * Remove a specific velocity gradient
  95093. * @param gradient defines the gradient to remove
  95094. * @returns the current particle system
  95095. */
  95096. removeVelocityGradient(gradient: number): IParticleSystem;
  95097. /**
  95098. * Gets the current list of limit velocity gradients.
  95099. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  95100. * @returns the list of limit velocity gradients
  95101. */
  95102. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  95103. /**
  95104. * Adds a new limit velocity gradient
  95105. * @param gradient defines the gradient to use (between 0 and 1)
  95106. * @param factor defines the limit velocity to affect to the specified gradient
  95107. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95108. * @returns the current particle system
  95109. */
  95110. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95111. /**
  95112. * Remove a specific limit velocity gradient
  95113. * @param gradient defines the gradient to remove
  95114. * @returns the current particle system
  95115. */
  95116. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  95117. /**
  95118. * Adds a new drag gradient
  95119. * @param gradient defines the gradient to use (between 0 and 1)
  95120. * @param factor defines the drag to affect to the specified gradient
  95121. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95122. * @returns the current particle system
  95123. */
  95124. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95125. /**
  95126. * Remove a specific drag gradient
  95127. * @param gradient defines the gradient to remove
  95128. * @returns the current particle system
  95129. */
  95130. removeDragGradient(gradient: number): IParticleSystem;
  95131. /**
  95132. * Gets the current list of drag gradients.
  95133. * You must use addDragGradient and removeDragGradient to udpate this list
  95134. * @returns the list of drag gradients
  95135. */
  95136. getDragGradients(): Nullable<Array<FactorGradient>>;
  95137. /**
  95138. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  95139. * @param gradient defines the gradient to use (between 0 and 1)
  95140. * @param factor defines the emit rate to affect to the specified gradient
  95141. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95142. * @returns the current particle system
  95143. */
  95144. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95145. /**
  95146. * Remove a specific emit rate gradient
  95147. * @param gradient defines the gradient to remove
  95148. * @returns the current particle system
  95149. */
  95150. removeEmitRateGradient(gradient: number): IParticleSystem;
  95151. /**
  95152. * Gets the current list of emit rate gradients.
  95153. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  95154. * @returns the list of emit rate gradients
  95155. */
  95156. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  95157. /**
  95158. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  95159. * @param gradient defines the gradient to use (between 0 and 1)
  95160. * @param factor defines the start size to affect to the specified gradient
  95161. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95162. * @returns the current particle system
  95163. */
  95164. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95165. /**
  95166. * Remove a specific start size gradient
  95167. * @param gradient defines the gradient to remove
  95168. * @returns the current particle system
  95169. */
  95170. removeStartSizeGradient(gradient: number): IParticleSystem;
  95171. /**
  95172. * Gets the current list of start size gradients.
  95173. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  95174. * @returns the list of start size gradients
  95175. */
  95176. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  95177. /**
  95178. * Adds a new life time gradient
  95179. * @param gradient defines the gradient to use (between 0 and 1)
  95180. * @param factor defines the life time factor to affect to the specified gradient
  95181. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95182. * @returns the current particle system
  95183. */
  95184. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95185. /**
  95186. * Remove a specific life time gradient
  95187. * @param gradient defines the gradient to remove
  95188. * @returns the current particle system
  95189. */
  95190. removeLifeTimeGradient(gradient: number): IParticleSystem;
  95191. /**
  95192. * Gets the current list of life time gradients.
  95193. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  95194. * @returns the list of life time gradients
  95195. */
  95196. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  95197. /**
  95198. * Gets the current list of color gradients.
  95199. * You must use addColorGradient and removeColorGradient to udpate this list
  95200. * @returns the list of color gradients
  95201. */
  95202. getColorGradients(): Nullable<Array<ColorGradient>>;
  95203. /**
  95204. * Adds a new ramp gradient used to remap particle colors
  95205. * @param gradient defines the gradient to use (between 0 and 1)
  95206. * @param color defines the color to affect to the specified gradient
  95207. * @returns the current particle system
  95208. */
  95209. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  95210. /**
  95211. * Gets the current list of ramp gradients.
  95212. * You must use addRampGradient and removeRampGradient to udpate this list
  95213. * @returns the list of ramp gradients
  95214. */
  95215. getRampGradients(): Nullable<Array<Color3Gradient>>;
  95216. /** Gets or sets a boolean indicating that ramp gradients must be used
  95217. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  95218. */
  95219. useRampGradients: boolean;
  95220. /**
  95221. * Adds a new color remap gradient
  95222. * @param gradient defines the gradient to use (between 0 and 1)
  95223. * @param min defines the color remap minimal range
  95224. * @param max defines the color remap maximal range
  95225. * @returns the current particle system
  95226. */
  95227. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95228. /**
  95229. * Gets the current list of color remap gradients.
  95230. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  95231. * @returns the list of color remap gradients
  95232. */
  95233. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  95234. /**
  95235. * Adds a new alpha remap gradient
  95236. * @param gradient defines the gradient to use (between 0 and 1)
  95237. * @param min defines the alpha remap minimal range
  95238. * @param max defines the alpha remap maximal range
  95239. * @returns the current particle system
  95240. */
  95241. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95242. /**
  95243. * Gets the current list of alpha remap gradients.
  95244. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  95245. * @returns the list of alpha remap gradients
  95246. */
  95247. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  95248. /**
  95249. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  95250. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95251. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95252. * @returns the emitter
  95253. */
  95254. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  95255. /**
  95256. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  95257. * @param radius The radius of the hemisphere to emit from
  95258. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95259. * @returns the emitter
  95260. */
  95261. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  95262. /**
  95263. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  95264. * @param radius The radius of the sphere to emit from
  95265. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95266. * @returns the emitter
  95267. */
  95268. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  95269. /**
  95270. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  95271. * @param radius The radius of the sphere to emit from
  95272. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  95273. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  95274. * @returns the emitter
  95275. */
  95276. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95277. /**
  95278. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  95279. * @param radius The radius of the emission cylinder
  95280. * @param height The height of the emission cylinder
  95281. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  95282. * @param directionRandomizer How much to randomize the particle direction [0-1]
  95283. * @returns the emitter
  95284. */
  95285. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  95286. /**
  95287. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  95288. * @param radius The radius of the cylinder to emit from
  95289. * @param height The height of the emission cylinder
  95290. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95291. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  95292. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  95293. * @returns the emitter
  95294. */
  95295. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95296. /**
  95297. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  95298. * @param radius The radius of the cone to emit from
  95299. * @param angle The base angle of the cone
  95300. * @returns the emitter
  95301. */
  95302. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  95303. /**
  95304. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  95305. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95306. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95307. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95308. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95309. * @returns the emitter
  95310. */
  95311. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  95312. /**
  95313. * Get hosting scene
  95314. * @returns the scene
  95315. */
  95316. getScene(): Nullable<Scene>;
  95317. }
  95318. }
  95319. declare module BABYLON {
  95320. /**
  95321. * 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.
  95322. * @see https://doc.babylonjs.com/how_to/transformnode
  95323. */
  95324. export class TransformNode extends Node {
  95325. /**
  95326. * Object will not rotate to face the camera
  95327. */
  95328. static BILLBOARDMODE_NONE: number;
  95329. /**
  95330. * Object will rotate to face the camera but only on the x axis
  95331. */
  95332. static BILLBOARDMODE_X: number;
  95333. /**
  95334. * Object will rotate to face the camera but only on the y axis
  95335. */
  95336. static BILLBOARDMODE_Y: number;
  95337. /**
  95338. * Object will rotate to face the camera but only on the z axis
  95339. */
  95340. static BILLBOARDMODE_Z: number;
  95341. /**
  95342. * Object will rotate to face the camera
  95343. */
  95344. static BILLBOARDMODE_ALL: number;
  95345. /**
  95346. * Object will rotate to face the camera's position instead of orientation
  95347. */
  95348. static BILLBOARDMODE_USE_POSITION: number;
  95349. private static _TmpRotation;
  95350. private static _TmpScaling;
  95351. private static _TmpTranslation;
  95352. private _forward;
  95353. private _forwardInverted;
  95354. private _up;
  95355. private _right;
  95356. private _rightInverted;
  95357. private _position;
  95358. private _rotation;
  95359. private _rotationQuaternion;
  95360. protected _scaling: Vector3;
  95361. protected _isDirty: boolean;
  95362. private _transformToBoneReferal;
  95363. private _isAbsoluteSynced;
  95364. private _billboardMode;
  95365. /**
  95366. * Gets or sets the billboard mode. Default is 0.
  95367. *
  95368. * | Value | Type | Description |
  95369. * | --- | --- | --- |
  95370. * | 0 | BILLBOARDMODE_NONE | |
  95371. * | 1 | BILLBOARDMODE_X | |
  95372. * | 2 | BILLBOARDMODE_Y | |
  95373. * | 4 | BILLBOARDMODE_Z | |
  95374. * | 7 | BILLBOARDMODE_ALL | |
  95375. *
  95376. */
  95377. get billboardMode(): number;
  95378. set billboardMode(value: number);
  95379. private _preserveParentRotationForBillboard;
  95380. /**
  95381. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95382. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95383. */
  95384. get preserveParentRotationForBillboard(): boolean;
  95385. set preserveParentRotationForBillboard(value: boolean);
  95386. /**
  95387. * 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
  95388. */
  95389. scalingDeterminant: number;
  95390. private _infiniteDistance;
  95391. /**
  95392. * Gets or sets the distance of the object to max, often used by skybox
  95393. */
  95394. get infiniteDistance(): boolean;
  95395. set infiniteDistance(value: boolean);
  95396. /**
  95397. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95398. * By default the system will update normals to compensate
  95399. */
  95400. ignoreNonUniformScaling: boolean;
  95401. /**
  95402. * 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
  95403. */
  95404. reIntegrateRotationIntoRotationQuaternion: boolean;
  95405. /** @hidden */
  95406. _poseMatrix: Nullable<Matrix>;
  95407. /** @hidden */
  95408. _localMatrix: Matrix;
  95409. private _usePivotMatrix;
  95410. private _absolutePosition;
  95411. private _absoluteScaling;
  95412. private _absoluteRotationQuaternion;
  95413. private _pivotMatrix;
  95414. private _pivotMatrixInverse;
  95415. /** @hidden */
  95416. _postMultiplyPivotMatrix: boolean;
  95417. protected _isWorldMatrixFrozen: boolean;
  95418. /** @hidden */
  95419. _indexInSceneTransformNodesArray: number;
  95420. /**
  95421. * An event triggered after the world matrix is updated
  95422. */
  95423. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95424. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95425. /**
  95426. * Gets a string identifying the name of the class
  95427. * @returns "TransformNode" string
  95428. */
  95429. getClassName(): string;
  95430. /**
  95431. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95432. */
  95433. get position(): Vector3;
  95434. set position(newPosition: Vector3);
  95435. /**
  95436. * 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)).
  95437. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95438. */
  95439. get rotation(): Vector3;
  95440. set rotation(newRotation: Vector3);
  95441. /**
  95442. * 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)).
  95443. */
  95444. get scaling(): Vector3;
  95445. set scaling(newScaling: Vector3);
  95446. /**
  95447. * 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).
  95448. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95449. */
  95450. get rotationQuaternion(): Nullable<Quaternion>;
  95451. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95452. /**
  95453. * The forward direction of that transform in world space.
  95454. */
  95455. get forward(): Vector3;
  95456. /**
  95457. * The up direction of that transform in world space.
  95458. */
  95459. get up(): Vector3;
  95460. /**
  95461. * The right direction of that transform in world space.
  95462. */
  95463. get right(): Vector3;
  95464. /**
  95465. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95466. * @param matrix the matrix to copy the pose from
  95467. * @returns this TransformNode.
  95468. */
  95469. updatePoseMatrix(matrix: Matrix): TransformNode;
  95470. /**
  95471. * Returns the mesh Pose matrix.
  95472. * @returns the pose matrix
  95473. */
  95474. getPoseMatrix(): Matrix;
  95475. /** @hidden */
  95476. _isSynchronized(): boolean;
  95477. /** @hidden */
  95478. _initCache(): void;
  95479. /**
  95480. * Flag the transform node as dirty (Forcing it to update everything)
  95481. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95482. * @returns this transform node
  95483. */
  95484. markAsDirty(property: string): TransformNode;
  95485. /**
  95486. * Returns the current mesh absolute position.
  95487. * Returns a Vector3.
  95488. */
  95489. get absolutePosition(): Vector3;
  95490. /**
  95491. * Returns the current mesh absolute scaling.
  95492. * Returns a Vector3.
  95493. */
  95494. get absoluteScaling(): Vector3;
  95495. /**
  95496. * Returns the current mesh absolute rotation.
  95497. * Returns a Quaternion.
  95498. */
  95499. get absoluteRotationQuaternion(): Quaternion;
  95500. /**
  95501. * Sets a new matrix to apply before all other transformation
  95502. * @param matrix defines the transform matrix
  95503. * @returns the current TransformNode
  95504. */
  95505. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95506. /**
  95507. * Sets a new pivot matrix to the current node
  95508. * @param matrix defines the new pivot matrix to use
  95509. * @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
  95510. * @returns the current TransformNode
  95511. */
  95512. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95513. /**
  95514. * Returns the mesh pivot matrix.
  95515. * Default : Identity.
  95516. * @returns the matrix
  95517. */
  95518. getPivotMatrix(): Matrix;
  95519. /**
  95520. * Instantiate (when possible) or clone that node with its hierarchy
  95521. * @param newParent defines the new parent to use for the instance (or clone)
  95522. * @param options defines options to configure how copy is done
  95523. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95524. * @returns an instance (or a clone) of the current node with its hiearchy
  95525. */
  95526. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95527. doNotInstantiate: boolean;
  95528. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95529. /**
  95530. * Prevents the World matrix to be computed any longer
  95531. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95532. * @returns the TransformNode.
  95533. */
  95534. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95535. /**
  95536. * Allows back the World matrix computation.
  95537. * @returns the TransformNode.
  95538. */
  95539. unfreezeWorldMatrix(): this;
  95540. /**
  95541. * True if the World matrix has been frozen.
  95542. */
  95543. get isWorldMatrixFrozen(): boolean;
  95544. /**
  95545. * Retuns the mesh absolute position in the World.
  95546. * @returns a Vector3.
  95547. */
  95548. getAbsolutePosition(): Vector3;
  95549. /**
  95550. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95551. * @param absolutePosition the absolute position to set
  95552. * @returns the TransformNode.
  95553. */
  95554. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95555. /**
  95556. * Sets the mesh position in its local space.
  95557. * @param vector3 the position to set in localspace
  95558. * @returns the TransformNode.
  95559. */
  95560. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95561. /**
  95562. * Returns the mesh position in the local space from the current World matrix values.
  95563. * @returns a new Vector3.
  95564. */
  95565. getPositionExpressedInLocalSpace(): Vector3;
  95566. /**
  95567. * Translates the mesh along the passed Vector3 in its local space.
  95568. * @param vector3 the distance to translate in localspace
  95569. * @returns the TransformNode.
  95570. */
  95571. locallyTranslate(vector3: Vector3): TransformNode;
  95572. private static _lookAtVectorCache;
  95573. /**
  95574. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95575. * @param targetPoint the position (must be in same space as current mesh) to look at
  95576. * @param yawCor optional yaw (y-axis) correction in radians
  95577. * @param pitchCor optional pitch (x-axis) correction in radians
  95578. * @param rollCor optional roll (z-axis) correction in radians
  95579. * @param space the choosen space of the target
  95580. * @returns the TransformNode.
  95581. */
  95582. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95583. /**
  95584. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95585. * This Vector3 is expressed in the World space.
  95586. * @param localAxis axis to rotate
  95587. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95588. */
  95589. getDirection(localAxis: Vector3): Vector3;
  95590. /**
  95591. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95592. * localAxis is expressed in the mesh local space.
  95593. * result is computed in the Wordl space from the mesh World matrix.
  95594. * @param localAxis axis to rotate
  95595. * @param result the resulting transformnode
  95596. * @returns this TransformNode.
  95597. */
  95598. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95599. /**
  95600. * Sets this transform node rotation to the given local axis.
  95601. * @param localAxis the axis in local space
  95602. * @param yawCor optional yaw (y-axis) correction in radians
  95603. * @param pitchCor optional pitch (x-axis) correction in radians
  95604. * @param rollCor optional roll (z-axis) correction in radians
  95605. * @returns this TransformNode
  95606. */
  95607. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95608. /**
  95609. * Sets a new pivot point to the current node
  95610. * @param point defines the new pivot point to use
  95611. * @param space defines if the point is in world or local space (local by default)
  95612. * @returns the current TransformNode
  95613. */
  95614. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95615. /**
  95616. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95617. * @returns the pivot point
  95618. */
  95619. getPivotPoint(): Vector3;
  95620. /**
  95621. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95622. * @param result the vector3 to store the result
  95623. * @returns this TransformNode.
  95624. */
  95625. getPivotPointToRef(result: Vector3): TransformNode;
  95626. /**
  95627. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95628. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95629. */
  95630. getAbsolutePivotPoint(): Vector3;
  95631. /**
  95632. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95633. * @param result vector3 to store the result
  95634. * @returns this TransformNode.
  95635. */
  95636. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95637. /**
  95638. * Defines the passed node as the parent of the current node.
  95639. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95640. * @see https://doc.babylonjs.com/how_to/parenting
  95641. * @param node the node ot set as the parent
  95642. * @returns this TransformNode.
  95643. */
  95644. setParent(node: Nullable<Node>): TransformNode;
  95645. private _nonUniformScaling;
  95646. /**
  95647. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95648. */
  95649. get nonUniformScaling(): boolean;
  95650. /** @hidden */
  95651. _updateNonUniformScalingState(value: boolean): boolean;
  95652. /**
  95653. * Attach the current TransformNode to another TransformNode associated with a bone
  95654. * @param bone Bone affecting the TransformNode
  95655. * @param affectedTransformNode TransformNode associated with the bone
  95656. * @returns this object
  95657. */
  95658. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95659. /**
  95660. * Detach the transform node if its associated with a bone
  95661. * @returns this object
  95662. */
  95663. detachFromBone(): TransformNode;
  95664. private static _rotationAxisCache;
  95665. /**
  95666. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95667. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95668. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95669. * The passed axis is also normalized.
  95670. * @param axis the axis to rotate around
  95671. * @param amount the amount to rotate in radians
  95672. * @param space Space to rotate in (Default: local)
  95673. * @returns the TransformNode.
  95674. */
  95675. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95676. /**
  95677. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95678. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95679. * The passed axis is also normalized. .
  95680. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95681. * @param point the point to rotate around
  95682. * @param axis the axis to rotate around
  95683. * @param amount the amount to rotate in radians
  95684. * @returns the TransformNode
  95685. */
  95686. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95687. /**
  95688. * Translates the mesh along the axis vector for the passed distance in the given space.
  95689. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95690. * @param axis the axis to translate in
  95691. * @param distance the distance to translate
  95692. * @param space Space to rotate in (Default: local)
  95693. * @returns the TransformNode.
  95694. */
  95695. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95696. /**
  95697. * Adds a rotation step to the mesh current rotation.
  95698. * x, y, z are Euler angles expressed in radians.
  95699. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95700. * This means this rotation is made in the mesh local space only.
  95701. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95702. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95703. * ```javascript
  95704. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95705. * ```
  95706. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95707. * 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.
  95708. * @param x Rotation to add
  95709. * @param y Rotation to add
  95710. * @param z Rotation to add
  95711. * @returns the TransformNode.
  95712. */
  95713. addRotation(x: number, y: number, z: number): TransformNode;
  95714. /**
  95715. * @hidden
  95716. */
  95717. protected _getEffectiveParent(): Nullable<Node>;
  95718. /**
  95719. * Computes the world matrix of the node
  95720. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95721. * @returns the world matrix
  95722. */
  95723. computeWorldMatrix(force?: boolean): Matrix;
  95724. /**
  95725. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95726. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95727. */
  95728. resetLocalMatrix(independentOfChildren?: boolean): void;
  95729. protected _afterComputeWorldMatrix(): void;
  95730. /**
  95731. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95732. * @param func callback function to add
  95733. *
  95734. * @returns the TransformNode.
  95735. */
  95736. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95737. /**
  95738. * Removes a registered callback function.
  95739. * @param func callback function to remove
  95740. * @returns the TransformNode.
  95741. */
  95742. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95743. /**
  95744. * Gets the position of the current mesh in camera space
  95745. * @param camera defines the camera to use
  95746. * @returns a position
  95747. */
  95748. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95749. /**
  95750. * Returns the distance from the mesh to the active camera
  95751. * @param camera defines the camera to use
  95752. * @returns the distance
  95753. */
  95754. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95755. /**
  95756. * Clone the current transform node
  95757. * @param name Name of the new clone
  95758. * @param newParent New parent for the clone
  95759. * @param doNotCloneChildren Do not clone children hierarchy
  95760. * @returns the new transform node
  95761. */
  95762. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95763. /**
  95764. * Serializes the objects information.
  95765. * @param currentSerializationObject defines the object to serialize in
  95766. * @returns the serialized object
  95767. */
  95768. serialize(currentSerializationObject?: any): any;
  95769. /**
  95770. * Returns a new TransformNode object parsed from the source provided.
  95771. * @param parsedTransformNode is the source.
  95772. * @param scene the scne the object belongs to
  95773. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95774. * @returns a new TransformNode object parsed from the source provided.
  95775. */
  95776. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95777. /**
  95778. * Get all child-transformNodes of this node
  95779. * @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
  95780. * @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
  95781. * @returns an array of TransformNode
  95782. */
  95783. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95784. /**
  95785. * Releases resources associated with this transform node.
  95786. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95787. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95788. */
  95789. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95790. /**
  95791. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95792. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95793. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95794. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95795. * @returns the current mesh
  95796. */
  95797. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95798. private _syncAbsoluteScalingAndRotation;
  95799. }
  95800. }
  95801. declare module BABYLON {
  95802. /**
  95803. * Class used to override all child animations of a given target
  95804. */
  95805. export class AnimationPropertiesOverride {
  95806. /**
  95807. * Gets or sets a value indicating if animation blending must be used
  95808. */
  95809. enableBlending: boolean;
  95810. /**
  95811. * Gets or sets the blending speed to use when enableBlending is true
  95812. */
  95813. blendingSpeed: number;
  95814. /**
  95815. * Gets or sets the default loop mode to use
  95816. */
  95817. loopMode: number;
  95818. }
  95819. }
  95820. declare module BABYLON {
  95821. /**
  95822. * Class used to store bone information
  95823. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95824. */
  95825. export class Bone extends Node {
  95826. /**
  95827. * defines the bone name
  95828. */
  95829. name: string;
  95830. private static _tmpVecs;
  95831. private static _tmpQuat;
  95832. private static _tmpMats;
  95833. /**
  95834. * Gets the list of child bones
  95835. */
  95836. children: Bone[];
  95837. /** Gets the animations associated with this bone */
  95838. animations: Animation[];
  95839. /**
  95840. * Gets or sets bone length
  95841. */
  95842. length: number;
  95843. /**
  95844. * @hidden Internal only
  95845. * Set this value to map this bone to a different index in the transform matrices
  95846. * Set this value to -1 to exclude the bone from the transform matrices
  95847. */
  95848. _index: Nullable<number>;
  95849. private _skeleton;
  95850. private _localMatrix;
  95851. private _restPose;
  95852. private _bindPose;
  95853. private _baseMatrix;
  95854. private _absoluteTransform;
  95855. private _invertedAbsoluteTransform;
  95856. private _parent;
  95857. private _scalingDeterminant;
  95858. private _worldTransform;
  95859. private _localScaling;
  95860. private _localRotation;
  95861. private _localPosition;
  95862. private _needToDecompose;
  95863. private _needToCompose;
  95864. /** @hidden */
  95865. _linkedTransformNode: Nullable<TransformNode>;
  95866. /** @hidden */
  95867. _waitingTransformNodeId: Nullable<string>;
  95868. /** @hidden */
  95869. get _matrix(): Matrix;
  95870. /** @hidden */
  95871. set _matrix(value: Matrix);
  95872. /**
  95873. * Create a new bone
  95874. * @param name defines the bone name
  95875. * @param skeleton defines the parent skeleton
  95876. * @param parentBone defines the parent (can be null if the bone is the root)
  95877. * @param localMatrix defines the local matrix
  95878. * @param restPose defines the rest pose matrix
  95879. * @param baseMatrix defines the base matrix
  95880. * @param index defines index of the bone in the hiearchy
  95881. */
  95882. constructor(
  95883. /**
  95884. * defines the bone name
  95885. */
  95886. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95887. /**
  95888. * Gets the current object class name.
  95889. * @return the class name
  95890. */
  95891. getClassName(): string;
  95892. /**
  95893. * Gets the parent skeleton
  95894. * @returns a skeleton
  95895. */
  95896. getSkeleton(): Skeleton;
  95897. /**
  95898. * Gets parent bone
  95899. * @returns a bone or null if the bone is the root of the bone hierarchy
  95900. */
  95901. getParent(): Nullable<Bone>;
  95902. /**
  95903. * Returns an array containing the root bones
  95904. * @returns an array containing the root bones
  95905. */
  95906. getChildren(): Array<Bone>;
  95907. /**
  95908. * Gets the node index in matrix array generated for rendering
  95909. * @returns the node index
  95910. */
  95911. getIndex(): number;
  95912. /**
  95913. * Sets the parent bone
  95914. * @param parent defines the parent (can be null if the bone is the root)
  95915. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95916. */
  95917. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  95918. /**
  95919. * Gets the local matrix
  95920. * @returns a matrix
  95921. */
  95922. getLocalMatrix(): Matrix;
  95923. /**
  95924. * Gets the base matrix (initial matrix which remains unchanged)
  95925. * @returns a matrix
  95926. */
  95927. getBaseMatrix(): Matrix;
  95928. /**
  95929. * Gets the rest pose matrix
  95930. * @returns a matrix
  95931. */
  95932. getRestPose(): Matrix;
  95933. /**
  95934. * Sets the rest pose matrix
  95935. * @param matrix the local-space rest pose to set for this bone
  95936. */
  95937. setRestPose(matrix: Matrix): void;
  95938. /**
  95939. * Gets the bind pose matrix
  95940. * @returns the bind pose matrix
  95941. */
  95942. getBindPose(): Matrix;
  95943. /**
  95944. * Sets the bind pose matrix
  95945. * @param matrix the local-space bind pose to set for this bone
  95946. */
  95947. setBindPose(matrix: Matrix): void;
  95948. /**
  95949. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95950. */
  95951. getWorldMatrix(): Matrix;
  95952. /**
  95953. * Sets the local matrix to rest pose matrix
  95954. */
  95955. returnToRest(): void;
  95956. /**
  95957. * Gets the inverse of the absolute transform matrix.
  95958. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95959. * @returns a matrix
  95960. */
  95961. getInvertedAbsoluteTransform(): Matrix;
  95962. /**
  95963. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95964. * @returns a matrix
  95965. */
  95966. getAbsoluteTransform(): Matrix;
  95967. /**
  95968. * Links with the given transform node.
  95969. * The local matrix of this bone is copied from the transform node every frame.
  95970. * @param transformNode defines the transform node to link to
  95971. */
  95972. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95973. /**
  95974. * Gets the node used to drive the bone's transformation
  95975. * @returns a transform node or null
  95976. */
  95977. getTransformNode(): Nullable<TransformNode>;
  95978. /** Gets or sets current position (in local space) */
  95979. get position(): Vector3;
  95980. set position(newPosition: Vector3);
  95981. /** Gets or sets current rotation (in local space) */
  95982. get rotation(): Vector3;
  95983. set rotation(newRotation: Vector3);
  95984. /** Gets or sets current rotation quaternion (in local space) */
  95985. get rotationQuaternion(): Quaternion;
  95986. set rotationQuaternion(newRotation: Quaternion);
  95987. /** Gets or sets current scaling (in local space) */
  95988. get scaling(): Vector3;
  95989. set scaling(newScaling: Vector3);
  95990. /**
  95991. * Gets the animation properties override
  95992. */
  95993. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95994. private _decompose;
  95995. private _compose;
  95996. /**
  95997. * Update the base and local matrices
  95998. * @param matrix defines the new base or local matrix
  95999. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96000. * @param updateLocalMatrix defines if the local matrix should be updated
  96001. */
  96002. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  96003. /** @hidden */
  96004. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  96005. /**
  96006. * Flag the bone as dirty (Forcing it to update everything)
  96007. */
  96008. markAsDirty(): void;
  96009. /** @hidden */
  96010. _markAsDirtyAndCompose(): void;
  96011. private _markAsDirtyAndDecompose;
  96012. /**
  96013. * Translate the bone in local or world space
  96014. * @param vec The amount to translate the bone
  96015. * @param space The space that the translation is in
  96016. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96017. */
  96018. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96019. /**
  96020. * Set the postion of the bone in local or world space
  96021. * @param position The position to set the bone
  96022. * @param space The space that the position is in
  96023. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96024. */
  96025. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96026. /**
  96027. * Set the absolute position of the bone (world space)
  96028. * @param position The position to set the bone
  96029. * @param mesh The mesh that this bone is attached to
  96030. */
  96031. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  96032. /**
  96033. * Scale the bone on the x, y and z axes (in local space)
  96034. * @param x The amount to scale the bone on the x axis
  96035. * @param y The amount to scale the bone on the y axis
  96036. * @param z The amount to scale the bone on the z axis
  96037. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  96038. */
  96039. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  96040. /**
  96041. * Set the bone scaling in local space
  96042. * @param scale defines the scaling vector
  96043. */
  96044. setScale(scale: Vector3): void;
  96045. /**
  96046. * Gets the current scaling in local space
  96047. * @returns the current scaling vector
  96048. */
  96049. getScale(): Vector3;
  96050. /**
  96051. * Gets the current scaling in local space and stores it in a target vector
  96052. * @param result defines the target vector
  96053. */
  96054. getScaleToRef(result: Vector3): void;
  96055. /**
  96056. * Set the yaw, pitch, and roll of the bone in local or world space
  96057. * @param yaw The rotation of the bone on the y axis
  96058. * @param pitch The rotation of the bone on the x axis
  96059. * @param roll The rotation of the bone on the z axis
  96060. * @param space The space that the axes of rotation are in
  96061. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96062. */
  96063. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  96064. /**
  96065. * Add a rotation to the bone on an axis in local or world space
  96066. * @param axis The axis to rotate the bone on
  96067. * @param amount The amount to rotate the bone
  96068. * @param space The space that the axis is in
  96069. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96070. */
  96071. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  96072. /**
  96073. * Set the rotation of the bone to a particular axis angle in local or world space
  96074. * @param axis The axis to rotate the bone on
  96075. * @param angle The angle that the bone should be rotated to
  96076. * @param space The space that the axis is in
  96077. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96078. */
  96079. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  96080. /**
  96081. * Set the euler rotation of the bone in local or world space
  96082. * @param rotation The euler rotation that the bone should be set to
  96083. * @param space The space that the rotation is in
  96084. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96085. */
  96086. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96087. /**
  96088. * Set the quaternion rotation of the bone in local or world space
  96089. * @param quat The quaternion rotation that the bone should be set to
  96090. * @param space The space that the rotation is in
  96091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96092. */
  96093. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  96094. /**
  96095. * Set the rotation matrix of the bone in local or world space
  96096. * @param rotMat The rotation matrix that the bone should be set to
  96097. * @param space The space that the rotation is in
  96098. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96099. */
  96100. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  96101. private _rotateWithMatrix;
  96102. private _getNegativeRotationToRef;
  96103. /**
  96104. * Get the position of the bone in local or world space
  96105. * @param space The space that the returned position is in
  96106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96107. * @returns The position of the bone
  96108. */
  96109. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96110. /**
  96111. * Copy the position of the bone to a vector3 in local or world space
  96112. * @param space The space that the returned position is in
  96113. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96114. * @param result The vector3 to copy the position to
  96115. */
  96116. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  96117. /**
  96118. * Get the absolute position of the bone (world space)
  96119. * @param mesh The mesh that this bone is attached to
  96120. * @returns The absolute position of the bone
  96121. */
  96122. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  96123. /**
  96124. * Copy the absolute position of the bone (world space) to the result param
  96125. * @param mesh The mesh that this bone is attached to
  96126. * @param result The vector3 to copy the absolute position to
  96127. */
  96128. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  96129. /**
  96130. * Compute the absolute transforms of this bone and its children
  96131. */
  96132. computeAbsoluteTransforms(): void;
  96133. /**
  96134. * Get the world direction from an axis that is in the local space of the bone
  96135. * @param localAxis The local direction that is used to compute the world direction
  96136. * @param mesh The mesh that this bone is attached to
  96137. * @returns The world direction
  96138. */
  96139. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96140. /**
  96141. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  96142. * @param localAxis The local direction that is used to compute the world direction
  96143. * @param mesh The mesh that this bone is attached to
  96144. * @param result The vector3 that the world direction will be copied to
  96145. */
  96146. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96147. /**
  96148. * Get the euler rotation of the bone in local or world space
  96149. * @param space The space that the rotation should be in
  96150. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96151. * @returns The euler rotation
  96152. */
  96153. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96154. /**
  96155. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  96156. * @param space The space that the rotation should be in
  96157. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96158. * @param result The vector3 that the rotation should be copied to
  96159. */
  96160. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96161. /**
  96162. * Get the quaternion rotation of the bone in either local or world space
  96163. * @param space The space that the rotation should be in
  96164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96165. * @returns The quaternion rotation
  96166. */
  96167. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  96168. /**
  96169. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  96170. * @param space The space that the rotation should be in
  96171. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96172. * @param result The quaternion that the rotation should be copied to
  96173. */
  96174. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  96175. /**
  96176. * Get the rotation matrix of the bone in local or world space
  96177. * @param space The space that the rotation should be in
  96178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96179. * @returns The rotation matrix
  96180. */
  96181. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  96182. /**
  96183. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  96184. * @param space The space that the rotation should be in
  96185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96186. * @param result The quaternion that the rotation should be copied to
  96187. */
  96188. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  96189. /**
  96190. * Get the world position of a point that is in the local space of the bone
  96191. * @param position The local position
  96192. * @param mesh The mesh that this bone is attached to
  96193. * @returns The world position
  96194. */
  96195. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96196. /**
  96197. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  96198. * @param position The local position
  96199. * @param mesh The mesh that this bone is attached to
  96200. * @param result The vector3 that the world position should be copied to
  96201. */
  96202. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96203. /**
  96204. * Get the local position of a point that is in world space
  96205. * @param position The world position
  96206. * @param mesh The mesh that this bone is attached to
  96207. * @returns The local position
  96208. */
  96209. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96210. /**
  96211. * Get the local position of a point that is in world space and copy it to the result param
  96212. * @param position The world position
  96213. * @param mesh The mesh that this bone is attached to
  96214. * @param result The vector3 that the local position should be copied to
  96215. */
  96216. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96217. /**
  96218. * Set the current local matrix as the restPose for this bone.
  96219. */
  96220. setCurrentPoseAsRest(): void;
  96221. }
  96222. }
  96223. declare module BABYLON {
  96224. /**
  96225. * Defines a runtime animation
  96226. */
  96227. export class RuntimeAnimation {
  96228. private _events;
  96229. /**
  96230. * The current frame of the runtime animation
  96231. */
  96232. private _currentFrame;
  96233. /**
  96234. * The animation used by the runtime animation
  96235. */
  96236. private _animation;
  96237. /**
  96238. * The target of the runtime animation
  96239. */
  96240. private _target;
  96241. /**
  96242. * The initiating animatable
  96243. */
  96244. private _host;
  96245. /**
  96246. * The original value of the runtime animation
  96247. */
  96248. private _originalValue;
  96249. /**
  96250. * The original blend value of the runtime animation
  96251. */
  96252. private _originalBlendValue;
  96253. /**
  96254. * The offsets cache of the runtime animation
  96255. */
  96256. private _offsetsCache;
  96257. /**
  96258. * The high limits cache of the runtime animation
  96259. */
  96260. private _highLimitsCache;
  96261. /**
  96262. * Specifies if the runtime animation has been stopped
  96263. */
  96264. private _stopped;
  96265. /**
  96266. * The blending factor of the runtime animation
  96267. */
  96268. private _blendingFactor;
  96269. /**
  96270. * The BabylonJS scene
  96271. */
  96272. private _scene;
  96273. /**
  96274. * The current value of the runtime animation
  96275. */
  96276. private _currentValue;
  96277. /** @hidden */
  96278. _animationState: _IAnimationState;
  96279. /**
  96280. * The active target of the runtime animation
  96281. */
  96282. private _activeTargets;
  96283. private _currentActiveTarget;
  96284. private _directTarget;
  96285. /**
  96286. * The target path of the runtime animation
  96287. */
  96288. private _targetPath;
  96289. /**
  96290. * The weight of the runtime animation
  96291. */
  96292. private _weight;
  96293. /**
  96294. * The ratio offset of the runtime animation
  96295. */
  96296. private _ratioOffset;
  96297. /**
  96298. * The previous delay of the runtime animation
  96299. */
  96300. private _previousDelay;
  96301. /**
  96302. * The previous ratio of the runtime animation
  96303. */
  96304. private _previousRatio;
  96305. private _enableBlending;
  96306. private _keys;
  96307. private _minFrame;
  96308. private _maxFrame;
  96309. private _minValue;
  96310. private _maxValue;
  96311. private _targetIsArray;
  96312. /**
  96313. * Gets the current frame of the runtime animation
  96314. */
  96315. get currentFrame(): number;
  96316. /**
  96317. * Gets the weight of the runtime animation
  96318. */
  96319. get weight(): number;
  96320. /**
  96321. * Gets the current value of the runtime animation
  96322. */
  96323. get currentValue(): any;
  96324. /**
  96325. * Gets the target path of the runtime animation
  96326. */
  96327. get targetPath(): string;
  96328. /**
  96329. * Gets the actual target of the runtime animation
  96330. */
  96331. get target(): any;
  96332. /**
  96333. * Gets the additive state of the runtime animation
  96334. */
  96335. get isAdditive(): boolean;
  96336. /** @hidden */
  96337. _onLoop: () => void;
  96338. /**
  96339. * Create a new RuntimeAnimation object
  96340. * @param target defines the target of the animation
  96341. * @param animation defines the source animation object
  96342. * @param scene defines the hosting scene
  96343. * @param host defines the initiating Animatable
  96344. */
  96345. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  96346. private _preparePath;
  96347. /**
  96348. * Gets the animation from the runtime animation
  96349. */
  96350. get animation(): Animation;
  96351. /**
  96352. * Resets the runtime animation to the beginning
  96353. * @param restoreOriginal defines whether to restore the target property to the original value
  96354. */
  96355. reset(restoreOriginal?: boolean): void;
  96356. /**
  96357. * Specifies if the runtime animation is stopped
  96358. * @returns Boolean specifying if the runtime animation is stopped
  96359. */
  96360. isStopped(): boolean;
  96361. /**
  96362. * Disposes of the runtime animation
  96363. */
  96364. dispose(): void;
  96365. /**
  96366. * Apply the interpolated value to the target
  96367. * @param currentValue defines the value computed by the animation
  96368. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  96369. */
  96370. setValue(currentValue: any, weight: number): void;
  96371. private _getOriginalValues;
  96372. private _setValue;
  96373. /**
  96374. * Gets the loop pmode of the runtime animation
  96375. * @returns Loop Mode
  96376. */
  96377. private _getCorrectLoopMode;
  96378. /**
  96379. * Move the current animation to a given frame
  96380. * @param frame defines the frame to move to
  96381. */
  96382. goToFrame(frame: number): void;
  96383. /**
  96384. * @hidden Internal use only
  96385. */
  96386. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96387. /**
  96388. * Execute the current animation
  96389. * @param delay defines the delay to add to the current frame
  96390. * @param from defines the lower bound of the animation range
  96391. * @param to defines the upper bound of the animation range
  96392. * @param loop defines if the current animation must loop
  96393. * @param speedRatio defines the current speed ratio
  96394. * @param weight defines the weight of the animation (default is -1 so no weight)
  96395. * @param onLoop optional callback called when animation loops
  96396. * @returns a boolean indicating if the animation is running
  96397. */
  96398. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96399. }
  96400. }
  96401. declare module BABYLON {
  96402. /**
  96403. * Class used to store an actual running animation
  96404. */
  96405. export class Animatable {
  96406. /** defines the target object */
  96407. target: any;
  96408. /** defines the starting frame number (default is 0) */
  96409. fromFrame: number;
  96410. /** defines the ending frame number (default is 100) */
  96411. toFrame: number;
  96412. /** defines if the animation must loop (default is false) */
  96413. loopAnimation: boolean;
  96414. /** defines a callback to call when animation ends if it is not looping */
  96415. onAnimationEnd?: (() => void) | null | undefined;
  96416. /** defines a callback to call when animation loops */
  96417. onAnimationLoop?: (() => void) | null | undefined;
  96418. /** defines whether the animation should be evaluated additively */
  96419. isAdditive: boolean;
  96420. private _localDelayOffset;
  96421. private _pausedDelay;
  96422. private _runtimeAnimations;
  96423. private _paused;
  96424. private _scene;
  96425. private _speedRatio;
  96426. private _weight;
  96427. private _syncRoot;
  96428. /**
  96429. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96430. * This will only apply for non looping animation (default is true)
  96431. */
  96432. disposeOnEnd: boolean;
  96433. /**
  96434. * Gets a boolean indicating if the animation has started
  96435. */
  96436. animationStarted: boolean;
  96437. /**
  96438. * Observer raised when the animation ends
  96439. */
  96440. onAnimationEndObservable: Observable<Animatable>;
  96441. /**
  96442. * Observer raised when the animation loops
  96443. */
  96444. onAnimationLoopObservable: Observable<Animatable>;
  96445. /**
  96446. * Gets the root Animatable used to synchronize and normalize animations
  96447. */
  96448. get syncRoot(): Nullable<Animatable>;
  96449. /**
  96450. * Gets the current frame of the first RuntimeAnimation
  96451. * Used to synchronize Animatables
  96452. */
  96453. get masterFrame(): number;
  96454. /**
  96455. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96456. */
  96457. get weight(): number;
  96458. set weight(value: number);
  96459. /**
  96460. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96461. */
  96462. get speedRatio(): number;
  96463. set speedRatio(value: number);
  96464. /**
  96465. * Creates a new Animatable
  96466. * @param scene defines the hosting scene
  96467. * @param target defines the target object
  96468. * @param fromFrame defines the starting frame number (default is 0)
  96469. * @param toFrame defines the ending frame number (default is 100)
  96470. * @param loopAnimation defines if the animation must loop (default is false)
  96471. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96472. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96473. * @param animations defines a group of animation to add to the new Animatable
  96474. * @param onAnimationLoop defines a callback to call when animation loops
  96475. * @param isAdditive defines whether the animation should be evaluated additively
  96476. */
  96477. constructor(scene: Scene,
  96478. /** defines the target object */
  96479. target: any,
  96480. /** defines the starting frame number (default is 0) */
  96481. fromFrame?: number,
  96482. /** defines the ending frame number (default is 100) */
  96483. toFrame?: number,
  96484. /** defines if the animation must loop (default is false) */
  96485. loopAnimation?: boolean, speedRatio?: number,
  96486. /** defines a callback to call when animation ends if it is not looping */
  96487. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96488. /** defines a callback to call when animation loops */
  96489. onAnimationLoop?: (() => void) | null | undefined,
  96490. /** defines whether the animation should be evaluated additively */
  96491. isAdditive?: boolean);
  96492. /**
  96493. * Synchronize and normalize current Animatable with a source Animatable
  96494. * This is useful when using animation weights and when animations are not of the same length
  96495. * @param root defines the root Animatable to synchronize with
  96496. * @returns the current Animatable
  96497. */
  96498. syncWith(root: Animatable): Animatable;
  96499. /**
  96500. * Gets the list of runtime animations
  96501. * @returns an array of RuntimeAnimation
  96502. */
  96503. getAnimations(): RuntimeAnimation[];
  96504. /**
  96505. * Adds more animations to the current animatable
  96506. * @param target defines the target of the animations
  96507. * @param animations defines the new animations to add
  96508. */
  96509. appendAnimations(target: any, animations: Animation[]): void;
  96510. /**
  96511. * Gets the source animation for a specific property
  96512. * @param property defines the propertyu to look for
  96513. * @returns null or the source animation for the given property
  96514. */
  96515. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96516. /**
  96517. * Gets the runtime animation for a specific property
  96518. * @param property defines the propertyu to look for
  96519. * @returns null or the runtime animation for the given property
  96520. */
  96521. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96522. /**
  96523. * Resets the animatable to its original state
  96524. */
  96525. reset(): void;
  96526. /**
  96527. * Allows the animatable to blend with current running animations
  96528. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96529. * @param blendingSpeed defines the blending speed to use
  96530. */
  96531. enableBlending(blendingSpeed: number): void;
  96532. /**
  96533. * Disable animation blending
  96534. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96535. */
  96536. disableBlending(): void;
  96537. /**
  96538. * Jump directly to a given frame
  96539. * @param frame defines the frame to jump to
  96540. */
  96541. goToFrame(frame: number): void;
  96542. /**
  96543. * Pause the animation
  96544. */
  96545. pause(): void;
  96546. /**
  96547. * Restart the animation
  96548. */
  96549. restart(): void;
  96550. private _raiseOnAnimationEnd;
  96551. /**
  96552. * Stop and delete the current animation
  96553. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96554. * @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)
  96555. */
  96556. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96557. /**
  96558. * Wait asynchronously for the animation to end
  96559. * @returns a promise which will be fullfilled when the animation ends
  96560. */
  96561. waitAsync(): Promise<Animatable>;
  96562. /** @hidden */
  96563. _animate(delay: number): boolean;
  96564. }
  96565. interface Scene {
  96566. /** @hidden */
  96567. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96568. /** @hidden */
  96569. _processLateAnimationBindingsForMatrices(holder: {
  96570. totalWeight: number;
  96571. totalAdditiveWeight: number;
  96572. animations: RuntimeAnimation[];
  96573. additiveAnimations: RuntimeAnimation[];
  96574. originalValue: Matrix;
  96575. }): any;
  96576. /** @hidden */
  96577. _processLateAnimationBindingsForQuaternions(holder: {
  96578. totalWeight: number;
  96579. totalAdditiveWeight: number;
  96580. animations: RuntimeAnimation[];
  96581. additiveAnimations: RuntimeAnimation[];
  96582. originalValue: Quaternion;
  96583. }, refQuaternion: Quaternion): Quaternion;
  96584. /** @hidden */
  96585. _processLateAnimationBindings(): void;
  96586. /**
  96587. * Will start the animation sequence of a given target
  96588. * @param target defines the target
  96589. * @param from defines from which frame should animation start
  96590. * @param to defines until which frame should animation run.
  96591. * @param weight defines the weight to apply to the animation (1.0 by default)
  96592. * @param loop defines if the animation loops
  96593. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96594. * @param onAnimationEnd defines the function to be executed when the animation ends
  96595. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96596. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96597. * @param onAnimationLoop defines the callback to call when an animation loops
  96598. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96599. * @returns the animatable object created for this animation
  96600. */
  96601. 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;
  96602. /**
  96603. * Will start the animation sequence of a given target
  96604. * @param target defines the target
  96605. * @param from defines from which frame should animation start
  96606. * @param to defines until which frame should animation run.
  96607. * @param loop defines if the animation loops
  96608. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96609. * @param onAnimationEnd defines the function to be executed when the animation ends
  96610. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96611. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96612. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96613. * @param onAnimationLoop defines the callback to call when an animation loops
  96614. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96615. * @returns the animatable object created for this animation
  96616. */
  96617. 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;
  96618. /**
  96619. * Will start the animation sequence of a given target and its hierarchy
  96620. * @param target defines the target
  96621. * @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.
  96622. * @param from defines from which frame should animation start
  96623. * @param to defines until which frame should animation run.
  96624. * @param loop defines if the animation loops
  96625. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96626. * @param onAnimationEnd defines the function to be executed when the animation ends
  96627. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96628. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96629. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96630. * @param onAnimationLoop defines the callback to call when an animation loops
  96631. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96632. * @returns the list of created animatables
  96633. */
  96634. 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[];
  96635. /**
  96636. * Begin a new animation on a given node
  96637. * @param target defines the target where the animation will take place
  96638. * @param animations defines the list of animations to start
  96639. * @param from defines the initial value
  96640. * @param to defines the final value
  96641. * @param loop defines if you want animation to loop (off by default)
  96642. * @param speedRatio defines the speed ratio to apply to all animations
  96643. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96644. * @param onAnimationLoop defines the callback to call when an animation loops
  96645. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96646. * @returns the list of created animatables
  96647. */
  96648. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96649. /**
  96650. * Begin a new animation on a given node and its hierarchy
  96651. * @param target defines the root node where the animation will take place
  96652. * @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.
  96653. * @param animations defines the list of animations to start
  96654. * @param from defines the initial value
  96655. * @param to defines the final value
  96656. * @param loop defines if you want animation to loop (off by default)
  96657. * @param speedRatio defines the speed ratio to apply to all animations
  96658. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96659. * @param onAnimationLoop defines the callback to call when an animation loops
  96660. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96661. * @returns the list of animatables created for all nodes
  96662. */
  96663. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96664. /**
  96665. * Gets the animatable associated with a specific target
  96666. * @param target defines the target of the animatable
  96667. * @returns the required animatable if found
  96668. */
  96669. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96670. /**
  96671. * Gets all animatables associated with a given target
  96672. * @param target defines the target to look animatables for
  96673. * @returns an array of Animatables
  96674. */
  96675. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96676. /**
  96677. * Stops and removes all animations that have been applied to the scene
  96678. */
  96679. stopAllAnimations(): void;
  96680. /**
  96681. * Gets the current delta time used by animation engine
  96682. */
  96683. deltaTime: number;
  96684. }
  96685. interface Bone {
  96686. /**
  96687. * Copy an animation range from another bone
  96688. * @param source defines the source bone
  96689. * @param rangeName defines the range name to copy
  96690. * @param frameOffset defines the frame offset
  96691. * @param rescaleAsRequired defines if rescaling must be applied if required
  96692. * @param skelDimensionsRatio defines the scaling ratio
  96693. * @returns true if operation was successful
  96694. */
  96695. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96696. }
  96697. }
  96698. declare module BABYLON {
  96699. /**
  96700. * Class used to handle skinning animations
  96701. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96702. */
  96703. export class Skeleton implements IAnimatable {
  96704. /** defines the skeleton name */
  96705. name: string;
  96706. /** defines the skeleton Id */
  96707. id: string;
  96708. /**
  96709. * Defines the list of child bones
  96710. */
  96711. bones: Bone[];
  96712. /**
  96713. * Defines an estimate of the dimension of the skeleton at rest
  96714. */
  96715. dimensionsAtRest: Vector3;
  96716. /**
  96717. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96718. */
  96719. needInitialSkinMatrix: boolean;
  96720. /**
  96721. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96722. */
  96723. overrideMesh: Nullable<AbstractMesh>;
  96724. /**
  96725. * Gets the list of animations attached to this skeleton
  96726. */
  96727. animations: Array<Animation>;
  96728. private _scene;
  96729. private _isDirty;
  96730. private _transformMatrices;
  96731. private _transformMatrixTexture;
  96732. private _meshesWithPoseMatrix;
  96733. private _animatables;
  96734. private _identity;
  96735. private _synchronizedWithMesh;
  96736. private _ranges;
  96737. private _lastAbsoluteTransformsUpdateId;
  96738. private _canUseTextureForBones;
  96739. private _uniqueId;
  96740. /** @hidden */
  96741. _numBonesWithLinkedTransformNode: number;
  96742. /** @hidden */
  96743. _hasWaitingData: Nullable<boolean>;
  96744. /** @hidden */
  96745. _waitingOverrideMeshId: Nullable<string>;
  96746. /**
  96747. * Specifies if the skeleton should be serialized
  96748. */
  96749. doNotSerialize: boolean;
  96750. private _useTextureToStoreBoneMatrices;
  96751. /**
  96752. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96753. * Please note that this option is not available if the hardware does not support it
  96754. */
  96755. get useTextureToStoreBoneMatrices(): boolean;
  96756. set useTextureToStoreBoneMatrices(value: boolean);
  96757. private _animationPropertiesOverride;
  96758. /**
  96759. * Gets or sets the animation properties override
  96760. */
  96761. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96762. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96763. /**
  96764. * List of inspectable custom properties (used by the Inspector)
  96765. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96766. */
  96767. inspectableCustomProperties: IInspectable[];
  96768. /**
  96769. * An observable triggered before computing the skeleton's matrices
  96770. */
  96771. onBeforeComputeObservable: Observable<Skeleton>;
  96772. /**
  96773. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96774. */
  96775. get isUsingTextureForMatrices(): boolean;
  96776. /**
  96777. * Gets the unique ID of this skeleton
  96778. */
  96779. get uniqueId(): number;
  96780. /**
  96781. * Creates a new skeleton
  96782. * @param name defines the skeleton name
  96783. * @param id defines the skeleton Id
  96784. * @param scene defines the hosting scene
  96785. */
  96786. constructor(
  96787. /** defines the skeleton name */
  96788. name: string,
  96789. /** defines the skeleton Id */
  96790. id: string, scene: Scene);
  96791. /**
  96792. * Gets the current object class name.
  96793. * @return the class name
  96794. */
  96795. getClassName(): string;
  96796. /**
  96797. * Returns an array containing the root bones
  96798. * @returns an array containing the root bones
  96799. */
  96800. getChildren(): Array<Bone>;
  96801. /**
  96802. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96803. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96804. * @returns a Float32Array containing matrices data
  96805. */
  96806. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96807. /**
  96808. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96809. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96810. * @returns a raw texture containing the data
  96811. */
  96812. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96813. /**
  96814. * Gets the current hosting scene
  96815. * @returns a scene object
  96816. */
  96817. getScene(): Scene;
  96818. /**
  96819. * Gets a string representing the current skeleton data
  96820. * @param fullDetails defines a boolean indicating if we want a verbose version
  96821. * @returns a string representing the current skeleton data
  96822. */
  96823. toString(fullDetails?: boolean): string;
  96824. /**
  96825. * Get bone's index searching by name
  96826. * @param name defines bone's name to search for
  96827. * @return the indice of the bone. Returns -1 if not found
  96828. */
  96829. getBoneIndexByName(name: string): number;
  96830. /**
  96831. * Creater a new animation range
  96832. * @param name defines the name of the range
  96833. * @param from defines the start key
  96834. * @param to defines the end key
  96835. */
  96836. createAnimationRange(name: string, from: number, to: number): void;
  96837. /**
  96838. * Delete a specific animation range
  96839. * @param name defines the name of the range
  96840. * @param deleteFrames defines if frames must be removed as well
  96841. */
  96842. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96843. /**
  96844. * Gets a specific animation range
  96845. * @param name defines the name of the range to look for
  96846. * @returns the requested animation range or null if not found
  96847. */
  96848. getAnimationRange(name: string): Nullable<AnimationRange>;
  96849. /**
  96850. * Gets the list of all animation ranges defined on this skeleton
  96851. * @returns an array
  96852. */
  96853. getAnimationRanges(): Nullable<AnimationRange>[];
  96854. /**
  96855. * Copy animation range from a source skeleton.
  96856. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96857. * @param source defines the source skeleton
  96858. * @param name defines the name of the range to copy
  96859. * @param rescaleAsRequired defines if rescaling must be applied if required
  96860. * @returns true if operation was successful
  96861. */
  96862. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96863. /**
  96864. * Forces the skeleton to go to rest pose
  96865. */
  96866. returnToRest(): void;
  96867. private _getHighestAnimationFrame;
  96868. /**
  96869. * Begin a specific animation range
  96870. * @param name defines the name of the range to start
  96871. * @param loop defines if looping must be turned on (false by default)
  96872. * @param speedRatio defines the speed ratio to apply (1 by default)
  96873. * @param onAnimationEnd defines a callback which will be called when animation will end
  96874. * @returns a new animatable
  96875. */
  96876. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96877. /**
  96878. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96879. * @param skeleton defines the Skeleton containing the animation range to convert
  96880. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96881. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96882. * @returns the original skeleton
  96883. */
  96884. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96885. /** @hidden */
  96886. _markAsDirty(): void;
  96887. /** @hidden */
  96888. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96889. /** @hidden */
  96890. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96891. private _computeTransformMatrices;
  96892. /**
  96893. * Build all resources required to render a skeleton
  96894. */
  96895. prepare(): void;
  96896. /**
  96897. * Gets the list of animatables currently running for this skeleton
  96898. * @returns an array of animatables
  96899. */
  96900. getAnimatables(): IAnimatable[];
  96901. /**
  96902. * Clone the current skeleton
  96903. * @param name defines the name of the new skeleton
  96904. * @param id defines the id of the new skeleton
  96905. * @returns the new skeleton
  96906. */
  96907. clone(name: string, id?: string): Skeleton;
  96908. /**
  96909. * Enable animation blending for this skeleton
  96910. * @param blendingSpeed defines the blending speed to apply
  96911. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96912. */
  96913. enableBlending(blendingSpeed?: number): void;
  96914. /**
  96915. * Releases all resources associated with the current skeleton
  96916. */
  96917. dispose(): void;
  96918. /**
  96919. * Serialize the skeleton in a JSON object
  96920. * @returns a JSON object
  96921. */
  96922. serialize(): any;
  96923. /**
  96924. * Creates a new skeleton from serialized data
  96925. * @param parsedSkeleton defines the serialized data
  96926. * @param scene defines the hosting scene
  96927. * @returns a new skeleton
  96928. */
  96929. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  96930. /**
  96931. * Compute all node absolute transforms
  96932. * @param forceUpdate defines if computation must be done even if cache is up to date
  96933. */
  96934. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  96935. /**
  96936. * Gets the root pose matrix
  96937. * @returns a matrix
  96938. */
  96939. getPoseMatrix(): Nullable<Matrix>;
  96940. /**
  96941. * Sorts bones per internal index
  96942. */
  96943. sortBones(): void;
  96944. private _sortBones;
  96945. /**
  96946. * Set the current local matrix as the restPose for all bones in the skeleton.
  96947. */
  96948. setCurrentPoseAsRest(): void;
  96949. }
  96950. }
  96951. declare module BABYLON {
  96952. /**
  96953. * Creates an instance based on a source mesh.
  96954. */
  96955. export class InstancedMesh extends AbstractMesh {
  96956. private _sourceMesh;
  96957. private _currentLOD;
  96958. /** @hidden */
  96959. _indexInSourceMeshInstanceArray: number;
  96960. constructor(name: string, source: Mesh);
  96961. /**
  96962. * Returns the string "InstancedMesh".
  96963. */
  96964. getClassName(): string;
  96965. /** Gets the list of lights affecting that mesh */
  96966. get lightSources(): Light[];
  96967. _resyncLightSources(): void;
  96968. _resyncLightSource(light: Light): void;
  96969. _removeLightSource(light: Light, dispose: boolean): void;
  96970. /**
  96971. * If the source mesh receives shadows
  96972. */
  96973. get receiveShadows(): boolean;
  96974. /**
  96975. * The material of the source mesh
  96976. */
  96977. get material(): Nullable<Material>;
  96978. /**
  96979. * Visibility of the source mesh
  96980. */
  96981. get visibility(): number;
  96982. /**
  96983. * Skeleton of the source mesh
  96984. */
  96985. get skeleton(): Nullable<Skeleton>;
  96986. /**
  96987. * Rendering ground id of the source mesh
  96988. */
  96989. get renderingGroupId(): number;
  96990. set renderingGroupId(value: number);
  96991. /**
  96992. * Returns the total number of vertices (integer).
  96993. */
  96994. getTotalVertices(): number;
  96995. /**
  96996. * Returns a positive integer : the total number of indices in this mesh geometry.
  96997. * @returns the numner of indices or zero if the mesh has no geometry.
  96998. */
  96999. getTotalIndices(): number;
  97000. /**
  97001. * The source mesh of the instance
  97002. */
  97003. get sourceMesh(): Mesh;
  97004. /**
  97005. * Creates a new InstancedMesh object from the mesh model.
  97006. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97007. * @param name defines the name of the new instance
  97008. * @returns a new InstancedMesh
  97009. */
  97010. createInstance(name: string): InstancedMesh;
  97011. /**
  97012. * Is this node ready to be used/rendered
  97013. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97014. * @return {boolean} is it ready
  97015. */
  97016. isReady(completeCheck?: boolean): boolean;
  97017. /**
  97018. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97019. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  97020. * @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.
  97021. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  97022. */
  97023. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  97024. /**
  97025. * Sets the vertex data of the mesh geometry for the requested `kind`.
  97026. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  97027. * The `data` are either a numeric array either a Float32Array.
  97028. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  97029. * 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).
  97030. * Note that a new underlying VertexBuffer object is created each call.
  97031. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  97032. *
  97033. * Possible `kind` values :
  97034. * - VertexBuffer.PositionKind
  97035. * - VertexBuffer.UVKind
  97036. * - VertexBuffer.UV2Kind
  97037. * - VertexBuffer.UV3Kind
  97038. * - VertexBuffer.UV4Kind
  97039. * - VertexBuffer.UV5Kind
  97040. * - VertexBuffer.UV6Kind
  97041. * - VertexBuffer.ColorKind
  97042. * - VertexBuffer.MatricesIndicesKind
  97043. * - VertexBuffer.MatricesIndicesExtraKind
  97044. * - VertexBuffer.MatricesWeightsKind
  97045. * - VertexBuffer.MatricesWeightsExtraKind
  97046. *
  97047. * Returns the Mesh.
  97048. */
  97049. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97050. /**
  97051. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  97052. * If the mesh has no geometry, it is simply returned as it is.
  97053. * The `data` are either a numeric array either a Float32Array.
  97054. * No new underlying VertexBuffer object is created.
  97055. * 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.
  97056. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  97057. *
  97058. * Possible `kind` values :
  97059. * - VertexBuffer.PositionKind
  97060. * - VertexBuffer.UVKind
  97061. * - VertexBuffer.UV2Kind
  97062. * - VertexBuffer.UV3Kind
  97063. * - VertexBuffer.UV4Kind
  97064. * - VertexBuffer.UV5Kind
  97065. * - VertexBuffer.UV6Kind
  97066. * - VertexBuffer.ColorKind
  97067. * - VertexBuffer.MatricesIndicesKind
  97068. * - VertexBuffer.MatricesIndicesExtraKind
  97069. * - VertexBuffer.MatricesWeightsKind
  97070. * - VertexBuffer.MatricesWeightsExtraKind
  97071. *
  97072. * Returns the Mesh.
  97073. */
  97074. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  97075. /**
  97076. * Sets the mesh indices.
  97077. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  97078. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  97079. * This method creates a new index buffer each call.
  97080. * Returns the Mesh.
  97081. */
  97082. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  97083. /**
  97084. * Boolean : True if the mesh owns the requested kind of data.
  97085. */
  97086. isVerticesDataPresent(kind: string): boolean;
  97087. /**
  97088. * Returns an array of indices (IndicesArray).
  97089. */
  97090. getIndices(): Nullable<IndicesArray>;
  97091. get _positions(): Nullable<Vector3[]>;
  97092. /**
  97093. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97094. * This means the mesh underlying bounding box and sphere are recomputed.
  97095. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97096. * @returns the current mesh
  97097. */
  97098. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  97099. /** @hidden */
  97100. _preActivate(): InstancedMesh;
  97101. /** @hidden */
  97102. _activate(renderId: number, intermediateRendering: boolean): boolean;
  97103. /** @hidden */
  97104. _postActivate(): void;
  97105. getWorldMatrix(): Matrix;
  97106. get isAnInstance(): boolean;
  97107. /**
  97108. * Returns the current associated LOD AbstractMesh.
  97109. */
  97110. getLOD(camera: Camera): AbstractMesh;
  97111. /** @hidden */
  97112. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97113. /** @hidden */
  97114. _syncSubMeshes(): InstancedMesh;
  97115. /** @hidden */
  97116. _generatePointsArray(): boolean;
  97117. /** @hidden */
  97118. _updateBoundingInfo(): AbstractMesh;
  97119. /**
  97120. * Creates a new InstancedMesh from the current mesh.
  97121. * - name (string) : the cloned mesh name
  97122. * - newParent (optional Node) : the optional Node to parent the clone to.
  97123. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  97124. *
  97125. * Returns the clone.
  97126. */
  97127. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  97128. /**
  97129. * Disposes the InstancedMesh.
  97130. * Returns nothing.
  97131. */
  97132. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97133. }
  97134. interface Mesh {
  97135. /**
  97136. * Register a custom buffer that will be instanced
  97137. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97138. * @param kind defines the buffer kind
  97139. * @param stride defines the stride in floats
  97140. */
  97141. registerInstancedBuffer(kind: string, stride: number): void;
  97142. /**
  97143. * true to use the edge renderer for all instances of this mesh
  97144. */
  97145. edgesShareWithInstances: boolean;
  97146. /** @hidden */
  97147. _userInstancedBuffersStorage: {
  97148. data: {
  97149. [key: string]: Float32Array;
  97150. };
  97151. sizes: {
  97152. [key: string]: number;
  97153. };
  97154. vertexBuffers: {
  97155. [key: string]: Nullable<VertexBuffer>;
  97156. };
  97157. strides: {
  97158. [key: string]: number;
  97159. };
  97160. };
  97161. }
  97162. interface AbstractMesh {
  97163. /**
  97164. * Object used to store instanced buffers defined by user
  97165. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97166. */
  97167. instancedBuffers: {
  97168. [key: string]: any;
  97169. };
  97170. }
  97171. }
  97172. declare module BABYLON {
  97173. /**
  97174. * Defines the options associated with the creation of a shader material.
  97175. */
  97176. export interface IShaderMaterialOptions {
  97177. /**
  97178. * Does the material work in alpha blend mode
  97179. */
  97180. needAlphaBlending: boolean;
  97181. /**
  97182. * Does the material work in alpha test mode
  97183. */
  97184. needAlphaTesting: boolean;
  97185. /**
  97186. * The list of attribute names used in the shader
  97187. */
  97188. attributes: string[];
  97189. /**
  97190. * The list of unifrom names used in the shader
  97191. */
  97192. uniforms: string[];
  97193. /**
  97194. * The list of UBO names used in the shader
  97195. */
  97196. uniformBuffers: string[];
  97197. /**
  97198. * The list of sampler names used in the shader
  97199. */
  97200. samplers: string[];
  97201. /**
  97202. * The list of defines used in the shader
  97203. */
  97204. defines: string[];
  97205. }
  97206. /**
  97207. * 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.
  97208. *
  97209. * This returned material effects how the mesh will look based on the code in the shaders.
  97210. *
  97211. * @see https://doc.babylonjs.com/how_to/shader_material
  97212. */
  97213. export class ShaderMaterial extends Material {
  97214. private _shaderPath;
  97215. private _options;
  97216. private _textures;
  97217. private _textureArrays;
  97218. private _floats;
  97219. private _ints;
  97220. private _floatsArrays;
  97221. private _colors3;
  97222. private _colors3Arrays;
  97223. private _colors4;
  97224. private _colors4Arrays;
  97225. private _vectors2;
  97226. private _vectors3;
  97227. private _vectors4;
  97228. private _matrices;
  97229. private _matrixArrays;
  97230. private _matrices3x3;
  97231. private _matrices2x2;
  97232. private _vectors2Arrays;
  97233. private _vectors3Arrays;
  97234. private _vectors4Arrays;
  97235. private _cachedWorldViewMatrix;
  97236. private _cachedWorldViewProjectionMatrix;
  97237. private _renderId;
  97238. private _multiview;
  97239. private _cachedDefines;
  97240. /** Define the Url to load snippets */
  97241. static SnippetUrl: string;
  97242. /** Snippet ID if the material was created from the snippet server */
  97243. snippetId: string;
  97244. /**
  97245. * Instantiate a new shader material.
  97246. * 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.
  97247. * This returned material effects how the mesh will look based on the code in the shaders.
  97248. * @see https://doc.babylonjs.com/how_to/shader_material
  97249. * @param name Define the name of the material in the scene
  97250. * @param scene Define the scene the material belongs to
  97251. * @param shaderPath Defines the route to the shader code in one of three ways:
  97252. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  97253. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  97254. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  97255. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  97256. * @param options Define the options used to create the shader
  97257. */
  97258. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  97259. /**
  97260. * Gets the shader path used to define the shader code
  97261. * It can be modified to trigger a new compilation
  97262. */
  97263. get shaderPath(): any;
  97264. /**
  97265. * Sets the shader path used to define the shader code
  97266. * It can be modified to trigger a new compilation
  97267. */
  97268. set shaderPath(shaderPath: any);
  97269. /**
  97270. * Gets the options used to compile the shader.
  97271. * They can be modified to trigger a new compilation
  97272. */
  97273. get options(): IShaderMaterialOptions;
  97274. /**
  97275. * Gets the current class name of the material e.g. "ShaderMaterial"
  97276. * Mainly use in serialization.
  97277. * @returns the class name
  97278. */
  97279. getClassName(): string;
  97280. /**
  97281. * Specifies if the material will require alpha blending
  97282. * @returns a boolean specifying if alpha blending is needed
  97283. */
  97284. needAlphaBlending(): boolean;
  97285. /**
  97286. * Specifies if this material should be rendered in alpha test mode
  97287. * @returns a boolean specifying if an alpha test is needed.
  97288. */
  97289. needAlphaTesting(): boolean;
  97290. private _checkUniform;
  97291. /**
  97292. * Set a texture in the shader.
  97293. * @param name Define the name of the uniform samplers as defined in the shader
  97294. * @param texture Define the texture to bind to this sampler
  97295. * @return the material itself allowing "fluent" like uniform updates
  97296. */
  97297. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  97298. /**
  97299. * Set a texture array in the shader.
  97300. * @param name Define the name of the uniform sampler array as defined in the shader
  97301. * @param textures Define the list of textures to bind to this sampler
  97302. * @return the material itself allowing "fluent" like uniform updates
  97303. */
  97304. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  97305. /**
  97306. * Set a float in the shader.
  97307. * @param name Define the name of the uniform as defined in the shader
  97308. * @param value Define the value to give to the uniform
  97309. * @return the material itself allowing "fluent" like uniform updates
  97310. */
  97311. setFloat(name: string, value: number): ShaderMaterial;
  97312. /**
  97313. * Set a int in the shader.
  97314. * @param name Define the name of the uniform as defined in the shader
  97315. * @param value Define the value to give to the uniform
  97316. * @return the material itself allowing "fluent" like uniform updates
  97317. */
  97318. setInt(name: string, value: number): ShaderMaterial;
  97319. /**
  97320. * Set an array of floats in the shader.
  97321. * @param name Define the name of the uniform as defined in the shader
  97322. * @param value Define the value to give to the uniform
  97323. * @return the material itself allowing "fluent" like uniform updates
  97324. */
  97325. setFloats(name: string, value: number[]): ShaderMaterial;
  97326. /**
  97327. * Set a vec3 in the shader from a Color3.
  97328. * @param name Define the name of the uniform as defined in the shader
  97329. * @param value Define the value to give to the uniform
  97330. * @return the material itself allowing "fluent" like uniform updates
  97331. */
  97332. setColor3(name: string, value: Color3): ShaderMaterial;
  97333. /**
  97334. * Set a vec3 array in the shader from a Color3 array.
  97335. * @param name Define the name of the uniform as defined in the shader
  97336. * @param value Define the value to give to the uniform
  97337. * @return the material itself allowing "fluent" like uniform updates
  97338. */
  97339. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  97340. /**
  97341. * Set a vec4 in the shader from a Color4.
  97342. * @param name Define the name of the uniform as defined in the shader
  97343. * @param value Define the value to give to the uniform
  97344. * @return the material itself allowing "fluent" like uniform updates
  97345. */
  97346. setColor4(name: string, value: Color4): ShaderMaterial;
  97347. /**
  97348. * Set a vec4 array in the shader from a Color4 array.
  97349. * @param name Define the name of the uniform as defined in the shader
  97350. * @param value Define the value to give to the uniform
  97351. * @return the material itself allowing "fluent" like uniform updates
  97352. */
  97353. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  97354. /**
  97355. * Set a vec2 in the shader from a Vector2.
  97356. * @param name Define the name of the uniform as defined in the shader
  97357. * @param value Define the value to give to the uniform
  97358. * @return the material itself allowing "fluent" like uniform updates
  97359. */
  97360. setVector2(name: string, value: Vector2): ShaderMaterial;
  97361. /**
  97362. * Set a vec3 in the shader from a Vector3.
  97363. * @param name Define the name of the uniform as defined in the shader
  97364. * @param value Define the value to give to the uniform
  97365. * @return the material itself allowing "fluent" like uniform updates
  97366. */
  97367. setVector3(name: string, value: Vector3): ShaderMaterial;
  97368. /**
  97369. * Set a vec4 in the shader from a Vector4.
  97370. * @param name Define the name of the uniform as defined in the shader
  97371. * @param value Define the value to give to the uniform
  97372. * @return the material itself allowing "fluent" like uniform updates
  97373. */
  97374. setVector4(name: string, value: Vector4): ShaderMaterial;
  97375. /**
  97376. * Set a mat4 in the shader from a Matrix.
  97377. * @param name Define the name of the uniform as defined in the shader
  97378. * @param value Define the value to give to the uniform
  97379. * @return the material itself allowing "fluent" like uniform updates
  97380. */
  97381. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97382. /**
  97383. * Set a float32Array in the shader from a matrix array.
  97384. * @param name Define the name of the uniform as defined in the shader
  97385. * @param value Define the value to give to the uniform
  97386. * @return the material itself allowing "fluent" like uniform updates
  97387. */
  97388. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97389. /**
  97390. * Set a mat3 in the shader from a Float32Array.
  97391. * @param name Define the name of the uniform as defined in the shader
  97392. * @param value Define the value to give to the uniform
  97393. * @return the material itself allowing "fluent" like uniform updates
  97394. */
  97395. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97396. /**
  97397. * Set a mat2 in the shader from a Float32Array.
  97398. * @param name Define the name of the uniform as defined in the shader
  97399. * @param value Define the value to give to the uniform
  97400. * @return the material itself allowing "fluent" like uniform updates
  97401. */
  97402. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97403. /**
  97404. * Set a vec2 array in the shader from a number array.
  97405. * @param name Define the name of the uniform as defined in the shader
  97406. * @param value Define the value to give to the uniform
  97407. * @return the material itself allowing "fluent" like uniform updates
  97408. */
  97409. setArray2(name: string, value: number[]): ShaderMaterial;
  97410. /**
  97411. * Set a vec3 array in the shader from a number array.
  97412. * @param name Define the name of the uniform as defined in the shader
  97413. * @param value Define the value to give to the uniform
  97414. * @return the material itself allowing "fluent" like uniform updates
  97415. */
  97416. setArray3(name: string, value: number[]): ShaderMaterial;
  97417. /**
  97418. * Set a vec4 array in the shader from a number array.
  97419. * @param name Define the name of the uniform as defined in the shader
  97420. * @param value Define the value to give to the uniform
  97421. * @return the material itself allowing "fluent" like uniform updates
  97422. */
  97423. setArray4(name: string, value: number[]): ShaderMaterial;
  97424. private _checkCache;
  97425. /**
  97426. * Specifies that the submesh is ready to be used
  97427. * @param mesh defines the mesh to check
  97428. * @param subMesh defines which submesh to check
  97429. * @param useInstances specifies that instances should be used
  97430. * @returns a boolean indicating that the submesh is ready or not
  97431. */
  97432. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97433. /**
  97434. * Checks if the material is ready to render the requested mesh
  97435. * @param mesh Define the mesh to render
  97436. * @param useInstances Define whether or not the material is used with instances
  97437. * @returns true if ready, otherwise false
  97438. */
  97439. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97440. /**
  97441. * Binds the world matrix to the material
  97442. * @param world defines the world transformation matrix
  97443. * @param effectOverride - If provided, use this effect instead of internal effect
  97444. */
  97445. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97446. /**
  97447. * Binds the submesh to this material by preparing the effect and shader to draw
  97448. * @param world defines the world transformation matrix
  97449. * @param mesh defines the mesh containing the submesh
  97450. * @param subMesh defines the submesh to bind the material to
  97451. */
  97452. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97453. /**
  97454. * Binds the material to the mesh
  97455. * @param world defines the world transformation matrix
  97456. * @param mesh defines the mesh to bind the material to
  97457. * @param effectOverride - If provided, use this effect instead of internal effect
  97458. */
  97459. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97460. protected _afterBind(mesh?: Mesh): void;
  97461. /**
  97462. * Gets the active textures from the material
  97463. * @returns an array of textures
  97464. */
  97465. getActiveTextures(): BaseTexture[];
  97466. /**
  97467. * Specifies if the material uses a texture
  97468. * @param texture defines the texture to check against the material
  97469. * @returns a boolean specifying if the material uses the texture
  97470. */
  97471. hasTexture(texture: BaseTexture): boolean;
  97472. /**
  97473. * Makes a duplicate of the material, and gives it a new name
  97474. * @param name defines the new name for the duplicated material
  97475. * @returns the cloned material
  97476. */
  97477. clone(name: string): ShaderMaterial;
  97478. /**
  97479. * Disposes the material
  97480. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97481. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97482. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97483. */
  97484. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97485. /**
  97486. * Serializes this material in a JSON representation
  97487. * @returns the serialized material object
  97488. */
  97489. serialize(): any;
  97490. /**
  97491. * Creates a shader material from parsed shader material data
  97492. * @param source defines the JSON represnetation of the material
  97493. * @param scene defines the hosting scene
  97494. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97495. * @returns a new material
  97496. */
  97497. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97498. /**
  97499. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97500. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97501. * @param url defines the url to load from
  97502. * @param scene defines the hosting scene
  97503. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97504. * @returns a promise that will resolve to the new ShaderMaterial
  97505. */
  97506. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97507. /**
  97508. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97509. * @param snippetId defines the snippet to load
  97510. * @param scene defines the hosting scene
  97511. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97512. * @returns a promise that will resolve to the new ShaderMaterial
  97513. */
  97514. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97515. }
  97516. }
  97517. declare module BABYLON {
  97518. /** @hidden */
  97519. export var colorPixelShader: {
  97520. name: string;
  97521. shader: string;
  97522. };
  97523. }
  97524. declare module BABYLON {
  97525. /** @hidden */
  97526. export var colorVertexShader: {
  97527. name: string;
  97528. shader: string;
  97529. };
  97530. }
  97531. declare module BABYLON {
  97532. /**
  97533. * Line mesh
  97534. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97535. */
  97536. export class LinesMesh extends Mesh {
  97537. /**
  97538. * If vertex color should be applied to the mesh
  97539. */
  97540. readonly useVertexColor?: boolean | undefined;
  97541. /**
  97542. * If vertex alpha should be applied to the mesh
  97543. */
  97544. readonly useVertexAlpha?: boolean | undefined;
  97545. /**
  97546. * Color of the line (Default: White)
  97547. */
  97548. color: Color3;
  97549. /**
  97550. * Alpha of the line (Default: 1)
  97551. */
  97552. alpha: number;
  97553. /**
  97554. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97555. * This margin is expressed in world space coordinates, so its value may vary.
  97556. * Default value is 0.1
  97557. */
  97558. intersectionThreshold: number;
  97559. private _colorShader;
  97560. private color4;
  97561. /**
  97562. * Creates a new LinesMesh
  97563. * @param name defines the name
  97564. * @param scene defines the hosting scene
  97565. * @param parent defines the parent mesh if any
  97566. * @param source defines the optional source LinesMesh used to clone data from
  97567. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97568. * When false, achieved by calling a clone(), also passing False.
  97569. * This will make creation of children, recursive.
  97570. * @param useVertexColor defines if this LinesMesh supports vertex color
  97571. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97572. */
  97573. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97574. /**
  97575. * If vertex color should be applied to the mesh
  97576. */
  97577. useVertexColor?: boolean | undefined,
  97578. /**
  97579. * If vertex alpha should be applied to the mesh
  97580. */
  97581. useVertexAlpha?: boolean | undefined);
  97582. private _addClipPlaneDefine;
  97583. private _removeClipPlaneDefine;
  97584. isReady(): boolean;
  97585. /**
  97586. * Returns the string "LineMesh"
  97587. */
  97588. getClassName(): string;
  97589. /**
  97590. * @hidden
  97591. */
  97592. get material(): Material;
  97593. /**
  97594. * @hidden
  97595. */
  97596. set material(value: Material);
  97597. /**
  97598. * @hidden
  97599. */
  97600. get checkCollisions(): boolean;
  97601. /** @hidden */
  97602. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97603. /** @hidden */
  97604. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97605. /**
  97606. * Disposes of the line mesh
  97607. * @param doNotRecurse If children should be disposed
  97608. */
  97609. dispose(doNotRecurse?: boolean): void;
  97610. /**
  97611. * Returns a new LineMesh object cloned from the current one.
  97612. */
  97613. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97614. /**
  97615. * Creates a new InstancedLinesMesh object from the mesh model.
  97616. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97617. * @param name defines the name of the new instance
  97618. * @returns a new InstancedLinesMesh
  97619. */
  97620. createInstance(name: string): InstancedLinesMesh;
  97621. }
  97622. /**
  97623. * Creates an instance based on a source LinesMesh
  97624. */
  97625. export class InstancedLinesMesh extends InstancedMesh {
  97626. /**
  97627. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97628. * This margin is expressed in world space coordinates, so its value may vary.
  97629. * Initilized with the intersectionThreshold value of the source LinesMesh
  97630. */
  97631. intersectionThreshold: number;
  97632. constructor(name: string, source: LinesMesh);
  97633. /**
  97634. * Returns the string "InstancedLinesMesh".
  97635. */
  97636. getClassName(): string;
  97637. }
  97638. }
  97639. declare module BABYLON {
  97640. /** @hidden */
  97641. export var linePixelShader: {
  97642. name: string;
  97643. shader: string;
  97644. };
  97645. }
  97646. declare module BABYLON {
  97647. /** @hidden */
  97648. export var lineVertexShader: {
  97649. name: string;
  97650. shader: string;
  97651. };
  97652. }
  97653. declare module BABYLON {
  97654. interface Scene {
  97655. /** @hidden */
  97656. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97657. }
  97658. interface AbstractMesh {
  97659. /**
  97660. * Gets the edgesRenderer associated with the mesh
  97661. */
  97662. edgesRenderer: Nullable<EdgesRenderer>;
  97663. }
  97664. interface LinesMesh {
  97665. /**
  97666. * Enables the edge rendering mode on the mesh.
  97667. * This mode makes the mesh edges visible
  97668. * @param epsilon defines the maximal distance between two angles to detect a face
  97669. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97670. * @returns the currentAbstractMesh
  97671. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97672. */
  97673. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97674. }
  97675. interface InstancedLinesMesh {
  97676. /**
  97677. * Enables the edge rendering mode on the mesh.
  97678. * This mode makes the mesh edges visible
  97679. * @param epsilon defines the maximal distance between two angles to detect a face
  97680. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97681. * @returns the current InstancedLinesMesh
  97682. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97683. */
  97684. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97685. }
  97686. /**
  97687. * Defines the minimum contract an Edges renderer should follow.
  97688. */
  97689. export interface IEdgesRenderer extends IDisposable {
  97690. /**
  97691. * Gets or sets a boolean indicating if the edgesRenderer is active
  97692. */
  97693. isEnabled: boolean;
  97694. /**
  97695. * Renders the edges of the attached mesh,
  97696. */
  97697. render(): void;
  97698. /**
  97699. * Checks wether or not the edges renderer is ready to render.
  97700. * @return true if ready, otherwise false.
  97701. */
  97702. isReady(): boolean;
  97703. /**
  97704. * List of instances to render in case the source mesh has instances
  97705. */
  97706. customInstances: SmartArray<Matrix>;
  97707. }
  97708. /**
  97709. * Defines the additional options of the edges renderer
  97710. */
  97711. export interface IEdgesRendererOptions {
  97712. /**
  97713. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97714. * If not defined, the default value is true
  97715. */
  97716. useAlternateEdgeFinder?: boolean;
  97717. /**
  97718. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97719. * If not defined, the default value is true.
  97720. * 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)
  97721. * This option is used only if useAlternateEdgeFinder = true
  97722. */
  97723. useFastVertexMerger?: boolean;
  97724. /**
  97725. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97726. * The default value is 1e-6
  97727. * This option is used only if useAlternateEdgeFinder = true
  97728. */
  97729. epsilonVertexMerge?: number;
  97730. /**
  97731. * 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
  97732. * 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.
  97733. * This option is used only if useAlternateEdgeFinder = true
  97734. */
  97735. applyTessellation?: boolean;
  97736. /**
  97737. * 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
  97738. * The default value is 1e-6
  97739. * This option is used only if useAlternateEdgeFinder = true
  97740. */
  97741. epsilonVertexAligned?: number;
  97742. }
  97743. /**
  97744. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97745. */
  97746. export class EdgesRenderer implements IEdgesRenderer {
  97747. /**
  97748. * Define the size of the edges with an orthographic camera
  97749. */
  97750. edgesWidthScalerForOrthographic: number;
  97751. /**
  97752. * Define the size of the edges with a perspective camera
  97753. */
  97754. edgesWidthScalerForPerspective: number;
  97755. protected _source: AbstractMesh;
  97756. protected _linesPositions: number[];
  97757. protected _linesNormals: number[];
  97758. protected _linesIndices: number[];
  97759. protected _epsilon: number;
  97760. protected _indicesCount: number;
  97761. protected _lineShader: ShaderMaterial;
  97762. protected _ib: DataBuffer;
  97763. protected _buffers: {
  97764. [key: string]: Nullable<VertexBuffer>;
  97765. };
  97766. protected _buffersForInstances: {
  97767. [key: string]: Nullable<VertexBuffer>;
  97768. };
  97769. protected _checkVerticesInsteadOfIndices: boolean;
  97770. protected _options: Nullable<IEdgesRendererOptions>;
  97771. private _meshRebuildObserver;
  97772. private _meshDisposeObserver;
  97773. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97774. isEnabled: boolean;
  97775. /**
  97776. * List of instances to render in case the source mesh has instances
  97777. */
  97778. customInstances: SmartArray<Matrix>;
  97779. private static GetShader;
  97780. /**
  97781. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97782. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97783. * @param source Mesh used to create edges
  97784. * @param epsilon sum of angles in adjacency to check for edge
  97785. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97786. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97787. * @param options The options to apply when generating the edges
  97788. */
  97789. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97790. protected _prepareRessources(): void;
  97791. /** @hidden */
  97792. _rebuild(): void;
  97793. /**
  97794. * Releases the required resources for the edges renderer
  97795. */
  97796. dispose(): void;
  97797. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97798. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97799. /**
  97800. * Checks if the pair of p0 and p1 is en edge
  97801. * @param faceIndex
  97802. * @param edge
  97803. * @param faceNormals
  97804. * @param p0
  97805. * @param p1
  97806. * @private
  97807. */
  97808. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97809. /**
  97810. * push line into the position, normal and index buffer
  97811. * @protected
  97812. */
  97813. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97814. /**
  97815. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97816. */
  97817. private _tessellateTriangle;
  97818. private _generateEdgesLinesAlternate;
  97819. /**
  97820. * Generates lines edges from adjacencjes
  97821. * @private
  97822. */
  97823. _generateEdgesLines(): void;
  97824. /**
  97825. * Checks wether or not the edges renderer is ready to render.
  97826. * @return true if ready, otherwise false.
  97827. */
  97828. isReady(): boolean;
  97829. /**
  97830. * Renders the edges of the attached mesh,
  97831. */
  97832. render(): void;
  97833. }
  97834. /**
  97835. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97836. */
  97837. export class LineEdgesRenderer extends EdgesRenderer {
  97838. /**
  97839. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97840. * @param source LineMesh used to generate edges
  97841. * @param epsilon not important (specified angle for edge detection)
  97842. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97843. */
  97844. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97845. /**
  97846. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97847. */
  97848. _generateEdgesLines(): void;
  97849. }
  97850. }
  97851. declare module BABYLON {
  97852. /**
  97853. * This represents the object necessary to create a rendering group.
  97854. * This is exclusively used and created by the rendering manager.
  97855. * To modify the behavior, you use the available helpers in your scene or meshes.
  97856. * @hidden
  97857. */
  97858. export class RenderingGroup {
  97859. index: number;
  97860. private static _zeroVector;
  97861. private _scene;
  97862. private _opaqueSubMeshes;
  97863. private _transparentSubMeshes;
  97864. private _alphaTestSubMeshes;
  97865. private _depthOnlySubMeshes;
  97866. private _particleSystems;
  97867. private _spriteManagers;
  97868. private _opaqueSortCompareFn;
  97869. private _alphaTestSortCompareFn;
  97870. private _transparentSortCompareFn;
  97871. private _renderOpaque;
  97872. private _renderAlphaTest;
  97873. private _renderTransparent;
  97874. /** @hidden */
  97875. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97876. onBeforeTransparentRendering: () => void;
  97877. /**
  97878. * Set the opaque sort comparison function.
  97879. * If null the sub meshes will be render in the order they were created
  97880. */
  97881. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97882. /**
  97883. * Set the alpha test sort comparison function.
  97884. * If null the sub meshes will be render in the order they were created
  97885. */
  97886. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97887. /**
  97888. * Set the transparent sort comparison function.
  97889. * If null the sub meshes will be render in the order they were created
  97890. */
  97891. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97892. /**
  97893. * Creates a new rendering group.
  97894. * @param index The rendering group index
  97895. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97896. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97897. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97898. */
  97899. 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>);
  97900. /**
  97901. * Render all the sub meshes contained in the group.
  97902. * @param customRenderFunction Used to override the default render behaviour of the group.
  97903. * @returns true if rendered some submeshes.
  97904. */
  97905. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97906. /**
  97907. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97908. * @param subMeshes The submeshes to render
  97909. */
  97910. private renderOpaqueSorted;
  97911. /**
  97912. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97913. * @param subMeshes The submeshes to render
  97914. */
  97915. private renderAlphaTestSorted;
  97916. /**
  97917. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  97918. * @param subMeshes The submeshes to render
  97919. */
  97920. private renderTransparentSorted;
  97921. /**
  97922. * Renders the submeshes in a specified order.
  97923. * @param subMeshes The submeshes to sort before render
  97924. * @param sortCompareFn The comparison function use to sort
  97925. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  97926. * @param transparent Specifies to activate blending if true
  97927. */
  97928. private static renderSorted;
  97929. /**
  97930. * Renders the submeshes in the order they were dispatched (no sort applied).
  97931. * @param subMeshes The submeshes to render
  97932. */
  97933. private static renderUnsorted;
  97934. /**
  97935. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97936. * are rendered back to front if in the same alpha index.
  97937. *
  97938. * @param a The first submesh
  97939. * @param b The second submesh
  97940. * @returns The result of the comparison
  97941. */
  97942. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  97943. /**
  97944. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97945. * are rendered back to front.
  97946. *
  97947. * @param a The first submesh
  97948. * @param b The second submesh
  97949. * @returns The result of the comparison
  97950. */
  97951. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97952. /**
  97953. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97954. * are rendered front to back (prevent overdraw).
  97955. *
  97956. * @param a The first submesh
  97957. * @param b The second submesh
  97958. * @returns The result of the comparison
  97959. */
  97960. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97961. /**
  97962. * Resets the different lists of submeshes to prepare a new frame.
  97963. */
  97964. prepare(): void;
  97965. dispose(): void;
  97966. /**
  97967. * Inserts the submesh in its correct queue depending on its material.
  97968. * @param subMesh The submesh to dispatch
  97969. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97970. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97971. */
  97972. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97973. dispatchSprites(spriteManager: ISpriteManager): void;
  97974. dispatchParticles(particleSystem: IParticleSystem): void;
  97975. private _renderParticles;
  97976. private _renderSprites;
  97977. }
  97978. }
  97979. declare module BABYLON {
  97980. /**
  97981. * Interface describing the different options available in the rendering manager
  97982. * regarding Auto Clear between groups.
  97983. */
  97984. export interface IRenderingManagerAutoClearSetup {
  97985. /**
  97986. * Defines whether or not autoclear is enable.
  97987. */
  97988. autoClear: boolean;
  97989. /**
  97990. * Defines whether or not to autoclear the depth buffer.
  97991. */
  97992. depth: boolean;
  97993. /**
  97994. * Defines whether or not to autoclear the stencil buffer.
  97995. */
  97996. stencil: boolean;
  97997. }
  97998. /**
  97999. * This class is used by the onRenderingGroupObservable
  98000. */
  98001. export class RenderingGroupInfo {
  98002. /**
  98003. * The Scene that being rendered
  98004. */
  98005. scene: Scene;
  98006. /**
  98007. * The camera currently used for the rendering pass
  98008. */
  98009. camera: Nullable<Camera>;
  98010. /**
  98011. * The ID of the renderingGroup being processed
  98012. */
  98013. renderingGroupId: number;
  98014. }
  98015. /**
  98016. * This is the manager responsible of all the rendering for meshes sprites and particles.
  98017. * It is enable to manage the different groups as well as the different necessary sort functions.
  98018. * This should not be used directly aside of the few static configurations
  98019. */
  98020. export class RenderingManager {
  98021. /**
  98022. * The max id used for rendering groups (not included)
  98023. */
  98024. static MAX_RENDERINGGROUPS: number;
  98025. /**
  98026. * The min id used for rendering groups (included)
  98027. */
  98028. static MIN_RENDERINGGROUPS: number;
  98029. /**
  98030. * Used to globally prevent autoclearing scenes.
  98031. */
  98032. static AUTOCLEAR: boolean;
  98033. /**
  98034. * @hidden
  98035. */
  98036. _useSceneAutoClearSetup: boolean;
  98037. private _scene;
  98038. private _renderingGroups;
  98039. private _depthStencilBufferAlreadyCleaned;
  98040. private _autoClearDepthStencil;
  98041. private _customOpaqueSortCompareFn;
  98042. private _customAlphaTestSortCompareFn;
  98043. private _customTransparentSortCompareFn;
  98044. private _renderingGroupInfo;
  98045. /**
  98046. * Instantiates a new rendering group for a particular scene
  98047. * @param scene Defines the scene the groups belongs to
  98048. */
  98049. constructor(scene: Scene);
  98050. private _clearDepthStencilBuffer;
  98051. /**
  98052. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  98053. * @hidden
  98054. */
  98055. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  98056. /**
  98057. * Resets the different information of the group to prepare a new frame
  98058. * @hidden
  98059. */
  98060. reset(): void;
  98061. /**
  98062. * Dispose and release the group and its associated resources.
  98063. * @hidden
  98064. */
  98065. dispose(): void;
  98066. /**
  98067. * Clear the info related to rendering groups preventing retention points during dispose.
  98068. */
  98069. freeRenderingGroups(): void;
  98070. private _prepareRenderingGroup;
  98071. /**
  98072. * Add a sprite manager to the rendering manager in order to render it this frame.
  98073. * @param spriteManager Define the sprite manager to render
  98074. */
  98075. dispatchSprites(spriteManager: ISpriteManager): void;
  98076. /**
  98077. * Add a particle system to the rendering manager in order to render it this frame.
  98078. * @param particleSystem Define the particle system to render
  98079. */
  98080. dispatchParticles(particleSystem: IParticleSystem): void;
  98081. /**
  98082. * Add a submesh to the manager in order to render it this frame
  98083. * @param subMesh The submesh to dispatch
  98084. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98085. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98086. */
  98087. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98088. /**
  98089. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98090. * This allowed control for front to back rendering or reversly depending of the special needs.
  98091. *
  98092. * @param renderingGroupId The rendering group id corresponding to its index
  98093. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98094. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98095. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98096. */
  98097. 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;
  98098. /**
  98099. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98100. *
  98101. * @param renderingGroupId The rendering group id corresponding to its index
  98102. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98103. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98104. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98105. */
  98106. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98107. /**
  98108. * Gets the current auto clear configuration for one rendering group of the rendering
  98109. * manager.
  98110. * @param index the rendering group index to get the information for
  98111. * @returns The auto clear setup for the requested rendering group
  98112. */
  98113. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98114. }
  98115. }
  98116. declare module BABYLON {
  98117. /**
  98118. * Defines the options associated with the creation of a custom shader for a shadow generator.
  98119. */
  98120. export interface ICustomShaderOptions {
  98121. /**
  98122. * Gets or sets the custom shader name to use
  98123. */
  98124. shaderName: string;
  98125. /**
  98126. * The list of attribute names used in the shader
  98127. */
  98128. attributes?: string[];
  98129. /**
  98130. * The list of unifrom names used in the shader
  98131. */
  98132. uniforms?: string[];
  98133. /**
  98134. * The list of sampler names used in the shader
  98135. */
  98136. samplers?: string[];
  98137. /**
  98138. * The list of defines used in the shader
  98139. */
  98140. defines?: string[];
  98141. }
  98142. /**
  98143. * Interface to implement to create a shadow generator compatible with BJS.
  98144. */
  98145. export interface IShadowGenerator {
  98146. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98147. id: string;
  98148. /**
  98149. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98150. * @returns The render target texture if present otherwise, null
  98151. */
  98152. getShadowMap(): Nullable<RenderTargetTexture>;
  98153. /**
  98154. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98155. * @param subMesh The submesh we want to render in the shadow map
  98156. * @param useInstances Defines wether will draw in the map using instances
  98157. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98158. * @returns true if ready otherwise, false
  98159. */
  98160. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98161. /**
  98162. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98163. * @param defines Defines of the material we want to update
  98164. * @param lightIndex Index of the light in the enabled light list of the material
  98165. */
  98166. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  98167. /**
  98168. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98169. * defined in the generator but impacting the effect).
  98170. * It implies the unifroms available on the materials are the standard BJS ones.
  98171. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98172. * @param effect The effect we are binfing the information for
  98173. */
  98174. bindShadowLight(lightIndex: string, effect: Effect): void;
  98175. /**
  98176. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98177. * (eq to shadow prjection matrix * light transform matrix)
  98178. * @returns The transform matrix used to create the shadow map
  98179. */
  98180. getTransformMatrix(): Matrix;
  98181. /**
  98182. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98183. * Cube and 2D textures for instance.
  98184. */
  98185. recreateShadowMap(): void;
  98186. /**
  98187. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98188. * @param onCompiled Callback triggered at the and of the effects compilation
  98189. * @param options Sets of optional options forcing the compilation with different modes
  98190. */
  98191. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98192. useInstances: boolean;
  98193. }>): void;
  98194. /**
  98195. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98196. * @param options Sets of optional options forcing the compilation with different modes
  98197. * @returns A promise that resolves when the compilation completes
  98198. */
  98199. forceCompilationAsync(options?: Partial<{
  98200. useInstances: boolean;
  98201. }>): Promise<void>;
  98202. /**
  98203. * Serializes the shadow generator setup to a json object.
  98204. * @returns The serialized JSON object
  98205. */
  98206. serialize(): any;
  98207. /**
  98208. * Disposes the Shadow map and related Textures and effects.
  98209. */
  98210. dispose(): void;
  98211. }
  98212. /**
  98213. * Default implementation IShadowGenerator.
  98214. * This is the main object responsible of generating shadows in the framework.
  98215. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  98216. */
  98217. export class ShadowGenerator implements IShadowGenerator {
  98218. /**
  98219. * Name of the shadow generator class
  98220. */
  98221. static CLASSNAME: string;
  98222. /**
  98223. * Shadow generator mode None: no filtering applied.
  98224. */
  98225. static readonly FILTER_NONE: number;
  98226. /**
  98227. * Shadow generator mode ESM: Exponential Shadow Mapping.
  98228. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98229. */
  98230. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  98231. /**
  98232. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  98233. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  98234. */
  98235. static readonly FILTER_POISSONSAMPLING: number;
  98236. /**
  98237. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  98238. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98239. */
  98240. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  98241. /**
  98242. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  98243. * edge artifacts on steep falloff.
  98244. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98245. */
  98246. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  98247. /**
  98248. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  98249. * edge artifacts on steep falloff.
  98250. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98251. */
  98252. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  98253. /**
  98254. * Shadow generator mode PCF: Percentage Closer Filtering
  98255. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98256. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  98257. */
  98258. static readonly FILTER_PCF: number;
  98259. /**
  98260. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  98261. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98262. * Contact Hardening
  98263. */
  98264. static readonly FILTER_PCSS: number;
  98265. /**
  98266. * Reserved for PCF and PCSS
  98267. * Highest Quality.
  98268. *
  98269. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  98270. *
  98271. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  98272. */
  98273. static readonly QUALITY_HIGH: number;
  98274. /**
  98275. * Reserved for PCF and PCSS
  98276. * Good tradeoff for quality/perf cross devices
  98277. *
  98278. * Execute PCF on a 3*3 kernel.
  98279. *
  98280. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  98281. */
  98282. static readonly QUALITY_MEDIUM: number;
  98283. /**
  98284. * Reserved for PCF and PCSS
  98285. * The lowest quality but the fastest.
  98286. *
  98287. * Execute PCF on a 1*1 kernel.
  98288. *
  98289. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  98290. */
  98291. static readonly QUALITY_LOW: number;
  98292. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98293. id: string;
  98294. /** Gets or sets the custom shader name to use */
  98295. customShaderOptions: ICustomShaderOptions;
  98296. /**
  98297. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  98298. */
  98299. onBeforeShadowMapRenderObservable: Observable<Effect>;
  98300. /**
  98301. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  98302. */
  98303. onAfterShadowMapRenderObservable: Observable<Effect>;
  98304. /**
  98305. * Observable triggered before a mesh is rendered in the shadow map.
  98306. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  98307. */
  98308. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  98309. /**
  98310. * Observable triggered after a mesh is rendered in the shadow map.
  98311. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  98312. */
  98313. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  98314. protected _bias: number;
  98315. /**
  98316. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  98317. */
  98318. get bias(): number;
  98319. /**
  98320. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  98321. */
  98322. set bias(bias: number);
  98323. protected _normalBias: number;
  98324. /**
  98325. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98326. */
  98327. get normalBias(): number;
  98328. /**
  98329. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98330. */
  98331. set normalBias(normalBias: number);
  98332. protected _blurBoxOffset: number;
  98333. /**
  98334. * Gets the blur box offset: offset applied during the blur pass.
  98335. * Only useful if useKernelBlur = false
  98336. */
  98337. get blurBoxOffset(): number;
  98338. /**
  98339. * Sets the blur box offset: offset applied during the blur pass.
  98340. * Only useful if useKernelBlur = false
  98341. */
  98342. set blurBoxOffset(value: number);
  98343. protected _blurScale: number;
  98344. /**
  98345. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  98346. * 2 means half of the size.
  98347. */
  98348. get blurScale(): number;
  98349. /**
  98350. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  98351. * 2 means half of the size.
  98352. */
  98353. set blurScale(value: number);
  98354. protected _blurKernel: number;
  98355. /**
  98356. * Gets the blur kernel: kernel size of the blur pass.
  98357. * Only useful if useKernelBlur = true
  98358. */
  98359. get blurKernel(): number;
  98360. /**
  98361. * Sets the blur kernel: kernel size of the blur pass.
  98362. * Only useful if useKernelBlur = true
  98363. */
  98364. set blurKernel(value: number);
  98365. protected _useKernelBlur: boolean;
  98366. /**
  98367. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  98368. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98369. */
  98370. get useKernelBlur(): boolean;
  98371. /**
  98372. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98373. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98374. */
  98375. set useKernelBlur(value: boolean);
  98376. protected _depthScale: number;
  98377. /**
  98378. * Gets the depth scale used in ESM mode.
  98379. */
  98380. get depthScale(): number;
  98381. /**
  98382. * Sets the depth scale used in ESM mode.
  98383. * This can override the scale stored on the light.
  98384. */
  98385. set depthScale(value: number);
  98386. protected _validateFilter(filter: number): number;
  98387. protected _filter: number;
  98388. /**
  98389. * Gets 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. get filter(): number;
  98393. /**
  98394. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98395. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98396. */
  98397. set filter(value: number);
  98398. /**
  98399. * Gets if the current filter is set to Poisson Sampling.
  98400. */
  98401. get usePoissonSampling(): boolean;
  98402. /**
  98403. * Sets the current filter to Poisson Sampling.
  98404. */
  98405. set usePoissonSampling(value: boolean);
  98406. /**
  98407. * Gets if the current filter is set to ESM.
  98408. */
  98409. get useExponentialShadowMap(): boolean;
  98410. /**
  98411. * Sets the current filter is to ESM.
  98412. */
  98413. set useExponentialShadowMap(value: boolean);
  98414. /**
  98415. * Gets if the current filter is set to filtered ESM.
  98416. */
  98417. get useBlurExponentialShadowMap(): boolean;
  98418. /**
  98419. * Gets if the current filter is set to filtered ESM.
  98420. */
  98421. set useBlurExponentialShadowMap(value: boolean);
  98422. /**
  98423. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98424. * exponential to prevent steep falloff artifacts).
  98425. */
  98426. get useCloseExponentialShadowMap(): boolean;
  98427. /**
  98428. * Sets the current filter to "close ESM" (using the inverse of the
  98429. * exponential to prevent steep falloff artifacts).
  98430. */
  98431. set useCloseExponentialShadowMap(value: boolean);
  98432. /**
  98433. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98434. * exponential to prevent steep falloff artifacts).
  98435. */
  98436. get useBlurCloseExponentialShadowMap(): boolean;
  98437. /**
  98438. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98439. * exponential to prevent steep falloff artifacts).
  98440. */
  98441. set useBlurCloseExponentialShadowMap(value: boolean);
  98442. /**
  98443. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98444. */
  98445. get usePercentageCloserFiltering(): boolean;
  98446. /**
  98447. * Sets the current filter to "PCF" (percentage closer filtering).
  98448. */
  98449. set usePercentageCloserFiltering(value: boolean);
  98450. protected _filteringQuality: number;
  98451. /**
  98452. * Gets the PCF or PCSS Quality.
  98453. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98454. */
  98455. get filteringQuality(): number;
  98456. /**
  98457. * Sets the PCF or PCSS Quality.
  98458. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98459. */
  98460. set filteringQuality(filteringQuality: number);
  98461. /**
  98462. * Gets if the current filter is set to "PCSS" (contact hardening).
  98463. */
  98464. get useContactHardeningShadow(): boolean;
  98465. /**
  98466. * Sets the current filter to "PCSS" (contact hardening).
  98467. */
  98468. set useContactHardeningShadow(value: boolean);
  98469. protected _contactHardeningLightSizeUVRatio: number;
  98470. /**
  98471. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98472. * Using a ratio helps keeping shape stability independently of the map size.
  98473. *
  98474. * It does not account for the light projection as it was having too much
  98475. * instability during the light setup or during light position changes.
  98476. *
  98477. * Only valid if useContactHardeningShadow is true.
  98478. */
  98479. get contactHardeningLightSizeUVRatio(): number;
  98480. /**
  98481. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98482. * Using a ratio helps keeping shape stability independently of the map size.
  98483. *
  98484. * It does not account for the light projection as it was having too much
  98485. * instability during the light setup or during light position changes.
  98486. *
  98487. * Only valid if useContactHardeningShadow is true.
  98488. */
  98489. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98490. protected _darkness: number;
  98491. /** Gets or sets the actual darkness of a shadow */
  98492. get darkness(): number;
  98493. set darkness(value: number);
  98494. /**
  98495. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98496. * 0 means strongest and 1 would means no shadow.
  98497. * @returns the darkness.
  98498. */
  98499. getDarkness(): number;
  98500. /**
  98501. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98502. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98503. * @returns the shadow generator allowing fluent coding.
  98504. */
  98505. setDarkness(darkness: number): ShadowGenerator;
  98506. protected _transparencyShadow: boolean;
  98507. /** Gets or sets the ability to have transparent shadow */
  98508. get transparencyShadow(): boolean;
  98509. set transparencyShadow(value: boolean);
  98510. /**
  98511. * Sets the ability to have transparent shadow (boolean).
  98512. * @param transparent True if transparent else False
  98513. * @returns the shadow generator allowing fluent coding
  98514. */
  98515. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98516. /**
  98517. * Enables or disables shadows with varying strength based on the transparency
  98518. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98519. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98520. * mesh.visibility * alphaTexture.a
  98521. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98522. */
  98523. enableSoftTransparentShadow: boolean;
  98524. protected _shadowMap: Nullable<RenderTargetTexture>;
  98525. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98526. /**
  98527. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98528. * @returns The render target texture if present otherwise, null
  98529. */
  98530. getShadowMap(): Nullable<RenderTargetTexture>;
  98531. /**
  98532. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98533. * @returns The render target texture if the shadow map is present otherwise, null
  98534. */
  98535. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98536. /**
  98537. * Gets the class name of that object
  98538. * @returns "ShadowGenerator"
  98539. */
  98540. getClassName(): string;
  98541. /**
  98542. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98543. * @param mesh Mesh to add
  98544. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98545. * @returns the Shadow Generator itself
  98546. */
  98547. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98548. /**
  98549. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98550. * @param mesh Mesh to remove
  98551. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98552. * @returns the Shadow Generator itself
  98553. */
  98554. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98555. /**
  98556. * Controls the extent to which the shadows fade out at the edge of the frustum
  98557. */
  98558. frustumEdgeFalloff: number;
  98559. protected _light: IShadowLight;
  98560. /**
  98561. * Returns the associated light object.
  98562. * @returns the light generating the shadow
  98563. */
  98564. getLight(): IShadowLight;
  98565. /**
  98566. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98567. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98568. * It might on the other hand introduce peter panning.
  98569. */
  98570. forceBackFacesOnly: boolean;
  98571. protected _scene: Scene;
  98572. protected _lightDirection: Vector3;
  98573. protected _effect: Effect;
  98574. protected _viewMatrix: Matrix;
  98575. protected _projectionMatrix: Matrix;
  98576. protected _transformMatrix: Matrix;
  98577. protected _cachedPosition: Vector3;
  98578. protected _cachedDirection: Vector3;
  98579. protected _cachedDefines: string;
  98580. protected _currentRenderID: number;
  98581. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98582. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98583. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98584. protected _blurPostProcesses: PostProcess[];
  98585. protected _mapSize: number;
  98586. protected _currentFaceIndex: number;
  98587. protected _currentFaceIndexCache: number;
  98588. protected _textureType: number;
  98589. protected _defaultTextureMatrix: Matrix;
  98590. protected _storedUniqueId: Nullable<number>;
  98591. /** @hidden */
  98592. static _SceneComponentInitialization: (scene: Scene) => void;
  98593. /**
  98594. * Gets or sets the size of the texture what stores the shadows
  98595. */
  98596. get mapSize(): number;
  98597. set mapSize(size: number);
  98598. /**
  98599. * Creates a ShadowGenerator object.
  98600. * A ShadowGenerator is the required tool to use the shadows.
  98601. * Each light casting shadows needs to use its own ShadowGenerator.
  98602. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98603. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98604. * @param light The light object generating the shadows.
  98605. * @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.
  98606. */
  98607. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98608. protected _initializeGenerator(): void;
  98609. protected _createTargetRenderTexture(): void;
  98610. protected _initializeShadowMap(): void;
  98611. protected _initializeBlurRTTAndPostProcesses(): void;
  98612. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98613. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98614. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98615. protected _applyFilterValues(): void;
  98616. /**
  98617. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98618. * @param onCompiled Callback triggered at the and of the effects compilation
  98619. * @param options Sets of optional options forcing the compilation with different modes
  98620. */
  98621. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98622. useInstances: boolean;
  98623. }>): void;
  98624. /**
  98625. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98626. * @param options Sets of optional options forcing the compilation with different modes
  98627. * @returns A promise that resolves when the compilation completes
  98628. */
  98629. forceCompilationAsync(options?: Partial<{
  98630. useInstances: boolean;
  98631. }>): Promise<void>;
  98632. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98633. private _prepareShadowDefines;
  98634. /**
  98635. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98636. * @param subMesh The submesh we want to render in the shadow map
  98637. * @param useInstances Defines wether will draw in the map using instances
  98638. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98639. * @returns true if ready otherwise, false
  98640. */
  98641. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98642. /**
  98643. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98644. * @param defines Defines of the material we want to update
  98645. * @param lightIndex Index of the light in the enabled light list of the material
  98646. */
  98647. prepareDefines(defines: any, lightIndex: number): void;
  98648. /**
  98649. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98650. * defined in the generator but impacting the effect).
  98651. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98652. * @param effect The effect we are binfing the information for
  98653. */
  98654. bindShadowLight(lightIndex: string, effect: Effect): void;
  98655. /**
  98656. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98657. * (eq to shadow prjection matrix * light transform matrix)
  98658. * @returns The transform matrix used to create the shadow map
  98659. */
  98660. getTransformMatrix(): Matrix;
  98661. /**
  98662. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98663. * Cube and 2D textures for instance.
  98664. */
  98665. recreateShadowMap(): void;
  98666. protected _disposeBlurPostProcesses(): void;
  98667. protected _disposeRTTandPostProcesses(): void;
  98668. /**
  98669. * Disposes the ShadowGenerator.
  98670. * Returns nothing.
  98671. */
  98672. dispose(): void;
  98673. /**
  98674. * Serializes the shadow generator setup to a json object.
  98675. * @returns The serialized JSON object
  98676. */
  98677. serialize(): any;
  98678. /**
  98679. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98680. * @param parsedShadowGenerator The JSON object to parse
  98681. * @param scene The scene to create the shadow map for
  98682. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98683. * @returns The parsed shadow generator
  98684. */
  98685. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98686. }
  98687. }
  98688. declare module BABYLON {
  98689. /**
  98690. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98691. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98692. * 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.
  98693. */
  98694. export abstract class Light extends Node {
  98695. /**
  98696. * Falloff Default: light is falling off following the material specification:
  98697. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98698. */
  98699. static readonly FALLOFF_DEFAULT: number;
  98700. /**
  98701. * Falloff Physical: light is falling off following the inverse squared distance law.
  98702. */
  98703. static readonly FALLOFF_PHYSICAL: number;
  98704. /**
  98705. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98706. * to enhance interoperability with other engines.
  98707. */
  98708. static readonly FALLOFF_GLTF: number;
  98709. /**
  98710. * Falloff Standard: light is falling off like in the standard material
  98711. * to enhance interoperability with other materials.
  98712. */
  98713. static readonly FALLOFF_STANDARD: number;
  98714. /**
  98715. * If every light affecting the material is in this lightmapMode,
  98716. * material.lightmapTexture adds or multiplies
  98717. * (depends on material.useLightmapAsShadowmap)
  98718. * after every other light calculations.
  98719. */
  98720. static readonly LIGHTMAP_DEFAULT: number;
  98721. /**
  98722. * material.lightmapTexture as only diffuse lighting from this light
  98723. * adds only specular lighting from this light
  98724. * adds dynamic shadows
  98725. */
  98726. static readonly LIGHTMAP_SPECULAR: number;
  98727. /**
  98728. * material.lightmapTexture as only lighting
  98729. * no light calculation from this light
  98730. * only adds dynamic shadows from this light
  98731. */
  98732. static readonly LIGHTMAP_SHADOWSONLY: number;
  98733. /**
  98734. * Each light type uses the default quantity according to its type:
  98735. * point/spot lights use luminous intensity
  98736. * directional lights use illuminance
  98737. */
  98738. static readonly INTENSITYMODE_AUTOMATIC: number;
  98739. /**
  98740. * lumen (lm)
  98741. */
  98742. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98743. /**
  98744. * candela (lm/sr)
  98745. */
  98746. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98747. /**
  98748. * lux (lm/m^2)
  98749. */
  98750. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98751. /**
  98752. * nit (cd/m^2)
  98753. */
  98754. static readonly INTENSITYMODE_LUMINANCE: number;
  98755. /**
  98756. * Light type const id of the point light.
  98757. */
  98758. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98759. /**
  98760. * Light type const id of the directional light.
  98761. */
  98762. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98763. /**
  98764. * Light type const id of the spot light.
  98765. */
  98766. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98767. /**
  98768. * Light type const id of the hemispheric light.
  98769. */
  98770. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98771. /**
  98772. * Diffuse gives the basic color to an object.
  98773. */
  98774. diffuse: Color3;
  98775. /**
  98776. * Specular produces a highlight color on an object.
  98777. * Note: This is note affecting PBR materials.
  98778. */
  98779. specular: Color3;
  98780. /**
  98781. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98782. * falling off base on range or angle.
  98783. * This can be set to any values in Light.FALLOFF_x.
  98784. *
  98785. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98786. * other types of materials.
  98787. */
  98788. falloffType: number;
  98789. /**
  98790. * Strength of the light.
  98791. * Note: By default it is define in the framework own unit.
  98792. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98793. */
  98794. intensity: number;
  98795. private _range;
  98796. protected _inverseSquaredRange: number;
  98797. /**
  98798. * Defines how far from the source the light is impacting in scene units.
  98799. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98800. */
  98801. get range(): number;
  98802. /**
  98803. * Defines how far from the source the light is impacting in scene units.
  98804. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98805. */
  98806. set range(value: number);
  98807. /**
  98808. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98809. * of light.
  98810. */
  98811. private _photometricScale;
  98812. private _intensityMode;
  98813. /**
  98814. * Gets the photometric scale used to interpret the intensity.
  98815. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98816. */
  98817. get intensityMode(): number;
  98818. /**
  98819. * Sets the photometric scale used to interpret the intensity.
  98820. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98821. */
  98822. set intensityMode(value: number);
  98823. private _radius;
  98824. /**
  98825. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98826. */
  98827. get radius(): number;
  98828. /**
  98829. * sets the light radius used by PBR Materials to simulate soft area lights.
  98830. */
  98831. set radius(value: number);
  98832. private _renderPriority;
  98833. /**
  98834. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98835. * exceeding the number allowed of the materials.
  98836. */
  98837. renderPriority: number;
  98838. private _shadowEnabled;
  98839. /**
  98840. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98841. * the current shadow generator.
  98842. */
  98843. get shadowEnabled(): boolean;
  98844. /**
  98845. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98846. * the current shadow generator.
  98847. */
  98848. set shadowEnabled(value: boolean);
  98849. private _includedOnlyMeshes;
  98850. /**
  98851. * Gets the only meshes impacted by this light.
  98852. */
  98853. get includedOnlyMeshes(): AbstractMesh[];
  98854. /**
  98855. * Sets the only meshes impacted by this light.
  98856. */
  98857. set includedOnlyMeshes(value: AbstractMesh[]);
  98858. private _excludedMeshes;
  98859. /**
  98860. * Gets the meshes not impacted by this light.
  98861. */
  98862. get excludedMeshes(): AbstractMesh[];
  98863. /**
  98864. * Sets the meshes not impacted by this light.
  98865. */
  98866. set excludedMeshes(value: AbstractMesh[]);
  98867. private _excludeWithLayerMask;
  98868. /**
  98869. * Gets the layer id use to find what meshes are not impacted by the light.
  98870. * Inactive if 0
  98871. */
  98872. get excludeWithLayerMask(): number;
  98873. /**
  98874. * Sets the layer id use to find what meshes are not impacted by the light.
  98875. * Inactive if 0
  98876. */
  98877. set excludeWithLayerMask(value: number);
  98878. private _includeOnlyWithLayerMask;
  98879. /**
  98880. * Gets the layer id use to find what meshes are impacted by the light.
  98881. * Inactive if 0
  98882. */
  98883. get includeOnlyWithLayerMask(): number;
  98884. /**
  98885. * Sets the layer id use to find what meshes are impacted by the light.
  98886. * Inactive if 0
  98887. */
  98888. set includeOnlyWithLayerMask(value: number);
  98889. private _lightmapMode;
  98890. /**
  98891. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98892. */
  98893. get lightmapMode(): number;
  98894. /**
  98895. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98896. */
  98897. set lightmapMode(value: number);
  98898. /**
  98899. * Shadow generator associted to the light.
  98900. * @hidden Internal use only.
  98901. */
  98902. _shadowGenerator: Nullable<IShadowGenerator>;
  98903. /**
  98904. * @hidden Internal use only.
  98905. */
  98906. _excludedMeshesIds: string[];
  98907. /**
  98908. * @hidden Internal use only.
  98909. */
  98910. _includedOnlyMeshesIds: string[];
  98911. /**
  98912. * The current light unifom buffer.
  98913. * @hidden Internal use only.
  98914. */
  98915. _uniformBuffer: UniformBuffer;
  98916. /** @hidden */
  98917. _renderId: number;
  98918. /**
  98919. * Creates a Light object in the scene.
  98920. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98921. * @param name The firendly name of the light
  98922. * @param scene The scene the light belongs too
  98923. */
  98924. constructor(name: string, scene: Scene);
  98925. protected abstract _buildUniformLayout(): void;
  98926. /**
  98927. * Sets the passed Effect "effect" with the Light information.
  98928. * @param effect The effect to update
  98929. * @param lightIndex The index of the light in the effect to update
  98930. * @returns The light
  98931. */
  98932. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  98933. /**
  98934. * Sets the passed Effect "effect" with the Light textures.
  98935. * @param effect The effect to update
  98936. * @param lightIndex The index of the light in the effect to update
  98937. * @returns The light
  98938. */
  98939. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  98940. /**
  98941. * Binds the lights information from the scene to the effect for the given mesh.
  98942. * @param lightIndex Light index
  98943. * @param scene The scene where the light belongs to
  98944. * @param effect The effect we are binding the data to
  98945. * @param useSpecular Defines if specular is supported
  98946. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98947. */
  98948. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98949. /**
  98950. * Sets the passed Effect "effect" with the Light information.
  98951. * @param effect The effect to update
  98952. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98953. * @returns The light
  98954. */
  98955. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98956. /**
  98957. * Returns the string "Light".
  98958. * @returns the class name
  98959. */
  98960. getClassName(): string;
  98961. /** @hidden */
  98962. readonly _isLight: boolean;
  98963. /**
  98964. * Converts the light information to a readable string for debug purpose.
  98965. * @param fullDetails Supports for multiple levels of logging within scene loading
  98966. * @returns the human readable light info
  98967. */
  98968. toString(fullDetails?: boolean): string;
  98969. /** @hidden */
  98970. protected _syncParentEnabledState(): void;
  98971. /**
  98972. * Set the enabled state of this node.
  98973. * @param value - the new enabled state
  98974. */
  98975. setEnabled(value: boolean): void;
  98976. /**
  98977. * Returns the Light associated shadow generator if any.
  98978. * @return the associated shadow generator.
  98979. */
  98980. getShadowGenerator(): Nullable<IShadowGenerator>;
  98981. /**
  98982. * Returns a Vector3, the absolute light position in the World.
  98983. * @returns the world space position of the light
  98984. */
  98985. getAbsolutePosition(): Vector3;
  98986. /**
  98987. * Specifies if the light will affect the passed mesh.
  98988. * @param mesh The mesh to test against the light
  98989. * @return true the mesh is affected otherwise, false.
  98990. */
  98991. canAffectMesh(mesh: AbstractMesh): boolean;
  98992. /**
  98993. * Sort function to order lights for rendering.
  98994. * @param a First Light object to compare to second.
  98995. * @param b Second Light object to compare first.
  98996. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  98997. */
  98998. static CompareLightsPriority(a: Light, b: Light): number;
  98999. /**
  99000. * Releases resources associated with this node.
  99001. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99002. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99003. */
  99004. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99005. /**
  99006. * Returns the light type ID (integer).
  99007. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99008. */
  99009. getTypeID(): number;
  99010. /**
  99011. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  99012. * @returns the scaled intensity in intensity mode unit
  99013. */
  99014. getScaledIntensity(): number;
  99015. /**
  99016. * Returns a new Light object, named "name", from the current one.
  99017. * @param name The name of the cloned light
  99018. * @param newParent The parent of this light, if it has one
  99019. * @returns the new created light
  99020. */
  99021. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  99022. /**
  99023. * Serializes the current light into a Serialization object.
  99024. * @returns the serialized object.
  99025. */
  99026. serialize(): any;
  99027. /**
  99028. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  99029. * This new light is named "name" and added to the passed scene.
  99030. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  99031. * @param name The friendly name of the light
  99032. * @param scene The scene the new light will belong to
  99033. * @returns the constructor function
  99034. */
  99035. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  99036. /**
  99037. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  99038. * @param parsedLight The JSON representation of the light
  99039. * @param scene The scene to create the parsed light in
  99040. * @returns the created light after parsing
  99041. */
  99042. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  99043. private _hookArrayForExcluded;
  99044. private _hookArrayForIncludedOnly;
  99045. private _resyncMeshes;
  99046. /**
  99047. * Forces the meshes to update their light related information in their rendering used effects
  99048. * @hidden Internal Use Only
  99049. */
  99050. _markMeshesAsLightDirty(): void;
  99051. /**
  99052. * Recomputes the cached photometric scale if needed.
  99053. */
  99054. private _computePhotometricScale;
  99055. /**
  99056. * Returns the Photometric Scale according to the light type and intensity mode.
  99057. */
  99058. private _getPhotometricScale;
  99059. /**
  99060. * Reorder the light in the scene according to their defined priority.
  99061. * @hidden Internal Use Only
  99062. */
  99063. _reorderLightsInScene(): void;
  99064. /**
  99065. * Prepares the list of defines specific to the light type.
  99066. * @param defines the list of defines
  99067. * @param lightIndex defines the index of the light for the effect
  99068. */
  99069. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99070. }
  99071. }
  99072. declare module BABYLON {
  99073. /**
  99074. * Configuration needed for prepass-capable materials
  99075. */
  99076. export class PrePassConfiguration {
  99077. /**
  99078. * Previous world matrices of meshes carrying this material
  99079. * Used for computing velocity
  99080. */
  99081. previousWorldMatrices: {
  99082. [index: number]: Matrix;
  99083. };
  99084. /**
  99085. * Previous view project matrix
  99086. * Used for computing velocity
  99087. */
  99088. previousViewProjection: Matrix;
  99089. /**
  99090. * Previous bones of meshes carrying this material
  99091. * Used for computing velocity
  99092. */
  99093. previousBones: {
  99094. [index: number]: Float32Array;
  99095. };
  99096. /**
  99097. * Add the required uniforms to the current list.
  99098. * @param uniforms defines the current uniform list.
  99099. */
  99100. static AddUniforms(uniforms: string[]): void;
  99101. /**
  99102. * Add the required samplers to the current list.
  99103. * @param samplers defines the current sampler list.
  99104. */
  99105. static AddSamplers(samplers: string[]): void;
  99106. /**
  99107. * Binds the material data.
  99108. * @param effect defines the effect to update
  99109. * @param scene defines the scene the material belongs to.
  99110. * @param mesh The mesh
  99111. * @param world World matrix of this mesh
  99112. * @param isFrozen Is the material frozen
  99113. */
  99114. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  99115. }
  99116. }
  99117. declare module BABYLON {
  99118. /**
  99119. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  99120. * This is the base of the follow, arc rotate cameras and Free camera
  99121. * @see https://doc.babylonjs.com/features/cameras
  99122. */
  99123. export class TargetCamera extends Camera {
  99124. private static _RigCamTransformMatrix;
  99125. private static _TargetTransformMatrix;
  99126. private static _TargetFocalPoint;
  99127. private _tmpUpVector;
  99128. private _tmpTargetVector;
  99129. /**
  99130. * Define the current direction the camera is moving to
  99131. */
  99132. cameraDirection: Vector3;
  99133. /**
  99134. * Define the current rotation the camera is rotating to
  99135. */
  99136. cameraRotation: Vector2;
  99137. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  99138. ignoreParentScaling: boolean;
  99139. /**
  99140. * When set, the up vector of the camera will be updated by the rotation of the camera
  99141. */
  99142. updateUpVectorFromRotation: boolean;
  99143. private _tmpQuaternion;
  99144. /**
  99145. * Define the current rotation of the camera
  99146. */
  99147. rotation: Vector3;
  99148. /**
  99149. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  99150. */
  99151. rotationQuaternion: Quaternion;
  99152. /**
  99153. * Define the current speed of the camera
  99154. */
  99155. speed: number;
  99156. /**
  99157. * Add constraint to the camera to prevent it to move freely in all directions and
  99158. * around all axis.
  99159. */
  99160. noRotationConstraint: boolean;
  99161. /**
  99162. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  99163. * panning
  99164. */
  99165. invertRotation: boolean;
  99166. /**
  99167. * Speed multiplier for inverse camera panning
  99168. */
  99169. inverseRotationSpeed: number;
  99170. /**
  99171. * Define the current target of the camera as an object or a position.
  99172. */
  99173. lockedTarget: any;
  99174. /** @hidden */
  99175. _currentTarget: Vector3;
  99176. /** @hidden */
  99177. _initialFocalDistance: number;
  99178. /** @hidden */
  99179. _viewMatrix: Matrix;
  99180. /** @hidden */
  99181. _camMatrix: Matrix;
  99182. /** @hidden */
  99183. _cameraTransformMatrix: Matrix;
  99184. /** @hidden */
  99185. _cameraRotationMatrix: Matrix;
  99186. /** @hidden */
  99187. _referencePoint: Vector3;
  99188. /** @hidden */
  99189. _transformedReferencePoint: Vector3;
  99190. /** @hidden */
  99191. _reset: () => void;
  99192. private _defaultUp;
  99193. /**
  99194. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  99195. * This is the base of the follow, arc rotate cameras and Free camera
  99196. * @see https://doc.babylonjs.com/features/cameras
  99197. * @param name Defines the name of the camera in the scene
  99198. * @param position Defines the start position of the camera in the scene
  99199. * @param scene Defines the scene the camera belongs to
  99200. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99201. */
  99202. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99203. /**
  99204. * Gets the position in front of the camera at a given distance.
  99205. * @param distance The distance from the camera we want the position to be
  99206. * @returns the position
  99207. */
  99208. getFrontPosition(distance: number): Vector3;
  99209. /** @hidden */
  99210. _getLockedTargetPosition(): Nullable<Vector3>;
  99211. private _storedPosition;
  99212. private _storedRotation;
  99213. private _storedRotationQuaternion;
  99214. /**
  99215. * Store current camera state of the camera (fov, position, rotation, etc..)
  99216. * @returns the camera
  99217. */
  99218. storeState(): Camera;
  99219. /**
  99220. * Restored camera state. You must call storeState() first
  99221. * @returns whether it was successful or not
  99222. * @hidden
  99223. */
  99224. _restoreStateValues(): boolean;
  99225. /** @hidden */
  99226. _initCache(): void;
  99227. /** @hidden */
  99228. _updateCache(ignoreParentClass?: boolean): void;
  99229. /** @hidden */
  99230. _isSynchronizedViewMatrix(): boolean;
  99231. /** @hidden */
  99232. _computeLocalCameraSpeed(): number;
  99233. /**
  99234. * Defines the target the camera should look at.
  99235. * @param target Defines the new target as a Vector or a mesh
  99236. */
  99237. setTarget(target: Vector3): void;
  99238. /**
  99239. * Defines the target point of the camera.
  99240. * The camera looks towards it form the radius distance.
  99241. */
  99242. get target(): Vector3;
  99243. set target(value: Vector3);
  99244. /**
  99245. * Return the current target position of the camera. This value is expressed in local space.
  99246. * @returns the target position
  99247. */
  99248. getTarget(): Vector3;
  99249. /** @hidden */
  99250. _decideIfNeedsToMove(): boolean;
  99251. /** @hidden */
  99252. _updatePosition(): void;
  99253. /** @hidden */
  99254. _checkInputs(): void;
  99255. protected _updateCameraRotationMatrix(): void;
  99256. /**
  99257. * 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)
  99258. * @returns the current camera
  99259. */
  99260. private _rotateUpVectorWithCameraRotationMatrix;
  99261. private _cachedRotationZ;
  99262. private _cachedQuaternionRotationZ;
  99263. /** @hidden */
  99264. _getViewMatrix(): Matrix;
  99265. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  99266. /**
  99267. * @hidden
  99268. */
  99269. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99270. /**
  99271. * @hidden
  99272. */
  99273. _updateRigCameras(): void;
  99274. private _getRigCamPositionAndTarget;
  99275. /**
  99276. * Gets the current object class name.
  99277. * @return the class name
  99278. */
  99279. getClassName(): string;
  99280. }
  99281. }
  99282. declare module BABYLON {
  99283. /**
  99284. * Gather the list of keyboard event types as constants.
  99285. */
  99286. export class KeyboardEventTypes {
  99287. /**
  99288. * The keydown event is fired when a key becomes active (pressed).
  99289. */
  99290. static readonly KEYDOWN: number;
  99291. /**
  99292. * The keyup event is fired when a key has been released.
  99293. */
  99294. static readonly KEYUP: number;
  99295. }
  99296. /**
  99297. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99298. */
  99299. export class KeyboardInfo {
  99300. /**
  99301. * Defines the type of event (KeyboardEventTypes)
  99302. */
  99303. type: number;
  99304. /**
  99305. * Defines the related dom event
  99306. */
  99307. event: KeyboardEvent;
  99308. /**
  99309. * Instantiates a new keyboard info.
  99310. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99311. * @param type Defines the type of event (KeyboardEventTypes)
  99312. * @param event Defines the related dom event
  99313. */
  99314. constructor(
  99315. /**
  99316. * Defines the type of event (KeyboardEventTypes)
  99317. */
  99318. type: number,
  99319. /**
  99320. * Defines the related dom event
  99321. */
  99322. event: KeyboardEvent);
  99323. }
  99324. /**
  99325. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99326. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  99327. */
  99328. export class KeyboardInfoPre extends KeyboardInfo {
  99329. /**
  99330. * Defines the type of event (KeyboardEventTypes)
  99331. */
  99332. type: number;
  99333. /**
  99334. * Defines the related dom event
  99335. */
  99336. event: KeyboardEvent;
  99337. /**
  99338. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  99339. */
  99340. skipOnPointerObservable: boolean;
  99341. /**
  99342. * Instantiates a new keyboard pre info.
  99343. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99344. * @param type Defines the type of event (KeyboardEventTypes)
  99345. * @param event Defines the related dom event
  99346. */
  99347. constructor(
  99348. /**
  99349. * Defines the type of event (KeyboardEventTypes)
  99350. */
  99351. type: number,
  99352. /**
  99353. * Defines the related dom event
  99354. */
  99355. event: KeyboardEvent);
  99356. }
  99357. }
  99358. declare module BABYLON {
  99359. /**
  99360. * Manage the keyboard inputs to control the movement of a free camera.
  99361. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99362. */
  99363. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  99364. /**
  99365. * Defines the camera the input is attached to.
  99366. */
  99367. camera: FreeCamera;
  99368. /**
  99369. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99370. */
  99371. keysUp: number[];
  99372. /**
  99373. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99374. */
  99375. keysUpward: number[];
  99376. /**
  99377. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99378. */
  99379. keysDown: number[];
  99380. /**
  99381. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99382. */
  99383. keysDownward: number[];
  99384. /**
  99385. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99386. */
  99387. keysLeft: number[];
  99388. /**
  99389. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99390. */
  99391. keysRight: number[];
  99392. private _keys;
  99393. private _onCanvasBlurObserver;
  99394. private _onKeyboardObserver;
  99395. private _engine;
  99396. private _scene;
  99397. /**
  99398. * Attach the input controls to a specific dom element to get the input from.
  99399. * @param element Defines the element the controls should be listened from
  99400. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99401. */
  99402. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99403. /**
  99404. * Detach the current controls from the specified dom element.
  99405. * @param element Defines the element to stop listening the inputs from
  99406. */
  99407. detachControl(element: Nullable<HTMLElement>): void;
  99408. /**
  99409. * Update the current camera state depending on the inputs that have been used this frame.
  99410. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99411. */
  99412. checkInputs(): void;
  99413. /**
  99414. * Gets the class name of the current intput.
  99415. * @returns the class name
  99416. */
  99417. getClassName(): string;
  99418. /** @hidden */
  99419. _onLostFocus(): void;
  99420. /**
  99421. * Get the friendly name associated with the input class.
  99422. * @returns the input friendly name
  99423. */
  99424. getSimpleName(): string;
  99425. }
  99426. }
  99427. declare module BABYLON {
  99428. /**
  99429. * Gather the list of pointer event types as constants.
  99430. */
  99431. export class PointerEventTypes {
  99432. /**
  99433. * 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.
  99434. */
  99435. static readonly POINTERDOWN: number;
  99436. /**
  99437. * The pointerup event is fired when a pointer is no longer active.
  99438. */
  99439. static readonly POINTERUP: number;
  99440. /**
  99441. * The pointermove event is fired when a pointer changes coordinates.
  99442. */
  99443. static readonly POINTERMOVE: number;
  99444. /**
  99445. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99446. */
  99447. static readonly POINTERWHEEL: number;
  99448. /**
  99449. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99450. */
  99451. static readonly POINTERPICK: number;
  99452. /**
  99453. * The pointertap event is fired when a the object has been touched and released without drag.
  99454. */
  99455. static readonly POINTERTAP: number;
  99456. /**
  99457. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99458. */
  99459. static readonly POINTERDOUBLETAP: number;
  99460. }
  99461. /**
  99462. * Base class of pointer info types.
  99463. */
  99464. export class PointerInfoBase {
  99465. /**
  99466. * Defines the type of event (PointerEventTypes)
  99467. */
  99468. type: number;
  99469. /**
  99470. * Defines the related dom event
  99471. */
  99472. event: PointerEvent | MouseWheelEvent;
  99473. /**
  99474. * Instantiates the base class of pointers info.
  99475. * @param type Defines the type of event (PointerEventTypes)
  99476. * @param event Defines the related dom event
  99477. */
  99478. constructor(
  99479. /**
  99480. * Defines the type of event (PointerEventTypes)
  99481. */
  99482. type: number,
  99483. /**
  99484. * Defines the related dom event
  99485. */
  99486. event: PointerEvent | MouseWheelEvent);
  99487. }
  99488. /**
  99489. * This class is used to store pointer related info for the onPrePointerObservable event.
  99490. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99491. */
  99492. export class PointerInfoPre extends PointerInfoBase {
  99493. /**
  99494. * Ray from a pointer if availible (eg. 6dof controller)
  99495. */
  99496. ray: Nullable<Ray>;
  99497. /**
  99498. * Defines the local position of the pointer on the canvas.
  99499. */
  99500. localPosition: Vector2;
  99501. /**
  99502. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99503. */
  99504. skipOnPointerObservable: boolean;
  99505. /**
  99506. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99507. * @param type Defines the type of event (PointerEventTypes)
  99508. * @param event Defines the related dom event
  99509. * @param localX Defines the local x coordinates of the pointer when the event occured
  99510. * @param localY Defines the local y coordinates of the pointer when the event occured
  99511. */
  99512. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99513. }
  99514. /**
  99515. * This type contains all the data related to a pointer event in Babylon.js.
  99516. * 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.
  99517. */
  99518. export class PointerInfo extends PointerInfoBase {
  99519. /**
  99520. * Defines the picking info associated to the info (if any)\
  99521. */
  99522. pickInfo: Nullable<PickingInfo>;
  99523. /**
  99524. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99525. * @param type Defines the type of event (PointerEventTypes)
  99526. * @param event Defines the related dom event
  99527. * @param pickInfo Defines the picking info associated to the info (if any)\
  99528. */
  99529. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99530. /**
  99531. * Defines the picking info associated to the info (if any)\
  99532. */
  99533. pickInfo: Nullable<PickingInfo>);
  99534. }
  99535. /**
  99536. * Data relating to a touch event on the screen.
  99537. */
  99538. export interface PointerTouch {
  99539. /**
  99540. * X coordinate of touch.
  99541. */
  99542. x: number;
  99543. /**
  99544. * Y coordinate of touch.
  99545. */
  99546. y: number;
  99547. /**
  99548. * Id of touch. Unique for each finger.
  99549. */
  99550. pointerId: number;
  99551. /**
  99552. * Event type passed from DOM.
  99553. */
  99554. type: any;
  99555. }
  99556. }
  99557. declare module BABYLON {
  99558. /**
  99559. * Manage the mouse inputs to control the movement of a free camera.
  99560. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99561. */
  99562. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99563. /**
  99564. * Define if touch is enabled in the mouse input
  99565. */
  99566. touchEnabled: boolean;
  99567. /**
  99568. * Defines the camera the input is attached to.
  99569. */
  99570. camera: FreeCamera;
  99571. /**
  99572. * Defines the buttons associated with the input to handle camera move.
  99573. */
  99574. buttons: number[];
  99575. /**
  99576. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99577. */
  99578. angularSensibility: number;
  99579. private _pointerInput;
  99580. private _onMouseMove;
  99581. private _observer;
  99582. private previousPosition;
  99583. /**
  99584. * Observable for when a pointer move event occurs containing the move offset
  99585. */
  99586. onPointerMovedObservable: Observable<{
  99587. offsetX: number;
  99588. offsetY: number;
  99589. }>;
  99590. /**
  99591. * @hidden
  99592. * If the camera should be rotated automatically based on pointer movement
  99593. */
  99594. _allowCameraRotation: boolean;
  99595. /**
  99596. * Manage the mouse inputs to control the movement of a free camera.
  99597. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99598. * @param touchEnabled Defines if touch is enabled or not
  99599. */
  99600. constructor(
  99601. /**
  99602. * Define if touch is enabled in the mouse input
  99603. */
  99604. touchEnabled?: boolean);
  99605. /**
  99606. * Attach the input controls to a specific dom element to get the input from.
  99607. * @param element Defines the element the controls should be listened from
  99608. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99609. */
  99610. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99611. /**
  99612. * Called on JS contextmenu event.
  99613. * Override this method to provide functionality.
  99614. */
  99615. protected onContextMenu(evt: PointerEvent): void;
  99616. /**
  99617. * Detach the current controls from the specified dom element.
  99618. * @param element Defines the element to stop listening the inputs from
  99619. */
  99620. detachControl(element: Nullable<HTMLElement>): void;
  99621. /**
  99622. * Gets the class name of the current intput.
  99623. * @returns the class name
  99624. */
  99625. getClassName(): string;
  99626. /**
  99627. * Get the friendly name associated with the input class.
  99628. * @returns the input friendly name
  99629. */
  99630. getSimpleName(): string;
  99631. }
  99632. }
  99633. declare module BABYLON {
  99634. /**
  99635. * Manage the touch inputs to control the movement of a free camera.
  99636. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99637. */
  99638. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99639. /**
  99640. * Define if mouse events can be treated as touch events
  99641. */
  99642. allowMouse: boolean;
  99643. /**
  99644. * Defines the camera the input is attached to.
  99645. */
  99646. camera: FreeCamera;
  99647. /**
  99648. * Defines the touch sensibility for rotation.
  99649. * The higher the faster.
  99650. */
  99651. touchAngularSensibility: number;
  99652. /**
  99653. * Defines the touch sensibility for move.
  99654. * The higher the faster.
  99655. */
  99656. touchMoveSensibility: number;
  99657. private _offsetX;
  99658. private _offsetY;
  99659. private _pointerPressed;
  99660. private _pointerInput;
  99661. private _observer;
  99662. private _onLostFocus;
  99663. /**
  99664. * Manage the touch inputs to control the movement of a free camera.
  99665. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99666. * @param allowMouse Defines if mouse events can be treated as touch events
  99667. */
  99668. constructor(
  99669. /**
  99670. * Define if mouse events can be treated as touch events
  99671. */
  99672. allowMouse?: boolean);
  99673. /**
  99674. * Attach the input controls to a specific dom element to get the input from.
  99675. * @param element Defines the element the controls should be listened from
  99676. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99677. */
  99678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99679. /**
  99680. * Detach the current controls from the specified dom element.
  99681. * @param element Defines the element to stop listening the inputs from
  99682. */
  99683. detachControl(element: Nullable<HTMLElement>): void;
  99684. /**
  99685. * Update the current camera state depending on the inputs that have been used this frame.
  99686. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99687. */
  99688. checkInputs(): void;
  99689. /**
  99690. * Gets the class name of the current intput.
  99691. * @returns the class name
  99692. */
  99693. getClassName(): string;
  99694. /**
  99695. * Get the friendly name associated with the input class.
  99696. * @returns the input friendly name
  99697. */
  99698. getSimpleName(): string;
  99699. }
  99700. }
  99701. declare module BABYLON {
  99702. /**
  99703. * Default Inputs manager for the FreeCamera.
  99704. * It groups all the default supported inputs for ease of use.
  99705. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99706. */
  99707. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99708. /**
  99709. * @hidden
  99710. */
  99711. _mouseInput: Nullable<FreeCameraMouseInput>;
  99712. /**
  99713. * Instantiates a new FreeCameraInputsManager.
  99714. * @param camera Defines the camera the inputs belong to
  99715. */
  99716. constructor(camera: FreeCamera);
  99717. /**
  99718. * Add keyboard input support to the input manager.
  99719. * @returns the current input manager
  99720. */
  99721. addKeyboard(): FreeCameraInputsManager;
  99722. /**
  99723. * Add mouse input support to the input manager.
  99724. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99725. * @returns the current input manager
  99726. */
  99727. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99728. /**
  99729. * Removes the mouse input support from the manager
  99730. * @returns the current input manager
  99731. */
  99732. removeMouse(): FreeCameraInputsManager;
  99733. /**
  99734. * Add touch input support to the input manager.
  99735. * @returns the current input manager
  99736. */
  99737. addTouch(): FreeCameraInputsManager;
  99738. /**
  99739. * Remove all attached input methods from a camera
  99740. */
  99741. clear(): void;
  99742. }
  99743. }
  99744. declare module BABYLON {
  99745. /**
  99746. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99747. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99748. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99749. */
  99750. export class FreeCamera extends TargetCamera {
  99751. /**
  99752. * Define the collision ellipsoid of the camera.
  99753. * This is helpful to simulate a camera body like the player body around the camera
  99754. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99755. */
  99756. ellipsoid: Vector3;
  99757. /**
  99758. * Define an offset for the position of the ellipsoid around the camera.
  99759. * This can be helpful to determine the center of the body near the gravity center of the body
  99760. * instead of its head.
  99761. */
  99762. ellipsoidOffset: Vector3;
  99763. /**
  99764. * Enable or disable collisions of the camera with the rest of the scene objects.
  99765. */
  99766. checkCollisions: boolean;
  99767. /**
  99768. * Enable or disable gravity on the camera.
  99769. */
  99770. applyGravity: boolean;
  99771. /**
  99772. * Define the input manager associated to the camera.
  99773. */
  99774. inputs: FreeCameraInputsManager;
  99775. /**
  99776. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99777. * Higher values reduce sensitivity.
  99778. */
  99779. get angularSensibility(): number;
  99780. /**
  99781. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99782. * Higher values reduce sensitivity.
  99783. */
  99784. set angularSensibility(value: number);
  99785. /**
  99786. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99787. */
  99788. get keysUp(): number[];
  99789. set keysUp(value: number[]);
  99790. /**
  99791. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99792. */
  99793. get keysUpward(): number[];
  99794. set keysUpward(value: number[]);
  99795. /**
  99796. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99797. */
  99798. get keysDown(): number[];
  99799. set keysDown(value: number[]);
  99800. /**
  99801. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99802. */
  99803. get keysDownward(): number[];
  99804. set keysDownward(value: number[]);
  99805. /**
  99806. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99807. */
  99808. get keysLeft(): number[];
  99809. set keysLeft(value: number[]);
  99810. /**
  99811. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99812. */
  99813. get keysRight(): number[];
  99814. set keysRight(value: number[]);
  99815. /**
  99816. * Event raised when the camera collide with a mesh in the scene.
  99817. */
  99818. onCollide: (collidedMesh: AbstractMesh) => void;
  99819. private _collider;
  99820. private _needMoveForGravity;
  99821. private _oldPosition;
  99822. private _diffPosition;
  99823. private _newPosition;
  99824. /** @hidden */
  99825. _localDirection: Vector3;
  99826. /** @hidden */
  99827. _transformedDirection: Vector3;
  99828. /**
  99829. * Instantiates a Free Camera.
  99830. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99831. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  99832. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99833. * @param name Define the name of the camera in the scene
  99834. * @param position Define the start position of the camera in the scene
  99835. * @param scene Define the scene the camera belongs to
  99836. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99837. */
  99838. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99839. /**
  99840. * Attached controls to the current camera.
  99841. * @param element Defines the element the controls should be listened from
  99842. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99843. */
  99844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99845. /**
  99846. * Detach the current controls from the camera.
  99847. * The camera will stop reacting to inputs.
  99848. * @param element Defines the element to stop listening the inputs from
  99849. */
  99850. detachControl(element: HTMLElement): void;
  99851. private _collisionMask;
  99852. /**
  99853. * Define a collision mask to limit the list of object the camera can collide with
  99854. */
  99855. get collisionMask(): number;
  99856. set collisionMask(mask: number);
  99857. /** @hidden */
  99858. _collideWithWorld(displacement: Vector3): void;
  99859. private _onCollisionPositionChange;
  99860. /** @hidden */
  99861. _checkInputs(): void;
  99862. /** @hidden */
  99863. _decideIfNeedsToMove(): boolean;
  99864. /** @hidden */
  99865. _updatePosition(): void;
  99866. /**
  99867. * Destroy the camera and release the current resources hold by it.
  99868. */
  99869. dispose(): void;
  99870. /**
  99871. * Gets the current object class name.
  99872. * @return the class name
  99873. */
  99874. getClassName(): string;
  99875. }
  99876. }
  99877. declare module BABYLON {
  99878. /**
  99879. * Represents a gamepad control stick position
  99880. */
  99881. export class StickValues {
  99882. /**
  99883. * The x component of the control stick
  99884. */
  99885. x: number;
  99886. /**
  99887. * The y component of the control stick
  99888. */
  99889. y: number;
  99890. /**
  99891. * Initializes the gamepad x and y control stick values
  99892. * @param x The x component of the gamepad control stick value
  99893. * @param y The y component of the gamepad control stick value
  99894. */
  99895. constructor(
  99896. /**
  99897. * The x component of the control stick
  99898. */
  99899. x: number,
  99900. /**
  99901. * The y component of the control stick
  99902. */
  99903. y: number);
  99904. }
  99905. /**
  99906. * An interface which manages callbacks for gamepad button changes
  99907. */
  99908. export interface GamepadButtonChanges {
  99909. /**
  99910. * Called when a gamepad has been changed
  99911. */
  99912. changed: boolean;
  99913. /**
  99914. * Called when a gamepad press event has been triggered
  99915. */
  99916. pressChanged: boolean;
  99917. /**
  99918. * Called when a touch event has been triggered
  99919. */
  99920. touchChanged: boolean;
  99921. /**
  99922. * Called when a value has changed
  99923. */
  99924. valueChanged: boolean;
  99925. }
  99926. /**
  99927. * Represents a gamepad
  99928. */
  99929. export class Gamepad {
  99930. /**
  99931. * The id of the gamepad
  99932. */
  99933. id: string;
  99934. /**
  99935. * The index of the gamepad
  99936. */
  99937. index: number;
  99938. /**
  99939. * The browser gamepad
  99940. */
  99941. browserGamepad: any;
  99942. /**
  99943. * Specifies what type of gamepad this represents
  99944. */
  99945. type: number;
  99946. private _leftStick;
  99947. private _rightStick;
  99948. /** @hidden */
  99949. _isConnected: boolean;
  99950. private _leftStickAxisX;
  99951. private _leftStickAxisY;
  99952. private _rightStickAxisX;
  99953. private _rightStickAxisY;
  99954. /**
  99955. * Triggered when the left control stick has been changed
  99956. */
  99957. private _onleftstickchanged;
  99958. /**
  99959. * Triggered when the right control stick has been changed
  99960. */
  99961. private _onrightstickchanged;
  99962. /**
  99963. * Represents a gamepad controller
  99964. */
  99965. static GAMEPAD: number;
  99966. /**
  99967. * Represents a generic controller
  99968. */
  99969. static GENERIC: number;
  99970. /**
  99971. * Represents an XBox controller
  99972. */
  99973. static XBOX: number;
  99974. /**
  99975. * Represents a pose-enabled controller
  99976. */
  99977. static POSE_ENABLED: number;
  99978. /**
  99979. * Represents an Dual Shock controller
  99980. */
  99981. static DUALSHOCK: number;
  99982. /**
  99983. * Specifies whether the left control stick should be Y-inverted
  99984. */
  99985. protected _invertLeftStickY: boolean;
  99986. /**
  99987. * Specifies if the gamepad has been connected
  99988. */
  99989. get isConnected(): boolean;
  99990. /**
  99991. * Initializes the gamepad
  99992. * @param id The id of the gamepad
  99993. * @param index The index of the gamepad
  99994. * @param browserGamepad The browser gamepad
  99995. * @param leftStickX The x component of the left joystick
  99996. * @param leftStickY The y component of the left joystick
  99997. * @param rightStickX The x component of the right joystick
  99998. * @param rightStickY The y component of the right joystick
  99999. */
  100000. constructor(
  100001. /**
  100002. * The id of the gamepad
  100003. */
  100004. id: string,
  100005. /**
  100006. * The index of the gamepad
  100007. */
  100008. index: number,
  100009. /**
  100010. * The browser gamepad
  100011. */
  100012. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  100013. /**
  100014. * Callback triggered when the left joystick has changed
  100015. * @param callback
  100016. */
  100017. onleftstickchanged(callback: (values: StickValues) => void): void;
  100018. /**
  100019. * Callback triggered when the right joystick has changed
  100020. * @param callback
  100021. */
  100022. onrightstickchanged(callback: (values: StickValues) => void): void;
  100023. /**
  100024. * Gets the left joystick
  100025. */
  100026. get leftStick(): StickValues;
  100027. /**
  100028. * Sets the left joystick values
  100029. */
  100030. set leftStick(newValues: StickValues);
  100031. /**
  100032. * Gets the right joystick
  100033. */
  100034. get rightStick(): StickValues;
  100035. /**
  100036. * Sets the right joystick value
  100037. */
  100038. set rightStick(newValues: StickValues);
  100039. /**
  100040. * Updates the gamepad joystick positions
  100041. */
  100042. update(): void;
  100043. /**
  100044. * Disposes the gamepad
  100045. */
  100046. dispose(): void;
  100047. }
  100048. /**
  100049. * Represents a generic gamepad
  100050. */
  100051. export class GenericPad extends Gamepad {
  100052. private _buttons;
  100053. private _onbuttondown;
  100054. private _onbuttonup;
  100055. /**
  100056. * Observable triggered when a button has been pressed
  100057. */
  100058. onButtonDownObservable: Observable<number>;
  100059. /**
  100060. * Observable triggered when a button has been released
  100061. */
  100062. onButtonUpObservable: Observable<number>;
  100063. /**
  100064. * Callback triggered when a button has been pressed
  100065. * @param callback Called when a button has been pressed
  100066. */
  100067. onbuttondown(callback: (buttonPressed: number) => void): void;
  100068. /**
  100069. * Callback triggered when a button has been released
  100070. * @param callback Called when a button has been released
  100071. */
  100072. onbuttonup(callback: (buttonReleased: number) => void): void;
  100073. /**
  100074. * Initializes the generic gamepad
  100075. * @param id The id of the generic gamepad
  100076. * @param index The index of the generic gamepad
  100077. * @param browserGamepad The browser gamepad
  100078. */
  100079. constructor(id: string, index: number, browserGamepad: any);
  100080. private _setButtonValue;
  100081. /**
  100082. * Updates the generic gamepad
  100083. */
  100084. update(): void;
  100085. /**
  100086. * Disposes the generic gamepad
  100087. */
  100088. dispose(): void;
  100089. }
  100090. }
  100091. declare module BABYLON {
  100092. /**
  100093. * Defines the types of pose enabled controllers that are supported
  100094. */
  100095. export enum PoseEnabledControllerType {
  100096. /**
  100097. * HTC Vive
  100098. */
  100099. VIVE = 0,
  100100. /**
  100101. * Oculus Rift
  100102. */
  100103. OCULUS = 1,
  100104. /**
  100105. * Windows mixed reality
  100106. */
  100107. WINDOWS = 2,
  100108. /**
  100109. * Samsung gear VR
  100110. */
  100111. GEAR_VR = 3,
  100112. /**
  100113. * Google Daydream
  100114. */
  100115. DAYDREAM = 4,
  100116. /**
  100117. * Generic
  100118. */
  100119. GENERIC = 5
  100120. }
  100121. /**
  100122. * Defines the MutableGamepadButton interface for the state of a gamepad button
  100123. */
  100124. export interface MutableGamepadButton {
  100125. /**
  100126. * Value of the button/trigger
  100127. */
  100128. value: number;
  100129. /**
  100130. * If the button/trigger is currently touched
  100131. */
  100132. touched: boolean;
  100133. /**
  100134. * If the button/trigger is currently pressed
  100135. */
  100136. pressed: boolean;
  100137. }
  100138. /**
  100139. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  100140. * @hidden
  100141. */
  100142. export interface ExtendedGamepadButton extends GamepadButton {
  100143. /**
  100144. * If the button/trigger is currently pressed
  100145. */
  100146. readonly pressed: boolean;
  100147. /**
  100148. * If the button/trigger is currently touched
  100149. */
  100150. readonly touched: boolean;
  100151. /**
  100152. * Value of the button/trigger
  100153. */
  100154. readonly value: number;
  100155. }
  100156. /** @hidden */
  100157. export interface _GamePadFactory {
  100158. /**
  100159. * Returns whether or not the current gamepad can be created for this type of controller.
  100160. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100161. * @returns true if it can be created, otherwise false
  100162. */
  100163. canCreate(gamepadInfo: any): boolean;
  100164. /**
  100165. * Creates a new instance of the Gamepad.
  100166. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100167. * @returns the new gamepad instance
  100168. */
  100169. create(gamepadInfo: any): Gamepad;
  100170. }
  100171. /**
  100172. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100173. */
  100174. export class PoseEnabledControllerHelper {
  100175. /** @hidden */
  100176. static _ControllerFactories: _GamePadFactory[];
  100177. /** @hidden */
  100178. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  100179. /**
  100180. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100181. * @param vrGamepad the gamepad to initialized
  100182. * @returns a vr controller of the type the gamepad identified as
  100183. */
  100184. static InitiateController(vrGamepad: any): Gamepad;
  100185. }
  100186. /**
  100187. * Defines the PoseEnabledController object that contains state of a vr capable controller
  100188. */
  100189. export class PoseEnabledController extends Gamepad implements PoseControlled {
  100190. /**
  100191. * If the controller is used in a webXR session
  100192. */
  100193. isXR: boolean;
  100194. private _deviceRoomPosition;
  100195. private _deviceRoomRotationQuaternion;
  100196. /**
  100197. * The device position in babylon space
  100198. */
  100199. devicePosition: Vector3;
  100200. /**
  100201. * The device rotation in babylon space
  100202. */
  100203. deviceRotationQuaternion: Quaternion;
  100204. /**
  100205. * The scale factor of the device in babylon space
  100206. */
  100207. deviceScaleFactor: number;
  100208. /**
  100209. * (Likely devicePosition should be used instead) The device position in its room space
  100210. */
  100211. position: Vector3;
  100212. /**
  100213. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  100214. */
  100215. rotationQuaternion: Quaternion;
  100216. /**
  100217. * The type of controller (Eg. Windows mixed reality)
  100218. */
  100219. controllerType: PoseEnabledControllerType;
  100220. protected _calculatedPosition: Vector3;
  100221. private _calculatedRotation;
  100222. /**
  100223. * The raw pose from the device
  100224. */
  100225. rawPose: DevicePose;
  100226. private _trackPosition;
  100227. private _maxRotationDistFromHeadset;
  100228. private _draggedRoomRotation;
  100229. /**
  100230. * @hidden
  100231. */
  100232. _disableTrackPosition(fixedPosition: Vector3): void;
  100233. /**
  100234. * Internal, the mesh attached to the controller
  100235. * @hidden
  100236. */
  100237. _mesh: Nullable<AbstractMesh>;
  100238. private _poseControlledCamera;
  100239. private _leftHandSystemQuaternion;
  100240. /**
  100241. * Internal, matrix used to convert room space to babylon space
  100242. * @hidden
  100243. */
  100244. _deviceToWorld: Matrix;
  100245. /**
  100246. * Node to be used when casting a ray from the controller
  100247. * @hidden
  100248. */
  100249. _pointingPoseNode: Nullable<TransformNode>;
  100250. /**
  100251. * Name of the child mesh that can be used to cast a ray from the controller
  100252. */
  100253. static readonly POINTING_POSE: string;
  100254. /**
  100255. * Creates a new PoseEnabledController from a gamepad
  100256. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  100257. */
  100258. constructor(browserGamepad: any);
  100259. private _workingMatrix;
  100260. /**
  100261. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  100262. */
  100263. update(): void;
  100264. /**
  100265. * Updates only the pose device and mesh without doing any button event checking
  100266. */
  100267. protected _updatePoseAndMesh(): void;
  100268. /**
  100269. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  100270. * @param poseData raw pose fromthe device
  100271. */
  100272. updateFromDevice(poseData: DevicePose): void;
  100273. /**
  100274. * @hidden
  100275. */
  100276. _meshAttachedObservable: Observable<AbstractMesh>;
  100277. /**
  100278. * Attaches a mesh to the controller
  100279. * @param mesh the mesh to be attached
  100280. */
  100281. attachToMesh(mesh: AbstractMesh): void;
  100282. /**
  100283. * Attaches the controllers mesh to a camera
  100284. * @param camera the camera the mesh should be attached to
  100285. */
  100286. attachToPoseControlledCamera(camera: TargetCamera): void;
  100287. /**
  100288. * Disposes of the controller
  100289. */
  100290. dispose(): void;
  100291. /**
  100292. * The mesh that is attached to the controller
  100293. */
  100294. get mesh(): Nullable<AbstractMesh>;
  100295. /**
  100296. * Gets the ray of the controller in the direction the controller is pointing
  100297. * @param length the length the resulting ray should be
  100298. * @returns a ray in the direction the controller is pointing
  100299. */
  100300. getForwardRay(length?: number): Ray;
  100301. }
  100302. }
  100303. declare module BABYLON {
  100304. /**
  100305. * Defines the WebVRController object that represents controllers tracked in 3D space
  100306. */
  100307. export abstract class WebVRController extends PoseEnabledController {
  100308. /**
  100309. * Internal, the default controller model for the controller
  100310. */
  100311. protected _defaultModel: Nullable<AbstractMesh>;
  100312. /**
  100313. * Fired when the trigger state has changed
  100314. */
  100315. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100316. /**
  100317. * Fired when the main button state has changed
  100318. */
  100319. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100320. /**
  100321. * Fired when the secondary button state has changed
  100322. */
  100323. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100324. /**
  100325. * Fired when the pad state has changed
  100326. */
  100327. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  100328. /**
  100329. * Fired when controllers stick values have changed
  100330. */
  100331. onPadValuesChangedObservable: Observable<StickValues>;
  100332. /**
  100333. * Array of button availible on the controller
  100334. */
  100335. protected _buttons: Array<MutableGamepadButton>;
  100336. private _onButtonStateChange;
  100337. /**
  100338. * Fired when a controller button's state has changed
  100339. * @param callback the callback containing the button that was modified
  100340. */
  100341. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  100342. /**
  100343. * X and Y axis corresponding to the controllers joystick
  100344. */
  100345. pad: StickValues;
  100346. /**
  100347. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  100348. */
  100349. hand: string;
  100350. /**
  100351. * The default controller model for the controller
  100352. */
  100353. get defaultModel(): Nullable<AbstractMesh>;
  100354. /**
  100355. * Creates a new WebVRController from a gamepad
  100356. * @param vrGamepad the gamepad that the WebVRController should be created from
  100357. */
  100358. constructor(vrGamepad: any);
  100359. /**
  100360. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  100361. */
  100362. update(): void;
  100363. /**
  100364. * Function to be called when a button is modified
  100365. */
  100366. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100367. /**
  100368. * Loads a mesh and attaches it to the controller
  100369. * @param scene the scene the mesh should be added to
  100370. * @param meshLoaded callback for when the mesh has been loaded
  100371. */
  100372. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100373. private _setButtonValue;
  100374. private _changes;
  100375. private _checkChanges;
  100376. /**
  100377. * Disposes of th webVRCOntroller
  100378. */
  100379. dispose(): void;
  100380. }
  100381. }
  100382. declare module BABYLON {
  100383. /**
  100384. * The HemisphericLight simulates the ambient environment light,
  100385. * so the passed direction is the light reflection direction, not the incoming direction.
  100386. */
  100387. export class HemisphericLight extends Light {
  100388. /**
  100389. * The groundColor is the light in the opposite direction to the one specified during creation.
  100390. * 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.
  100391. */
  100392. groundColor: Color3;
  100393. /**
  100394. * The light reflection direction, not the incoming direction.
  100395. */
  100396. direction: Vector3;
  100397. /**
  100398. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  100399. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  100400. * The HemisphericLight can't cast shadows.
  100401. * Documentation : https://doc.babylonjs.com/babylon101/lights
  100402. * @param name The friendly name of the light
  100403. * @param direction The direction of the light reflection
  100404. * @param scene The scene the light belongs to
  100405. */
  100406. constructor(name: string, direction: Vector3, scene: Scene);
  100407. protected _buildUniformLayout(): void;
  100408. /**
  100409. * Returns the string "HemisphericLight".
  100410. * @return The class name
  100411. */
  100412. getClassName(): string;
  100413. /**
  100414. * Sets the HemisphericLight direction towards the passed target (Vector3).
  100415. * Returns the updated direction.
  100416. * @param target The target the direction should point to
  100417. * @return The computed direction
  100418. */
  100419. setDirectionToTarget(target: Vector3): Vector3;
  100420. /**
  100421. * Returns the shadow generator associated to the light.
  100422. * @returns Always null for hemispheric lights because it does not support shadows.
  100423. */
  100424. getShadowGenerator(): Nullable<IShadowGenerator>;
  100425. /**
  100426. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  100427. * @param effect The effect to update
  100428. * @param lightIndex The index of the light in the effect to update
  100429. * @returns The hemispheric light
  100430. */
  100431. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  100432. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  100433. /**
  100434. * Computes the world matrix of the node
  100435. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100436. * @param useWasUpdatedFlag defines a reserved property
  100437. * @returns the world matrix
  100438. */
  100439. computeWorldMatrix(): Matrix;
  100440. /**
  100441. * Returns the integer 3.
  100442. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  100443. */
  100444. getTypeID(): number;
  100445. /**
  100446. * Prepares the list of defines specific to the light type.
  100447. * @param defines the list of defines
  100448. * @param lightIndex defines the index of the light for the effect
  100449. */
  100450. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  100451. }
  100452. }
  100453. declare module BABYLON {
  100454. /** @hidden */
  100455. export var vrMultiviewToSingleviewPixelShader: {
  100456. name: string;
  100457. shader: string;
  100458. };
  100459. }
  100460. declare module BABYLON {
  100461. /**
  100462. * Renders to multiple views with a single draw call
  100463. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100464. */
  100465. export class MultiviewRenderTarget extends RenderTargetTexture {
  100466. /**
  100467. * Creates a multiview render target
  100468. * @param scene scene used with the render target
  100469. * @param size the size of the render target (used for each view)
  100470. */
  100471. constructor(scene: Scene, size?: number | {
  100472. width: number;
  100473. height: number;
  100474. } | {
  100475. ratio: number;
  100476. });
  100477. /**
  100478. * @hidden
  100479. * @param faceIndex the face index, if its a cube texture
  100480. */
  100481. _bindFrameBuffer(faceIndex?: number): void;
  100482. /**
  100483. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100484. * @returns the view count
  100485. */
  100486. getViewCount(): number;
  100487. }
  100488. }
  100489. declare module BABYLON {
  100490. interface Engine {
  100491. /**
  100492. * Creates a new multiview render target
  100493. * @param width defines the width of the texture
  100494. * @param height defines the height of the texture
  100495. * @returns the created multiview texture
  100496. */
  100497. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100498. /**
  100499. * Binds a multiview framebuffer to be drawn to
  100500. * @param multiviewTexture texture to bind
  100501. */
  100502. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100503. }
  100504. interface Camera {
  100505. /**
  100506. * @hidden
  100507. * 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)
  100508. */
  100509. _useMultiviewToSingleView: boolean;
  100510. /**
  100511. * @hidden
  100512. * 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)
  100513. */
  100514. _multiviewTexture: Nullable<RenderTargetTexture>;
  100515. /**
  100516. * @hidden
  100517. * ensures the multiview texture of the camera exists and has the specified width/height
  100518. * @param width height to set on the multiview texture
  100519. * @param height width to set on the multiview texture
  100520. */
  100521. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100522. }
  100523. interface Scene {
  100524. /** @hidden */
  100525. _transformMatrixR: Matrix;
  100526. /** @hidden */
  100527. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100528. /** @hidden */
  100529. _createMultiviewUbo(): void;
  100530. /** @hidden */
  100531. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100532. /** @hidden */
  100533. _renderMultiviewToSingleView(camera: Camera): void;
  100534. }
  100535. }
  100536. declare module BABYLON {
  100537. /**
  100538. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100539. * This will not be used for webXR as it supports displaying texture arrays directly
  100540. */
  100541. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100542. /**
  100543. * Gets a string identifying the name of the class
  100544. * @returns "VRMultiviewToSingleviewPostProcess" string
  100545. */
  100546. getClassName(): string;
  100547. /**
  100548. * Initializes a VRMultiviewToSingleview
  100549. * @param name name of the post process
  100550. * @param camera camera to be applied to
  100551. * @param scaleFactor scaling factor to the size of the output texture
  100552. */
  100553. constructor(name: string, camera: Camera, scaleFactor: number);
  100554. }
  100555. }
  100556. declare module BABYLON {
  100557. /**
  100558. * Interface used to define additional presentation attributes
  100559. */
  100560. export interface IVRPresentationAttributes {
  100561. /**
  100562. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100563. */
  100564. highRefreshRate: boolean;
  100565. /**
  100566. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100567. */
  100568. foveationLevel: number;
  100569. }
  100570. interface Engine {
  100571. /** @hidden */
  100572. _vrDisplay: any;
  100573. /** @hidden */
  100574. _vrSupported: boolean;
  100575. /** @hidden */
  100576. _oldSize: Size;
  100577. /** @hidden */
  100578. _oldHardwareScaleFactor: number;
  100579. /** @hidden */
  100580. _vrExclusivePointerMode: boolean;
  100581. /** @hidden */
  100582. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100583. /** @hidden */
  100584. _onVRDisplayPointerRestricted: () => void;
  100585. /** @hidden */
  100586. _onVRDisplayPointerUnrestricted: () => void;
  100587. /** @hidden */
  100588. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100589. /** @hidden */
  100590. _onVrDisplayDisconnect: Nullable<() => void>;
  100591. /** @hidden */
  100592. _onVrDisplayPresentChange: Nullable<() => void>;
  100593. /**
  100594. * Observable signaled when VR display mode changes
  100595. */
  100596. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100597. /**
  100598. * Observable signaled when VR request present is complete
  100599. */
  100600. onVRRequestPresentComplete: Observable<boolean>;
  100601. /**
  100602. * Observable signaled when VR request present starts
  100603. */
  100604. onVRRequestPresentStart: Observable<Engine>;
  100605. /**
  100606. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100607. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100608. */
  100609. isInVRExclusivePointerMode: boolean;
  100610. /**
  100611. * Gets a boolean indicating if a webVR device was detected
  100612. * @returns true if a webVR device was detected
  100613. */
  100614. isVRDevicePresent(): boolean;
  100615. /**
  100616. * Gets the current webVR device
  100617. * @returns the current webVR device (or null)
  100618. */
  100619. getVRDevice(): any;
  100620. /**
  100621. * Initializes a webVR display and starts listening to display change events
  100622. * The onVRDisplayChangedObservable will be notified upon these changes
  100623. * @returns A promise containing a VRDisplay and if vr is supported
  100624. */
  100625. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100626. /** @hidden */
  100627. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100628. /**
  100629. * Gets or sets the presentation attributes used to configure VR rendering
  100630. */
  100631. vrPresentationAttributes?: IVRPresentationAttributes;
  100632. /**
  100633. * Call this function to switch to webVR mode
  100634. * Will do nothing if webVR is not supported or if there is no webVR device
  100635. * @param options the webvr options provided to the camera. mainly used for multiview
  100636. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100637. */
  100638. enableVR(options: WebVROptions): void;
  100639. /** @hidden */
  100640. _onVRFullScreenTriggered(): void;
  100641. }
  100642. }
  100643. declare module BABYLON {
  100644. /**
  100645. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100646. * IMPORTANT!! The data is right-hand data.
  100647. * @export
  100648. * @interface DevicePose
  100649. */
  100650. export interface DevicePose {
  100651. /**
  100652. * The position of the device, values in array are [x,y,z].
  100653. */
  100654. readonly position: Nullable<Float32Array>;
  100655. /**
  100656. * The linearVelocity of the device, values in array are [x,y,z].
  100657. */
  100658. readonly linearVelocity: Nullable<Float32Array>;
  100659. /**
  100660. * The linearAcceleration of the device, values in array are [x,y,z].
  100661. */
  100662. readonly linearAcceleration: Nullable<Float32Array>;
  100663. /**
  100664. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100665. */
  100666. readonly orientation: Nullable<Float32Array>;
  100667. /**
  100668. * The angularVelocity of the device, values in array are [x,y,z].
  100669. */
  100670. readonly angularVelocity: Nullable<Float32Array>;
  100671. /**
  100672. * The angularAcceleration of the device, values in array are [x,y,z].
  100673. */
  100674. readonly angularAcceleration: Nullable<Float32Array>;
  100675. }
  100676. /**
  100677. * Interface representing a pose controlled object in Babylon.
  100678. * A pose controlled object has both regular pose values as well as pose values
  100679. * from an external device such as a VR head mounted display
  100680. */
  100681. export interface PoseControlled {
  100682. /**
  100683. * The position of the object in babylon space.
  100684. */
  100685. position: Vector3;
  100686. /**
  100687. * The rotation quaternion of the object in babylon space.
  100688. */
  100689. rotationQuaternion: Quaternion;
  100690. /**
  100691. * The position of the device in babylon space.
  100692. */
  100693. devicePosition?: Vector3;
  100694. /**
  100695. * The rotation quaternion of the device in babylon space.
  100696. */
  100697. deviceRotationQuaternion: Quaternion;
  100698. /**
  100699. * The raw pose coming from the device.
  100700. */
  100701. rawPose: Nullable<DevicePose>;
  100702. /**
  100703. * The scale of the device to be used when translating from device space to babylon space.
  100704. */
  100705. deviceScaleFactor: number;
  100706. /**
  100707. * Updates the poseControlled values based on the input device pose.
  100708. * @param poseData the pose data to update the object with
  100709. */
  100710. updateFromDevice(poseData: DevicePose): void;
  100711. }
  100712. /**
  100713. * Set of options to customize the webVRCamera
  100714. */
  100715. export interface WebVROptions {
  100716. /**
  100717. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100718. */
  100719. trackPosition?: boolean;
  100720. /**
  100721. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100722. */
  100723. positionScale?: number;
  100724. /**
  100725. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100726. */
  100727. displayName?: string;
  100728. /**
  100729. * Should the native controller meshes be initialized. (default: true)
  100730. */
  100731. controllerMeshes?: boolean;
  100732. /**
  100733. * Creating a default HemiLight only on controllers. (default: true)
  100734. */
  100735. defaultLightingOnControllers?: boolean;
  100736. /**
  100737. * If you don't want to use the default VR button of the helper. (default: false)
  100738. */
  100739. useCustomVRButton?: boolean;
  100740. /**
  100741. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100742. */
  100743. customVRButton?: HTMLButtonElement;
  100744. /**
  100745. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100746. */
  100747. rayLength?: number;
  100748. /**
  100749. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100750. */
  100751. defaultHeight?: number;
  100752. /**
  100753. * If multiview should be used if availible (default: false)
  100754. */
  100755. useMultiview?: boolean;
  100756. }
  100757. /**
  100758. * This represents a WebVR camera.
  100759. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100760. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100761. */
  100762. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100763. private webVROptions;
  100764. /**
  100765. * @hidden
  100766. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100767. */
  100768. _vrDevice: any;
  100769. /**
  100770. * The rawPose of the vrDevice.
  100771. */
  100772. rawPose: Nullable<DevicePose>;
  100773. private _onVREnabled;
  100774. private _specsVersion;
  100775. private _attached;
  100776. private _frameData;
  100777. protected _descendants: Array<Node>;
  100778. private _deviceRoomPosition;
  100779. /** @hidden */
  100780. _deviceRoomRotationQuaternion: Quaternion;
  100781. private _standingMatrix;
  100782. /**
  100783. * Represents device position in babylon space.
  100784. */
  100785. devicePosition: Vector3;
  100786. /**
  100787. * Represents device rotation in babylon space.
  100788. */
  100789. deviceRotationQuaternion: Quaternion;
  100790. /**
  100791. * The scale of the device to be used when translating from device space to babylon space.
  100792. */
  100793. deviceScaleFactor: number;
  100794. private _deviceToWorld;
  100795. private _worldToDevice;
  100796. /**
  100797. * References to the webVR controllers for the vrDevice.
  100798. */
  100799. controllers: Array<WebVRController>;
  100800. /**
  100801. * Emits an event when a controller is attached.
  100802. */
  100803. onControllersAttachedObservable: Observable<WebVRController[]>;
  100804. /**
  100805. * Emits an event when a controller's mesh has been loaded;
  100806. */
  100807. onControllerMeshLoadedObservable: Observable<WebVRController>;
  100808. /**
  100809. * Emits an event when the HMD's pose has been updated.
  100810. */
  100811. onPoseUpdatedFromDeviceObservable: Observable<any>;
  100812. private _poseSet;
  100813. /**
  100814. * If the rig cameras be used as parent instead of this camera.
  100815. */
  100816. rigParenting: boolean;
  100817. private _lightOnControllers;
  100818. private _defaultHeight?;
  100819. /**
  100820. * Instantiates a WebVRFreeCamera.
  100821. * @param name The name of the WebVRFreeCamera
  100822. * @param position The starting anchor position for the camera
  100823. * @param scene The scene the camera belongs to
  100824. * @param webVROptions a set of customizable options for the webVRCamera
  100825. */
  100826. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  100827. /**
  100828. * Gets the device distance from the ground in meters.
  100829. * @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.
  100830. */
  100831. deviceDistanceToRoomGround(): number;
  100832. /**
  100833. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100834. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  100835. */
  100836. useStandingMatrix(callback?: (bool: boolean) => void): void;
  100837. /**
  100838. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100839. * @returns A promise with a boolean set to if the standing matrix is supported.
  100840. */
  100841. useStandingMatrixAsync(): Promise<boolean>;
  100842. /**
  100843. * Disposes the camera
  100844. */
  100845. dispose(): void;
  100846. /**
  100847. * Gets a vrController by name.
  100848. * @param name The name of the controller to retreive
  100849. * @returns the controller matching the name specified or null if not found
  100850. */
  100851. getControllerByName(name: string): Nullable<WebVRController>;
  100852. private _leftController;
  100853. /**
  100854. * The controller corresponding to the users left hand.
  100855. */
  100856. get leftController(): Nullable<WebVRController>;
  100857. private _rightController;
  100858. /**
  100859. * The controller corresponding to the users right hand.
  100860. */
  100861. get rightController(): Nullable<WebVRController>;
  100862. /**
  100863. * Casts a ray forward from the vrCamera's gaze.
  100864. * @param length Length of the ray (default: 100)
  100865. * @returns the ray corresponding to the gaze
  100866. */
  100867. getForwardRay(length?: number): Ray;
  100868. /**
  100869. * @hidden
  100870. * Updates the camera based on device's frame data
  100871. */
  100872. _checkInputs(): void;
  100873. /**
  100874. * Updates the poseControlled values based on the input device pose.
  100875. * @param poseData Pose coming from the device
  100876. */
  100877. updateFromDevice(poseData: DevicePose): void;
  100878. private _htmlElementAttached;
  100879. private _detachIfAttached;
  100880. /**
  100881. * WebVR's attach control will start broadcasting frames to the device.
  100882. * Note that in certain browsers (chrome for example) this function must be called
  100883. * within a user-interaction callback. Example:
  100884. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100885. *
  100886. * @param element html element to attach the vrDevice to
  100887. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100888. */
  100889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100890. /**
  100891. * Detaches the camera from the html element and disables VR
  100892. *
  100893. * @param element html element to detach from
  100894. */
  100895. detachControl(element: HTMLElement): void;
  100896. /**
  100897. * @returns the name of this class
  100898. */
  100899. getClassName(): string;
  100900. /**
  100901. * Calls resetPose on the vrDisplay
  100902. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100903. */
  100904. resetToCurrentRotation(): void;
  100905. /**
  100906. * @hidden
  100907. * Updates the rig cameras (left and right eye)
  100908. */
  100909. _updateRigCameras(): void;
  100910. private _workingVector;
  100911. private _oneVector;
  100912. private _workingMatrix;
  100913. private updateCacheCalled;
  100914. private _correctPositionIfNotTrackPosition;
  100915. /**
  100916. * @hidden
  100917. * Updates the cached values of the camera
  100918. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  100919. */
  100920. _updateCache(ignoreParentClass?: boolean): void;
  100921. /**
  100922. * @hidden
  100923. * Get current device position in babylon world
  100924. */
  100925. _computeDevicePosition(): void;
  100926. /**
  100927. * Updates the current device position and rotation in the babylon world
  100928. */
  100929. update(): void;
  100930. /**
  100931. * @hidden
  100932. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  100933. * @returns an identity matrix
  100934. */
  100935. _getViewMatrix(): Matrix;
  100936. private _tmpMatrix;
  100937. /**
  100938. * This function is called by the two RIG cameras.
  100939. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  100940. * @hidden
  100941. */
  100942. _getWebVRViewMatrix(): Matrix;
  100943. /** @hidden */
  100944. _getWebVRProjectionMatrix(): Matrix;
  100945. private _onGamepadConnectedObserver;
  100946. private _onGamepadDisconnectedObserver;
  100947. private _updateCacheWhenTrackingDisabledObserver;
  100948. /**
  100949. * Initializes the controllers and their meshes
  100950. */
  100951. initControllers(): void;
  100952. }
  100953. }
  100954. declare module BABYLON {
  100955. /**
  100956. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  100957. *
  100958. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  100959. *
  100960. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100961. */
  100962. export class MaterialHelper {
  100963. /**
  100964. * Bind the current view position to an effect.
  100965. * @param effect The effect to be bound
  100966. * @param scene The scene the eyes position is used from
  100967. * @param variableName name of the shader variable that will hold the eye position
  100968. */
  100969. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  100970. /**
  100971. * Helps preparing the defines values about the UVs in used in the effect.
  100972. * UVs are shared as much as we can accross channels in the shaders.
  100973. * @param texture The texture we are preparing the UVs for
  100974. * @param defines The defines to update
  100975. * @param key The channel key "diffuse", "specular"... used in the shader
  100976. */
  100977. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  100978. /**
  100979. * Binds a texture matrix value to its corrsponding uniform
  100980. * @param texture The texture to bind the matrix for
  100981. * @param uniformBuffer The uniform buffer receivin the data
  100982. * @param key The channel key "diffuse", "specular"... used in the shader
  100983. */
  100984. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  100985. /**
  100986. * Gets the current status of the fog (should it be enabled?)
  100987. * @param mesh defines the mesh to evaluate for fog support
  100988. * @param scene defines the hosting scene
  100989. * @returns true if fog must be enabled
  100990. */
  100991. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  100992. /**
  100993. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  100994. * @param mesh defines the current mesh
  100995. * @param scene defines the current scene
  100996. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  100997. * @param pointsCloud defines if point cloud rendering has to be turned on
  100998. * @param fogEnabled defines if fog has to be turned on
  100999. * @param alphaTest defines if alpha testing has to be turned on
  101000. * @param defines defines the current list of defines
  101001. */
  101002. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  101003. /**
  101004. * Helper used to prepare the list of defines associated with frame values for shader compilation
  101005. * @param scene defines the current scene
  101006. * @param engine defines the current engine
  101007. * @param defines specifies the list of active defines
  101008. * @param useInstances defines if instances have to be turned on
  101009. * @param useClipPlane defines if clip plane have to be turned on
  101010. * @param useInstances defines if instances have to be turned on
  101011. * @param useThinInstances defines if thin instances have to be turned on
  101012. */
  101013. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  101014. /**
  101015. * Prepares the defines for bones
  101016. * @param mesh The mesh containing the geometry data we will draw
  101017. * @param defines The defines to update
  101018. */
  101019. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  101020. /**
  101021. * Prepares the defines for morph targets
  101022. * @param mesh The mesh containing the geometry data we will draw
  101023. * @param defines The defines to update
  101024. */
  101025. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  101026. /**
  101027. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  101028. * @param mesh The mesh containing the geometry data we will draw
  101029. * @param defines The defines to update
  101030. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  101031. * @param useBones Precise whether bones should be used or not (override mesh info)
  101032. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  101033. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  101034. * @returns false if defines are considered not dirty and have not been checked
  101035. */
  101036. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  101037. /**
  101038. * Prepares the defines related to multiview
  101039. * @param scene The scene we are intending to draw
  101040. * @param defines The defines to update
  101041. */
  101042. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  101043. /**
  101044. * Prepares the defines related to the prepass
  101045. * @param scene The scene we are intending to draw
  101046. * @param defines The defines to update
  101047. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  101048. */
  101049. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  101050. /**
  101051. * Prepares the defines related to the light information passed in parameter
  101052. * @param scene The scene we are intending to draw
  101053. * @param mesh The mesh the effect is compiling for
  101054. * @param light The light the effect is compiling for
  101055. * @param lightIndex The index of the light
  101056. * @param defines The defines to update
  101057. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101058. * @param state Defines the current state regarding what is needed (normals, etc...)
  101059. */
  101060. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  101061. needNormals: boolean;
  101062. needRebuild: boolean;
  101063. shadowEnabled: boolean;
  101064. specularEnabled: boolean;
  101065. lightmapMode: boolean;
  101066. }): void;
  101067. /**
  101068. * Prepares the defines related to the light information passed in parameter
  101069. * @param scene The scene we are intending to draw
  101070. * @param mesh The mesh the effect is compiling for
  101071. * @param defines The defines to update
  101072. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101073. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  101074. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  101075. * @returns true if normals will be required for the rest of the effect
  101076. */
  101077. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  101078. /**
  101079. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  101080. * @param lightIndex defines the light index
  101081. * @param uniformsList The uniform list
  101082. * @param samplersList The sampler list
  101083. * @param projectedLightTexture defines if projected texture must be used
  101084. * @param uniformBuffersList defines an optional list of uniform buffers
  101085. */
  101086. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  101087. /**
  101088. * Prepares the uniforms and samplers list to be used in the effect
  101089. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  101090. * @param samplersList The sampler list
  101091. * @param defines The defines helping in the list generation
  101092. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  101093. */
  101094. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  101095. /**
  101096. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  101097. * @param defines The defines to update while falling back
  101098. * @param fallbacks The authorized effect fallbacks
  101099. * @param maxSimultaneousLights The maximum number of lights allowed
  101100. * @param rank the current rank of the Effect
  101101. * @returns The newly affected rank
  101102. */
  101103. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  101104. private static _TmpMorphInfluencers;
  101105. /**
  101106. * Prepares the list of attributes required for morph targets according to the effect defines.
  101107. * @param attribs The current list of supported attribs
  101108. * @param mesh The mesh to prepare the morph targets attributes for
  101109. * @param influencers The number of influencers
  101110. */
  101111. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  101112. /**
  101113. * Prepares the list of attributes required for morph targets according to the effect defines.
  101114. * @param attribs The current list of supported attribs
  101115. * @param mesh The mesh to prepare the morph targets attributes for
  101116. * @param defines The current Defines of the effect
  101117. */
  101118. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  101119. /**
  101120. * Prepares the list of attributes required for bones according to the effect defines.
  101121. * @param attribs The current list of supported attribs
  101122. * @param mesh The mesh to prepare the bones attributes for
  101123. * @param defines The current Defines of the effect
  101124. * @param fallbacks The current efffect fallback strategy
  101125. */
  101126. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  101127. /**
  101128. * Check and prepare the list of attributes required for instances according to the effect defines.
  101129. * @param attribs The current list of supported attribs
  101130. * @param defines The current MaterialDefines of the effect
  101131. */
  101132. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  101133. /**
  101134. * Add the list of attributes required for instances to the attribs array.
  101135. * @param attribs The current list of supported attribs
  101136. */
  101137. static PushAttributesForInstances(attribs: string[]): void;
  101138. /**
  101139. * Binds the light information to the effect.
  101140. * @param light The light containing the generator
  101141. * @param effect The effect we are binding the data to
  101142. * @param lightIndex The light index in the effect used to render
  101143. */
  101144. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  101145. /**
  101146. * Binds the lights information from the scene to the effect for the given mesh.
  101147. * @param light Light to bind
  101148. * @param lightIndex Light index
  101149. * @param scene The scene where the light belongs to
  101150. * @param effect The effect we are binding the data to
  101151. * @param useSpecular Defines if specular is supported
  101152. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101153. */
  101154. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  101155. /**
  101156. * Binds the lights information from the scene to the effect for the given mesh.
  101157. * @param scene The scene the lights belongs to
  101158. * @param mesh The mesh we are binding the information to render
  101159. * @param effect The effect we are binding the data to
  101160. * @param defines The generated defines for the effect
  101161. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  101162. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101163. */
  101164. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  101165. private static _tempFogColor;
  101166. /**
  101167. * Binds the fog information from the scene to the effect for the given mesh.
  101168. * @param scene The scene the lights belongs to
  101169. * @param mesh The mesh we are binding the information to render
  101170. * @param effect The effect we are binding the data to
  101171. * @param linearSpace Defines if the fog effect is applied in linear space
  101172. */
  101173. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  101174. /**
  101175. * Binds the bones information from the mesh to the effect.
  101176. * @param mesh The mesh we are binding the information to render
  101177. * @param effect The effect we are binding the data to
  101178. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  101179. */
  101180. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  101181. private static _CopyBonesTransformationMatrices;
  101182. /**
  101183. * Binds the morph targets information from the mesh to the effect.
  101184. * @param abstractMesh The mesh we are binding the information to render
  101185. * @param effect The effect we are binding the data to
  101186. */
  101187. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  101188. /**
  101189. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  101190. * @param defines The generated defines used in the effect
  101191. * @param effect The effect we are binding the data to
  101192. * @param scene The scene we are willing to render with logarithmic scale for
  101193. */
  101194. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  101195. /**
  101196. * Binds the clip plane information from the scene to the effect.
  101197. * @param scene The scene the clip plane information are extracted from
  101198. * @param effect The effect we are binding the data to
  101199. */
  101200. static BindClipPlane(effect: Effect, scene: Scene): void;
  101201. }
  101202. }
  101203. declare module BABYLON {
  101204. /**
  101205. * Block used to expose an input value
  101206. */
  101207. export class InputBlock extends NodeMaterialBlock {
  101208. private _mode;
  101209. private _associatedVariableName;
  101210. private _storedValue;
  101211. private _valueCallback;
  101212. private _type;
  101213. private _animationType;
  101214. /** Gets or set a value used to limit the range of float values */
  101215. min: number;
  101216. /** Gets or set a value used to limit the range of float values */
  101217. max: number;
  101218. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  101219. isBoolean: boolean;
  101220. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  101221. matrixMode: number;
  101222. /** @hidden */
  101223. _systemValue: Nullable<NodeMaterialSystemValues>;
  101224. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  101225. isConstant: boolean;
  101226. /** Gets or sets the group to use to display this block in the Inspector */
  101227. groupInInspector: string;
  101228. /** Gets an observable raised when the value is changed */
  101229. onValueChangedObservable: Observable<InputBlock>;
  101230. /**
  101231. * Gets or sets the connection point type (default is float)
  101232. */
  101233. get type(): NodeMaterialBlockConnectionPointTypes;
  101234. /**
  101235. * Creates a new InputBlock
  101236. * @param name defines the block name
  101237. * @param target defines the target of that block (Vertex by default)
  101238. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  101239. */
  101240. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  101241. /**
  101242. * Validates if a name is a reserve word.
  101243. * @param newName the new name to be given to the node.
  101244. * @returns false if the name is a reserve word, else true.
  101245. */
  101246. validateBlockName(newName: string): boolean;
  101247. /**
  101248. * Gets the output component
  101249. */
  101250. get output(): NodeMaterialConnectionPoint;
  101251. /**
  101252. * Set the source of this connection point to a vertex attribute
  101253. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  101254. * @returns the current connection point
  101255. */
  101256. setAsAttribute(attributeName?: string): InputBlock;
  101257. /**
  101258. * Set the source of this connection point to a system value
  101259. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  101260. * @returns the current connection point
  101261. */
  101262. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  101263. /**
  101264. * Gets or sets the value of that point.
  101265. * Please note that this value will be ignored if valueCallback is defined
  101266. */
  101267. get value(): any;
  101268. set value(value: any);
  101269. /**
  101270. * Gets or sets a callback used to get the value of that point.
  101271. * Please note that setting this value will force the connection point to ignore the value property
  101272. */
  101273. get valueCallback(): () => any;
  101274. set valueCallback(value: () => any);
  101275. /**
  101276. * Gets or sets the associated variable name in the shader
  101277. */
  101278. get associatedVariableName(): string;
  101279. set associatedVariableName(value: string);
  101280. /** Gets or sets the type of animation applied to the input */
  101281. get animationType(): AnimatedInputBlockTypes;
  101282. set animationType(value: AnimatedInputBlockTypes);
  101283. /**
  101284. * Gets a boolean indicating that this connection point not defined yet
  101285. */
  101286. get isUndefined(): boolean;
  101287. /**
  101288. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  101289. * In this case the connection point name must be the name of the uniform to use.
  101290. * Can only be set on inputs
  101291. */
  101292. get isUniform(): boolean;
  101293. set isUniform(value: boolean);
  101294. /**
  101295. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  101296. * In this case the connection point name must be the name of the attribute to use
  101297. * Can only be set on inputs
  101298. */
  101299. get isAttribute(): boolean;
  101300. set isAttribute(value: boolean);
  101301. /**
  101302. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  101303. * Can only be set on exit points
  101304. */
  101305. get isVarying(): boolean;
  101306. set isVarying(value: boolean);
  101307. /**
  101308. * Gets a boolean indicating that the current connection point is a system value
  101309. */
  101310. get isSystemValue(): boolean;
  101311. /**
  101312. * Gets or sets the current well known value or null if not defined as a system value
  101313. */
  101314. get systemValue(): Nullable<NodeMaterialSystemValues>;
  101315. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  101316. /**
  101317. * Gets the current class name
  101318. * @returns the class name
  101319. */
  101320. getClassName(): string;
  101321. /**
  101322. * Animate the input if animationType !== None
  101323. * @param scene defines the rendering scene
  101324. */
  101325. animate(scene: Scene): void;
  101326. private _emitDefine;
  101327. initialize(state: NodeMaterialBuildState): void;
  101328. /**
  101329. * Set the input block to its default value (based on its type)
  101330. */
  101331. setDefaultValue(): void;
  101332. private _emitConstant;
  101333. /** @hidden */
  101334. get _noContextSwitch(): boolean;
  101335. private _emit;
  101336. /** @hidden */
  101337. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  101338. /** @hidden */
  101339. _transmit(effect: Effect, scene: Scene): void;
  101340. protected _buildBlock(state: NodeMaterialBuildState): void;
  101341. protected _dumpPropertiesCode(): string;
  101342. dispose(): void;
  101343. serialize(): any;
  101344. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101345. }
  101346. }
  101347. declare module BABYLON {
  101348. /**
  101349. * Enum used to define the compatibility state between two connection points
  101350. */
  101351. export enum NodeMaterialConnectionPointCompatibilityStates {
  101352. /** Points are compatibles */
  101353. Compatible = 0,
  101354. /** Points are incompatible because of their types */
  101355. TypeIncompatible = 1,
  101356. /** Points are incompatible because of their targets (vertex vs fragment) */
  101357. TargetIncompatible = 2
  101358. }
  101359. /**
  101360. * Defines the direction of a connection point
  101361. */
  101362. export enum NodeMaterialConnectionPointDirection {
  101363. /** Input */
  101364. Input = 0,
  101365. /** Output */
  101366. Output = 1
  101367. }
  101368. /**
  101369. * Defines a connection point for a block
  101370. */
  101371. export class NodeMaterialConnectionPoint {
  101372. /** @hidden */
  101373. _ownerBlock: NodeMaterialBlock;
  101374. /** @hidden */
  101375. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  101376. private _endpoints;
  101377. private _associatedVariableName;
  101378. private _direction;
  101379. /** @hidden */
  101380. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101381. /** @hidden */
  101382. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101383. private _type;
  101384. /** @hidden */
  101385. _enforceAssociatedVariableName: boolean;
  101386. /** Gets the direction of the point */
  101387. get direction(): NodeMaterialConnectionPointDirection;
  101388. /** Indicates that this connection point needs dual validation before being connected to another point */
  101389. needDualDirectionValidation: boolean;
  101390. /**
  101391. * Gets or sets the additional types supported by this connection point
  101392. */
  101393. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101394. /**
  101395. * Gets or sets the additional types excluded by this connection point
  101396. */
  101397. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101398. /**
  101399. * Observable triggered when this point is connected
  101400. */
  101401. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  101402. /**
  101403. * Gets or sets the associated variable name in the shader
  101404. */
  101405. get associatedVariableName(): string;
  101406. set associatedVariableName(value: string);
  101407. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  101408. get innerType(): NodeMaterialBlockConnectionPointTypes;
  101409. /**
  101410. * Gets or sets the connection point type (default is float)
  101411. */
  101412. get type(): NodeMaterialBlockConnectionPointTypes;
  101413. set type(value: NodeMaterialBlockConnectionPointTypes);
  101414. /**
  101415. * Gets or sets the connection point name
  101416. */
  101417. name: string;
  101418. /**
  101419. * Gets or sets the connection point name
  101420. */
  101421. displayName: string;
  101422. /**
  101423. * Gets or sets a boolean indicating that this connection point can be omitted
  101424. */
  101425. isOptional: boolean;
  101426. /**
  101427. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  101428. */
  101429. isExposedOnFrame: boolean;
  101430. /**
  101431. * Gets or sets number indicating the position that the port is exposed to on a frame
  101432. */
  101433. exposedPortPosition: number;
  101434. /**
  101435. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  101436. */
  101437. define: string;
  101438. /** @hidden */
  101439. _prioritizeVertex: boolean;
  101440. private _target;
  101441. /** Gets or sets the target of that connection point */
  101442. get target(): NodeMaterialBlockTargets;
  101443. set target(value: NodeMaterialBlockTargets);
  101444. /**
  101445. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  101446. */
  101447. get isConnected(): boolean;
  101448. /**
  101449. * Gets a boolean indicating that the current point is connected to an input block
  101450. */
  101451. get isConnectedToInputBlock(): boolean;
  101452. /**
  101453. * Gets a the connected input block (if any)
  101454. */
  101455. get connectInputBlock(): Nullable<InputBlock>;
  101456. /** Get the other side of the connection (if any) */
  101457. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  101458. /** Get the block that owns this connection point */
  101459. get ownerBlock(): NodeMaterialBlock;
  101460. /** Get the block connected on the other side of this connection (if any) */
  101461. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101462. /** Get the block connected on the endpoints of this connection (if any) */
  101463. get connectedBlocks(): Array<NodeMaterialBlock>;
  101464. /** Gets the list of connected endpoints */
  101465. get endpoints(): NodeMaterialConnectionPoint[];
  101466. /** Gets a boolean indicating if that output point is connected to at least one input */
  101467. get hasEndpoints(): boolean;
  101468. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101469. get isConnectedInVertexShader(): boolean;
  101470. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101471. get isConnectedInFragmentShader(): boolean;
  101472. /**
  101473. * Creates a block suitable to be used as an input for this input point.
  101474. * If null is returned, a block based on the point type will be created.
  101475. * @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
  101476. */
  101477. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101478. /**
  101479. * Creates a new connection point
  101480. * @param name defines the connection point name
  101481. * @param ownerBlock defines the block hosting this connection point
  101482. * @param direction defines the direction of the connection point
  101483. */
  101484. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101485. /**
  101486. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101487. * @returns the class name
  101488. */
  101489. getClassName(): string;
  101490. /**
  101491. * Gets a boolean indicating if the current point can be connected to another point
  101492. * @param connectionPoint defines the other connection point
  101493. * @returns a boolean
  101494. */
  101495. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101496. /**
  101497. * Gets a number indicating if the current point can be connected to another point
  101498. * @param connectionPoint defines the other connection point
  101499. * @returns a number defining the compatibility state
  101500. */
  101501. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101502. /**
  101503. * Connect this point to another connection point
  101504. * @param connectionPoint defines the other connection point
  101505. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101506. * @returns the current connection point
  101507. */
  101508. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101509. /**
  101510. * Disconnect this point from one of his endpoint
  101511. * @param endpoint defines the other connection point
  101512. * @returns the current connection point
  101513. */
  101514. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101515. /**
  101516. * Serializes this point in a JSON representation
  101517. * @param isInput defines if the connection point is an input (default is true)
  101518. * @returns the serialized point object
  101519. */
  101520. serialize(isInput?: boolean): any;
  101521. /**
  101522. * Release resources
  101523. */
  101524. dispose(): void;
  101525. }
  101526. }
  101527. declare module BABYLON {
  101528. /**
  101529. * Enum used to define the material modes
  101530. */
  101531. export enum NodeMaterialModes {
  101532. /** Regular material */
  101533. Material = 0,
  101534. /** For post process */
  101535. PostProcess = 1,
  101536. /** For particle system */
  101537. Particle = 2,
  101538. /** For procedural texture */
  101539. ProceduralTexture = 3
  101540. }
  101541. }
  101542. declare module BABYLON {
  101543. /**
  101544. * Block used to read a texture from a sampler
  101545. */
  101546. export class TextureBlock extends NodeMaterialBlock {
  101547. private _defineName;
  101548. private _linearDefineName;
  101549. private _gammaDefineName;
  101550. private _tempTextureRead;
  101551. private _samplerName;
  101552. private _transformedUVName;
  101553. private _textureTransformName;
  101554. private _textureInfoName;
  101555. private _mainUVName;
  101556. private _mainUVDefineName;
  101557. private _fragmentOnly;
  101558. /**
  101559. * Gets or sets the texture associated with the node
  101560. */
  101561. texture: Nullable<Texture>;
  101562. /**
  101563. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101564. */
  101565. convertToGammaSpace: boolean;
  101566. /**
  101567. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101568. */
  101569. convertToLinearSpace: boolean;
  101570. /**
  101571. * Create a new TextureBlock
  101572. * @param name defines the block name
  101573. */
  101574. constructor(name: string, fragmentOnly?: boolean);
  101575. /**
  101576. * Gets the current class name
  101577. * @returns the class name
  101578. */
  101579. getClassName(): string;
  101580. /**
  101581. * Gets the uv input component
  101582. */
  101583. get uv(): NodeMaterialConnectionPoint;
  101584. /**
  101585. * Gets the rgba output component
  101586. */
  101587. get rgba(): NodeMaterialConnectionPoint;
  101588. /**
  101589. * Gets the rgb output component
  101590. */
  101591. get rgb(): NodeMaterialConnectionPoint;
  101592. /**
  101593. * Gets the r output component
  101594. */
  101595. get r(): NodeMaterialConnectionPoint;
  101596. /**
  101597. * Gets the g output component
  101598. */
  101599. get g(): NodeMaterialConnectionPoint;
  101600. /**
  101601. * Gets the b output component
  101602. */
  101603. get b(): NodeMaterialConnectionPoint;
  101604. /**
  101605. * Gets the a output component
  101606. */
  101607. get a(): NodeMaterialConnectionPoint;
  101608. get target(): NodeMaterialBlockTargets;
  101609. autoConfigure(material: NodeMaterial): void;
  101610. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101611. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101612. isReady(): boolean;
  101613. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101614. private get _isMixed();
  101615. private _injectVertexCode;
  101616. private _writeTextureRead;
  101617. private _writeOutput;
  101618. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101619. protected _dumpPropertiesCode(): string;
  101620. serialize(): any;
  101621. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101622. }
  101623. }
  101624. declare module BABYLON {
  101625. /** @hidden */
  101626. export var reflectionFunction: {
  101627. name: string;
  101628. shader: string;
  101629. };
  101630. }
  101631. declare module BABYLON {
  101632. /**
  101633. * Base block used to read a reflection texture from a sampler
  101634. */
  101635. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101636. /** @hidden */
  101637. _define3DName: string;
  101638. /** @hidden */
  101639. _defineCubicName: string;
  101640. /** @hidden */
  101641. _defineExplicitName: string;
  101642. /** @hidden */
  101643. _defineProjectionName: string;
  101644. /** @hidden */
  101645. _defineLocalCubicName: string;
  101646. /** @hidden */
  101647. _defineSphericalName: string;
  101648. /** @hidden */
  101649. _definePlanarName: string;
  101650. /** @hidden */
  101651. _defineEquirectangularName: string;
  101652. /** @hidden */
  101653. _defineMirroredEquirectangularFixedName: string;
  101654. /** @hidden */
  101655. _defineEquirectangularFixedName: string;
  101656. /** @hidden */
  101657. _defineSkyboxName: string;
  101658. /** @hidden */
  101659. _defineOppositeZ: string;
  101660. /** @hidden */
  101661. _cubeSamplerName: string;
  101662. /** @hidden */
  101663. _2DSamplerName: string;
  101664. protected _positionUVWName: string;
  101665. protected _directionWName: string;
  101666. protected _reflectionVectorName: string;
  101667. /** @hidden */
  101668. _reflectionCoordsName: string;
  101669. /** @hidden */
  101670. _reflectionMatrixName: string;
  101671. protected _reflectionColorName: string;
  101672. /**
  101673. * Gets or sets the texture associated with the node
  101674. */
  101675. texture: Nullable<BaseTexture>;
  101676. /**
  101677. * Create a new ReflectionTextureBaseBlock
  101678. * @param name defines the block name
  101679. */
  101680. constructor(name: string);
  101681. /**
  101682. * Gets the current class name
  101683. * @returns the class name
  101684. */
  101685. getClassName(): string;
  101686. /**
  101687. * Gets the world position input component
  101688. */
  101689. abstract get position(): NodeMaterialConnectionPoint;
  101690. /**
  101691. * Gets the world position input component
  101692. */
  101693. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101694. /**
  101695. * Gets the world normal input component
  101696. */
  101697. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101698. /**
  101699. * Gets the world input component
  101700. */
  101701. abstract get world(): NodeMaterialConnectionPoint;
  101702. /**
  101703. * Gets the camera (or eye) position component
  101704. */
  101705. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101706. /**
  101707. * Gets the view input component
  101708. */
  101709. abstract get view(): NodeMaterialConnectionPoint;
  101710. protected _getTexture(): Nullable<BaseTexture>;
  101711. autoConfigure(material: NodeMaterial): void;
  101712. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101713. isReady(): boolean;
  101714. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101715. /**
  101716. * Gets the code to inject in the vertex shader
  101717. * @param state current state of the node material building
  101718. * @returns the shader code
  101719. */
  101720. handleVertexSide(state: NodeMaterialBuildState): string;
  101721. /**
  101722. * Handles the inits for the fragment code path
  101723. * @param state node material build state
  101724. */
  101725. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101726. /**
  101727. * Generates the reflection coords code for the fragment code path
  101728. * @param worldNormalVarName name of the world normal variable
  101729. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101730. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101731. * @returns the shader code
  101732. */
  101733. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101734. /**
  101735. * Generates the reflection color code for the fragment code path
  101736. * @param lodVarName name of the lod variable
  101737. * @param swizzleLookupTexture swizzle to use for the final color variable
  101738. * @returns the shader code
  101739. */
  101740. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101741. /**
  101742. * Generates the code corresponding to the connected output points
  101743. * @param state node material build state
  101744. * @param varName name of the variable to output
  101745. * @returns the shader code
  101746. */
  101747. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101748. protected _buildBlock(state: NodeMaterialBuildState): this;
  101749. protected _dumpPropertiesCode(): string;
  101750. serialize(): any;
  101751. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101752. }
  101753. }
  101754. declare module BABYLON {
  101755. /**
  101756. * Defines a connection point to be used for points with a custom object type
  101757. */
  101758. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101759. private _blockType;
  101760. private _blockName;
  101761. private _nameForCheking?;
  101762. /**
  101763. * Creates a new connection point
  101764. * @param name defines the connection point name
  101765. * @param ownerBlock defines the block hosting this connection point
  101766. * @param direction defines the direction of the connection point
  101767. */
  101768. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101769. /**
  101770. * Gets a number indicating if the current point can be connected to another point
  101771. * @param connectionPoint defines the other connection point
  101772. * @returns a number defining the compatibility state
  101773. */
  101774. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101775. /**
  101776. * Creates a block suitable to be used as an input for this input point.
  101777. * If null is returned, a block based on the point type will be created.
  101778. * @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
  101779. */
  101780. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101781. }
  101782. }
  101783. declare module BABYLON {
  101784. /**
  101785. * Enum defining the type of properties that can be edited in the property pages in the NME
  101786. */
  101787. export enum PropertyTypeForEdition {
  101788. /** property is a boolean */
  101789. Boolean = 0,
  101790. /** property is a float */
  101791. Float = 1,
  101792. /** property is a Vector2 */
  101793. Vector2 = 2,
  101794. /** property is a list of values */
  101795. List = 3
  101796. }
  101797. /**
  101798. * Interface that defines an option in a variable of type list
  101799. */
  101800. export interface IEditablePropertyListOption {
  101801. /** label of the option */
  101802. "label": string;
  101803. /** value of the option */
  101804. "value": number;
  101805. }
  101806. /**
  101807. * Interface that defines the options available for an editable property
  101808. */
  101809. export interface IEditablePropertyOption {
  101810. /** min value */
  101811. "min"?: number;
  101812. /** max value */
  101813. "max"?: number;
  101814. /** notifiers: indicates which actions to take when the property is changed */
  101815. "notifiers"?: {
  101816. /** the material should be rebuilt */
  101817. "rebuild"?: boolean;
  101818. /** the preview should be updated */
  101819. "update"?: boolean;
  101820. };
  101821. /** list of the options for a variable of type list */
  101822. "options"?: IEditablePropertyListOption[];
  101823. }
  101824. /**
  101825. * Interface that describes an editable property
  101826. */
  101827. export interface IPropertyDescriptionForEdition {
  101828. /** name of the property */
  101829. "propertyName": string;
  101830. /** display name of the property */
  101831. "displayName": string;
  101832. /** type of the property */
  101833. "type": PropertyTypeForEdition;
  101834. /** group of the property - all properties with the same group value will be displayed in a specific section */
  101835. "groupName": string;
  101836. /** options for the property */
  101837. "options": IEditablePropertyOption;
  101838. }
  101839. /**
  101840. * Decorator that flags a property in a node material block as being editable
  101841. */
  101842. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  101843. }
  101844. declare module BABYLON {
  101845. /**
  101846. * Block used to implement the refraction part of the sub surface module of the PBR material
  101847. */
  101848. export class RefractionBlock extends NodeMaterialBlock {
  101849. /** @hidden */
  101850. _define3DName: string;
  101851. /** @hidden */
  101852. _refractionMatrixName: string;
  101853. /** @hidden */
  101854. _defineLODRefractionAlpha: string;
  101855. /** @hidden */
  101856. _defineLinearSpecularRefraction: string;
  101857. /** @hidden */
  101858. _defineOppositeZ: string;
  101859. /** @hidden */
  101860. _cubeSamplerName: string;
  101861. /** @hidden */
  101862. _2DSamplerName: string;
  101863. /** @hidden */
  101864. _vRefractionMicrosurfaceInfosName: string;
  101865. /** @hidden */
  101866. _vRefractionInfosName: string;
  101867. private _scene;
  101868. /**
  101869. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101870. * Materials half opaque for instance using refraction could benefit from this control.
  101871. */
  101872. linkRefractionWithTransparency: boolean;
  101873. /**
  101874. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101875. */
  101876. invertRefractionY: boolean;
  101877. /**
  101878. * Gets or sets the texture associated with the node
  101879. */
  101880. texture: Nullable<BaseTexture>;
  101881. /**
  101882. * Create a new RefractionBlock
  101883. * @param name defines the block name
  101884. */
  101885. constructor(name: string);
  101886. /**
  101887. * Gets the current class name
  101888. * @returns the class name
  101889. */
  101890. getClassName(): string;
  101891. /**
  101892. * Gets the intensity input component
  101893. */
  101894. get intensity(): NodeMaterialConnectionPoint;
  101895. /**
  101896. * Gets the index of refraction input component
  101897. */
  101898. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101899. /**
  101900. * Gets the tint at distance input component
  101901. */
  101902. get tintAtDistance(): NodeMaterialConnectionPoint;
  101903. /**
  101904. * Gets the view input component
  101905. */
  101906. get view(): NodeMaterialConnectionPoint;
  101907. /**
  101908. * Gets the refraction object output component
  101909. */
  101910. get refraction(): NodeMaterialConnectionPoint;
  101911. /**
  101912. * Returns true if the block has a texture
  101913. */
  101914. get hasTexture(): boolean;
  101915. protected _getTexture(): Nullable<BaseTexture>;
  101916. autoConfigure(material: NodeMaterial): void;
  101917. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101918. isReady(): boolean;
  101919. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101920. /**
  101921. * Gets the main code of the block (fragment side)
  101922. * @param state current state of the node material building
  101923. * @returns the shader code
  101924. */
  101925. getCode(state: NodeMaterialBuildState): string;
  101926. protected _buildBlock(state: NodeMaterialBuildState): this;
  101927. protected _dumpPropertiesCode(): string;
  101928. serialize(): any;
  101929. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101930. }
  101931. }
  101932. declare module BABYLON {
  101933. /**
  101934. * Base block used as input for post process
  101935. */
  101936. export class CurrentScreenBlock extends NodeMaterialBlock {
  101937. private _samplerName;
  101938. private _linearDefineName;
  101939. private _gammaDefineName;
  101940. private _mainUVName;
  101941. private _tempTextureRead;
  101942. /**
  101943. * Gets or sets the texture associated with the node
  101944. */
  101945. texture: Nullable<BaseTexture>;
  101946. /**
  101947. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101948. */
  101949. convertToGammaSpace: boolean;
  101950. /**
  101951. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101952. */
  101953. convertToLinearSpace: boolean;
  101954. /**
  101955. * Create a new CurrentScreenBlock
  101956. * @param name defines the block name
  101957. */
  101958. constructor(name: string);
  101959. /**
  101960. * Gets the current class name
  101961. * @returns the class name
  101962. */
  101963. getClassName(): string;
  101964. /**
  101965. * Gets the uv input component
  101966. */
  101967. get uv(): NodeMaterialConnectionPoint;
  101968. /**
  101969. * Gets the rgba output component
  101970. */
  101971. get rgba(): NodeMaterialConnectionPoint;
  101972. /**
  101973. * Gets the rgb output component
  101974. */
  101975. get rgb(): NodeMaterialConnectionPoint;
  101976. /**
  101977. * Gets the r output component
  101978. */
  101979. get r(): NodeMaterialConnectionPoint;
  101980. /**
  101981. * Gets the g output component
  101982. */
  101983. get g(): NodeMaterialConnectionPoint;
  101984. /**
  101985. * Gets the b output component
  101986. */
  101987. get b(): NodeMaterialConnectionPoint;
  101988. /**
  101989. * Gets the a output component
  101990. */
  101991. get a(): NodeMaterialConnectionPoint;
  101992. /**
  101993. * Initialize the block and prepare the context for build
  101994. * @param state defines the state that will be used for the build
  101995. */
  101996. initialize(state: NodeMaterialBuildState): void;
  101997. get target(): NodeMaterialBlockTargets;
  101998. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101999. isReady(): boolean;
  102000. private _injectVertexCode;
  102001. private _writeTextureRead;
  102002. private _writeOutput;
  102003. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102004. serialize(): any;
  102005. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102006. }
  102007. }
  102008. declare module BABYLON {
  102009. /**
  102010. * Base block used for the particle texture
  102011. */
  102012. export class ParticleTextureBlock extends NodeMaterialBlock {
  102013. private _samplerName;
  102014. private _linearDefineName;
  102015. private _gammaDefineName;
  102016. private _tempTextureRead;
  102017. /**
  102018. * Gets or sets the texture associated with the node
  102019. */
  102020. texture: Nullable<BaseTexture>;
  102021. /**
  102022. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102023. */
  102024. convertToGammaSpace: boolean;
  102025. /**
  102026. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102027. */
  102028. convertToLinearSpace: boolean;
  102029. /**
  102030. * Create a new ParticleTextureBlock
  102031. * @param name defines the block name
  102032. */
  102033. constructor(name: string);
  102034. /**
  102035. * Gets the current class name
  102036. * @returns the class name
  102037. */
  102038. getClassName(): string;
  102039. /**
  102040. * Gets the uv input component
  102041. */
  102042. get uv(): NodeMaterialConnectionPoint;
  102043. /**
  102044. * Gets the rgba output component
  102045. */
  102046. get rgba(): NodeMaterialConnectionPoint;
  102047. /**
  102048. * Gets the rgb output component
  102049. */
  102050. get rgb(): NodeMaterialConnectionPoint;
  102051. /**
  102052. * Gets the r output component
  102053. */
  102054. get r(): NodeMaterialConnectionPoint;
  102055. /**
  102056. * Gets the g output component
  102057. */
  102058. get g(): NodeMaterialConnectionPoint;
  102059. /**
  102060. * Gets the b output component
  102061. */
  102062. get b(): NodeMaterialConnectionPoint;
  102063. /**
  102064. * Gets the a output component
  102065. */
  102066. get a(): NodeMaterialConnectionPoint;
  102067. /**
  102068. * Initialize the block and prepare the context for build
  102069. * @param state defines the state that will be used for the build
  102070. */
  102071. initialize(state: NodeMaterialBuildState): void;
  102072. autoConfigure(material: NodeMaterial): void;
  102073. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102074. isReady(): boolean;
  102075. private _writeOutput;
  102076. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102077. serialize(): any;
  102078. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102079. }
  102080. }
  102081. declare module BABYLON {
  102082. /**
  102083. * Class used to store shared data between 2 NodeMaterialBuildState
  102084. */
  102085. export class NodeMaterialBuildStateSharedData {
  102086. /**
  102087. * Gets the list of emitted varyings
  102088. */
  102089. temps: string[];
  102090. /**
  102091. * Gets the list of emitted varyings
  102092. */
  102093. varyings: string[];
  102094. /**
  102095. * Gets the varying declaration string
  102096. */
  102097. varyingDeclaration: string;
  102098. /**
  102099. * Input blocks
  102100. */
  102101. inputBlocks: InputBlock[];
  102102. /**
  102103. * Input blocks
  102104. */
  102105. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102106. /**
  102107. * Bindable blocks (Blocks that need to set data to the effect)
  102108. */
  102109. bindableBlocks: NodeMaterialBlock[];
  102110. /**
  102111. * List of blocks that can provide a compilation fallback
  102112. */
  102113. blocksWithFallbacks: NodeMaterialBlock[];
  102114. /**
  102115. * List of blocks that can provide a define update
  102116. */
  102117. blocksWithDefines: NodeMaterialBlock[];
  102118. /**
  102119. * List of blocks that can provide a repeatable content
  102120. */
  102121. repeatableContentBlocks: NodeMaterialBlock[];
  102122. /**
  102123. * List of blocks that can provide a dynamic list of uniforms
  102124. */
  102125. dynamicUniformBlocks: NodeMaterialBlock[];
  102126. /**
  102127. * List of blocks that can block the isReady function for the material
  102128. */
  102129. blockingBlocks: NodeMaterialBlock[];
  102130. /**
  102131. * Gets the list of animated inputs
  102132. */
  102133. animatedInputs: InputBlock[];
  102134. /**
  102135. * Build Id used to avoid multiple recompilations
  102136. */
  102137. buildId: number;
  102138. /** List of emitted variables */
  102139. variableNames: {
  102140. [key: string]: number;
  102141. };
  102142. /** List of emitted defines */
  102143. defineNames: {
  102144. [key: string]: number;
  102145. };
  102146. /** Should emit comments? */
  102147. emitComments: boolean;
  102148. /** Emit build activity */
  102149. verbose: boolean;
  102150. /** Gets or sets the hosting scene */
  102151. scene: Scene;
  102152. /**
  102153. * Gets the compilation hints emitted at compilation time
  102154. */
  102155. hints: {
  102156. needWorldViewMatrix: boolean;
  102157. needWorldViewProjectionMatrix: boolean;
  102158. needAlphaBlending: boolean;
  102159. needAlphaTesting: boolean;
  102160. };
  102161. /**
  102162. * List of compilation checks
  102163. */
  102164. checks: {
  102165. emitVertex: boolean;
  102166. emitFragment: boolean;
  102167. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  102168. };
  102169. /**
  102170. * Is vertex program allowed to be empty?
  102171. */
  102172. allowEmptyVertexProgram: boolean;
  102173. /** Creates a new shared data */
  102174. constructor();
  102175. /**
  102176. * Emits console errors and exceptions if there is a failing check
  102177. */
  102178. emitErrors(): void;
  102179. }
  102180. }
  102181. declare module BABYLON {
  102182. /**
  102183. * Class used to store node based material build state
  102184. */
  102185. export class NodeMaterialBuildState {
  102186. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  102187. supportUniformBuffers: boolean;
  102188. /**
  102189. * Gets the list of emitted attributes
  102190. */
  102191. attributes: string[];
  102192. /**
  102193. * Gets the list of emitted uniforms
  102194. */
  102195. uniforms: string[];
  102196. /**
  102197. * Gets the list of emitted constants
  102198. */
  102199. constants: string[];
  102200. /**
  102201. * Gets the list of emitted samplers
  102202. */
  102203. samplers: string[];
  102204. /**
  102205. * Gets the list of emitted functions
  102206. */
  102207. functions: {
  102208. [key: string]: string;
  102209. };
  102210. /**
  102211. * Gets the list of emitted extensions
  102212. */
  102213. extensions: {
  102214. [key: string]: string;
  102215. };
  102216. /**
  102217. * Gets the target of the compilation state
  102218. */
  102219. target: NodeMaterialBlockTargets;
  102220. /**
  102221. * Gets the list of emitted counters
  102222. */
  102223. counters: {
  102224. [key: string]: number;
  102225. };
  102226. /**
  102227. * Shared data between multiple NodeMaterialBuildState instances
  102228. */
  102229. sharedData: NodeMaterialBuildStateSharedData;
  102230. /** @hidden */
  102231. _vertexState: NodeMaterialBuildState;
  102232. /** @hidden */
  102233. _attributeDeclaration: string;
  102234. /** @hidden */
  102235. _uniformDeclaration: string;
  102236. /** @hidden */
  102237. _constantDeclaration: string;
  102238. /** @hidden */
  102239. _samplerDeclaration: string;
  102240. /** @hidden */
  102241. _varyingTransfer: string;
  102242. /** @hidden */
  102243. _injectAtEnd: string;
  102244. private _repeatableContentAnchorIndex;
  102245. /** @hidden */
  102246. _builtCompilationString: string;
  102247. /**
  102248. * Gets the emitted compilation strings
  102249. */
  102250. compilationString: string;
  102251. /**
  102252. * Finalize the compilation strings
  102253. * @param state defines the current compilation state
  102254. */
  102255. finalize(state: NodeMaterialBuildState): void;
  102256. /** @hidden */
  102257. get _repeatableContentAnchor(): string;
  102258. /** @hidden */
  102259. _getFreeVariableName(prefix: string): string;
  102260. /** @hidden */
  102261. _getFreeDefineName(prefix: string): string;
  102262. /** @hidden */
  102263. _excludeVariableName(name: string): void;
  102264. /** @hidden */
  102265. _emit2DSampler(name: string): void;
  102266. /** @hidden */
  102267. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  102268. /** @hidden */
  102269. _emitExtension(name: string, extension: string, define?: string): void;
  102270. /** @hidden */
  102271. _emitFunction(name: string, code: string, comments: string): void;
  102272. /** @hidden */
  102273. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  102274. replaceStrings?: {
  102275. search: RegExp;
  102276. replace: string;
  102277. }[];
  102278. repeatKey?: string;
  102279. }): string;
  102280. /** @hidden */
  102281. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  102282. repeatKey?: string;
  102283. removeAttributes?: boolean;
  102284. removeUniforms?: boolean;
  102285. removeVaryings?: boolean;
  102286. removeIfDef?: boolean;
  102287. replaceStrings?: {
  102288. search: RegExp;
  102289. replace: string;
  102290. }[];
  102291. }, storeKey?: string): void;
  102292. /** @hidden */
  102293. _registerTempVariable(name: string): boolean;
  102294. /** @hidden */
  102295. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  102296. /** @hidden */
  102297. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  102298. /** @hidden */
  102299. _emitFloat(value: number): string;
  102300. }
  102301. }
  102302. declare module BABYLON {
  102303. /**
  102304. * Helper class used to generate session unique ID
  102305. */
  102306. export class UniqueIdGenerator {
  102307. private static _UniqueIdCounter;
  102308. /**
  102309. * Gets an unique (relatively to the current scene) Id
  102310. */
  102311. static get UniqueId(): number;
  102312. }
  102313. }
  102314. declare module BABYLON {
  102315. /**
  102316. * Defines a block that can be used inside a node based material
  102317. */
  102318. export class NodeMaterialBlock {
  102319. private _buildId;
  102320. private _buildTarget;
  102321. private _target;
  102322. private _isFinalMerger;
  102323. private _isInput;
  102324. private _name;
  102325. protected _isUnique: boolean;
  102326. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  102327. inputsAreExclusive: boolean;
  102328. /** @hidden */
  102329. _codeVariableName: string;
  102330. /** @hidden */
  102331. _inputs: NodeMaterialConnectionPoint[];
  102332. /** @hidden */
  102333. _outputs: NodeMaterialConnectionPoint[];
  102334. /** @hidden */
  102335. _preparationId: number;
  102336. /**
  102337. * Gets the name of the block
  102338. */
  102339. get name(): string;
  102340. /**
  102341. * Sets the name of the block. Will check if the name is valid.
  102342. */
  102343. set name(newName: string);
  102344. /**
  102345. * Gets or sets the unique id of the node
  102346. */
  102347. uniqueId: number;
  102348. /**
  102349. * Gets or sets the comments associated with this block
  102350. */
  102351. comments: string;
  102352. /**
  102353. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  102354. */
  102355. get isUnique(): boolean;
  102356. /**
  102357. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  102358. */
  102359. get isFinalMerger(): boolean;
  102360. /**
  102361. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  102362. */
  102363. get isInput(): boolean;
  102364. /**
  102365. * Gets or sets the build Id
  102366. */
  102367. get buildId(): number;
  102368. set buildId(value: number);
  102369. /**
  102370. * Gets or sets the target of the block
  102371. */
  102372. get target(): NodeMaterialBlockTargets;
  102373. set target(value: NodeMaterialBlockTargets);
  102374. /**
  102375. * Gets the list of input points
  102376. */
  102377. get inputs(): NodeMaterialConnectionPoint[];
  102378. /** Gets the list of output points */
  102379. get outputs(): NodeMaterialConnectionPoint[];
  102380. /**
  102381. * Find an input by its name
  102382. * @param name defines the name of the input to look for
  102383. * @returns the input or null if not found
  102384. */
  102385. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102386. /**
  102387. * Find an output by its name
  102388. * @param name defines the name of the outputto look for
  102389. * @returns the output or null if not found
  102390. */
  102391. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102392. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  102393. visibleInInspector: boolean;
  102394. /**
  102395. * Creates a new NodeMaterialBlock
  102396. * @param name defines the block name
  102397. * @param target defines the target of that block (Vertex by default)
  102398. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  102399. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  102400. */
  102401. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  102402. /**
  102403. * Initialize the block and prepare the context for build
  102404. * @param state defines the state that will be used for the build
  102405. */
  102406. initialize(state: NodeMaterialBuildState): void;
  102407. /**
  102408. * Bind data to effect. Will only be called for blocks with isBindable === true
  102409. * @param effect defines the effect to bind data to
  102410. * @param nodeMaterial defines the hosting NodeMaterial
  102411. * @param mesh defines the mesh that will be rendered
  102412. * @param subMesh defines the submesh that will be rendered
  102413. */
  102414. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102415. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  102416. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  102417. protected _writeFloat(value: number): string;
  102418. /**
  102419. * Gets the current class name e.g. "NodeMaterialBlock"
  102420. * @returns the class name
  102421. */
  102422. getClassName(): string;
  102423. /**
  102424. * Register a new input. 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 isOptional defines a boolean indicating that this input can be omitted
  102428. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102429. * @param point an already created connection point. If not provided, create a new one
  102430. * @returns the current block
  102431. */
  102432. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102433. /**
  102434. * Register a new output. Must be called inside a block constructor
  102435. * @param name defines the connection point name
  102436. * @param type defines the connection point type
  102437. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102438. * @param point an already created connection point. If not provided, create a new one
  102439. * @returns the current block
  102440. */
  102441. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102442. /**
  102443. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  102444. * @param forOutput defines an optional connection point to check compatibility with
  102445. * @returns the first available input or null
  102446. */
  102447. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  102448. /**
  102449. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  102450. * @param forBlock defines an optional block to check compatibility with
  102451. * @returns the first available input or null
  102452. */
  102453. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  102454. /**
  102455. * Gets the sibling of the given output
  102456. * @param current defines the current output
  102457. * @returns the next output in the list or null
  102458. */
  102459. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102460. /**
  102461. * Connect current block with another block
  102462. * @param other defines the block to connect with
  102463. * @param options define the various options to help pick the right connections
  102464. * @returns the current block
  102465. */
  102466. connectTo(other: NodeMaterialBlock, options?: {
  102467. input?: string;
  102468. output?: string;
  102469. outputSwizzle?: string;
  102470. }): this | undefined;
  102471. protected _buildBlock(state: NodeMaterialBuildState): void;
  102472. /**
  102473. * Add uniforms, samplers and uniform buffers at compilation time
  102474. * @param state defines the state to update
  102475. * @param nodeMaterial defines the node material requesting the update
  102476. * @param defines defines the material defines to update
  102477. * @param uniformBuffers defines the list of uniform buffer names
  102478. */
  102479. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102480. /**
  102481. * Add potential fallbacks if shader compilation fails
  102482. * @param mesh defines the mesh to be rendered
  102483. * @param fallbacks defines the current prioritized list of fallbacks
  102484. */
  102485. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102486. /**
  102487. * Initialize defines for shader compilation
  102488. * @param mesh defines the mesh to be rendered
  102489. * @param nodeMaterial defines the node material requesting the update
  102490. * @param defines defines the material defines to update
  102491. * @param useInstances specifies that instances should be used
  102492. */
  102493. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102494. /**
  102495. * Update defines for shader compilation
  102496. * @param mesh defines the mesh to be rendered
  102497. * @param nodeMaterial defines the node material requesting the update
  102498. * @param defines defines the material defines to update
  102499. * @param useInstances specifies that instances should be used
  102500. * @param subMesh defines which submesh to render
  102501. */
  102502. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102503. /**
  102504. * Lets the block try to connect some inputs automatically
  102505. * @param material defines the hosting NodeMaterial
  102506. */
  102507. autoConfigure(material: NodeMaterial): void;
  102508. /**
  102509. * Function called when a block is declared as repeatable content generator
  102510. * @param vertexShaderState defines the current compilation state for the vertex shader
  102511. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102512. * @param mesh defines the mesh to be rendered
  102513. * @param defines defines the material defines to update
  102514. */
  102515. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102516. /**
  102517. * Checks if the block is ready
  102518. * @param mesh defines the mesh to be rendered
  102519. * @param nodeMaterial defines the node material requesting the update
  102520. * @param defines defines the material defines to update
  102521. * @param useInstances specifies that instances should be used
  102522. * @returns true if the block is ready
  102523. */
  102524. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102525. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102526. private _processBuild;
  102527. /**
  102528. * Validates the new name for the block node.
  102529. * @param newName the new name to be given to the node.
  102530. * @returns false if the name is a reserve word, else true.
  102531. */
  102532. validateBlockName(newName: string): boolean;
  102533. /**
  102534. * Compile the current node and generate the shader code
  102535. * @param state defines the current compilation state (uniforms, samplers, current string)
  102536. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102537. * @returns true if already built
  102538. */
  102539. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102540. protected _inputRename(name: string): string;
  102541. protected _outputRename(name: string): string;
  102542. protected _dumpPropertiesCode(): string;
  102543. /** @hidden */
  102544. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102545. /** @hidden */
  102546. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102547. /**
  102548. * Clone the current block to a new identical block
  102549. * @param scene defines the hosting scene
  102550. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102551. * @returns a copy of the current block
  102552. */
  102553. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102554. /**
  102555. * Serializes this block in a JSON representation
  102556. * @returns the serialized block object
  102557. */
  102558. serialize(): any;
  102559. /** @hidden */
  102560. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102561. private _deserializePortDisplayNamesAndExposedOnFrame;
  102562. /**
  102563. * Release resources
  102564. */
  102565. dispose(): void;
  102566. }
  102567. }
  102568. declare module BABYLON {
  102569. /**
  102570. * Base class of materials working in push mode in babylon JS
  102571. * @hidden
  102572. */
  102573. export class PushMaterial extends Material {
  102574. protected _activeEffect: Effect;
  102575. protected _normalMatrix: Matrix;
  102576. constructor(name: string, scene: Scene);
  102577. getEffect(): Effect;
  102578. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102579. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102580. /**
  102581. * Binds the given world matrix to the active effect
  102582. *
  102583. * @param world the matrix to bind
  102584. */
  102585. bindOnlyWorldMatrix(world: Matrix): void;
  102586. /**
  102587. * Binds the given normal matrix to the active effect
  102588. *
  102589. * @param normalMatrix the matrix to bind
  102590. */
  102591. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102592. bind(world: Matrix, mesh?: Mesh): void;
  102593. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102594. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102595. }
  102596. }
  102597. declare module BABYLON {
  102598. /**
  102599. * Root class for all node material optimizers
  102600. */
  102601. export class NodeMaterialOptimizer {
  102602. /**
  102603. * Function used to optimize a NodeMaterial graph
  102604. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102605. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102606. */
  102607. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102608. }
  102609. }
  102610. declare module BABYLON {
  102611. /**
  102612. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102613. */
  102614. export class TransformBlock extends NodeMaterialBlock {
  102615. /**
  102616. * Defines the value to use to complement W value to transform it to a Vector4
  102617. */
  102618. complementW: number;
  102619. /**
  102620. * Defines the value to use to complement z value to transform it to a Vector4
  102621. */
  102622. complementZ: number;
  102623. /**
  102624. * Creates a new TransformBlock
  102625. * @param name defines the block name
  102626. */
  102627. constructor(name: string);
  102628. /**
  102629. * Gets the current class name
  102630. * @returns the class name
  102631. */
  102632. getClassName(): string;
  102633. /**
  102634. * Gets the vector input
  102635. */
  102636. get vector(): NodeMaterialConnectionPoint;
  102637. /**
  102638. * Gets the output component
  102639. */
  102640. get output(): NodeMaterialConnectionPoint;
  102641. /**
  102642. * Gets the xyz output component
  102643. */
  102644. get xyz(): NodeMaterialConnectionPoint;
  102645. /**
  102646. * Gets the matrix transform input
  102647. */
  102648. get transform(): NodeMaterialConnectionPoint;
  102649. protected _buildBlock(state: NodeMaterialBuildState): this;
  102650. /**
  102651. * Update defines for shader compilation
  102652. * @param mesh defines the mesh to be rendered
  102653. * @param nodeMaterial defines the node material requesting the update
  102654. * @param defines defines the material defines to update
  102655. * @param useInstances specifies that instances should be used
  102656. * @param subMesh defines which submesh to render
  102657. */
  102658. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102659. serialize(): any;
  102660. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102661. protected _dumpPropertiesCode(): string;
  102662. }
  102663. }
  102664. declare module BABYLON {
  102665. /**
  102666. * Block used to output the vertex position
  102667. */
  102668. export class VertexOutputBlock extends NodeMaterialBlock {
  102669. /**
  102670. * Creates a new VertexOutputBlock
  102671. * @param name defines the block name
  102672. */
  102673. constructor(name: string);
  102674. /**
  102675. * Gets the current class name
  102676. * @returns the class name
  102677. */
  102678. getClassName(): string;
  102679. /**
  102680. * Gets the vector input component
  102681. */
  102682. get vector(): NodeMaterialConnectionPoint;
  102683. protected _buildBlock(state: NodeMaterialBuildState): this;
  102684. }
  102685. }
  102686. declare module BABYLON {
  102687. /**
  102688. * Block used to output the final color
  102689. */
  102690. export class FragmentOutputBlock extends NodeMaterialBlock {
  102691. /**
  102692. * Create a new FragmentOutputBlock
  102693. * @param name defines the block name
  102694. */
  102695. constructor(name: string);
  102696. /**
  102697. * Gets the current class name
  102698. * @returns the class name
  102699. */
  102700. getClassName(): string;
  102701. /**
  102702. * Gets the rgba input component
  102703. */
  102704. get rgba(): NodeMaterialConnectionPoint;
  102705. /**
  102706. * Gets the rgb input component
  102707. */
  102708. get rgb(): NodeMaterialConnectionPoint;
  102709. /**
  102710. * Gets the a input component
  102711. */
  102712. get a(): NodeMaterialConnectionPoint;
  102713. protected _buildBlock(state: NodeMaterialBuildState): this;
  102714. }
  102715. }
  102716. declare module BABYLON {
  102717. /**
  102718. * Block used for the particle ramp gradient section
  102719. */
  102720. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102721. /**
  102722. * Create a new ParticleRampGradientBlock
  102723. * @param name defines the block name
  102724. */
  102725. constructor(name: string);
  102726. /**
  102727. * Gets the current class name
  102728. * @returns the class name
  102729. */
  102730. getClassName(): string;
  102731. /**
  102732. * Gets the color input component
  102733. */
  102734. get color(): NodeMaterialConnectionPoint;
  102735. /**
  102736. * Gets the rampColor output component
  102737. */
  102738. get rampColor(): NodeMaterialConnectionPoint;
  102739. /**
  102740. * Initialize the block and prepare the context for build
  102741. * @param state defines the state that will be used for the build
  102742. */
  102743. initialize(state: NodeMaterialBuildState): void;
  102744. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102745. }
  102746. }
  102747. declare module BABYLON {
  102748. /**
  102749. * Block used for the particle blend multiply section
  102750. */
  102751. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102752. /**
  102753. * Create a new ParticleBlendMultiplyBlock
  102754. * @param name defines the block name
  102755. */
  102756. constructor(name: string);
  102757. /**
  102758. * Gets the current class name
  102759. * @returns the class name
  102760. */
  102761. getClassName(): string;
  102762. /**
  102763. * Gets the color input component
  102764. */
  102765. get color(): NodeMaterialConnectionPoint;
  102766. /**
  102767. * Gets the alphaTexture input component
  102768. */
  102769. get alphaTexture(): NodeMaterialConnectionPoint;
  102770. /**
  102771. * Gets the alphaColor input component
  102772. */
  102773. get alphaColor(): NodeMaterialConnectionPoint;
  102774. /**
  102775. * Gets the blendColor output component
  102776. */
  102777. get blendColor(): NodeMaterialConnectionPoint;
  102778. /**
  102779. * Initialize the block and prepare the context for build
  102780. * @param state defines the state that will be used for the build
  102781. */
  102782. initialize(state: NodeMaterialBuildState): void;
  102783. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102784. }
  102785. }
  102786. declare module BABYLON {
  102787. /**
  102788. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102789. */
  102790. export class VectorMergerBlock extends NodeMaterialBlock {
  102791. /**
  102792. * Create a new VectorMergerBlock
  102793. * @param name defines the block name
  102794. */
  102795. constructor(name: string);
  102796. /**
  102797. * Gets the current class name
  102798. * @returns the class name
  102799. */
  102800. getClassName(): string;
  102801. /**
  102802. * Gets the xyz component (input)
  102803. */
  102804. get xyzIn(): NodeMaterialConnectionPoint;
  102805. /**
  102806. * Gets the xy component (input)
  102807. */
  102808. get xyIn(): NodeMaterialConnectionPoint;
  102809. /**
  102810. * Gets the x component (input)
  102811. */
  102812. get x(): NodeMaterialConnectionPoint;
  102813. /**
  102814. * Gets the y component (input)
  102815. */
  102816. get y(): NodeMaterialConnectionPoint;
  102817. /**
  102818. * Gets the z component (input)
  102819. */
  102820. get z(): NodeMaterialConnectionPoint;
  102821. /**
  102822. * Gets the w component (input)
  102823. */
  102824. get w(): NodeMaterialConnectionPoint;
  102825. /**
  102826. * Gets the xyzw component (output)
  102827. */
  102828. get xyzw(): NodeMaterialConnectionPoint;
  102829. /**
  102830. * Gets the xyz component (output)
  102831. */
  102832. get xyzOut(): NodeMaterialConnectionPoint;
  102833. /**
  102834. * Gets the xy component (output)
  102835. */
  102836. get xyOut(): NodeMaterialConnectionPoint;
  102837. /**
  102838. * Gets the xy component (output)
  102839. * @deprecated Please use xyOut instead.
  102840. */
  102841. get xy(): NodeMaterialConnectionPoint;
  102842. /**
  102843. * Gets the xyz component (output)
  102844. * @deprecated Please use xyzOut instead.
  102845. */
  102846. get xyz(): NodeMaterialConnectionPoint;
  102847. protected _buildBlock(state: NodeMaterialBuildState): this;
  102848. }
  102849. }
  102850. declare module BABYLON {
  102851. /**
  102852. * Block used to remap a float from a range to a new one
  102853. */
  102854. export class RemapBlock extends NodeMaterialBlock {
  102855. /**
  102856. * Gets or sets the source range
  102857. */
  102858. sourceRange: Vector2;
  102859. /**
  102860. * Gets or sets the target range
  102861. */
  102862. targetRange: Vector2;
  102863. /**
  102864. * Creates a new RemapBlock
  102865. * @param name defines the block name
  102866. */
  102867. constructor(name: string);
  102868. /**
  102869. * Gets the current class name
  102870. * @returns the class name
  102871. */
  102872. getClassName(): string;
  102873. /**
  102874. * Gets the input component
  102875. */
  102876. get input(): NodeMaterialConnectionPoint;
  102877. /**
  102878. * Gets the source min input component
  102879. */
  102880. get sourceMin(): NodeMaterialConnectionPoint;
  102881. /**
  102882. * Gets the source max input component
  102883. */
  102884. get sourceMax(): NodeMaterialConnectionPoint;
  102885. /**
  102886. * Gets the target min input component
  102887. */
  102888. get targetMin(): NodeMaterialConnectionPoint;
  102889. /**
  102890. * Gets the target max input component
  102891. */
  102892. get targetMax(): NodeMaterialConnectionPoint;
  102893. /**
  102894. * Gets the output component
  102895. */
  102896. get output(): NodeMaterialConnectionPoint;
  102897. protected _buildBlock(state: NodeMaterialBuildState): this;
  102898. protected _dumpPropertiesCode(): string;
  102899. serialize(): any;
  102900. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102901. }
  102902. }
  102903. declare module BABYLON {
  102904. /**
  102905. * Block used to multiply 2 values
  102906. */
  102907. export class MultiplyBlock extends NodeMaterialBlock {
  102908. /**
  102909. * Creates a new MultiplyBlock
  102910. * @param name defines the block name
  102911. */
  102912. constructor(name: string);
  102913. /**
  102914. * Gets the current class name
  102915. * @returns the class name
  102916. */
  102917. getClassName(): string;
  102918. /**
  102919. * Gets the left operand input component
  102920. */
  102921. get left(): NodeMaterialConnectionPoint;
  102922. /**
  102923. * Gets the right operand input component
  102924. */
  102925. get right(): NodeMaterialConnectionPoint;
  102926. /**
  102927. * Gets the output component
  102928. */
  102929. get output(): NodeMaterialConnectionPoint;
  102930. protected _buildBlock(state: NodeMaterialBuildState): this;
  102931. }
  102932. }
  102933. declare module BABYLON {
  102934. /**
  102935. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102936. */
  102937. export class ColorSplitterBlock extends NodeMaterialBlock {
  102938. /**
  102939. * Create a new ColorSplitterBlock
  102940. * @param name defines the block name
  102941. */
  102942. constructor(name: string);
  102943. /**
  102944. * Gets the current class name
  102945. * @returns the class name
  102946. */
  102947. getClassName(): string;
  102948. /**
  102949. * Gets the rgba component (input)
  102950. */
  102951. get rgba(): NodeMaterialConnectionPoint;
  102952. /**
  102953. * Gets the rgb component (input)
  102954. */
  102955. get rgbIn(): NodeMaterialConnectionPoint;
  102956. /**
  102957. * Gets the rgb component (output)
  102958. */
  102959. get rgbOut(): NodeMaterialConnectionPoint;
  102960. /**
  102961. * Gets the r component (output)
  102962. */
  102963. get r(): NodeMaterialConnectionPoint;
  102964. /**
  102965. * Gets the g component (output)
  102966. */
  102967. get g(): NodeMaterialConnectionPoint;
  102968. /**
  102969. * Gets the b component (output)
  102970. */
  102971. get b(): NodeMaterialConnectionPoint;
  102972. /**
  102973. * Gets the a component (output)
  102974. */
  102975. get a(): NodeMaterialConnectionPoint;
  102976. protected _inputRename(name: string): string;
  102977. protected _outputRename(name: string): string;
  102978. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102979. }
  102980. }
  102981. declare module BABYLON {
  102982. /**
  102983. * Operations supported by the Trigonometry block
  102984. */
  102985. export enum TrigonometryBlockOperations {
  102986. /** Cos */
  102987. Cos = 0,
  102988. /** Sin */
  102989. Sin = 1,
  102990. /** Abs */
  102991. Abs = 2,
  102992. /** Exp */
  102993. Exp = 3,
  102994. /** Exp2 */
  102995. Exp2 = 4,
  102996. /** Round */
  102997. Round = 5,
  102998. /** Floor */
  102999. Floor = 6,
  103000. /** Ceiling */
  103001. Ceiling = 7,
  103002. /** Square root */
  103003. Sqrt = 8,
  103004. /** Log */
  103005. Log = 9,
  103006. /** Tangent */
  103007. Tan = 10,
  103008. /** Arc tangent */
  103009. ArcTan = 11,
  103010. /** Arc cosinus */
  103011. ArcCos = 12,
  103012. /** Arc sinus */
  103013. ArcSin = 13,
  103014. /** Fraction */
  103015. Fract = 14,
  103016. /** Sign */
  103017. Sign = 15,
  103018. /** To radians (from degrees) */
  103019. Radians = 16,
  103020. /** To degrees (from radians) */
  103021. Degrees = 17
  103022. }
  103023. /**
  103024. * Block used to apply trigonometry operation to floats
  103025. */
  103026. export class TrigonometryBlock extends NodeMaterialBlock {
  103027. /**
  103028. * Gets or sets the operation applied by the block
  103029. */
  103030. operation: TrigonometryBlockOperations;
  103031. /**
  103032. * Creates a new TrigonometryBlock
  103033. * @param name defines the block name
  103034. */
  103035. constructor(name: string);
  103036. /**
  103037. * Gets the current class name
  103038. * @returns the class name
  103039. */
  103040. getClassName(): string;
  103041. /**
  103042. * Gets the input component
  103043. */
  103044. get input(): NodeMaterialConnectionPoint;
  103045. /**
  103046. * Gets the output component
  103047. */
  103048. get output(): NodeMaterialConnectionPoint;
  103049. protected _buildBlock(state: NodeMaterialBuildState): this;
  103050. serialize(): any;
  103051. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103052. protected _dumpPropertiesCode(): string;
  103053. }
  103054. }
  103055. declare module BABYLON {
  103056. /**
  103057. * Interface used to configure the node material editor
  103058. */
  103059. export interface INodeMaterialEditorOptions {
  103060. /** Define the URl to load node editor script */
  103061. editorURL?: string;
  103062. }
  103063. /** @hidden */
  103064. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103065. NORMAL: boolean;
  103066. TANGENT: boolean;
  103067. UV1: boolean;
  103068. /** BONES */
  103069. NUM_BONE_INFLUENCERS: number;
  103070. BonesPerMesh: number;
  103071. BONETEXTURE: boolean;
  103072. /** MORPH TARGETS */
  103073. MORPHTARGETS: boolean;
  103074. MORPHTARGETS_NORMAL: boolean;
  103075. MORPHTARGETS_TANGENT: boolean;
  103076. MORPHTARGETS_UV: boolean;
  103077. NUM_MORPH_INFLUENCERS: number;
  103078. /** IMAGE PROCESSING */
  103079. IMAGEPROCESSING: boolean;
  103080. VIGNETTE: boolean;
  103081. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103082. VIGNETTEBLENDMODEOPAQUE: boolean;
  103083. TONEMAPPING: boolean;
  103084. TONEMAPPING_ACES: boolean;
  103085. CONTRAST: boolean;
  103086. EXPOSURE: boolean;
  103087. COLORCURVES: boolean;
  103088. COLORGRADING: boolean;
  103089. COLORGRADING3D: boolean;
  103090. SAMPLER3DGREENDEPTH: boolean;
  103091. SAMPLER3DBGRMAP: boolean;
  103092. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103093. /** MISC. */
  103094. BUMPDIRECTUV: number;
  103095. constructor();
  103096. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  103097. }
  103098. /**
  103099. * Class used to configure NodeMaterial
  103100. */
  103101. export interface INodeMaterialOptions {
  103102. /**
  103103. * Defines if blocks should emit comments
  103104. */
  103105. emitComments: boolean;
  103106. }
  103107. /**
  103108. * Class used to create a node based material built by assembling shader blocks
  103109. */
  103110. export class NodeMaterial extends PushMaterial {
  103111. private static _BuildIdGenerator;
  103112. private _options;
  103113. private _vertexCompilationState;
  103114. private _fragmentCompilationState;
  103115. private _sharedData;
  103116. private _buildId;
  103117. private _buildWasSuccessful;
  103118. private _cachedWorldViewMatrix;
  103119. private _cachedWorldViewProjectionMatrix;
  103120. private _optimizers;
  103121. private _animationFrame;
  103122. /** Define the Url to load node editor script */
  103123. static EditorURL: string;
  103124. /** Define the Url to load snippets */
  103125. static SnippetUrl: string;
  103126. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  103127. static IgnoreTexturesAtLoadTime: boolean;
  103128. private BJSNODEMATERIALEDITOR;
  103129. /** Get the inspector from bundle or global */
  103130. private _getGlobalNodeMaterialEditor;
  103131. /**
  103132. * Snippet ID if the material was created from the snippet server
  103133. */
  103134. snippetId: string;
  103135. /**
  103136. * Gets or sets data used by visual editor
  103137. * @see https://nme.babylonjs.com
  103138. */
  103139. editorData: any;
  103140. /**
  103141. * 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)
  103142. */
  103143. ignoreAlpha: boolean;
  103144. /**
  103145. * Defines the maximum number of lights that can be used in the material
  103146. */
  103147. maxSimultaneousLights: number;
  103148. /**
  103149. * Observable raised when the material is built
  103150. */
  103151. onBuildObservable: Observable<NodeMaterial>;
  103152. /**
  103153. * Gets or sets the root nodes of the material vertex shader
  103154. */
  103155. _vertexOutputNodes: NodeMaterialBlock[];
  103156. /**
  103157. * Gets or sets the root nodes of the material fragment (pixel) shader
  103158. */
  103159. _fragmentOutputNodes: NodeMaterialBlock[];
  103160. /** Gets or sets options to control the node material overall behavior */
  103161. get options(): INodeMaterialOptions;
  103162. set options(options: INodeMaterialOptions);
  103163. /**
  103164. * Default configuration related to image processing available in the standard Material.
  103165. */
  103166. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103167. /**
  103168. * Gets the image processing configuration used either in this material.
  103169. */
  103170. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103171. /**
  103172. * Sets the Default image processing configuration used either in the this material.
  103173. *
  103174. * If sets to null, the scene one is in use.
  103175. */
  103176. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103177. /**
  103178. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  103179. */
  103180. attachedBlocks: NodeMaterialBlock[];
  103181. /**
  103182. * Specifies the mode of the node material
  103183. * @hidden
  103184. */
  103185. _mode: NodeMaterialModes;
  103186. /**
  103187. * Gets the mode property
  103188. */
  103189. get mode(): NodeMaterialModes;
  103190. /**
  103191. * Create a new node based material
  103192. * @param name defines the material name
  103193. * @param scene defines the hosting scene
  103194. * @param options defines creation option
  103195. */
  103196. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  103197. /**
  103198. * Gets the current class name of the material e.g. "NodeMaterial"
  103199. * @returns the class name
  103200. */
  103201. getClassName(): string;
  103202. /**
  103203. * Keep track of the image processing observer to allow dispose and replace.
  103204. */
  103205. private _imageProcessingObserver;
  103206. /**
  103207. * Attaches a new image processing configuration to the Standard Material.
  103208. * @param configuration
  103209. */
  103210. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103211. /**
  103212. * Get a block by its name
  103213. * @param name defines the name of the block to retrieve
  103214. * @returns the required block or null if not found
  103215. */
  103216. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  103217. /**
  103218. * Get a block by its name
  103219. * @param predicate defines the predicate used to find the good candidate
  103220. * @returns the required block or null if not found
  103221. */
  103222. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  103223. /**
  103224. * Get an input block by its name
  103225. * @param predicate defines the predicate used to find the good candidate
  103226. * @returns the required input block or null if not found
  103227. */
  103228. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  103229. /**
  103230. * Gets the list of input blocks attached to this material
  103231. * @returns an array of InputBlocks
  103232. */
  103233. getInputBlocks(): InputBlock[];
  103234. /**
  103235. * Adds a new optimizer to the list of optimizers
  103236. * @param optimizer defines the optimizers to add
  103237. * @returns the current material
  103238. */
  103239. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103240. /**
  103241. * Remove an optimizer from the list of optimizers
  103242. * @param optimizer defines the optimizers to remove
  103243. * @returns the current material
  103244. */
  103245. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103246. /**
  103247. * Add a new block to the list of output nodes
  103248. * @param node defines the node to add
  103249. * @returns the current material
  103250. */
  103251. addOutputNode(node: NodeMaterialBlock): this;
  103252. /**
  103253. * Remove a block from the list of root nodes
  103254. * @param node defines the node to remove
  103255. * @returns the current material
  103256. */
  103257. removeOutputNode(node: NodeMaterialBlock): this;
  103258. private _addVertexOutputNode;
  103259. private _removeVertexOutputNode;
  103260. private _addFragmentOutputNode;
  103261. private _removeFragmentOutputNode;
  103262. /**
  103263. * Specifies if the material will require alpha blending
  103264. * @returns a boolean specifying if alpha blending is needed
  103265. */
  103266. needAlphaBlending(): boolean;
  103267. /**
  103268. * Specifies if this material should be rendered in alpha test mode
  103269. * @returns a boolean specifying if an alpha test is needed.
  103270. */
  103271. needAlphaTesting(): boolean;
  103272. private _initializeBlock;
  103273. private _resetDualBlocks;
  103274. /**
  103275. * Remove a block from the current node material
  103276. * @param block defines the block to remove
  103277. */
  103278. removeBlock(block: NodeMaterialBlock): void;
  103279. /**
  103280. * Build the material and generates the inner effect
  103281. * @param verbose defines if the build should log activity
  103282. */
  103283. build(verbose?: boolean): void;
  103284. /**
  103285. * Runs an otpimization phase to try to improve the shader code
  103286. */
  103287. optimize(): void;
  103288. private _prepareDefinesForAttributes;
  103289. /**
  103290. * Create a post process from the material
  103291. * @param camera The camera to apply the render pass to.
  103292. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103294. * @param engine The engine which the post process will be applied. (default: current engine)
  103295. * @param reusable If the post process can be reused on the same frame. (default: false)
  103296. * @param textureType Type of textures used when performing the post process. (default: 0)
  103297. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103298. * @returns the post process created
  103299. */
  103300. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  103301. /**
  103302. * Create the post process effect from the material
  103303. * @param postProcess The post process to create the effect for
  103304. */
  103305. createEffectForPostProcess(postProcess: PostProcess): void;
  103306. private _createEffectForPostProcess;
  103307. /**
  103308. * Create a new procedural texture based on this node material
  103309. * @param size defines the size of the texture
  103310. * @param scene defines the hosting scene
  103311. * @returns the new procedural texture attached to this node material
  103312. */
  103313. createProceduralTexture(size: number | {
  103314. width: number;
  103315. height: number;
  103316. layers?: number;
  103317. }, scene: Scene): Nullable<ProceduralTexture>;
  103318. private _createEffectForParticles;
  103319. private _checkInternals;
  103320. /**
  103321. * Create the effect to be used as the custom effect for a particle system
  103322. * @param particleSystem Particle system to create the effect for
  103323. * @param onCompiled defines a function to call when the effect creation is successful
  103324. * @param onError defines a function to call when the effect creation has failed
  103325. */
  103326. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103327. private _processDefines;
  103328. /**
  103329. * Get if the submesh is ready to be used and all its information available.
  103330. * Child classes can use it to update shaders
  103331. * @param mesh defines the mesh to check
  103332. * @param subMesh defines which submesh to check
  103333. * @param useInstances specifies that instances should be used
  103334. * @returns a boolean indicating that the submesh is ready or not
  103335. */
  103336. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103337. /**
  103338. * Get a string representing the shaders built by the current node graph
  103339. */
  103340. get compiledShaders(): string;
  103341. /**
  103342. * Binds the world matrix to the material
  103343. * @param world defines the world transformation matrix
  103344. */
  103345. bindOnlyWorldMatrix(world: Matrix): void;
  103346. /**
  103347. * Binds the submesh to this material by preparing the effect and shader to draw
  103348. * @param world defines the world transformation matrix
  103349. * @param mesh defines the mesh containing the submesh
  103350. * @param subMesh defines the submesh to bind the material to
  103351. */
  103352. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103353. /**
  103354. * Gets the active textures from the material
  103355. * @returns an array of textures
  103356. */
  103357. getActiveTextures(): BaseTexture[];
  103358. /**
  103359. * Gets the list of texture blocks
  103360. * @returns an array of texture blocks
  103361. */
  103362. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  103363. /**
  103364. * Specifies if the material uses a texture
  103365. * @param texture defines the texture to check against the material
  103366. * @returns a boolean specifying if the material uses the texture
  103367. */
  103368. hasTexture(texture: BaseTexture): boolean;
  103369. /**
  103370. * Disposes the material
  103371. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103372. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103373. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103374. */
  103375. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103376. /** Creates the node editor window. */
  103377. private _createNodeEditor;
  103378. /**
  103379. * Launch the node material editor
  103380. * @param config Define the configuration of the editor
  103381. * @return a promise fulfilled when the node editor is visible
  103382. */
  103383. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  103384. /**
  103385. * Clear the current material
  103386. */
  103387. clear(): void;
  103388. /**
  103389. * Clear the current material and set it to a default state
  103390. */
  103391. setToDefault(): void;
  103392. /**
  103393. * Clear the current material and set it to a default state for post process
  103394. */
  103395. setToDefaultPostProcess(): void;
  103396. /**
  103397. * Clear the current material and set it to a default state for procedural texture
  103398. */
  103399. setToDefaultProceduralTexture(): void;
  103400. /**
  103401. * Clear the current material and set it to a default state for particle
  103402. */
  103403. setToDefaultParticle(): void;
  103404. /**
  103405. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  103406. * @param url defines the url to load from
  103407. * @returns a promise that will fullfil when the material is fully loaded
  103408. */
  103409. loadAsync(url: string): Promise<void>;
  103410. private _gatherBlocks;
  103411. /**
  103412. * Generate a string containing the code declaration required to create an equivalent of this material
  103413. * @returns a string
  103414. */
  103415. generateCode(): string;
  103416. /**
  103417. * Serializes this material in a JSON representation
  103418. * @returns the serialized material object
  103419. */
  103420. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  103421. private _restoreConnections;
  103422. /**
  103423. * Clear the current graph and load a new one from a serialization object
  103424. * @param source defines the JSON representation of the material
  103425. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103426. * @param merge defines whether or not the source must be merged or replace the current content
  103427. */
  103428. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103429. /**
  103430. * Makes a duplicate of the current material.
  103431. * @param name - name to use for the new material.
  103432. */
  103433. clone(name: string): NodeMaterial;
  103434. /**
  103435. * Creates a node material from parsed material data
  103436. * @param source defines the JSON representation of the material
  103437. * @param scene defines the hosting scene
  103438. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103439. * @returns a new node material
  103440. */
  103441. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103442. /**
  103443. * Creates a node material from a snippet saved in a remote file
  103444. * @param name defines the name of the material to create
  103445. * @param url defines the url to load from
  103446. * @param scene defines the hosting scene
  103447. * @returns a promise that will resolve to the new node material
  103448. */
  103449. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103450. /**
  103451. * Creates a node material from a snippet saved by the node material editor
  103452. * @param snippetId defines the snippet to load
  103453. * @param scene defines the hosting scene
  103454. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103455. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103456. * @returns a promise that will resolve to the new node material
  103457. */
  103458. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103459. /**
  103460. * Creates a new node material set to default basic configuration
  103461. * @param name defines the name of the material
  103462. * @param scene defines the hosting scene
  103463. * @returns a new NodeMaterial
  103464. */
  103465. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103466. }
  103467. }
  103468. declare module BABYLON {
  103469. interface ThinEngine {
  103470. /**
  103471. * Unbind a list of render target textures from the webGL context
  103472. * This is used only when drawBuffer extension or webGL2 are active
  103473. * @param textures defines the render target textures to unbind
  103474. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103475. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103476. */
  103477. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103478. /**
  103479. * Create a multi render target texture
  103480. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103481. * @param size defines the size of the texture
  103482. * @param options defines the creation options
  103483. * @returns the cube texture as an InternalTexture
  103484. */
  103485. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103486. /**
  103487. * Update the sample count for a given multiple render target texture
  103488. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103489. * @param textures defines the textures to update
  103490. * @param samples defines the sample count to set
  103491. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103492. */
  103493. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103494. /**
  103495. * Select a subsets of attachments to draw to.
  103496. * @param attachments gl attachments
  103497. */
  103498. bindAttachments(attachments: number[]): void;
  103499. /**
  103500. * Creates a layout object to draw/clear on specific textures in a MRT
  103501. * @param textureStatus textureStatus[i] indicates if the i-th is active
  103502. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  103503. */
  103504. buildTextureLayout(textureStatus: boolean[]): number[];
  103505. /**
  103506. * Restores the webgl state to only draw on the main color attachment
  103507. */
  103508. restoreSingleAttachment(): void;
  103509. }
  103510. }
  103511. declare module BABYLON {
  103512. /**
  103513. * Creation options of the multi render target texture.
  103514. */
  103515. export interface IMultiRenderTargetOptions {
  103516. /**
  103517. * Define if the texture needs to create mip maps after render.
  103518. */
  103519. generateMipMaps?: boolean;
  103520. /**
  103521. * Define the types of all the draw buffers we want to create
  103522. */
  103523. types?: number[];
  103524. /**
  103525. * Define the sampling modes of all the draw buffers we want to create
  103526. */
  103527. samplingModes?: number[];
  103528. /**
  103529. * Define if a depth buffer is required
  103530. */
  103531. generateDepthBuffer?: boolean;
  103532. /**
  103533. * Define if a stencil buffer is required
  103534. */
  103535. generateStencilBuffer?: boolean;
  103536. /**
  103537. * Define if a depth texture is required instead of a depth buffer
  103538. */
  103539. generateDepthTexture?: boolean;
  103540. /**
  103541. * Define the number of desired draw buffers
  103542. */
  103543. textureCount?: number;
  103544. /**
  103545. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103546. */
  103547. doNotChangeAspectRatio?: boolean;
  103548. /**
  103549. * Define the default type of the buffers we are creating
  103550. */
  103551. defaultType?: number;
  103552. }
  103553. /**
  103554. * A multi render target, like a render target provides the ability to render to a texture.
  103555. * Unlike the render target, it can render to several draw buffers in one draw.
  103556. * This is specially interesting in deferred rendering or for any effects requiring more than
  103557. * just one color from a single pass.
  103558. */
  103559. export class MultiRenderTarget extends RenderTargetTexture {
  103560. private _internalTextures;
  103561. private _textures;
  103562. private _multiRenderTargetOptions;
  103563. private _count;
  103564. /**
  103565. * Get if draw buffers are currently supported by the used hardware and browser.
  103566. */
  103567. get isSupported(): boolean;
  103568. /**
  103569. * Get the list of textures generated by the multi render target.
  103570. */
  103571. get textures(): Texture[];
  103572. /**
  103573. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103574. */
  103575. get count(): number;
  103576. /**
  103577. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103578. */
  103579. get depthTexture(): Texture;
  103580. /**
  103581. * Set the wrapping mode on U of all the textures we are rendering to.
  103582. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103583. */
  103584. set wrapU(wrap: number);
  103585. /**
  103586. * Set the wrapping mode on V of all the textures we are rendering to.
  103587. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103588. */
  103589. set wrapV(wrap: number);
  103590. /**
  103591. * Instantiate a new multi render target texture.
  103592. * A multi render target, like a render target provides the ability to render to a texture.
  103593. * Unlike the render target, it can render to several draw buffers in one draw.
  103594. * This is specially interesting in deferred rendering or for any effects requiring more than
  103595. * just one color from a single pass.
  103596. * @param name Define the name of the texture
  103597. * @param size Define the size of the buffers to render to
  103598. * @param count Define the number of target we are rendering into
  103599. * @param scene Define the scene the texture belongs to
  103600. * @param options Define the options used to create the multi render target
  103601. */
  103602. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103603. private _initTypes;
  103604. /** @hidden */
  103605. _rebuild(forceFullRebuild?: boolean): void;
  103606. private _createInternalTextures;
  103607. private _createTextures;
  103608. /**
  103609. * Replaces a texture within the MRT.
  103610. * @param texture The new texture to insert in the MRT
  103611. * @param index The index of the texture to replace
  103612. */
  103613. replaceTexture(texture: Texture, index: number): void;
  103614. /**
  103615. * Define the number of samples used if MSAA is enabled.
  103616. */
  103617. get samples(): number;
  103618. set samples(value: number);
  103619. /**
  103620. * Resize all the textures in the multi render target.
  103621. * Be careful as it will recreate all the data in the new texture.
  103622. * @param size Define the new size
  103623. */
  103624. resize(size: any): void;
  103625. /**
  103626. * Changes the number of render targets in this MRT
  103627. * Be careful as it will recreate all the data in the new texture.
  103628. * @param count new texture count
  103629. * @param options Specifies texture types and sampling modes for new textures
  103630. */
  103631. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  103632. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103633. /**
  103634. * Dispose the render targets and their associated resources
  103635. */
  103636. dispose(): void;
  103637. /**
  103638. * Release all the underlying texture used as draw buffers.
  103639. */
  103640. releaseInternalTextures(): void;
  103641. }
  103642. }
  103643. declare module BABYLON {
  103644. /** @hidden */
  103645. export var imageProcessingPixelShader: {
  103646. name: string;
  103647. shader: string;
  103648. };
  103649. }
  103650. declare module BABYLON {
  103651. /**
  103652. * ImageProcessingPostProcess
  103653. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103654. */
  103655. export class ImageProcessingPostProcess extends PostProcess {
  103656. /**
  103657. * Default configuration related to image processing available in the PBR Material.
  103658. */
  103659. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103660. /**
  103661. * Gets the image processing configuration used either in this material.
  103662. */
  103663. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103664. /**
  103665. * Sets the Default image processing configuration used either in the this material.
  103666. *
  103667. * If sets to null, the scene one is in use.
  103668. */
  103669. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103670. /**
  103671. * Keep track of the image processing observer to allow dispose and replace.
  103672. */
  103673. private _imageProcessingObserver;
  103674. /**
  103675. * Attaches a new image processing configuration to the PBR Material.
  103676. * @param configuration
  103677. */
  103678. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103679. /**
  103680. * If the post process is supported.
  103681. */
  103682. get isSupported(): boolean;
  103683. /**
  103684. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103685. */
  103686. get colorCurves(): Nullable<ColorCurves>;
  103687. /**
  103688. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103689. */
  103690. set colorCurves(value: Nullable<ColorCurves>);
  103691. /**
  103692. * Gets wether the color curves effect is enabled.
  103693. */
  103694. get colorCurvesEnabled(): boolean;
  103695. /**
  103696. * Sets wether the color curves effect is enabled.
  103697. */
  103698. set colorCurvesEnabled(value: boolean);
  103699. /**
  103700. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103701. */
  103702. get colorGradingTexture(): Nullable<BaseTexture>;
  103703. /**
  103704. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103705. */
  103706. set colorGradingTexture(value: Nullable<BaseTexture>);
  103707. /**
  103708. * Gets wether the color grading effect is enabled.
  103709. */
  103710. get colorGradingEnabled(): boolean;
  103711. /**
  103712. * Gets wether the color grading effect is enabled.
  103713. */
  103714. set colorGradingEnabled(value: boolean);
  103715. /**
  103716. * Gets exposure used in the effect.
  103717. */
  103718. get exposure(): number;
  103719. /**
  103720. * Sets exposure used in the effect.
  103721. */
  103722. set exposure(value: number);
  103723. /**
  103724. * Gets wether tonemapping is enabled or not.
  103725. */
  103726. get toneMappingEnabled(): boolean;
  103727. /**
  103728. * Sets wether tonemapping is enabled or not
  103729. */
  103730. set toneMappingEnabled(value: boolean);
  103731. /**
  103732. * Gets the type of tone mapping effect.
  103733. */
  103734. get toneMappingType(): number;
  103735. /**
  103736. * Sets the type of tone mapping effect.
  103737. */
  103738. set toneMappingType(value: number);
  103739. /**
  103740. * Gets contrast used in the effect.
  103741. */
  103742. get contrast(): number;
  103743. /**
  103744. * Sets contrast used in the effect.
  103745. */
  103746. set contrast(value: number);
  103747. /**
  103748. * Gets Vignette stretch size.
  103749. */
  103750. get vignetteStretch(): number;
  103751. /**
  103752. * Sets Vignette stretch size.
  103753. */
  103754. set vignetteStretch(value: number);
  103755. /**
  103756. * Gets Vignette centre X Offset.
  103757. */
  103758. get vignetteCentreX(): number;
  103759. /**
  103760. * Sets Vignette centre X Offset.
  103761. */
  103762. set vignetteCentreX(value: number);
  103763. /**
  103764. * Gets Vignette centre Y Offset.
  103765. */
  103766. get vignetteCentreY(): number;
  103767. /**
  103768. * Sets Vignette centre Y Offset.
  103769. */
  103770. set vignetteCentreY(value: number);
  103771. /**
  103772. * Gets Vignette weight or intensity of the vignette effect.
  103773. */
  103774. get vignetteWeight(): number;
  103775. /**
  103776. * Sets Vignette weight or intensity of the vignette effect.
  103777. */
  103778. set vignetteWeight(value: number);
  103779. /**
  103780. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103781. * if vignetteEnabled is set to true.
  103782. */
  103783. get vignetteColor(): Color4;
  103784. /**
  103785. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103786. * if vignetteEnabled is set to true.
  103787. */
  103788. set vignetteColor(value: Color4);
  103789. /**
  103790. * Gets Camera field of view used by the Vignette effect.
  103791. */
  103792. get vignetteCameraFov(): number;
  103793. /**
  103794. * Sets Camera field of view used by the Vignette effect.
  103795. */
  103796. set vignetteCameraFov(value: number);
  103797. /**
  103798. * Gets the vignette blend mode allowing different kind of effect.
  103799. */
  103800. get vignetteBlendMode(): number;
  103801. /**
  103802. * Sets the vignette blend mode allowing different kind of effect.
  103803. */
  103804. set vignetteBlendMode(value: number);
  103805. /**
  103806. * Gets wether the vignette effect is enabled.
  103807. */
  103808. get vignetteEnabled(): boolean;
  103809. /**
  103810. * Sets wether the vignette effect is enabled.
  103811. */
  103812. set vignetteEnabled(value: boolean);
  103813. private _fromLinearSpace;
  103814. /**
  103815. * Gets wether the input of the processing is in Gamma or Linear Space.
  103816. */
  103817. get fromLinearSpace(): boolean;
  103818. /**
  103819. * Sets wether the input of the processing is in Gamma or Linear Space.
  103820. */
  103821. set fromLinearSpace(value: boolean);
  103822. /**
  103823. * Defines cache preventing GC.
  103824. */
  103825. private _defines;
  103826. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103827. /**
  103828. * "ImageProcessingPostProcess"
  103829. * @returns "ImageProcessingPostProcess"
  103830. */
  103831. getClassName(): string;
  103832. /**
  103833. * @hidden
  103834. */
  103835. _updateParameters(): void;
  103836. dispose(camera?: Camera): void;
  103837. }
  103838. }
  103839. declare module BABYLON {
  103840. /**
  103841. * Interface for defining prepass effects in the prepass post-process pipeline
  103842. */
  103843. export interface PrePassEffectConfiguration {
  103844. /**
  103845. * Name of the effect
  103846. */
  103847. name: string;
  103848. /**
  103849. * Post process to attach for this effect
  103850. */
  103851. postProcess?: PostProcess;
  103852. /**
  103853. * Textures required in the MRT
  103854. */
  103855. texturesRequired: number[];
  103856. /**
  103857. * Is the effect enabled
  103858. */
  103859. enabled: boolean;
  103860. /**
  103861. * Disposes the effect configuration
  103862. */
  103863. dispose?: () => void;
  103864. /**
  103865. * Creates the associated post process
  103866. */
  103867. createPostProcess?: () => PostProcess;
  103868. }
  103869. }
  103870. declare module BABYLON {
  103871. /**
  103872. * Options to be used when creating a FresnelParameters.
  103873. */
  103874. export type IFresnelParametersCreationOptions = {
  103875. /**
  103876. * Define the color used on edges (grazing angle)
  103877. */
  103878. leftColor?: Color3;
  103879. /**
  103880. * Define the color used on center
  103881. */
  103882. rightColor?: Color3;
  103883. /**
  103884. * Define bias applied to computed fresnel term
  103885. */
  103886. bias?: number;
  103887. /**
  103888. * Defined the power exponent applied to fresnel term
  103889. */
  103890. power?: number;
  103891. /**
  103892. * Define if the fresnel effect is enable or not.
  103893. */
  103894. isEnabled?: boolean;
  103895. };
  103896. /**
  103897. * Serialized format for FresnelParameters.
  103898. */
  103899. export type IFresnelParametersSerialized = {
  103900. /**
  103901. * Define the color used on edges (grazing angle) [as an array]
  103902. */
  103903. leftColor: number[];
  103904. /**
  103905. * Define the color used on center [as an array]
  103906. */
  103907. rightColor: number[];
  103908. /**
  103909. * Define bias applied to computed fresnel term
  103910. */
  103911. bias: number;
  103912. /**
  103913. * Defined the power exponent applied to fresnel term
  103914. */
  103915. power?: number;
  103916. /**
  103917. * Define if the fresnel effect is enable or not.
  103918. */
  103919. isEnabled: boolean;
  103920. };
  103921. /**
  103922. * This represents all the required information to add a fresnel effect on a material:
  103923. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103924. */
  103925. export class FresnelParameters {
  103926. private _isEnabled;
  103927. /**
  103928. * Define if the fresnel effect is enable or not.
  103929. */
  103930. get isEnabled(): boolean;
  103931. set isEnabled(value: boolean);
  103932. /**
  103933. * Define the color used on edges (grazing angle)
  103934. */
  103935. leftColor: Color3;
  103936. /**
  103937. * Define the color used on center
  103938. */
  103939. rightColor: Color3;
  103940. /**
  103941. * Define bias applied to computed fresnel term
  103942. */
  103943. bias: number;
  103944. /**
  103945. * Defined the power exponent applied to fresnel term
  103946. */
  103947. power: number;
  103948. /**
  103949. * Creates a new FresnelParameters object.
  103950. *
  103951. * @param options provide your own settings to optionally to override defaults
  103952. */
  103953. constructor(options?: IFresnelParametersCreationOptions);
  103954. /**
  103955. * Clones the current fresnel and its valuues
  103956. * @returns a clone fresnel configuration
  103957. */
  103958. clone(): FresnelParameters;
  103959. /**
  103960. * Determines equality between FresnelParameters objects
  103961. * @param otherFresnelParameters defines the second operand
  103962. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  103963. */
  103964. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  103965. /**
  103966. * Serializes the current fresnel parameters to a JSON representation.
  103967. * @return the JSON serialization
  103968. */
  103969. serialize(): IFresnelParametersSerialized;
  103970. /**
  103971. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  103972. * @param parsedFresnelParameters Define the JSON representation
  103973. * @returns the parsed parameters
  103974. */
  103975. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  103976. }
  103977. }
  103978. declare module BABYLON {
  103979. /**
  103980. * This groups all the flags used to control the materials channel.
  103981. */
  103982. export class MaterialFlags {
  103983. private static _DiffuseTextureEnabled;
  103984. /**
  103985. * Are diffuse textures enabled in the application.
  103986. */
  103987. static get DiffuseTextureEnabled(): boolean;
  103988. static set DiffuseTextureEnabled(value: boolean);
  103989. private static _DetailTextureEnabled;
  103990. /**
  103991. * Are detail textures enabled in the application.
  103992. */
  103993. static get DetailTextureEnabled(): boolean;
  103994. static set DetailTextureEnabled(value: boolean);
  103995. private static _AmbientTextureEnabled;
  103996. /**
  103997. * Are ambient textures enabled in the application.
  103998. */
  103999. static get AmbientTextureEnabled(): boolean;
  104000. static set AmbientTextureEnabled(value: boolean);
  104001. private static _OpacityTextureEnabled;
  104002. /**
  104003. * Are opacity textures enabled in the application.
  104004. */
  104005. static get OpacityTextureEnabled(): boolean;
  104006. static set OpacityTextureEnabled(value: boolean);
  104007. private static _ReflectionTextureEnabled;
  104008. /**
  104009. * Are reflection textures enabled in the application.
  104010. */
  104011. static get ReflectionTextureEnabled(): boolean;
  104012. static set ReflectionTextureEnabled(value: boolean);
  104013. private static _EmissiveTextureEnabled;
  104014. /**
  104015. * Are emissive textures enabled in the application.
  104016. */
  104017. static get EmissiveTextureEnabled(): boolean;
  104018. static set EmissiveTextureEnabled(value: boolean);
  104019. private static _SpecularTextureEnabled;
  104020. /**
  104021. * Are specular textures enabled in the application.
  104022. */
  104023. static get SpecularTextureEnabled(): boolean;
  104024. static set SpecularTextureEnabled(value: boolean);
  104025. private static _BumpTextureEnabled;
  104026. /**
  104027. * Are bump textures enabled in the application.
  104028. */
  104029. static get BumpTextureEnabled(): boolean;
  104030. static set BumpTextureEnabled(value: boolean);
  104031. private static _LightmapTextureEnabled;
  104032. /**
  104033. * Are lightmap textures enabled in the application.
  104034. */
  104035. static get LightmapTextureEnabled(): boolean;
  104036. static set LightmapTextureEnabled(value: boolean);
  104037. private static _RefractionTextureEnabled;
  104038. /**
  104039. * Are refraction textures enabled in the application.
  104040. */
  104041. static get RefractionTextureEnabled(): boolean;
  104042. static set RefractionTextureEnabled(value: boolean);
  104043. private static _ColorGradingTextureEnabled;
  104044. /**
  104045. * Are color grading textures enabled in the application.
  104046. */
  104047. static get ColorGradingTextureEnabled(): boolean;
  104048. static set ColorGradingTextureEnabled(value: boolean);
  104049. private static _FresnelEnabled;
  104050. /**
  104051. * Are fresnels enabled in the application.
  104052. */
  104053. static get FresnelEnabled(): boolean;
  104054. static set FresnelEnabled(value: boolean);
  104055. private static _ClearCoatTextureEnabled;
  104056. /**
  104057. * Are clear coat textures enabled in the application.
  104058. */
  104059. static get ClearCoatTextureEnabled(): boolean;
  104060. static set ClearCoatTextureEnabled(value: boolean);
  104061. private static _ClearCoatBumpTextureEnabled;
  104062. /**
  104063. * Are clear coat bump textures enabled in the application.
  104064. */
  104065. static get ClearCoatBumpTextureEnabled(): boolean;
  104066. static set ClearCoatBumpTextureEnabled(value: boolean);
  104067. private static _ClearCoatTintTextureEnabled;
  104068. /**
  104069. * Are clear coat tint textures enabled in the application.
  104070. */
  104071. static get ClearCoatTintTextureEnabled(): boolean;
  104072. static set ClearCoatTintTextureEnabled(value: boolean);
  104073. private static _SheenTextureEnabled;
  104074. /**
  104075. * Are sheen textures enabled in the application.
  104076. */
  104077. static get SheenTextureEnabled(): boolean;
  104078. static set SheenTextureEnabled(value: boolean);
  104079. private static _AnisotropicTextureEnabled;
  104080. /**
  104081. * Are anisotropic textures enabled in the application.
  104082. */
  104083. static get AnisotropicTextureEnabled(): boolean;
  104084. static set AnisotropicTextureEnabled(value: boolean);
  104085. private static _ThicknessTextureEnabled;
  104086. /**
  104087. * Are thickness textures enabled in the application.
  104088. */
  104089. static get ThicknessTextureEnabled(): boolean;
  104090. static set ThicknessTextureEnabled(value: boolean);
  104091. }
  104092. }
  104093. declare module BABYLON {
  104094. /** @hidden */
  104095. export var defaultFragmentDeclaration: {
  104096. name: string;
  104097. shader: string;
  104098. };
  104099. }
  104100. declare module BABYLON {
  104101. /** @hidden */
  104102. export var defaultUboDeclaration: {
  104103. name: string;
  104104. shader: string;
  104105. };
  104106. }
  104107. declare module BABYLON {
  104108. /** @hidden */
  104109. export var prePassDeclaration: {
  104110. name: string;
  104111. shader: string;
  104112. };
  104113. }
  104114. declare module BABYLON {
  104115. /** @hidden */
  104116. export var lightFragmentDeclaration: {
  104117. name: string;
  104118. shader: string;
  104119. };
  104120. }
  104121. declare module BABYLON {
  104122. /** @hidden */
  104123. export var lightUboDeclaration: {
  104124. name: string;
  104125. shader: string;
  104126. };
  104127. }
  104128. declare module BABYLON {
  104129. /** @hidden */
  104130. export var lightsFragmentFunctions: {
  104131. name: string;
  104132. shader: string;
  104133. };
  104134. }
  104135. declare module BABYLON {
  104136. /** @hidden */
  104137. export var shadowsFragmentFunctions: {
  104138. name: string;
  104139. shader: string;
  104140. };
  104141. }
  104142. declare module BABYLON {
  104143. /** @hidden */
  104144. export var fresnelFunction: {
  104145. name: string;
  104146. shader: string;
  104147. };
  104148. }
  104149. declare module BABYLON {
  104150. /** @hidden */
  104151. export var bumpFragmentMainFunctions: {
  104152. name: string;
  104153. shader: string;
  104154. };
  104155. }
  104156. declare module BABYLON {
  104157. /** @hidden */
  104158. export var bumpFragmentFunctions: {
  104159. name: string;
  104160. shader: string;
  104161. };
  104162. }
  104163. declare module BABYLON {
  104164. /** @hidden */
  104165. export var logDepthDeclaration: {
  104166. name: string;
  104167. shader: string;
  104168. };
  104169. }
  104170. declare module BABYLON {
  104171. /** @hidden */
  104172. export var bumpFragment: {
  104173. name: string;
  104174. shader: string;
  104175. };
  104176. }
  104177. declare module BABYLON {
  104178. /** @hidden */
  104179. export var depthPrePass: {
  104180. name: string;
  104181. shader: string;
  104182. };
  104183. }
  104184. declare module BABYLON {
  104185. /** @hidden */
  104186. export var lightFragment: {
  104187. name: string;
  104188. shader: string;
  104189. };
  104190. }
  104191. declare module BABYLON {
  104192. /** @hidden */
  104193. export var logDepthFragment: {
  104194. name: string;
  104195. shader: string;
  104196. };
  104197. }
  104198. declare module BABYLON {
  104199. /** @hidden */
  104200. export var defaultPixelShader: {
  104201. name: string;
  104202. shader: string;
  104203. };
  104204. }
  104205. declare module BABYLON {
  104206. /** @hidden */
  104207. export var defaultVertexDeclaration: {
  104208. name: string;
  104209. shader: string;
  104210. };
  104211. }
  104212. declare module BABYLON {
  104213. /** @hidden */
  104214. export var prePassVertexDeclaration: {
  104215. name: string;
  104216. shader: string;
  104217. };
  104218. }
  104219. declare module BABYLON {
  104220. /** @hidden */
  104221. export var bumpVertexDeclaration: {
  104222. name: string;
  104223. shader: string;
  104224. };
  104225. }
  104226. declare module BABYLON {
  104227. /** @hidden */
  104228. export var prePassVertex: {
  104229. name: string;
  104230. shader: string;
  104231. };
  104232. }
  104233. declare module BABYLON {
  104234. /** @hidden */
  104235. export var bumpVertex: {
  104236. name: string;
  104237. shader: string;
  104238. };
  104239. }
  104240. declare module BABYLON {
  104241. /** @hidden */
  104242. export var fogVertex: {
  104243. name: string;
  104244. shader: string;
  104245. };
  104246. }
  104247. declare module BABYLON {
  104248. /** @hidden */
  104249. export var shadowsVertex: {
  104250. name: string;
  104251. shader: string;
  104252. };
  104253. }
  104254. declare module BABYLON {
  104255. /** @hidden */
  104256. export var pointCloudVertex: {
  104257. name: string;
  104258. shader: string;
  104259. };
  104260. }
  104261. declare module BABYLON {
  104262. /** @hidden */
  104263. export var logDepthVertex: {
  104264. name: string;
  104265. shader: string;
  104266. };
  104267. }
  104268. declare module BABYLON {
  104269. /** @hidden */
  104270. export var defaultVertexShader: {
  104271. name: string;
  104272. shader: string;
  104273. };
  104274. }
  104275. declare module BABYLON {
  104276. /**
  104277. * @hidden
  104278. */
  104279. export interface IMaterialDetailMapDefines {
  104280. DETAIL: boolean;
  104281. DETAILDIRECTUV: number;
  104282. DETAIL_NORMALBLENDMETHOD: number;
  104283. /** @hidden */
  104284. _areTexturesDirty: boolean;
  104285. }
  104286. /**
  104287. * Define the code related to the detail map parameters of a material
  104288. *
  104289. * Inspired from:
  104290. * 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
  104291. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  104292. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  104293. */
  104294. export class DetailMapConfiguration {
  104295. private _texture;
  104296. /**
  104297. * The detail texture of the material.
  104298. */
  104299. texture: Nullable<BaseTexture>;
  104300. /**
  104301. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  104302. * Bigger values mean stronger blending
  104303. */
  104304. diffuseBlendLevel: number;
  104305. /**
  104306. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  104307. * Bigger values mean stronger blending. Only used with PBR materials
  104308. */
  104309. roughnessBlendLevel: number;
  104310. /**
  104311. * Defines how strong the bump effect from the detail map is
  104312. * Bigger values mean stronger effect
  104313. */
  104314. bumpLevel: number;
  104315. private _normalBlendMethod;
  104316. /**
  104317. * The method used to blend the bump and detail normals together
  104318. */
  104319. normalBlendMethod: number;
  104320. private _isEnabled;
  104321. /**
  104322. * Enable or disable the detail map on this material
  104323. */
  104324. isEnabled: boolean;
  104325. /** @hidden */
  104326. private _internalMarkAllSubMeshesAsTexturesDirty;
  104327. /** @hidden */
  104328. _markAllSubMeshesAsTexturesDirty(): void;
  104329. /**
  104330. * Instantiate a new detail map
  104331. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104332. */
  104333. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104334. /**
  104335. * Gets whether the submesh is ready to be used or not.
  104336. * @param defines the list of "defines" to update.
  104337. * @param scene defines the scene the material belongs to.
  104338. * @returns - boolean indicating that the submesh is ready or not.
  104339. */
  104340. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  104341. /**
  104342. * Update the defines for detail map usage
  104343. * @param defines the list of "defines" to update.
  104344. * @param scene defines the scene the material belongs to.
  104345. */
  104346. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  104347. /**
  104348. * Binds the material data.
  104349. * @param uniformBuffer defines the Uniform buffer to fill in.
  104350. * @param scene defines the scene the material belongs to.
  104351. * @param isFrozen defines whether the material is frozen or not.
  104352. */
  104353. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104354. /**
  104355. * Checks to see if a texture is used in the material.
  104356. * @param texture - Base texture to use.
  104357. * @returns - Boolean specifying if a texture is used in the material.
  104358. */
  104359. hasTexture(texture: BaseTexture): boolean;
  104360. /**
  104361. * Returns an array of the actively used textures.
  104362. * @param activeTextures Array of BaseTextures
  104363. */
  104364. getActiveTextures(activeTextures: BaseTexture[]): void;
  104365. /**
  104366. * Returns the animatable textures.
  104367. * @param animatables Array of animatable textures.
  104368. */
  104369. getAnimatables(animatables: IAnimatable[]): void;
  104370. /**
  104371. * Disposes the resources of the material.
  104372. * @param forceDisposeTextures - Forces the disposal of all textures.
  104373. */
  104374. dispose(forceDisposeTextures?: boolean): void;
  104375. /**
  104376. * Get the current class name useful for serialization or dynamic coding.
  104377. * @returns "DetailMap"
  104378. */
  104379. getClassName(): string;
  104380. /**
  104381. * Add the required uniforms to the current list.
  104382. * @param uniforms defines the current uniform list.
  104383. */
  104384. static AddUniforms(uniforms: string[]): void;
  104385. /**
  104386. * Add the required samplers to the current list.
  104387. * @param samplers defines the current sampler list.
  104388. */
  104389. static AddSamplers(samplers: string[]): void;
  104390. /**
  104391. * Add the required uniforms to the current buffer.
  104392. * @param uniformBuffer defines the current uniform buffer.
  104393. */
  104394. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104395. /**
  104396. * Makes a duplicate of the current instance into another one.
  104397. * @param detailMap define the instance where to copy the info
  104398. */
  104399. copyTo(detailMap: DetailMapConfiguration): void;
  104400. /**
  104401. * Serializes this detail map instance
  104402. * @returns - An object with the serialized instance.
  104403. */
  104404. serialize(): any;
  104405. /**
  104406. * Parses a detail map setting from a serialized object.
  104407. * @param source - Serialized object.
  104408. * @param scene Defines the scene we are parsing for
  104409. * @param rootUrl Defines the rootUrl to load from
  104410. */
  104411. parse(source: any, scene: Scene, rootUrl: string): void;
  104412. }
  104413. }
  104414. declare module BABYLON {
  104415. /** @hidden */
  104416. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  104417. MAINUV1: boolean;
  104418. MAINUV2: boolean;
  104419. DIFFUSE: boolean;
  104420. DIFFUSEDIRECTUV: number;
  104421. DETAIL: boolean;
  104422. DETAILDIRECTUV: number;
  104423. DETAIL_NORMALBLENDMETHOD: number;
  104424. AMBIENT: boolean;
  104425. AMBIENTDIRECTUV: number;
  104426. OPACITY: boolean;
  104427. OPACITYDIRECTUV: number;
  104428. OPACITYRGB: boolean;
  104429. REFLECTION: boolean;
  104430. EMISSIVE: boolean;
  104431. EMISSIVEDIRECTUV: number;
  104432. SPECULAR: boolean;
  104433. SPECULARDIRECTUV: number;
  104434. BUMP: boolean;
  104435. BUMPDIRECTUV: number;
  104436. PARALLAX: boolean;
  104437. PARALLAXOCCLUSION: boolean;
  104438. SPECULAROVERALPHA: boolean;
  104439. CLIPPLANE: boolean;
  104440. CLIPPLANE2: boolean;
  104441. CLIPPLANE3: boolean;
  104442. CLIPPLANE4: boolean;
  104443. CLIPPLANE5: boolean;
  104444. CLIPPLANE6: boolean;
  104445. ALPHATEST: boolean;
  104446. DEPTHPREPASS: boolean;
  104447. ALPHAFROMDIFFUSE: boolean;
  104448. POINTSIZE: boolean;
  104449. FOG: boolean;
  104450. SPECULARTERM: boolean;
  104451. DIFFUSEFRESNEL: boolean;
  104452. OPACITYFRESNEL: boolean;
  104453. REFLECTIONFRESNEL: boolean;
  104454. REFRACTIONFRESNEL: boolean;
  104455. EMISSIVEFRESNEL: boolean;
  104456. FRESNEL: boolean;
  104457. NORMAL: boolean;
  104458. UV1: boolean;
  104459. UV2: boolean;
  104460. VERTEXCOLOR: boolean;
  104461. VERTEXALPHA: boolean;
  104462. NUM_BONE_INFLUENCERS: number;
  104463. BonesPerMesh: number;
  104464. BONETEXTURE: boolean;
  104465. BONES_VELOCITY_ENABLED: boolean;
  104466. INSTANCES: boolean;
  104467. THIN_INSTANCES: boolean;
  104468. GLOSSINESS: boolean;
  104469. ROUGHNESS: boolean;
  104470. EMISSIVEASILLUMINATION: boolean;
  104471. LINKEMISSIVEWITHDIFFUSE: boolean;
  104472. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104473. LIGHTMAP: boolean;
  104474. LIGHTMAPDIRECTUV: number;
  104475. OBJECTSPACE_NORMALMAP: boolean;
  104476. USELIGHTMAPASSHADOWMAP: boolean;
  104477. REFLECTIONMAP_3D: boolean;
  104478. REFLECTIONMAP_SPHERICAL: boolean;
  104479. REFLECTIONMAP_PLANAR: boolean;
  104480. REFLECTIONMAP_CUBIC: boolean;
  104481. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104482. REFLECTIONMAP_PROJECTION: boolean;
  104483. REFLECTIONMAP_SKYBOX: boolean;
  104484. REFLECTIONMAP_EXPLICIT: boolean;
  104485. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104486. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104487. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104488. INVERTCUBICMAP: boolean;
  104489. LOGARITHMICDEPTH: boolean;
  104490. REFRACTION: boolean;
  104491. REFRACTIONMAP_3D: boolean;
  104492. REFLECTIONOVERALPHA: boolean;
  104493. TWOSIDEDLIGHTING: boolean;
  104494. SHADOWFLOAT: boolean;
  104495. MORPHTARGETS: boolean;
  104496. MORPHTARGETS_NORMAL: boolean;
  104497. MORPHTARGETS_TANGENT: boolean;
  104498. MORPHTARGETS_UV: boolean;
  104499. NUM_MORPH_INFLUENCERS: number;
  104500. NONUNIFORMSCALING: boolean;
  104501. PREMULTIPLYALPHA: boolean;
  104502. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  104503. ALPHABLEND: boolean;
  104504. PREPASS: boolean;
  104505. PREPASS_IRRADIANCE: boolean;
  104506. PREPASS_IRRADIANCE_INDEX: number;
  104507. PREPASS_ALBEDO: boolean;
  104508. PREPASS_ALBEDO_INDEX: number;
  104509. PREPASS_DEPTHNORMAL: boolean;
  104510. PREPASS_DEPTHNORMAL_INDEX: number;
  104511. PREPASS_POSITION: boolean;
  104512. PREPASS_POSITION_INDEX: number;
  104513. PREPASS_VELOCITY: boolean;
  104514. PREPASS_VELOCITY_INDEX: number;
  104515. PREPASS_REFLECTIVITY: boolean;
  104516. PREPASS_REFLECTIVITY_INDEX: number;
  104517. SCENE_MRT_COUNT: number;
  104518. RGBDLIGHTMAP: boolean;
  104519. RGBDREFLECTION: boolean;
  104520. RGBDREFRACTION: boolean;
  104521. IMAGEPROCESSING: boolean;
  104522. VIGNETTE: boolean;
  104523. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104524. VIGNETTEBLENDMODEOPAQUE: boolean;
  104525. TONEMAPPING: boolean;
  104526. TONEMAPPING_ACES: boolean;
  104527. CONTRAST: boolean;
  104528. COLORCURVES: boolean;
  104529. COLORGRADING: boolean;
  104530. COLORGRADING3D: boolean;
  104531. SAMPLER3DGREENDEPTH: boolean;
  104532. SAMPLER3DBGRMAP: boolean;
  104533. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104534. MULTIVIEW: boolean;
  104535. /**
  104536. * If the reflection texture on this material is in linear color space
  104537. * @hidden
  104538. */
  104539. IS_REFLECTION_LINEAR: boolean;
  104540. /**
  104541. * If the refraction texture on this material is in linear color space
  104542. * @hidden
  104543. */
  104544. IS_REFRACTION_LINEAR: boolean;
  104545. EXPOSURE: boolean;
  104546. constructor();
  104547. setReflectionMode(modeToEnable: string): void;
  104548. }
  104549. /**
  104550. * This is the default material used in Babylon. It is the best trade off between quality
  104551. * and performances.
  104552. * @see https://doc.babylonjs.com/babylon101/materials
  104553. */
  104554. export class StandardMaterial extends PushMaterial {
  104555. private _diffuseTexture;
  104556. /**
  104557. * The basic texture of the material as viewed under a light.
  104558. */
  104559. diffuseTexture: Nullable<BaseTexture>;
  104560. private _ambientTexture;
  104561. /**
  104562. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104563. */
  104564. ambientTexture: Nullable<BaseTexture>;
  104565. private _opacityTexture;
  104566. /**
  104567. * Define the transparency of the material from a texture.
  104568. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104569. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104570. */
  104571. opacityTexture: Nullable<BaseTexture>;
  104572. private _reflectionTexture;
  104573. /**
  104574. * Define the texture used to display the reflection.
  104575. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104576. */
  104577. reflectionTexture: Nullable<BaseTexture>;
  104578. private _emissiveTexture;
  104579. /**
  104580. * Define texture of the material as if self lit.
  104581. * This will be mixed in the final result even in the absence of light.
  104582. */
  104583. emissiveTexture: Nullable<BaseTexture>;
  104584. private _specularTexture;
  104585. /**
  104586. * Define how the color and intensity of the highlight given by the light in the material.
  104587. */
  104588. specularTexture: Nullable<BaseTexture>;
  104589. private _bumpTexture;
  104590. /**
  104591. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104592. * 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.
  104593. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  104594. */
  104595. bumpTexture: Nullable<BaseTexture>;
  104596. private _lightmapTexture;
  104597. /**
  104598. * Complex lighting can be computationally expensive to compute at runtime.
  104599. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104600. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  104601. */
  104602. lightmapTexture: Nullable<BaseTexture>;
  104603. private _refractionTexture;
  104604. /**
  104605. * Define the texture used to display the refraction.
  104606. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104607. */
  104608. refractionTexture: Nullable<BaseTexture>;
  104609. /**
  104610. * The color of the material lit by the environmental background lighting.
  104611. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104612. */
  104613. ambientColor: Color3;
  104614. /**
  104615. * The basic color of the material as viewed under a light.
  104616. */
  104617. diffuseColor: Color3;
  104618. /**
  104619. * Define how the color and intensity of the highlight given by the light in the material.
  104620. */
  104621. specularColor: Color3;
  104622. /**
  104623. * Define the color of the material as if self lit.
  104624. * This will be mixed in the final result even in the absence of light.
  104625. */
  104626. emissiveColor: Color3;
  104627. /**
  104628. * Defines how sharp are the highlights in the material.
  104629. * The bigger the value the sharper giving a more glossy feeling to the result.
  104630. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104631. */
  104632. specularPower: number;
  104633. private _useAlphaFromDiffuseTexture;
  104634. /**
  104635. * Does the transparency come from the diffuse texture alpha channel.
  104636. */
  104637. useAlphaFromDiffuseTexture: boolean;
  104638. private _useEmissiveAsIllumination;
  104639. /**
  104640. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104641. */
  104642. useEmissiveAsIllumination: boolean;
  104643. private _linkEmissiveWithDiffuse;
  104644. /**
  104645. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104646. * the emissive level when the final color is close to one.
  104647. */
  104648. linkEmissiveWithDiffuse: boolean;
  104649. private _useSpecularOverAlpha;
  104650. /**
  104651. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104652. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104653. */
  104654. useSpecularOverAlpha: boolean;
  104655. private _useReflectionOverAlpha;
  104656. /**
  104657. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104658. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104659. */
  104660. useReflectionOverAlpha: boolean;
  104661. private _disableLighting;
  104662. /**
  104663. * Does lights from the scene impacts this material.
  104664. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104665. */
  104666. disableLighting: boolean;
  104667. private _useObjectSpaceNormalMap;
  104668. /**
  104669. * Allows using an object space normal map (instead of tangent space).
  104670. */
  104671. useObjectSpaceNormalMap: boolean;
  104672. private _useParallax;
  104673. /**
  104674. * Is parallax enabled or not.
  104675. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104676. */
  104677. useParallax: boolean;
  104678. private _useParallaxOcclusion;
  104679. /**
  104680. * Is parallax occlusion enabled or not.
  104681. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104682. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104683. */
  104684. useParallaxOcclusion: boolean;
  104685. /**
  104686. * 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.
  104687. */
  104688. parallaxScaleBias: number;
  104689. private _roughness;
  104690. /**
  104691. * Helps to define how blurry the reflections should appears in the material.
  104692. */
  104693. roughness: number;
  104694. /**
  104695. * In case of refraction, define the value of the index of refraction.
  104696. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104697. */
  104698. indexOfRefraction: number;
  104699. /**
  104700. * Invert the refraction texture alongside the y axis.
  104701. * It can be useful with procedural textures or probe for instance.
  104702. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104703. */
  104704. invertRefractionY: boolean;
  104705. /**
  104706. * Defines the alpha limits in alpha test mode.
  104707. */
  104708. alphaCutOff: number;
  104709. private _useLightmapAsShadowmap;
  104710. /**
  104711. * In case of light mapping, define whether the map contains light or shadow informations.
  104712. */
  104713. useLightmapAsShadowmap: boolean;
  104714. private _diffuseFresnelParameters;
  104715. /**
  104716. * Define the diffuse fresnel parameters of the material.
  104717. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104718. */
  104719. diffuseFresnelParameters: FresnelParameters;
  104720. private _opacityFresnelParameters;
  104721. /**
  104722. * Define the opacity fresnel parameters of the material.
  104723. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104724. */
  104725. opacityFresnelParameters: FresnelParameters;
  104726. private _reflectionFresnelParameters;
  104727. /**
  104728. * Define the reflection fresnel parameters of the material.
  104729. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104730. */
  104731. reflectionFresnelParameters: FresnelParameters;
  104732. private _refractionFresnelParameters;
  104733. /**
  104734. * Define the refraction fresnel parameters of the material.
  104735. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104736. */
  104737. refractionFresnelParameters: FresnelParameters;
  104738. private _emissiveFresnelParameters;
  104739. /**
  104740. * Define the emissive fresnel parameters of the material.
  104741. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104742. */
  104743. emissiveFresnelParameters: FresnelParameters;
  104744. private _useReflectionFresnelFromSpecular;
  104745. /**
  104746. * If true automatically deducts the fresnels values from the material specularity.
  104747. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104748. */
  104749. useReflectionFresnelFromSpecular: boolean;
  104750. private _useGlossinessFromSpecularMapAlpha;
  104751. /**
  104752. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104753. */
  104754. useGlossinessFromSpecularMapAlpha: boolean;
  104755. private _maxSimultaneousLights;
  104756. /**
  104757. * Defines the maximum number of lights that can be used in the material
  104758. */
  104759. maxSimultaneousLights: number;
  104760. private _invertNormalMapX;
  104761. /**
  104762. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104763. */
  104764. invertNormalMapX: boolean;
  104765. private _invertNormalMapY;
  104766. /**
  104767. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104768. */
  104769. invertNormalMapY: boolean;
  104770. private _twoSidedLighting;
  104771. /**
  104772. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104773. */
  104774. twoSidedLighting: boolean;
  104775. /**
  104776. * Default configuration related to image processing available in the standard Material.
  104777. */
  104778. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104779. /**
  104780. * Gets the image processing configuration used either in this material.
  104781. */
  104782. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104783. /**
  104784. * Sets the Default image processing configuration used either in the this material.
  104785. *
  104786. * If sets to null, the scene one is in use.
  104787. */
  104788. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104789. /**
  104790. * Keep track of the image processing observer to allow dispose and replace.
  104791. */
  104792. private _imageProcessingObserver;
  104793. /**
  104794. * Attaches a new image processing configuration to the Standard Material.
  104795. * @param configuration
  104796. */
  104797. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104798. /**
  104799. * Defines additionnal PrePass parameters for the material.
  104800. */
  104801. readonly prePassConfiguration: PrePassConfiguration;
  104802. /**
  104803. * Gets wether the color curves effect is enabled.
  104804. */
  104805. get cameraColorCurvesEnabled(): boolean;
  104806. /**
  104807. * Sets wether the color curves effect is enabled.
  104808. */
  104809. set cameraColorCurvesEnabled(value: boolean);
  104810. /**
  104811. * Gets wether the color grading effect is enabled.
  104812. */
  104813. get cameraColorGradingEnabled(): boolean;
  104814. /**
  104815. * Gets wether the color grading effect is enabled.
  104816. */
  104817. set cameraColorGradingEnabled(value: boolean);
  104818. /**
  104819. * Gets wether tonemapping is enabled or not.
  104820. */
  104821. get cameraToneMappingEnabled(): boolean;
  104822. /**
  104823. * Sets wether tonemapping is enabled or not
  104824. */
  104825. set cameraToneMappingEnabled(value: boolean);
  104826. /**
  104827. * The camera exposure used on this material.
  104828. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104829. * This corresponds to a photographic exposure.
  104830. */
  104831. get cameraExposure(): number;
  104832. /**
  104833. * The camera exposure used on this material.
  104834. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104835. * This corresponds to a photographic exposure.
  104836. */
  104837. set cameraExposure(value: number);
  104838. /**
  104839. * Gets The camera contrast used on this material.
  104840. */
  104841. get cameraContrast(): number;
  104842. /**
  104843. * Sets The camera contrast used on this material.
  104844. */
  104845. set cameraContrast(value: number);
  104846. /**
  104847. * Gets the Color Grading 2D Lookup Texture.
  104848. */
  104849. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  104850. /**
  104851. * Sets the Color Grading 2D Lookup Texture.
  104852. */
  104853. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  104854. /**
  104855. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104856. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104857. * 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;
  104858. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104859. */
  104860. get cameraColorCurves(): Nullable<ColorCurves>;
  104861. /**
  104862. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104863. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104864. * 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;
  104865. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104866. */
  104867. set cameraColorCurves(value: Nullable<ColorCurves>);
  104868. /**
  104869. * Can this material render to several textures at once
  104870. */
  104871. get canRenderToMRT(): boolean;
  104872. /**
  104873. * Defines the detail map parameters for the material.
  104874. */
  104875. readonly detailMap: DetailMapConfiguration;
  104876. protected _renderTargets: SmartArray<RenderTargetTexture>;
  104877. protected _worldViewProjectionMatrix: Matrix;
  104878. protected _globalAmbientColor: Color3;
  104879. protected _useLogarithmicDepth: boolean;
  104880. protected _rebuildInParallel: boolean;
  104881. /**
  104882. * Instantiates a new standard material.
  104883. * This is the default material used in Babylon. It is the best trade off between quality
  104884. * and performances.
  104885. * @see https://doc.babylonjs.com/babylon101/materials
  104886. * @param name Define the name of the material in the scene
  104887. * @param scene Define the scene the material belong to
  104888. */
  104889. constructor(name: string, scene: Scene);
  104890. /**
  104891. * Gets a boolean indicating that current material needs to register RTT
  104892. */
  104893. get hasRenderTargetTextures(): boolean;
  104894. /**
  104895. * Gets the current class name of the material e.g. "StandardMaterial"
  104896. * Mainly use in serialization.
  104897. * @returns the class name
  104898. */
  104899. getClassName(): string;
  104900. /**
  104901. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  104902. * You can try switching to logarithmic depth.
  104903. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  104904. */
  104905. get useLogarithmicDepth(): boolean;
  104906. set useLogarithmicDepth(value: boolean);
  104907. /**
  104908. * Specifies if the material will require alpha blending
  104909. * @returns a boolean specifying if alpha blending is needed
  104910. */
  104911. needAlphaBlending(): boolean;
  104912. /**
  104913. * Specifies if this material should be rendered in alpha test mode
  104914. * @returns a boolean specifying if an alpha test is needed.
  104915. */
  104916. needAlphaTesting(): boolean;
  104917. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  104918. /**
  104919. * Get the texture used for alpha test purpose.
  104920. * @returns the diffuse texture in case of the standard material.
  104921. */
  104922. getAlphaTestTexture(): Nullable<BaseTexture>;
  104923. /**
  104924. * Get if the submesh is ready to be used and all its information available.
  104925. * Child classes can use it to update shaders
  104926. * @param mesh defines the mesh to check
  104927. * @param subMesh defines which submesh to check
  104928. * @param useInstances specifies that instances should be used
  104929. * @returns a boolean indicating that the submesh is ready or not
  104930. */
  104931. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104932. /**
  104933. * Builds the material UBO layouts.
  104934. * Used internally during the effect preparation.
  104935. */
  104936. buildUniformLayout(): void;
  104937. /**
  104938. * Unbinds the material from the mesh
  104939. */
  104940. unbind(): void;
  104941. /**
  104942. * Binds the submesh to this material by preparing the effect and shader to draw
  104943. * @param world defines the world transformation matrix
  104944. * @param mesh defines the mesh containing the submesh
  104945. * @param subMesh defines the submesh to bind the material to
  104946. */
  104947. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104948. /**
  104949. * Get the list of animatables in the material.
  104950. * @returns the list of animatables object used in the material
  104951. */
  104952. getAnimatables(): IAnimatable[];
  104953. /**
  104954. * Gets the active textures from the material
  104955. * @returns an array of textures
  104956. */
  104957. getActiveTextures(): BaseTexture[];
  104958. /**
  104959. * Specifies if the material uses a texture
  104960. * @param texture defines the texture to check against the material
  104961. * @returns a boolean specifying if the material uses the texture
  104962. */
  104963. hasTexture(texture: BaseTexture): boolean;
  104964. /**
  104965. * Disposes the material
  104966. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104967. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104968. */
  104969. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104970. /**
  104971. * Makes a duplicate of the material, and gives it a new name
  104972. * @param name defines the new name for the duplicated material
  104973. * @returns the cloned material
  104974. */
  104975. clone(name: string): StandardMaterial;
  104976. /**
  104977. * Serializes this material in a JSON representation
  104978. * @returns the serialized material object
  104979. */
  104980. serialize(): any;
  104981. /**
  104982. * Creates a standard material from parsed material data
  104983. * @param source defines the JSON representation of the material
  104984. * @param scene defines the hosting scene
  104985. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104986. * @returns a new standard material
  104987. */
  104988. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  104989. /**
  104990. * Are diffuse textures enabled in the application.
  104991. */
  104992. static get DiffuseTextureEnabled(): boolean;
  104993. static set DiffuseTextureEnabled(value: boolean);
  104994. /**
  104995. * Are detail textures enabled in the application.
  104996. */
  104997. static get DetailTextureEnabled(): boolean;
  104998. static set DetailTextureEnabled(value: boolean);
  104999. /**
  105000. * Are ambient textures enabled in the application.
  105001. */
  105002. static get AmbientTextureEnabled(): boolean;
  105003. static set AmbientTextureEnabled(value: boolean);
  105004. /**
  105005. * Are opacity textures enabled in the application.
  105006. */
  105007. static get OpacityTextureEnabled(): boolean;
  105008. static set OpacityTextureEnabled(value: boolean);
  105009. /**
  105010. * Are reflection textures enabled in the application.
  105011. */
  105012. static get ReflectionTextureEnabled(): boolean;
  105013. static set ReflectionTextureEnabled(value: boolean);
  105014. /**
  105015. * Are emissive textures enabled in the application.
  105016. */
  105017. static get EmissiveTextureEnabled(): boolean;
  105018. static set EmissiveTextureEnabled(value: boolean);
  105019. /**
  105020. * Are specular textures enabled in the application.
  105021. */
  105022. static get SpecularTextureEnabled(): boolean;
  105023. static set SpecularTextureEnabled(value: boolean);
  105024. /**
  105025. * Are bump textures enabled in the application.
  105026. */
  105027. static get BumpTextureEnabled(): boolean;
  105028. static set BumpTextureEnabled(value: boolean);
  105029. /**
  105030. * Are lightmap textures enabled in the application.
  105031. */
  105032. static get LightmapTextureEnabled(): boolean;
  105033. static set LightmapTextureEnabled(value: boolean);
  105034. /**
  105035. * Are refraction textures enabled in the application.
  105036. */
  105037. static get RefractionTextureEnabled(): boolean;
  105038. static set RefractionTextureEnabled(value: boolean);
  105039. /**
  105040. * Are color grading textures enabled in the application.
  105041. */
  105042. static get ColorGradingTextureEnabled(): boolean;
  105043. static set ColorGradingTextureEnabled(value: boolean);
  105044. /**
  105045. * Are fresnels enabled in the application.
  105046. */
  105047. static get FresnelEnabled(): boolean;
  105048. static set FresnelEnabled(value: boolean);
  105049. }
  105050. }
  105051. declare module BABYLON {
  105052. /** @hidden */
  105053. export var rgbdDecodePixelShader: {
  105054. name: string;
  105055. shader: string;
  105056. };
  105057. }
  105058. declare module BABYLON {
  105059. /**
  105060. * Class used to host RGBD texture specific utilities
  105061. */
  105062. export class RGBDTextureTools {
  105063. /**
  105064. * Expand the RGBD Texture from RGBD to Half Float if possible.
  105065. * @param texture the texture to expand.
  105066. */
  105067. static ExpandRGBDTexture(texture: Texture): void;
  105068. }
  105069. }
  105070. declare module BABYLON {
  105071. /**
  105072. * Class used to host texture specific utilities
  105073. */
  105074. export class BRDFTextureTools {
  105075. /**
  105076. * Prevents texture cache collision
  105077. */
  105078. private static _instanceNumber;
  105079. /**
  105080. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  105081. * @param scene defines the hosting scene
  105082. * @returns the environment BRDF texture
  105083. */
  105084. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  105085. private static _environmentBRDFBase64Texture;
  105086. }
  105087. }
  105088. declare module BABYLON {
  105089. /**
  105090. * @hidden
  105091. */
  105092. export interface IMaterialClearCoatDefines {
  105093. CLEARCOAT: boolean;
  105094. CLEARCOAT_DEFAULTIOR: boolean;
  105095. CLEARCOAT_TEXTURE: boolean;
  105096. CLEARCOAT_TEXTUREDIRECTUV: number;
  105097. CLEARCOAT_BUMP: boolean;
  105098. CLEARCOAT_BUMPDIRECTUV: number;
  105099. CLEARCOAT_REMAP_F0: boolean;
  105100. CLEARCOAT_TINT: boolean;
  105101. CLEARCOAT_TINT_TEXTURE: boolean;
  105102. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  105103. /** @hidden */
  105104. _areTexturesDirty: boolean;
  105105. }
  105106. /**
  105107. * Define the code related to the clear coat parameters of the pbr material.
  105108. */
  105109. export class PBRClearCoatConfiguration {
  105110. /**
  105111. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105112. * The default fits with a polyurethane material.
  105113. */
  105114. private static readonly _DefaultIndexOfRefraction;
  105115. private _isEnabled;
  105116. /**
  105117. * Defines if the clear coat is enabled in the material.
  105118. */
  105119. isEnabled: boolean;
  105120. /**
  105121. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  105122. */
  105123. intensity: number;
  105124. /**
  105125. * Defines the clear coat layer roughness.
  105126. */
  105127. roughness: number;
  105128. private _indexOfRefraction;
  105129. /**
  105130. * Defines the index of refraction of the clear coat.
  105131. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105132. * The default fits with a polyurethane material.
  105133. * Changing the default value is more performance intensive.
  105134. */
  105135. indexOfRefraction: number;
  105136. private _texture;
  105137. /**
  105138. * Stores the clear coat values in a texture.
  105139. */
  105140. texture: Nullable<BaseTexture>;
  105141. private _remapF0OnInterfaceChange;
  105142. /**
  105143. * Defines if the F0 value should be remapped to account for the interface change in the material.
  105144. */
  105145. remapF0OnInterfaceChange: boolean;
  105146. private _bumpTexture;
  105147. /**
  105148. * Define the clear coat specific bump texture.
  105149. */
  105150. bumpTexture: Nullable<BaseTexture>;
  105151. private _isTintEnabled;
  105152. /**
  105153. * Defines if the clear coat tint is enabled in the material.
  105154. */
  105155. isTintEnabled: boolean;
  105156. /**
  105157. * Defines the clear coat tint of the material.
  105158. * This is only use if tint is enabled
  105159. */
  105160. tintColor: Color3;
  105161. /**
  105162. * Defines the distance at which the tint color should be found in the
  105163. * clear coat media.
  105164. * This is only use if tint is enabled
  105165. */
  105166. tintColorAtDistance: number;
  105167. /**
  105168. * Defines the clear coat layer thickness.
  105169. * This is only use if tint is enabled
  105170. */
  105171. tintThickness: number;
  105172. private _tintTexture;
  105173. /**
  105174. * Stores the clear tint values in a texture.
  105175. * rgb is tint
  105176. * a is a thickness factor
  105177. */
  105178. tintTexture: Nullable<BaseTexture>;
  105179. /** @hidden */
  105180. private _internalMarkAllSubMeshesAsTexturesDirty;
  105181. /** @hidden */
  105182. _markAllSubMeshesAsTexturesDirty(): void;
  105183. /**
  105184. * Instantiate a new istance of clear coat configuration.
  105185. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105186. */
  105187. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105188. /**
  105189. * Gets wehter the submesh is ready to be used or not.
  105190. * @param defines the list of "defines" to update.
  105191. * @param scene defines the scene the material belongs to.
  105192. * @param engine defines the engine the material belongs to.
  105193. * @param disableBumpMap defines wether the material disables bump or not.
  105194. * @returns - boolean indicating that the submesh is ready or not.
  105195. */
  105196. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  105197. /**
  105198. * Checks to see if a texture is used in the material.
  105199. * @param defines the list of "defines" to update.
  105200. * @param scene defines the scene to the material belongs to.
  105201. */
  105202. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  105203. /**
  105204. * Binds the material data.
  105205. * @param uniformBuffer defines the Uniform buffer to fill in.
  105206. * @param scene defines the scene the material belongs to.
  105207. * @param engine defines the engine the material belongs to.
  105208. * @param disableBumpMap defines wether the material disables bump or not.
  105209. * @param isFrozen defines wether the material is frozen or not.
  105210. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105211. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105212. */
  105213. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  105214. /**
  105215. * Checks to see if a texture is used in the material.
  105216. * @param texture - Base texture to use.
  105217. * @returns - Boolean specifying if a texture is used in the material.
  105218. */
  105219. hasTexture(texture: BaseTexture): boolean;
  105220. /**
  105221. * Returns an array of the actively used textures.
  105222. * @param activeTextures Array of BaseTextures
  105223. */
  105224. getActiveTextures(activeTextures: BaseTexture[]): void;
  105225. /**
  105226. * Returns the animatable textures.
  105227. * @param animatables Array of animatable textures.
  105228. */
  105229. getAnimatables(animatables: IAnimatable[]): void;
  105230. /**
  105231. * Disposes the resources of the material.
  105232. * @param forceDisposeTextures - Forces the disposal of all textures.
  105233. */
  105234. dispose(forceDisposeTextures?: boolean): void;
  105235. /**
  105236. * Get the current class name of the texture useful for serialization or dynamic coding.
  105237. * @returns "PBRClearCoatConfiguration"
  105238. */
  105239. getClassName(): string;
  105240. /**
  105241. * Add fallbacks to the effect fallbacks list.
  105242. * @param defines defines the Base texture to use.
  105243. * @param fallbacks defines the current fallback list.
  105244. * @param currentRank defines the current fallback rank.
  105245. * @returns the new fallback rank.
  105246. */
  105247. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105248. /**
  105249. * Add the required uniforms to the current list.
  105250. * @param uniforms defines the current uniform list.
  105251. */
  105252. static AddUniforms(uniforms: string[]): void;
  105253. /**
  105254. * Add the required samplers to the current list.
  105255. * @param samplers defines the current sampler list.
  105256. */
  105257. static AddSamplers(samplers: string[]): void;
  105258. /**
  105259. * Add the required uniforms to the current buffer.
  105260. * @param uniformBuffer defines the current uniform buffer.
  105261. */
  105262. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105263. /**
  105264. * Makes a duplicate of the current configuration into another one.
  105265. * @param clearCoatConfiguration define the config where to copy the info
  105266. */
  105267. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  105268. /**
  105269. * Serializes this clear coat configuration.
  105270. * @returns - An object with the serialized config.
  105271. */
  105272. serialize(): any;
  105273. /**
  105274. * Parses a anisotropy Configuration from a serialized object.
  105275. * @param source - Serialized object.
  105276. * @param scene Defines the scene we are parsing for
  105277. * @param rootUrl Defines the rootUrl to load from
  105278. */
  105279. parse(source: any, scene: Scene, rootUrl: string): void;
  105280. }
  105281. }
  105282. declare module BABYLON {
  105283. /**
  105284. * @hidden
  105285. */
  105286. export interface IMaterialAnisotropicDefines {
  105287. ANISOTROPIC: boolean;
  105288. ANISOTROPIC_TEXTURE: boolean;
  105289. ANISOTROPIC_TEXTUREDIRECTUV: number;
  105290. MAINUV1: boolean;
  105291. _areTexturesDirty: boolean;
  105292. _needUVs: boolean;
  105293. }
  105294. /**
  105295. * Define the code related to the anisotropic parameters of the pbr material.
  105296. */
  105297. export class PBRAnisotropicConfiguration {
  105298. private _isEnabled;
  105299. /**
  105300. * Defines if the anisotropy is enabled in the material.
  105301. */
  105302. isEnabled: boolean;
  105303. /**
  105304. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  105305. */
  105306. intensity: number;
  105307. /**
  105308. * Defines if the effect is along the tangents, bitangents or in between.
  105309. * By default, the effect is "strectching" the highlights along the tangents.
  105310. */
  105311. direction: Vector2;
  105312. private _texture;
  105313. /**
  105314. * Stores the anisotropy values in a texture.
  105315. * rg is direction (like normal from -1 to 1)
  105316. * b is a intensity
  105317. */
  105318. texture: Nullable<BaseTexture>;
  105319. /** @hidden */
  105320. private _internalMarkAllSubMeshesAsTexturesDirty;
  105321. /** @hidden */
  105322. _markAllSubMeshesAsTexturesDirty(): void;
  105323. /**
  105324. * Instantiate a new istance of anisotropy configuration.
  105325. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105326. */
  105327. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105328. /**
  105329. * Specifies that the submesh is ready to be used.
  105330. * @param defines the list of "defines" to update.
  105331. * @param scene defines the scene the material belongs to.
  105332. * @returns - boolean indicating that the submesh is ready or not.
  105333. */
  105334. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  105335. /**
  105336. * Checks to see if a texture is used in the material.
  105337. * @param defines the list of "defines" to update.
  105338. * @param mesh the mesh we are preparing the defines for.
  105339. * @param scene defines the scene the material belongs to.
  105340. */
  105341. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  105342. /**
  105343. * Binds the material data.
  105344. * @param uniformBuffer defines the Uniform buffer to fill in.
  105345. * @param scene defines the scene the material belongs to.
  105346. * @param isFrozen defines wether the material is frozen or not.
  105347. */
  105348. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105349. /**
  105350. * Checks to see if a texture is used in the material.
  105351. * @param texture - Base texture to use.
  105352. * @returns - Boolean specifying if a texture is used in the material.
  105353. */
  105354. hasTexture(texture: BaseTexture): boolean;
  105355. /**
  105356. * Returns an array of the actively used textures.
  105357. * @param activeTextures Array of BaseTextures
  105358. */
  105359. getActiveTextures(activeTextures: BaseTexture[]): void;
  105360. /**
  105361. * Returns the animatable textures.
  105362. * @param animatables Array of animatable textures.
  105363. */
  105364. getAnimatables(animatables: IAnimatable[]): void;
  105365. /**
  105366. * Disposes the resources of the material.
  105367. * @param forceDisposeTextures - Forces the disposal of all textures.
  105368. */
  105369. dispose(forceDisposeTextures?: boolean): void;
  105370. /**
  105371. * Get the current class name of the texture useful for serialization or dynamic coding.
  105372. * @returns "PBRAnisotropicConfiguration"
  105373. */
  105374. getClassName(): string;
  105375. /**
  105376. * Add fallbacks to the effect fallbacks list.
  105377. * @param defines defines the Base texture to use.
  105378. * @param fallbacks defines the current fallback list.
  105379. * @param currentRank defines the current fallback rank.
  105380. * @returns the new fallback rank.
  105381. */
  105382. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105383. /**
  105384. * Add the required uniforms to the current list.
  105385. * @param uniforms defines the current uniform list.
  105386. */
  105387. static AddUniforms(uniforms: string[]): void;
  105388. /**
  105389. * Add the required uniforms to the current buffer.
  105390. * @param uniformBuffer defines the current uniform buffer.
  105391. */
  105392. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105393. /**
  105394. * Add the required samplers to the current list.
  105395. * @param samplers defines the current sampler list.
  105396. */
  105397. static AddSamplers(samplers: string[]): void;
  105398. /**
  105399. * Makes a duplicate of the current configuration into another one.
  105400. * @param anisotropicConfiguration define the config where to copy the info
  105401. */
  105402. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  105403. /**
  105404. * Serializes this anisotropy configuration.
  105405. * @returns - An object with the serialized config.
  105406. */
  105407. serialize(): any;
  105408. /**
  105409. * Parses a anisotropy Configuration from a serialized object.
  105410. * @param source - Serialized object.
  105411. * @param scene Defines the scene we are parsing for
  105412. * @param rootUrl Defines the rootUrl to load from
  105413. */
  105414. parse(source: any, scene: Scene, rootUrl: string): void;
  105415. }
  105416. }
  105417. declare module BABYLON {
  105418. /**
  105419. * @hidden
  105420. */
  105421. export interface IMaterialBRDFDefines {
  105422. BRDF_V_HEIGHT_CORRELATED: boolean;
  105423. MS_BRDF_ENERGY_CONSERVATION: boolean;
  105424. SPHERICAL_HARMONICS: boolean;
  105425. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  105426. /** @hidden */
  105427. _areMiscDirty: boolean;
  105428. }
  105429. /**
  105430. * Define the code related to the BRDF parameters of the pbr material.
  105431. */
  105432. export class PBRBRDFConfiguration {
  105433. /**
  105434. * Default value used for the energy conservation.
  105435. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105436. */
  105437. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  105438. /**
  105439. * Default value used for the Smith Visibility Height Correlated mode.
  105440. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105441. */
  105442. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  105443. /**
  105444. * Default value used for the IBL diffuse part.
  105445. * This can help switching back to the polynomials mode globally which is a tiny bit
  105446. * less GPU intensive at the drawback of a lower quality.
  105447. */
  105448. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  105449. /**
  105450. * Default value used for activating energy conservation for the specular workflow.
  105451. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105452. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105453. */
  105454. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  105455. private _useEnergyConservation;
  105456. /**
  105457. * Defines if the material uses energy conservation.
  105458. */
  105459. useEnergyConservation: boolean;
  105460. private _useSmithVisibilityHeightCorrelated;
  105461. /**
  105462. * LEGACY Mode set to false
  105463. * Defines if the material uses height smith correlated visibility term.
  105464. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  105465. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105466. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  105467. * Not relying on height correlated will also disable energy conservation.
  105468. */
  105469. useSmithVisibilityHeightCorrelated: boolean;
  105470. private _useSphericalHarmonics;
  105471. /**
  105472. * LEGACY Mode set to false
  105473. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  105474. * diffuse part of the IBL.
  105475. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  105476. * to the ground truth.
  105477. */
  105478. useSphericalHarmonics: boolean;
  105479. private _useSpecularGlossinessInputEnergyConservation;
  105480. /**
  105481. * Defines if the material uses energy conservation, when the specular workflow is active.
  105482. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105483. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105484. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  105485. */
  105486. useSpecularGlossinessInputEnergyConservation: boolean;
  105487. /** @hidden */
  105488. private _internalMarkAllSubMeshesAsMiscDirty;
  105489. /** @hidden */
  105490. _markAllSubMeshesAsMiscDirty(): void;
  105491. /**
  105492. * Instantiate a new istance of clear coat configuration.
  105493. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  105494. */
  105495. constructor(markAllSubMeshesAsMiscDirty: () => void);
  105496. /**
  105497. * Checks to see if a texture is used in the material.
  105498. * @param defines the list of "defines" to update.
  105499. */
  105500. prepareDefines(defines: IMaterialBRDFDefines): void;
  105501. /**
  105502. * Get the current class name of the texture useful for serialization or dynamic coding.
  105503. * @returns "PBRClearCoatConfiguration"
  105504. */
  105505. getClassName(): string;
  105506. /**
  105507. * Makes a duplicate of the current configuration into another one.
  105508. * @param brdfConfiguration define the config where to copy the info
  105509. */
  105510. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  105511. /**
  105512. * Serializes this BRDF configuration.
  105513. * @returns - An object with the serialized config.
  105514. */
  105515. serialize(): any;
  105516. /**
  105517. * Parses a anisotropy Configuration from a serialized object.
  105518. * @param source - Serialized object.
  105519. * @param scene Defines the scene we are parsing for
  105520. * @param rootUrl Defines the rootUrl to load from
  105521. */
  105522. parse(source: any, scene: Scene, rootUrl: string): void;
  105523. }
  105524. }
  105525. declare module BABYLON {
  105526. /**
  105527. * @hidden
  105528. */
  105529. export interface IMaterialSheenDefines {
  105530. SHEEN: boolean;
  105531. SHEEN_TEXTURE: boolean;
  105532. SHEEN_TEXTUREDIRECTUV: number;
  105533. SHEEN_LINKWITHALBEDO: boolean;
  105534. SHEEN_ROUGHNESS: boolean;
  105535. SHEEN_ALBEDOSCALING: boolean;
  105536. /** @hidden */
  105537. _areTexturesDirty: boolean;
  105538. }
  105539. /**
  105540. * Define the code related to the Sheen parameters of the pbr material.
  105541. */
  105542. export class PBRSheenConfiguration {
  105543. private _isEnabled;
  105544. /**
  105545. * Defines if the material uses sheen.
  105546. */
  105547. isEnabled: boolean;
  105548. private _linkSheenWithAlbedo;
  105549. /**
  105550. * Defines if the sheen is linked to the sheen color.
  105551. */
  105552. linkSheenWithAlbedo: boolean;
  105553. /**
  105554. * Defines the sheen intensity.
  105555. */
  105556. intensity: number;
  105557. /**
  105558. * Defines the sheen color.
  105559. */
  105560. color: Color3;
  105561. private _texture;
  105562. /**
  105563. * Stores the sheen tint values in a texture.
  105564. * rgb is tint
  105565. * a is a intensity or roughness if roughness has been defined
  105566. */
  105567. texture: Nullable<BaseTexture>;
  105568. private _roughness;
  105569. /**
  105570. * Defines the sheen roughness.
  105571. * It is not taken into account if linkSheenWithAlbedo is true.
  105572. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  105573. */
  105574. roughness: Nullable<number>;
  105575. private _albedoScaling;
  105576. /**
  105577. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  105578. * It allows the strength of the sheen effect to not depend on the base color of the material,
  105579. * making it easier to setup and tweak the effect
  105580. */
  105581. albedoScaling: boolean;
  105582. /** @hidden */
  105583. private _internalMarkAllSubMeshesAsTexturesDirty;
  105584. /** @hidden */
  105585. _markAllSubMeshesAsTexturesDirty(): void;
  105586. /**
  105587. * Instantiate a new istance of clear coat configuration.
  105588. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105589. */
  105590. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105591. /**
  105592. * Specifies that the submesh is ready to be used.
  105593. * @param defines the list of "defines" to update.
  105594. * @param scene defines the scene the material belongs to.
  105595. * @returns - boolean indicating that the submesh is ready or not.
  105596. */
  105597. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  105598. /**
  105599. * Checks to see if a texture is used in the material.
  105600. * @param defines the list of "defines" to update.
  105601. * @param scene defines the scene the material belongs to.
  105602. */
  105603. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  105604. /**
  105605. * Binds the material data.
  105606. * @param uniformBuffer defines the Uniform buffer to fill in.
  105607. * @param scene defines the scene the material belongs to.
  105608. * @param isFrozen defines wether the material is frozen or not.
  105609. */
  105610. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105611. /**
  105612. * Checks to see if a texture is used in the material.
  105613. * @param texture - Base texture to use.
  105614. * @returns - Boolean specifying if a texture is used in the material.
  105615. */
  105616. hasTexture(texture: BaseTexture): boolean;
  105617. /**
  105618. * Returns an array of the actively used textures.
  105619. * @param activeTextures Array of BaseTextures
  105620. */
  105621. getActiveTextures(activeTextures: BaseTexture[]): void;
  105622. /**
  105623. * Returns the animatable textures.
  105624. * @param animatables Array of animatable textures.
  105625. */
  105626. getAnimatables(animatables: IAnimatable[]): void;
  105627. /**
  105628. * Disposes the resources of the material.
  105629. * @param forceDisposeTextures - Forces the disposal of all textures.
  105630. */
  105631. dispose(forceDisposeTextures?: boolean): void;
  105632. /**
  105633. * Get the current class name of the texture useful for serialization or dynamic coding.
  105634. * @returns "PBRSheenConfiguration"
  105635. */
  105636. getClassName(): string;
  105637. /**
  105638. * Add fallbacks to the effect fallbacks list.
  105639. * @param defines defines the Base texture to use.
  105640. * @param fallbacks defines the current fallback list.
  105641. * @param currentRank defines the current fallback rank.
  105642. * @returns the new fallback rank.
  105643. */
  105644. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105645. /**
  105646. * Add the required uniforms to the current list.
  105647. * @param uniforms defines the current uniform list.
  105648. */
  105649. static AddUniforms(uniforms: string[]): void;
  105650. /**
  105651. * Add the required uniforms to the current buffer.
  105652. * @param uniformBuffer defines the current uniform buffer.
  105653. */
  105654. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105655. /**
  105656. * Add the required samplers to the current list.
  105657. * @param samplers defines the current sampler list.
  105658. */
  105659. static AddSamplers(samplers: string[]): void;
  105660. /**
  105661. * Makes a duplicate of the current configuration into another one.
  105662. * @param sheenConfiguration define the config where to copy the info
  105663. */
  105664. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  105665. /**
  105666. * Serializes this BRDF configuration.
  105667. * @returns - An object with the serialized config.
  105668. */
  105669. serialize(): any;
  105670. /**
  105671. * Parses a anisotropy Configuration from a serialized object.
  105672. * @param source - Serialized object.
  105673. * @param scene Defines the scene we are parsing for
  105674. * @param rootUrl Defines the rootUrl to load from
  105675. */
  105676. parse(source: any, scene: Scene, rootUrl: string): void;
  105677. }
  105678. }
  105679. declare module BABYLON {
  105680. /**
  105681. * @hidden
  105682. */
  105683. export interface IMaterialSubSurfaceDefines {
  105684. SUBSURFACE: boolean;
  105685. SS_REFRACTION: boolean;
  105686. SS_TRANSLUCENCY: boolean;
  105687. SS_SCATTERING: boolean;
  105688. SS_THICKNESSANDMASK_TEXTURE: boolean;
  105689. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  105690. SS_REFRACTIONMAP_3D: boolean;
  105691. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  105692. SS_LODINREFRACTIONALPHA: boolean;
  105693. SS_GAMMAREFRACTION: boolean;
  105694. SS_RGBDREFRACTION: boolean;
  105695. SS_LINEARSPECULARREFRACTION: boolean;
  105696. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  105697. SS_ALBEDOFORREFRACTIONTINT: boolean;
  105698. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  105699. /** @hidden */
  105700. _areTexturesDirty: boolean;
  105701. }
  105702. /**
  105703. * Define the code related to the sub surface parameters of the pbr material.
  105704. */
  105705. export class PBRSubSurfaceConfiguration {
  105706. private _isRefractionEnabled;
  105707. /**
  105708. * Defines if the refraction is enabled in the material.
  105709. */
  105710. isRefractionEnabled: boolean;
  105711. private _isTranslucencyEnabled;
  105712. /**
  105713. * Defines if the translucency is enabled in the material.
  105714. */
  105715. isTranslucencyEnabled: boolean;
  105716. private _isScatteringEnabled;
  105717. /**
  105718. * Defines if the sub surface scattering is enabled in the material.
  105719. */
  105720. isScatteringEnabled: boolean;
  105721. private _scatteringDiffusionProfileIndex;
  105722. /**
  105723. * Diffusion profile for subsurface scattering.
  105724. * Useful for better scattering in the skins or foliages.
  105725. */
  105726. get scatteringDiffusionProfile(): Nullable<Color3>;
  105727. set scatteringDiffusionProfile(c: Nullable<Color3>);
  105728. /**
  105729. * Defines the refraction intensity of the material.
  105730. * The refraction when enabled replaces the Diffuse part of the material.
  105731. * The intensity helps transitionning between diffuse and refraction.
  105732. */
  105733. refractionIntensity: number;
  105734. /**
  105735. * Defines the translucency intensity of the material.
  105736. * When translucency has been enabled, this defines how much of the "translucency"
  105737. * is addded to the diffuse part of the material.
  105738. */
  105739. translucencyIntensity: number;
  105740. /**
  105741. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  105742. */
  105743. useAlbedoToTintRefraction: boolean;
  105744. private _thicknessTexture;
  105745. /**
  105746. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  105747. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  105748. * 0 would mean minimumThickness
  105749. * 1 would mean maximumThickness
  105750. * The other channels might be use as a mask to vary the different effects intensity.
  105751. */
  105752. thicknessTexture: Nullable<BaseTexture>;
  105753. private _refractionTexture;
  105754. /**
  105755. * Defines the texture to use for refraction.
  105756. */
  105757. refractionTexture: Nullable<BaseTexture>;
  105758. private _indexOfRefraction;
  105759. /**
  105760. * Index of refraction of the material base layer.
  105761. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105762. *
  105763. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  105764. *
  105765. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  105766. */
  105767. indexOfRefraction: number;
  105768. private _volumeIndexOfRefraction;
  105769. /**
  105770. * Index of refraction of the material's volume.
  105771. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105772. *
  105773. * This ONLY impacts refraction. If not provided or given a non-valid value,
  105774. * the volume will use the same IOR as the surface.
  105775. */
  105776. get volumeIndexOfRefraction(): number;
  105777. set volumeIndexOfRefraction(value: number);
  105778. private _invertRefractionY;
  105779. /**
  105780. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105781. */
  105782. invertRefractionY: boolean;
  105783. private _linkRefractionWithTransparency;
  105784. /**
  105785. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105786. * Materials half opaque for instance using refraction could benefit from this control.
  105787. */
  105788. linkRefractionWithTransparency: boolean;
  105789. /**
  105790. * Defines the minimum thickness stored in the thickness map.
  105791. * If no thickness map is defined, this value will be used to simulate thickness.
  105792. */
  105793. minimumThickness: number;
  105794. /**
  105795. * Defines the maximum thickness stored in the thickness map.
  105796. */
  105797. maximumThickness: number;
  105798. /**
  105799. * Defines the volume tint of the material.
  105800. * This is used for both translucency and scattering.
  105801. */
  105802. tintColor: Color3;
  105803. /**
  105804. * Defines the distance at which the tint color should be found in the media.
  105805. * This is used for refraction only.
  105806. */
  105807. tintColorAtDistance: number;
  105808. /**
  105809. * Defines how far each channel transmit through the media.
  105810. * It is defined as a color to simplify it selection.
  105811. */
  105812. diffusionDistance: Color3;
  105813. private _useMaskFromThicknessTexture;
  105814. /**
  105815. * Stores the intensity of the different subsurface effects in the thickness texture.
  105816. * * the green channel is the translucency intensity.
  105817. * * the blue channel is the scattering intensity.
  105818. * * the alpha channel is the refraction intensity.
  105819. */
  105820. useMaskFromThicknessTexture: boolean;
  105821. private _scene;
  105822. /** @hidden */
  105823. private _internalMarkAllSubMeshesAsTexturesDirty;
  105824. private _internalMarkScenePrePassDirty;
  105825. /** @hidden */
  105826. _markAllSubMeshesAsTexturesDirty(): void;
  105827. /** @hidden */
  105828. _markScenePrePassDirty(): void;
  105829. /**
  105830. * Instantiate a new istance of sub surface configuration.
  105831. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105832. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  105833. * @param scene The scene
  105834. */
  105835. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  105836. /**
  105837. * Gets wehter the submesh is ready to be used or not.
  105838. * @param defines the list of "defines" to update.
  105839. * @param scene defines the scene the material belongs to.
  105840. * @returns - boolean indicating that the submesh is ready or not.
  105841. */
  105842. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  105843. /**
  105844. * Checks to see if a texture is used in the material.
  105845. * @param defines the list of "defines" to update.
  105846. * @param scene defines the scene to the material belongs to.
  105847. */
  105848. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  105849. /**
  105850. * Binds the material data.
  105851. * @param uniformBuffer defines the Uniform buffer to fill in.
  105852. * @param scene defines the scene the material belongs to.
  105853. * @param engine defines the engine the material belongs to.
  105854. * @param isFrozen defines whether the material is frozen or not.
  105855. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  105856. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  105857. */
  105858. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  105859. /**
  105860. * Unbinds the material from the mesh.
  105861. * @param activeEffect defines the effect that should be unbound from.
  105862. * @returns true if unbound, otherwise false
  105863. */
  105864. unbind(activeEffect: Effect): boolean;
  105865. /**
  105866. * Returns the texture used for refraction or null if none is used.
  105867. * @param scene defines the scene the material belongs to.
  105868. * @returns - Refraction texture if present. If no refraction texture and refraction
  105869. * is linked with transparency, returns environment texture. Otherwise, returns null.
  105870. */
  105871. private _getRefractionTexture;
  105872. /**
  105873. * Returns true if alpha blending should be disabled.
  105874. */
  105875. get disableAlphaBlending(): boolean;
  105876. /**
  105877. * Fills the list of render target textures.
  105878. * @param renderTargets the list of render targets to update
  105879. */
  105880. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  105881. /**
  105882. * Checks to see if a texture is used in the material.
  105883. * @param texture - Base texture to use.
  105884. * @returns - Boolean specifying if a texture is used in the material.
  105885. */
  105886. hasTexture(texture: BaseTexture): boolean;
  105887. /**
  105888. * Gets a boolean indicating that current material needs to register RTT
  105889. * @returns true if this uses a render target otherwise false.
  105890. */
  105891. hasRenderTargetTextures(): boolean;
  105892. /**
  105893. * Returns an array of the actively used textures.
  105894. * @param activeTextures Array of BaseTextures
  105895. */
  105896. getActiveTextures(activeTextures: BaseTexture[]): void;
  105897. /**
  105898. * Returns the animatable textures.
  105899. * @param animatables Array of animatable textures.
  105900. */
  105901. getAnimatables(animatables: IAnimatable[]): void;
  105902. /**
  105903. * Disposes the resources of the material.
  105904. * @param forceDisposeTextures - Forces the disposal of all textures.
  105905. */
  105906. dispose(forceDisposeTextures?: boolean): void;
  105907. /**
  105908. * Get the current class name of the texture useful for serialization or dynamic coding.
  105909. * @returns "PBRSubSurfaceConfiguration"
  105910. */
  105911. getClassName(): string;
  105912. /**
  105913. * Add fallbacks to the effect fallbacks list.
  105914. * @param defines defines the Base texture to use.
  105915. * @param fallbacks defines the current fallback list.
  105916. * @param currentRank defines the current fallback rank.
  105917. * @returns the new fallback rank.
  105918. */
  105919. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105920. /**
  105921. * Add the required uniforms to the current list.
  105922. * @param uniforms defines the current uniform list.
  105923. */
  105924. static AddUniforms(uniforms: string[]): void;
  105925. /**
  105926. * Add the required samplers to the current list.
  105927. * @param samplers defines the current sampler list.
  105928. */
  105929. static AddSamplers(samplers: string[]): void;
  105930. /**
  105931. * Add the required uniforms to the current buffer.
  105932. * @param uniformBuffer defines the current uniform buffer.
  105933. */
  105934. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105935. /**
  105936. * Makes a duplicate of the current configuration into another one.
  105937. * @param configuration define the config where to copy the info
  105938. */
  105939. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  105940. /**
  105941. * Serializes this Sub Surface configuration.
  105942. * @returns - An object with the serialized config.
  105943. */
  105944. serialize(): any;
  105945. /**
  105946. * Parses a anisotropy Configuration from a serialized object.
  105947. * @param source - Serialized object.
  105948. * @param scene Defines the scene we are parsing for
  105949. * @param rootUrl Defines the rootUrl to load from
  105950. */
  105951. parse(source: any, scene: Scene, rootUrl: string): void;
  105952. }
  105953. }
  105954. declare module BABYLON {
  105955. /**
  105956. * Class representing spherical harmonics coefficients to the 3rd degree
  105957. */
  105958. export class SphericalHarmonics {
  105959. /**
  105960. * Defines whether or not the harmonics have been prescaled for rendering.
  105961. */
  105962. preScaled: boolean;
  105963. /**
  105964. * The l0,0 coefficients of the spherical harmonics
  105965. */
  105966. l00: Vector3;
  105967. /**
  105968. * The l1,-1 coefficients of the spherical harmonics
  105969. */
  105970. l1_1: Vector3;
  105971. /**
  105972. * The l1,0 coefficients of the spherical harmonics
  105973. */
  105974. l10: Vector3;
  105975. /**
  105976. * The l1,1 coefficients of the spherical harmonics
  105977. */
  105978. l11: Vector3;
  105979. /**
  105980. * The l2,-2 coefficients of the spherical harmonics
  105981. */
  105982. l2_2: Vector3;
  105983. /**
  105984. * The l2,-1 coefficients of the spherical harmonics
  105985. */
  105986. l2_1: Vector3;
  105987. /**
  105988. * The l2,0 coefficients of the spherical harmonics
  105989. */
  105990. l20: Vector3;
  105991. /**
  105992. * The l2,1 coefficients of the spherical harmonics
  105993. */
  105994. l21: Vector3;
  105995. /**
  105996. * The l2,2 coefficients of the spherical harmonics
  105997. */
  105998. l22: Vector3;
  105999. /**
  106000. * Adds a light to the spherical harmonics
  106001. * @param direction the direction of the light
  106002. * @param color the color of the light
  106003. * @param deltaSolidAngle the delta solid angle of the light
  106004. */
  106005. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106006. /**
  106007. * Scales the spherical harmonics by the given amount
  106008. * @param scale the amount to scale
  106009. */
  106010. scaleInPlace(scale: number): void;
  106011. /**
  106012. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106013. *
  106014. * ```
  106015. * E_lm = A_l * L_lm
  106016. * ```
  106017. *
  106018. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106019. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106020. * the scaling factors are given in equation 9.
  106021. */
  106022. convertIncidentRadianceToIrradiance(): void;
  106023. /**
  106024. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106025. *
  106026. * ```
  106027. * L = (1/pi) * E * rho
  106028. * ```
  106029. *
  106030. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106031. */
  106032. convertIrradianceToLambertianRadiance(): void;
  106033. /**
  106034. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106035. * required operations at run time.
  106036. *
  106037. * This is simply done by scaling back the SH with Ylm constants parameter.
  106038. * The trigonometric part being applied by the shader at run time.
  106039. */
  106040. preScaleForRendering(): void;
  106041. /**
  106042. * Constructs a spherical harmonics from an array.
  106043. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106044. * @returns the spherical harmonics
  106045. */
  106046. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106047. /**
  106048. * Gets the spherical harmonics from polynomial
  106049. * @param polynomial the spherical polynomial
  106050. * @returns the spherical harmonics
  106051. */
  106052. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106053. }
  106054. /**
  106055. * Class representing spherical polynomial coefficients to the 3rd degree
  106056. */
  106057. export class SphericalPolynomial {
  106058. private _harmonics;
  106059. /**
  106060. * The spherical harmonics used to create the polynomials.
  106061. */
  106062. get preScaledHarmonics(): SphericalHarmonics;
  106063. /**
  106064. * The x coefficients of the spherical polynomial
  106065. */
  106066. x: Vector3;
  106067. /**
  106068. * The y coefficients of the spherical polynomial
  106069. */
  106070. y: Vector3;
  106071. /**
  106072. * The z coefficients of the spherical polynomial
  106073. */
  106074. z: Vector3;
  106075. /**
  106076. * The xx coefficients of the spherical polynomial
  106077. */
  106078. xx: Vector3;
  106079. /**
  106080. * The yy coefficients of the spherical polynomial
  106081. */
  106082. yy: Vector3;
  106083. /**
  106084. * The zz coefficients of the spherical polynomial
  106085. */
  106086. zz: Vector3;
  106087. /**
  106088. * The xy coefficients of the spherical polynomial
  106089. */
  106090. xy: Vector3;
  106091. /**
  106092. * The yz coefficients of the spherical polynomial
  106093. */
  106094. yz: Vector3;
  106095. /**
  106096. * The zx coefficients of the spherical polynomial
  106097. */
  106098. zx: Vector3;
  106099. /**
  106100. * Adds an ambient color to the spherical polynomial
  106101. * @param color the color to add
  106102. */
  106103. addAmbient(color: Color3): void;
  106104. /**
  106105. * Scales the spherical polynomial by the given amount
  106106. * @param scale the amount to scale
  106107. */
  106108. scaleInPlace(scale: number): void;
  106109. /**
  106110. * Gets the spherical polynomial from harmonics
  106111. * @param harmonics the spherical harmonics
  106112. * @returns the spherical polynomial
  106113. */
  106114. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106115. /**
  106116. * Constructs a spherical polynomial from an array.
  106117. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106118. * @returns the spherical polynomial
  106119. */
  106120. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106121. }
  106122. }
  106123. declare module BABYLON {
  106124. /**
  106125. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  106126. */
  106127. export interface CubeMapInfo {
  106128. /**
  106129. * The pixel array for the front face.
  106130. * This is stored in format, left to right, up to down format.
  106131. */
  106132. front: Nullable<ArrayBufferView>;
  106133. /**
  106134. * The pixel array for the back face.
  106135. * This is stored in format, left to right, up to down format.
  106136. */
  106137. back: Nullable<ArrayBufferView>;
  106138. /**
  106139. * The pixel array for the left face.
  106140. * This is stored in format, left to right, up to down format.
  106141. */
  106142. left: Nullable<ArrayBufferView>;
  106143. /**
  106144. * The pixel array for the right face.
  106145. * This is stored in format, left to right, up to down format.
  106146. */
  106147. right: Nullable<ArrayBufferView>;
  106148. /**
  106149. * The pixel array for the up face.
  106150. * This is stored in format, left to right, up to down format.
  106151. */
  106152. up: Nullable<ArrayBufferView>;
  106153. /**
  106154. * The pixel array for the down face.
  106155. * This is stored in format, left to right, up to down format.
  106156. */
  106157. down: Nullable<ArrayBufferView>;
  106158. /**
  106159. * The size of the cubemap stored.
  106160. *
  106161. * Each faces will be size * size pixels.
  106162. */
  106163. size: number;
  106164. /**
  106165. * The format of the texture.
  106166. *
  106167. * RGBA, RGB.
  106168. */
  106169. format: number;
  106170. /**
  106171. * The type of the texture data.
  106172. *
  106173. * UNSIGNED_INT, FLOAT.
  106174. */
  106175. type: number;
  106176. /**
  106177. * Specifies whether the texture is in gamma space.
  106178. */
  106179. gammaSpace: boolean;
  106180. }
  106181. /**
  106182. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  106183. */
  106184. export class PanoramaToCubeMapTools {
  106185. private static FACE_LEFT;
  106186. private static FACE_RIGHT;
  106187. private static FACE_FRONT;
  106188. private static FACE_BACK;
  106189. private static FACE_DOWN;
  106190. private static FACE_UP;
  106191. /**
  106192. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  106193. *
  106194. * @param float32Array The source data.
  106195. * @param inputWidth The width of the input panorama.
  106196. * @param inputHeight The height of the input panorama.
  106197. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  106198. * @return The cubemap data
  106199. */
  106200. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  106201. private static CreateCubemapTexture;
  106202. private static CalcProjectionSpherical;
  106203. }
  106204. }
  106205. declare module BABYLON {
  106206. /**
  106207. * Helper class dealing with the extraction of spherical polynomial dataArray
  106208. * from a cube map.
  106209. */
  106210. export class CubeMapToSphericalPolynomialTools {
  106211. private static FileFaces;
  106212. /**
  106213. * Converts a texture to the according Spherical Polynomial data.
  106214. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106215. *
  106216. * @param texture The texture to extract the information from.
  106217. * @return The Spherical Polynomial data.
  106218. */
  106219. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  106220. /**
  106221. * Converts a cubemap to the according Spherical Polynomial data.
  106222. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106223. *
  106224. * @param cubeInfo The Cube map to extract the information from.
  106225. * @return The Spherical Polynomial data.
  106226. */
  106227. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  106228. }
  106229. }
  106230. declare module BABYLON {
  106231. interface BaseTexture {
  106232. /**
  106233. * Get the polynomial representation of the texture data.
  106234. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  106235. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  106236. */
  106237. sphericalPolynomial: Nullable<SphericalPolynomial>;
  106238. }
  106239. }
  106240. declare module BABYLON {
  106241. /** @hidden */
  106242. export var pbrFragmentDeclaration: {
  106243. name: string;
  106244. shader: string;
  106245. };
  106246. }
  106247. declare module BABYLON {
  106248. /** @hidden */
  106249. export var pbrUboDeclaration: {
  106250. name: string;
  106251. shader: string;
  106252. };
  106253. }
  106254. declare module BABYLON {
  106255. /** @hidden */
  106256. export var pbrFragmentExtraDeclaration: {
  106257. name: string;
  106258. shader: string;
  106259. };
  106260. }
  106261. declare module BABYLON {
  106262. /** @hidden */
  106263. export var pbrFragmentSamplersDeclaration: {
  106264. name: string;
  106265. shader: string;
  106266. };
  106267. }
  106268. declare module BABYLON {
  106269. /** @hidden */
  106270. export var subSurfaceScatteringFunctions: {
  106271. name: string;
  106272. shader: string;
  106273. };
  106274. }
  106275. declare module BABYLON {
  106276. /** @hidden */
  106277. export var importanceSampling: {
  106278. name: string;
  106279. shader: string;
  106280. };
  106281. }
  106282. declare module BABYLON {
  106283. /** @hidden */
  106284. export var pbrHelperFunctions: {
  106285. name: string;
  106286. shader: string;
  106287. };
  106288. }
  106289. declare module BABYLON {
  106290. /** @hidden */
  106291. export var harmonicsFunctions: {
  106292. name: string;
  106293. shader: string;
  106294. };
  106295. }
  106296. declare module BABYLON {
  106297. /** @hidden */
  106298. export var pbrDirectLightingSetupFunctions: {
  106299. name: string;
  106300. shader: string;
  106301. };
  106302. }
  106303. declare module BABYLON {
  106304. /** @hidden */
  106305. export var pbrDirectLightingFalloffFunctions: {
  106306. name: string;
  106307. shader: string;
  106308. };
  106309. }
  106310. declare module BABYLON {
  106311. /** @hidden */
  106312. export var pbrBRDFFunctions: {
  106313. name: string;
  106314. shader: string;
  106315. };
  106316. }
  106317. declare module BABYLON {
  106318. /** @hidden */
  106319. export var hdrFilteringFunctions: {
  106320. name: string;
  106321. shader: string;
  106322. };
  106323. }
  106324. declare module BABYLON {
  106325. /** @hidden */
  106326. export var pbrDirectLightingFunctions: {
  106327. name: string;
  106328. shader: string;
  106329. };
  106330. }
  106331. declare module BABYLON {
  106332. /** @hidden */
  106333. export var pbrIBLFunctions: {
  106334. name: string;
  106335. shader: string;
  106336. };
  106337. }
  106338. declare module BABYLON {
  106339. /** @hidden */
  106340. export var pbrBlockAlbedoOpacity: {
  106341. name: string;
  106342. shader: string;
  106343. };
  106344. }
  106345. declare module BABYLON {
  106346. /** @hidden */
  106347. export var pbrBlockReflectivity: {
  106348. name: string;
  106349. shader: string;
  106350. };
  106351. }
  106352. declare module BABYLON {
  106353. /** @hidden */
  106354. export var pbrBlockAmbientOcclusion: {
  106355. name: string;
  106356. shader: string;
  106357. };
  106358. }
  106359. declare module BABYLON {
  106360. /** @hidden */
  106361. export var pbrBlockAlphaFresnel: {
  106362. name: string;
  106363. shader: string;
  106364. };
  106365. }
  106366. declare module BABYLON {
  106367. /** @hidden */
  106368. export var pbrBlockAnisotropic: {
  106369. name: string;
  106370. shader: string;
  106371. };
  106372. }
  106373. declare module BABYLON {
  106374. /** @hidden */
  106375. export var pbrBlockReflection: {
  106376. name: string;
  106377. shader: string;
  106378. };
  106379. }
  106380. declare module BABYLON {
  106381. /** @hidden */
  106382. export var pbrBlockSheen: {
  106383. name: string;
  106384. shader: string;
  106385. };
  106386. }
  106387. declare module BABYLON {
  106388. /** @hidden */
  106389. export var pbrBlockClearcoat: {
  106390. name: string;
  106391. shader: string;
  106392. };
  106393. }
  106394. declare module BABYLON {
  106395. /** @hidden */
  106396. export var pbrBlockSubSurface: {
  106397. name: string;
  106398. shader: string;
  106399. };
  106400. }
  106401. declare module BABYLON {
  106402. /** @hidden */
  106403. export var pbrBlockNormalGeometric: {
  106404. name: string;
  106405. shader: string;
  106406. };
  106407. }
  106408. declare module BABYLON {
  106409. /** @hidden */
  106410. export var pbrBlockNormalFinal: {
  106411. name: string;
  106412. shader: string;
  106413. };
  106414. }
  106415. declare module BABYLON {
  106416. /** @hidden */
  106417. export var pbrBlockLightmapInit: {
  106418. name: string;
  106419. shader: string;
  106420. };
  106421. }
  106422. declare module BABYLON {
  106423. /** @hidden */
  106424. export var pbrBlockGeometryInfo: {
  106425. name: string;
  106426. shader: string;
  106427. };
  106428. }
  106429. declare module BABYLON {
  106430. /** @hidden */
  106431. export var pbrBlockReflectance0: {
  106432. name: string;
  106433. shader: string;
  106434. };
  106435. }
  106436. declare module BABYLON {
  106437. /** @hidden */
  106438. export var pbrBlockReflectance: {
  106439. name: string;
  106440. shader: string;
  106441. };
  106442. }
  106443. declare module BABYLON {
  106444. /** @hidden */
  106445. export var pbrBlockDirectLighting: {
  106446. name: string;
  106447. shader: string;
  106448. };
  106449. }
  106450. declare module BABYLON {
  106451. /** @hidden */
  106452. export var pbrBlockFinalLitComponents: {
  106453. name: string;
  106454. shader: string;
  106455. };
  106456. }
  106457. declare module BABYLON {
  106458. /** @hidden */
  106459. export var pbrBlockFinalUnlitComponents: {
  106460. name: string;
  106461. shader: string;
  106462. };
  106463. }
  106464. declare module BABYLON {
  106465. /** @hidden */
  106466. export var pbrBlockFinalColorComposition: {
  106467. name: string;
  106468. shader: string;
  106469. };
  106470. }
  106471. declare module BABYLON {
  106472. /** @hidden */
  106473. export var pbrBlockImageProcessing: {
  106474. name: string;
  106475. shader: string;
  106476. };
  106477. }
  106478. declare module BABYLON {
  106479. /** @hidden */
  106480. export var pbrDebug: {
  106481. name: string;
  106482. shader: string;
  106483. };
  106484. }
  106485. declare module BABYLON {
  106486. /** @hidden */
  106487. export var pbrPixelShader: {
  106488. name: string;
  106489. shader: string;
  106490. };
  106491. }
  106492. declare module BABYLON {
  106493. /** @hidden */
  106494. export var pbrVertexDeclaration: {
  106495. name: string;
  106496. shader: string;
  106497. };
  106498. }
  106499. declare module BABYLON {
  106500. /** @hidden */
  106501. export var pbrVertexShader: {
  106502. name: string;
  106503. shader: string;
  106504. };
  106505. }
  106506. declare module BABYLON {
  106507. /**
  106508. * Manages the defines for the PBR Material.
  106509. * @hidden
  106510. */
  106511. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  106512. PBR: boolean;
  106513. NUM_SAMPLES: string;
  106514. REALTIME_FILTERING: boolean;
  106515. MAINUV1: boolean;
  106516. MAINUV2: boolean;
  106517. UV1: boolean;
  106518. UV2: boolean;
  106519. ALBEDO: boolean;
  106520. GAMMAALBEDO: boolean;
  106521. ALBEDODIRECTUV: number;
  106522. VERTEXCOLOR: boolean;
  106523. DETAIL: boolean;
  106524. DETAILDIRECTUV: number;
  106525. DETAIL_NORMALBLENDMETHOD: number;
  106526. AMBIENT: boolean;
  106527. AMBIENTDIRECTUV: number;
  106528. AMBIENTINGRAYSCALE: boolean;
  106529. OPACITY: boolean;
  106530. VERTEXALPHA: boolean;
  106531. OPACITYDIRECTUV: number;
  106532. OPACITYRGB: boolean;
  106533. ALPHATEST: boolean;
  106534. DEPTHPREPASS: boolean;
  106535. ALPHABLEND: boolean;
  106536. ALPHAFROMALBEDO: boolean;
  106537. ALPHATESTVALUE: string;
  106538. SPECULAROVERALPHA: boolean;
  106539. RADIANCEOVERALPHA: boolean;
  106540. ALPHAFRESNEL: boolean;
  106541. LINEARALPHAFRESNEL: boolean;
  106542. PREMULTIPLYALPHA: boolean;
  106543. EMISSIVE: boolean;
  106544. EMISSIVEDIRECTUV: number;
  106545. REFLECTIVITY: boolean;
  106546. REFLECTIVITYDIRECTUV: number;
  106547. SPECULARTERM: boolean;
  106548. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  106549. MICROSURFACEAUTOMATIC: boolean;
  106550. LODBASEDMICROSFURACE: boolean;
  106551. MICROSURFACEMAP: boolean;
  106552. MICROSURFACEMAPDIRECTUV: number;
  106553. METALLICWORKFLOW: boolean;
  106554. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  106555. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  106556. METALLNESSSTOREINMETALMAPBLUE: boolean;
  106557. AOSTOREINMETALMAPRED: boolean;
  106558. METALLIC_REFLECTANCE: boolean;
  106559. METALLIC_REFLECTANCEDIRECTUV: number;
  106560. ENVIRONMENTBRDF: boolean;
  106561. ENVIRONMENTBRDF_RGBD: boolean;
  106562. NORMAL: boolean;
  106563. TANGENT: boolean;
  106564. BUMP: boolean;
  106565. BUMPDIRECTUV: number;
  106566. OBJECTSPACE_NORMALMAP: boolean;
  106567. PARALLAX: boolean;
  106568. PARALLAXOCCLUSION: boolean;
  106569. NORMALXYSCALE: boolean;
  106570. LIGHTMAP: boolean;
  106571. LIGHTMAPDIRECTUV: number;
  106572. USELIGHTMAPASSHADOWMAP: boolean;
  106573. GAMMALIGHTMAP: boolean;
  106574. RGBDLIGHTMAP: boolean;
  106575. REFLECTION: boolean;
  106576. REFLECTIONMAP_3D: boolean;
  106577. REFLECTIONMAP_SPHERICAL: boolean;
  106578. REFLECTIONMAP_PLANAR: boolean;
  106579. REFLECTIONMAP_CUBIC: boolean;
  106580. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106581. REFLECTIONMAP_PROJECTION: boolean;
  106582. REFLECTIONMAP_SKYBOX: boolean;
  106583. REFLECTIONMAP_EXPLICIT: boolean;
  106584. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106585. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106586. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106587. INVERTCUBICMAP: boolean;
  106588. USESPHERICALFROMREFLECTIONMAP: boolean;
  106589. USEIRRADIANCEMAP: boolean;
  106590. SPHERICAL_HARMONICS: boolean;
  106591. USESPHERICALINVERTEX: boolean;
  106592. REFLECTIONMAP_OPPOSITEZ: boolean;
  106593. LODINREFLECTIONALPHA: boolean;
  106594. GAMMAREFLECTION: boolean;
  106595. RGBDREFLECTION: boolean;
  106596. LINEARSPECULARREFLECTION: boolean;
  106597. RADIANCEOCCLUSION: boolean;
  106598. HORIZONOCCLUSION: boolean;
  106599. INSTANCES: boolean;
  106600. THIN_INSTANCES: boolean;
  106601. PREPASS: boolean;
  106602. PREPASS_IRRADIANCE: boolean;
  106603. PREPASS_IRRADIANCE_INDEX: number;
  106604. PREPASS_ALBEDO: boolean;
  106605. PREPASS_ALBEDO_INDEX: number;
  106606. PREPASS_DEPTHNORMAL: boolean;
  106607. PREPASS_DEPTHNORMAL_INDEX: number;
  106608. PREPASS_POSITION: boolean;
  106609. PREPASS_POSITION_INDEX: number;
  106610. PREPASS_VELOCITY: boolean;
  106611. PREPASS_VELOCITY_INDEX: number;
  106612. PREPASS_REFLECTIVITY: boolean;
  106613. PREPASS_REFLECTIVITY_INDEX: number;
  106614. SCENE_MRT_COUNT: number;
  106615. NUM_BONE_INFLUENCERS: number;
  106616. BonesPerMesh: number;
  106617. BONETEXTURE: boolean;
  106618. BONES_VELOCITY_ENABLED: boolean;
  106619. NONUNIFORMSCALING: boolean;
  106620. MORPHTARGETS: boolean;
  106621. MORPHTARGETS_NORMAL: boolean;
  106622. MORPHTARGETS_TANGENT: boolean;
  106623. MORPHTARGETS_UV: boolean;
  106624. NUM_MORPH_INFLUENCERS: number;
  106625. IMAGEPROCESSING: boolean;
  106626. VIGNETTE: boolean;
  106627. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106628. VIGNETTEBLENDMODEOPAQUE: boolean;
  106629. TONEMAPPING: boolean;
  106630. TONEMAPPING_ACES: boolean;
  106631. CONTRAST: boolean;
  106632. COLORCURVES: boolean;
  106633. COLORGRADING: boolean;
  106634. COLORGRADING3D: boolean;
  106635. SAMPLER3DGREENDEPTH: boolean;
  106636. SAMPLER3DBGRMAP: boolean;
  106637. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106638. EXPOSURE: boolean;
  106639. MULTIVIEW: boolean;
  106640. USEPHYSICALLIGHTFALLOFF: boolean;
  106641. USEGLTFLIGHTFALLOFF: boolean;
  106642. TWOSIDEDLIGHTING: boolean;
  106643. SHADOWFLOAT: boolean;
  106644. CLIPPLANE: boolean;
  106645. CLIPPLANE2: boolean;
  106646. CLIPPLANE3: boolean;
  106647. CLIPPLANE4: boolean;
  106648. CLIPPLANE5: boolean;
  106649. CLIPPLANE6: boolean;
  106650. POINTSIZE: boolean;
  106651. FOG: boolean;
  106652. LOGARITHMICDEPTH: boolean;
  106653. FORCENORMALFORWARD: boolean;
  106654. SPECULARAA: boolean;
  106655. CLEARCOAT: boolean;
  106656. CLEARCOAT_DEFAULTIOR: boolean;
  106657. CLEARCOAT_TEXTURE: boolean;
  106658. CLEARCOAT_TEXTUREDIRECTUV: number;
  106659. CLEARCOAT_BUMP: boolean;
  106660. CLEARCOAT_BUMPDIRECTUV: number;
  106661. CLEARCOAT_REMAP_F0: boolean;
  106662. CLEARCOAT_TINT: boolean;
  106663. CLEARCOAT_TINT_TEXTURE: boolean;
  106664. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106665. ANISOTROPIC: boolean;
  106666. ANISOTROPIC_TEXTURE: boolean;
  106667. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106668. BRDF_V_HEIGHT_CORRELATED: boolean;
  106669. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106670. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106671. SHEEN: boolean;
  106672. SHEEN_TEXTURE: boolean;
  106673. SHEEN_TEXTUREDIRECTUV: number;
  106674. SHEEN_LINKWITHALBEDO: boolean;
  106675. SHEEN_ROUGHNESS: boolean;
  106676. SHEEN_ALBEDOSCALING: boolean;
  106677. SUBSURFACE: boolean;
  106678. SS_REFRACTION: boolean;
  106679. SS_TRANSLUCENCY: boolean;
  106680. SS_SCATTERING: boolean;
  106681. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106682. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106683. SS_REFRACTIONMAP_3D: boolean;
  106684. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106685. SS_LODINREFRACTIONALPHA: boolean;
  106686. SS_GAMMAREFRACTION: boolean;
  106687. SS_RGBDREFRACTION: boolean;
  106688. SS_LINEARSPECULARREFRACTION: boolean;
  106689. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106690. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106691. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106692. UNLIT: boolean;
  106693. DEBUGMODE: number;
  106694. /**
  106695. * Initializes the PBR Material defines.
  106696. */
  106697. constructor();
  106698. /**
  106699. * Resets the PBR Material defines.
  106700. */
  106701. reset(): void;
  106702. }
  106703. /**
  106704. * The Physically based material base class of BJS.
  106705. *
  106706. * This offers the main features of a standard PBR material.
  106707. * For more information, please refer to the documentation :
  106708. * https://doc.babylonjs.com/how_to/physically_based_rendering
  106709. */
  106710. export abstract class PBRBaseMaterial extends PushMaterial {
  106711. /**
  106712. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  106713. */
  106714. static readonly PBRMATERIAL_OPAQUE: number;
  106715. /**
  106716. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  106717. */
  106718. static readonly PBRMATERIAL_ALPHATEST: number;
  106719. /**
  106720. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106721. */
  106722. static readonly PBRMATERIAL_ALPHABLEND: number;
  106723. /**
  106724. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106725. * They are also discarded below the alpha cutoff threshold to improve performances.
  106726. */
  106727. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  106728. /**
  106729. * Defines the default value of how much AO map is occluding the analytical lights
  106730. * (point spot...).
  106731. */
  106732. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  106733. /**
  106734. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  106735. */
  106736. static readonly LIGHTFALLOFF_PHYSICAL: number;
  106737. /**
  106738. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  106739. * to enhance interoperability with other engines.
  106740. */
  106741. static readonly LIGHTFALLOFF_GLTF: number;
  106742. /**
  106743. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  106744. * to enhance interoperability with other materials.
  106745. */
  106746. static readonly LIGHTFALLOFF_STANDARD: number;
  106747. /**
  106748. * Intensity of the direct lights e.g. the four lights available in your scene.
  106749. * This impacts both the direct diffuse and specular highlights.
  106750. */
  106751. protected _directIntensity: number;
  106752. /**
  106753. * Intensity of the emissive part of the material.
  106754. * This helps controlling the emissive effect without modifying the emissive color.
  106755. */
  106756. protected _emissiveIntensity: number;
  106757. /**
  106758. * Intensity of the environment e.g. how much the environment will light the object
  106759. * either through harmonics for rough material or through the refelction for shiny ones.
  106760. */
  106761. protected _environmentIntensity: number;
  106762. /**
  106763. * This is a special control allowing the reduction of the specular highlights coming from the
  106764. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  106765. */
  106766. protected _specularIntensity: number;
  106767. /**
  106768. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  106769. */
  106770. private _lightingInfos;
  106771. /**
  106772. * Debug Control allowing disabling the bump map on this material.
  106773. */
  106774. protected _disableBumpMap: boolean;
  106775. /**
  106776. * AKA Diffuse Texture in standard nomenclature.
  106777. */
  106778. protected _albedoTexture: Nullable<BaseTexture>;
  106779. /**
  106780. * AKA Occlusion Texture in other nomenclature.
  106781. */
  106782. protected _ambientTexture: Nullable<BaseTexture>;
  106783. /**
  106784. * AKA Occlusion Texture Intensity in other nomenclature.
  106785. */
  106786. protected _ambientTextureStrength: number;
  106787. /**
  106788. * Defines how much the AO map is occluding the analytical lights (point spot...).
  106789. * 1 means it completely occludes it
  106790. * 0 mean it has no impact
  106791. */
  106792. protected _ambientTextureImpactOnAnalyticalLights: number;
  106793. /**
  106794. * Stores the alpha values in a texture.
  106795. */
  106796. protected _opacityTexture: Nullable<BaseTexture>;
  106797. /**
  106798. * Stores the reflection values in a texture.
  106799. */
  106800. protected _reflectionTexture: Nullable<BaseTexture>;
  106801. /**
  106802. * Stores the emissive values in a texture.
  106803. */
  106804. protected _emissiveTexture: Nullable<BaseTexture>;
  106805. /**
  106806. * AKA Specular texture in other nomenclature.
  106807. */
  106808. protected _reflectivityTexture: Nullable<BaseTexture>;
  106809. /**
  106810. * Used to switch from specular/glossiness to metallic/roughness workflow.
  106811. */
  106812. protected _metallicTexture: Nullable<BaseTexture>;
  106813. /**
  106814. * Specifies the metallic scalar of the metallic/roughness workflow.
  106815. * Can also be used to scale the metalness values of the metallic texture.
  106816. */
  106817. protected _metallic: Nullable<number>;
  106818. /**
  106819. * Specifies the roughness scalar of the metallic/roughness workflow.
  106820. * Can also be used to scale the roughness values of the metallic texture.
  106821. */
  106822. protected _roughness: Nullable<number>;
  106823. /**
  106824. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  106825. * By default the indexOfrefraction is used to compute F0;
  106826. *
  106827. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  106828. *
  106829. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  106830. * F90 = metallicReflectanceColor;
  106831. */
  106832. protected _metallicF0Factor: number;
  106833. /**
  106834. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  106835. * By default the F90 is always 1;
  106836. *
  106837. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  106838. *
  106839. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  106840. * F90 = metallicReflectanceColor;
  106841. */
  106842. protected _metallicReflectanceColor: Color3;
  106843. /**
  106844. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  106845. * This is multiply against the scalar values defined in the material.
  106846. */
  106847. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  106848. /**
  106849. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  106850. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  106851. */
  106852. protected _microSurfaceTexture: Nullable<BaseTexture>;
  106853. /**
  106854. * Stores surface normal data used to displace a mesh in a texture.
  106855. */
  106856. protected _bumpTexture: Nullable<BaseTexture>;
  106857. /**
  106858. * Stores the pre-calculated light information of a mesh in a texture.
  106859. */
  106860. protected _lightmapTexture: Nullable<BaseTexture>;
  106861. /**
  106862. * The color of a material in ambient lighting.
  106863. */
  106864. protected _ambientColor: Color3;
  106865. /**
  106866. * AKA Diffuse Color in other nomenclature.
  106867. */
  106868. protected _albedoColor: Color3;
  106869. /**
  106870. * AKA Specular Color in other nomenclature.
  106871. */
  106872. protected _reflectivityColor: Color3;
  106873. /**
  106874. * The color applied when light is reflected from a material.
  106875. */
  106876. protected _reflectionColor: Color3;
  106877. /**
  106878. * The color applied when light is emitted from a material.
  106879. */
  106880. protected _emissiveColor: Color3;
  106881. /**
  106882. * AKA Glossiness in other nomenclature.
  106883. */
  106884. protected _microSurface: number;
  106885. /**
  106886. * Specifies that the material will use the light map as a show map.
  106887. */
  106888. protected _useLightmapAsShadowmap: boolean;
  106889. /**
  106890. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  106891. * makes the reflect vector face the model (under horizon).
  106892. */
  106893. protected _useHorizonOcclusion: boolean;
  106894. /**
  106895. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  106896. * too much the area relying on ambient texture to define their ambient occlusion.
  106897. */
  106898. protected _useRadianceOcclusion: boolean;
  106899. /**
  106900. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  106901. */
  106902. protected _useAlphaFromAlbedoTexture: boolean;
  106903. /**
  106904. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  106905. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106906. */
  106907. protected _useSpecularOverAlpha: boolean;
  106908. /**
  106909. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  106910. */
  106911. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  106912. /**
  106913. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  106914. */
  106915. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  106916. /**
  106917. * Specifies if the metallic texture contains the roughness information in its green channel.
  106918. */
  106919. protected _useRoughnessFromMetallicTextureGreen: boolean;
  106920. /**
  106921. * Specifies if the metallic texture contains the metallness information in its blue channel.
  106922. */
  106923. protected _useMetallnessFromMetallicTextureBlue: boolean;
  106924. /**
  106925. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  106926. */
  106927. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  106928. /**
  106929. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  106930. */
  106931. protected _useAmbientInGrayScale: boolean;
  106932. /**
  106933. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  106934. * The material will try to infer what glossiness each pixel should be.
  106935. */
  106936. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  106937. /**
  106938. * Defines the falloff type used in this material.
  106939. * It by default is Physical.
  106940. */
  106941. protected _lightFalloff: number;
  106942. /**
  106943. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106944. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106945. */
  106946. protected _useRadianceOverAlpha: boolean;
  106947. /**
  106948. * Allows using an object space normal map (instead of tangent space).
  106949. */
  106950. protected _useObjectSpaceNormalMap: boolean;
  106951. /**
  106952. * Allows using the bump map in parallax mode.
  106953. */
  106954. protected _useParallax: boolean;
  106955. /**
  106956. * Allows using the bump map in parallax occlusion mode.
  106957. */
  106958. protected _useParallaxOcclusion: boolean;
  106959. /**
  106960. * Controls the scale bias of the parallax mode.
  106961. */
  106962. protected _parallaxScaleBias: number;
  106963. /**
  106964. * If sets to true, disables all the lights affecting the material.
  106965. */
  106966. protected _disableLighting: boolean;
  106967. /**
  106968. * Number of Simultaneous lights allowed on the material.
  106969. */
  106970. protected _maxSimultaneousLights: number;
  106971. /**
  106972. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  106973. */
  106974. protected _invertNormalMapX: boolean;
  106975. /**
  106976. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  106977. */
  106978. protected _invertNormalMapY: boolean;
  106979. /**
  106980. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106981. */
  106982. protected _twoSidedLighting: boolean;
  106983. /**
  106984. * Defines the alpha limits in alpha test mode.
  106985. */
  106986. protected _alphaCutOff: number;
  106987. /**
  106988. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  106989. */
  106990. protected _forceAlphaTest: boolean;
  106991. /**
  106992. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  106993. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  106994. */
  106995. protected _useAlphaFresnel: boolean;
  106996. /**
  106997. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  106998. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  106999. */
  107000. protected _useLinearAlphaFresnel: boolean;
  107001. /**
  107002. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  107003. * from cos thetav and roughness:
  107004. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  107005. */
  107006. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  107007. /**
  107008. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107009. */
  107010. protected _forceIrradianceInFragment: boolean;
  107011. private _realTimeFiltering;
  107012. /**
  107013. * Enables realtime filtering on the texture.
  107014. */
  107015. get realTimeFiltering(): boolean;
  107016. set realTimeFiltering(b: boolean);
  107017. private _realTimeFilteringQuality;
  107018. /**
  107019. * Quality switch for realtime filtering
  107020. */
  107021. get realTimeFilteringQuality(): number;
  107022. set realTimeFilteringQuality(n: number);
  107023. /**
  107024. * Can this material render to several textures at once
  107025. */
  107026. get canRenderToMRT(): boolean;
  107027. /**
  107028. * Force normal to face away from face.
  107029. */
  107030. protected _forceNormalForward: boolean;
  107031. /**
  107032. * Enables specular anti aliasing in the PBR shader.
  107033. * It will both interacts on the Geometry for analytical and IBL lighting.
  107034. * It also prefilter the roughness map based on the bump values.
  107035. */
  107036. protected _enableSpecularAntiAliasing: boolean;
  107037. /**
  107038. * Default configuration related to image processing available in the PBR Material.
  107039. */
  107040. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107041. /**
  107042. * Keep track of the image processing observer to allow dispose and replace.
  107043. */
  107044. private _imageProcessingObserver;
  107045. /**
  107046. * Attaches a new image processing configuration to the PBR Material.
  107047. * @param configuration
  107048. */
  107049. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107050. /**
  107051. * Stores the available render targets.
  107052. */
  107053. private _renderTargets;
  107054. /**
  107055. * Sets the global ambient color for the material used in lighting calculations.
  107056. */
  107057. private _globalAmbientColor;
  107058. /**
  107059. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  107060. */
  107061. private _useLogarithmicDepth;
  107062. /**
  107063. * If set to true, no lighting calculations will be applied.
  107064. */
  107065. private _unlit;
  107066. private _debugMode;
  107067. /**
  107068. * @hidden
  107069. * This is reserved for the inspector.
  107070. * Defines the material debug mode.
  107071. * It helps seeing only some components of the material while troubleshooting.
  107072. */
  107073. debugMode: number;
  107074. /**
  107075. * @hidden
  107076. * This is reserved for the inspector.
  107077. * Specify from where on screen the debug mode should start.
  107078. * The value goes from -1 (full screen) to 1 (not visible)
  107079. * It helps with side by side comparison against the final render
  107080. * This defaults to -1
  107081. */
  107082. private debugLimit;
  107083. /**
  107084. * @hidden
  107085. * This is reserved for the inspector.
  107086. * As the default viewing range might not be enough (if the ambient is really small for instance)
  107087. * You can use the factor to better multiply the final value.
  107088. */
  107089. private debugFactor;
  107090. /**
  107091. * Defines the clear coat layer parameters for the material.
  107092. */
  107093. readonly clearCoat: PBRClearCoatConfiguration;
  107094. /**
  107095. * Defines the anisotropic parameters for the material.
  107096. */
  107097. readonly anisotropy: PBRAnisotropicConfiguration;
  107098. /**
  107099. * Defines the BRDF parameters for the material.
  107100. */
  107101. readonly brdf: PBRBRDFConfiguration;
  107102. /**
  107103. * Defines the Sheen parameters for the material.
  107104. */
  107105. readonly sheen: PBRSheenConfiguration;
  107106. /**
  107107. * Defines the SubSurface parameters for the material.
  107108. */
  107109. readonly subSurface: PBRSubSurfaceConfiguration;
  107110. /**
  107111. * Defines additionnal PrePass parameters for the material.
  107112. */
  107113. readonly prePassConfiguration: PrePassConfiguration;
  107114. /**
  107115. * Defines the detail map parameters for the material.
  107116. */
  107117. readonly detailMap: DetailMapConfiguration;
  107118. protected _rebuildInParallel: boolean;
  107119. /**
  107120. * Instantiates a new PBRMaterial instance.
  107121. *
  107122. * @param name The material name
  107123. * @param scene The scene the material will be use in.
  107124. */
  107125. constructor(name: string, scene: Scene);
  107126. /**
  107127. * Gets a boolean indicating that current material needs to register RTT
  107128. */
  107129. get hasRenderTargetTextures(): boolean;
  107130. /**
  107131. * Gets the name of the material class.
  107132. */
  107133. getClassName(): string;
  107134. /**
  107135. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107136. */
  107137. get useLogarithmicDepth(): boolean;
  107138. /**
  107139. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107140. */
  107141. set useLogarithmicDepth(value: boolean);
  107142. /**
  107143. * Returns true if alpha blending should be disabled.
  107144. */
  107145. protected get _disableAlphaBlending(): boolean;
  107146. /**
  107147. * Specifies whether or not this material should be rendered in alpha blend mode.
  107148. */
  107149. needAlphaBlending(): boolean;
  107150. /**
  107151. * Specifies whether or not this material should be rendered in alpha test mode.
  107152. */
  107153. needAlphaTesting(): boolean;
  107154. /**
  107155. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  107156. */
  107157. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  107158. /**
  107159. * Gets the texture used for the alpha test.
  107160. */
  107161. getAlphaTestTexture(): Nullable<BaseTexture>;
  107162. /**
  107163. * Specifies that the submesh is ready to be used.
  107164. * @param mesh - BJS mesh.
  107165. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  107166. * @param useInstances - Specifies that instances should be used.
  107167. * @returns - boolean indicating that the submesh is ready or not.
  107168. */
  107169. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107170. /**
  107171. * Specifies if the material uses metallic roughness workflow.
  107172. * @returns boolean specifiying if the material uses metallic roughness workflow.
  107173. */
  107174. isMetallicWorkflow(): boolean;
  107175. private _prepareEffect;
  107176. private _prepareDefines;
  107177. /**
  107178. * Force shader compilation
  107179. */
  107180. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  107181. /**
  107182. * Initializes the uniform buffer layout for the shader.
  107183. */
  107184. buildUniformLayout(): void;
  107185. /**
  107186. * Unbinds the material from the mesh
  107187. */
  107188. unbind(): void;
  107189. /**
  107190. * Binds the submesh data.
  107191. * @param world - The world matrix.
  107192. * @param mesh - The BJS mesh.
  107193. * @param subMesh - A submesh of the BJS mesh.
  107194. */
  107195. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107196. /**
  107197. * Returns the animatable textures.
  107198. * @returns - Array of animatable textures.
  107199. */
  107200. getAnimatables(): IAnimatable[];
  107201. /**
  107202. * Returns the texture used for reflections.
  107203. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  107204. */
  107205. private _getReflectionTexture;
  107206. /**
  107207. * Returns an array of the actively used textures.
  107208. * @returns - Array of BaseTextures
  107209. */
  107210. getActiveTextures(): BaseTexture[];
  107211. /**
  107212. * Checks to see if a texture is used in the material.
  107213. * @param texture - Base texture to use.
  107214. * @returns - Boolean specifying if a texture is used in the material.
  107215. */
  107216. hasTexture(texture: BaseTexture): boolean;
  107217. /**
  107218. * Sets the required values to the prepass renderer.
  107219. * @param prePassRenderer defines the prepass renderer to setup
  107220. */
  107221. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  107222. /**
  107223. * Disposes the resources of the material.
  107224. * @param forceDisposeEffect - Forces the disposal of effects.
  107225. * @param forceDisposeTextures - Forces the disposal of all textures.
  107226. */
  107227. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107228. }
  107229. }
  107230. declare module BABYLON {
  107231. /**
  107232. * The Physically based material of BJS.
  107233. *
  107234. * This offers the main features of a standard PBR material.
  107235. * For more information, please refer to the documentation :
  107236. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107237. */
  107238. export class PBRMaterial extends PBRBaseMaterial {
  107239. /**
  107240. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107241. */
  107242. static readonly PBRMATERIAL_OPAQUE: number;
  107243. /**
  107244. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107245. */
  107246. static readonly PBRMATERIAL_ALPHATEST: number;
  107247. /**
  107248. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107249. */
  107250. static readonly PBRMATERIAL_ALPHABLEND: number;
  107251. /**
  107252. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107253. * They are also discarded below the alpha cutoff threshold to improve performances.
  107254. */
  107255. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107256. /**
  107257. * Defines the default value of how much AO map is occluding the analytical lights
  107258. * (point spot...).
  107259. */
  107260. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107261. /**
  107262. * Intensity of the direct lights e.g. the four lights available in your scene.
  107263. * This impacts both the direct diffuse and specular highlights.
  107264. */
  107265. directIntensity: number;
  107266. /**
  107267. * Intensity of the emissive part of the material.
  107268. * This helps controlling the emissive effect without modifying the emissive color.
  107269. */
  107270. emissiveIntensity: number;
  107271. /**
  107272. * Intensity of the environment e.g. how much the environment will light the object
  107273. * either through harmonics for rough material or through the refelction for shiny ones.
  107274. */
  107275. environmentIntensity: number;
  107276. /**
  107277. * This is a special control allowing the reduction of the specular highlights coming from the
  107278. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107279. */
  107280. specularIntensity: number;
  107281. /**
  107282. * Debug Control allowing disabling the bump map on this material.
  107283. */
  107284. disableBumpMap: boolean;
  107285. /**
  107286. * AKA Diffuse Texture in standard nomenclature.
  107287. */
  107288. albedoTexture: BaseTexture;
  107289. /**
  107290. * AKA Occlusion Texture in other nomenclature.
  107291. */
  107292. ambientTexture: BaseTexture;
  107293. /**
  107294. * AKA Occlusion Texture Intensity in other nomenclature.
  107295. */
  107296. ambientTextureStrength: number;
  107297. /**
  107298. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107299. * 1 means it completely occludes it
  107300. * 0 mean it has no impact
  107301. */
  107302. ambientTextureImpactOnAnalyticalLights: number;
  107303. /**
  107304. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  107305. */
  107306. opacityTexture: BaseTexture;
  107307. /**
  107308. * Stores the reflection values in a texture.
  107309. */
  107310. reflectionTexture: Nullable<BaseTexture>;
  107311. /**
  107312. * Stores the emissive values in a texture.
  107313. */
  107314. emissiveTexture: BaseTexture;
  107315. /**
  107316. * AKA Specular texture in other nomenclature.
  107317. */
  107318. reflectivityTexture: BaseTexture;
  107319. /**
  107320. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107321. */
  107322. metallicTexture: BaseTexture;
  107323. /**
  107324. * Specifies the metallic scalar of the metallic/roughness workflow.
  107325. * Can also be used to scale the metalness values of the metallic texture.
  107326. */
  107327. metallic: Nullable<number>;
  107328. /**
  107329. * Specifies the roughness scalar of the metallic/roughness workflow.
  107330. * Can also be used to scale the roughness values of the metallic texture.
  107331. */
  107332. roughness: Nullable<number>;
  107333. /**
  107334. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107335. * By default the indexOfrefraction is used to compute F0;
  107336. *
  107337. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107338. *
  107339. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107340. * F90 = metallicReflectanceColor;
  107341. */
  107342. metallicF0Factor: number;
  107343. /**
  107344. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107345. * By default the F90 is always 1;
  107346. *
  107347. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107348. *
  107349. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107350. * F90 = metallicReflectanceColor;
  107351. */
  107352. metallicReflectanceColor: Color3;
  107353. /**
  107354. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107355. * This is multiply against the scalar values defined in the material.
  107356. */
  107357. metallicReflectanceTexture: Nullable<BaseTexture>;
  107358. /**
  107359. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107360. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107361. */
  107362. microSurfaceTexture: BaseTexture;
  107363. /**
  107364. * Stores surface normal data used to displace a mesh in a texture.
  107365. */
  107366. bumpTexture: BaseTexture;
  107367. /**
  107368. * Stores the pre-calculated light information of a mesh in a texture.
  107369. */
  107370. lightmapTexture: BaseTexture;
  107371. /**
  107372. * Stores the refracted light information in a texture.
  107373. */
  107374. get refractionTexture(): Nullable<BaseTexture>;
  107375. set refractionTexture(value: Nullable<BaseTexture>);
  107376. /**
  107377. * The color of a material in ambient lighting.
  107378. */
  107379. ambientColor: Color3;
  107380. /**
  107381. * AKA Diffuse Color in other nomenclature.
  107382. */
  107383. albedoColor: Color3;
  107384. /**
  107385. * AKA Specular Color in other nomenclature.
  107386. */
  107387. reflectivityColor: Color3;
  107388. /**
  107389. * The color reflected from the material.
  107390. */
  107391. reflectionColor: Color3;
  107392. /**
  107393. * The color emitted from the material.
  107394. */
  107395. emissiveColor: Color3;
  107396. /**
  107397. * AKA Glossiness in other nomenclature.
  107398. */
  107399. microSurface: number;
  107400. /**
  107401. * Index of refraction of the material base layer.
  107402. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107403. *
  107404. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  107405. *
  107406. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  107407. */
  107408. get indexOfRefraction(): number;
  107409. set indexOfRefraction(value: number);
  107410. /**
  107411. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107412. */
  107413. get invertRefractionY(): boolean;
  107414. set invertRefractionY(value: boolean);
  107415. /**
  107416. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107417. * Materials half opaque for instance using refraction could benefit from this control.
  107418. */
  107419. get linkRefractionWithTransparency(): boolean;
  107420. set linkRefractionWithTransparency(value: boolean);
  107421. /**
  107422. * If true, the light map contains occlusion information instead of lighting info.
  107423. */
  107424. useLightmapAsShadowmap: boolean;
  107425. /**
  107426. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107427. */
  107428. useAlphaFromAlbedoTexture: boolean;
  107429. /**
  107430. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107431. */
  107432. forceAlphaTest: boolean;
  107433. /**
  107434. * Defines the alpha limits in alpha test mode.
  107435. */
  107436. alphaCutOff: number;
  107437. /**
  107438. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107439. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107440. */
  107441. useSpecularOverAlpha: boolean;
  107442. /**
  107443. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107444. */
  107445. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107446. /**
  107447. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107448. */
  107449. useRoughnessFromMetallicTextureAlpha: boolean;
  107450. /**
  107451. * Specifies if the metallic texture contains the roughness information in its green channel.
  107452. */
  107453. useRoughnessFromMetallicTextureGreen: boolean;
  107454. /**
  107455. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107456. */
  107457. useMetallnessFromMetallicTextureBlue: boolean;
  107458. /**
  107459. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107460. */
  107461. useAmbientOcclusionFromMetallicTextureRed: boolean;
  107462. /**
  107463. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107464. */
  107465. useAmbientInGrayScale: boolean;
  107466. /**
  107467. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107468. * The material will try to infer what glossiness each pixel should be.
  107469. */
  107470. useAutoMicroSurfaceFromReflectivityMap: boolean;
  107471. /**
  107472. * BJS is using an harcoded light falloff based on a manually sets up range.
  107473. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107474. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107475. */
  107476. get usePhysicalLightFalloff(): boolean;
  107477. /**
  107478. * BJS is using an harcoded light falloff based on a manually sets up range.
  107479. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107480. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107481. */
  107482. set usePhysicalLightFalloff(value: boolean);
  107483. /**
  107484. * In order to support the falloff compatibility with gltf, a special mode has been added
  107485. * to reproduce the gltf light falloff.
  107486. */
  107487. get useGLTFLightFalloff(): boolean;
  107488. /**
  107489. * In order to support the falloff compatibility with gltf, a special mode has been added
  107490. * to reproduce the gltf light falloff.
  107491. */
  107492. set useGLTFLightFalloff(value: boolean);
  107493. /**
  107494. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107495. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107496. */
  107497. useRadianceOverAlpha: boolean;
  107498. /**
  107499. * Allows using an object space normal map (instead of tangent space).
  107500. */
  107501. useObjectSpaceNormalMap: boolean;
  107502. /**
  107503. * Allows using the bump map in parallax mode.
  107504. */
  107505. useParallax: boolean;
  107506. /**
  107507. * Allows using the bump map in parallax occlusion mode.
  107508. */
  107509. useParallaxOcclusion: boolean;
  107510. /**
  107511. * Controls the scale bias of the parallax mode.
  107512. */
  107513. parallaxScaleBias: number;
  107514. /**
  107515. * If sets to true, disables all the lights affecting the material.
  107516. */
  107517. disableLighting: boolean;
  107518. /**
  107519. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107520. */
  107521. forceIrradianceInFragment: boolean;
  107522. /**
  107523. * Number of Simultaneous lights allowed on the material.
  107524. */
  107525. maxSimultaneousLights: number;
  107526. /**
  107527. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107528. */
  107529. invertNormalMapX: boolean;
  107530. /**
  107531. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107532. */
  107533. invertNormalMapY: boolean;
  107534. /**
  107535. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107536. */
  107537. twoSidedLighting: boolean;
  107538. /**
  107539. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107540. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107541. */
  107542. useAlphaFresnel: boolean;
  107543. /**
  107544. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107545. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107546. */
  107547. useLinearAlphaFresnel: boolean;
  107548. /**
  107549. * Let user defines the brdf lookup texture used for IBL.
  107550. * A default 8bit version is embedded but you could point at :
  107551. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  107552. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107553. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  107554. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107555. */
  107556. environmentBRDFTexture: Nullable<BaseTexture>;
  107557. /**
  107558. * Force normal to face away from face.
  107559. */
  107560. forceNormalForward: boolean;
  107561. /**
  107562. * Enables specular anti aliasing in the PBR shader.
  107563. * It will both interacts on the Geometry for analytical and IBL lighting.
  107564. * It also prefilter the roughness map based on the bump values.
  107565. */
  107566. enableSpecularAntiAliasing: boolean;
  107567. /**
  107568. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107569. * makes the reflect vector face the model (under horizon).
  107570. */
  107571. useHorizonOcclusion: boolean;
  107572. /**
  107573. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107574. * too much the area relying on ambient texture to define their ambient occlusion.
  107575. */
  107576. useRadianceOcclusion: boolean;
  107577. /**
  107578. * If set to true, no lighting calculations will be applied.
  107579. */
  107580. unlit: boolean;
  107581. /**
  107582. * Gets the image processing configuration used either in this material.
  107583. */
  107584. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107585. /**
  107586. * Sets the Default image processing configuration used either in the this material.
  107587. *
  107588. * If sets to null, the scene one is in use.
  107589. */
  107590. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107591. /**
  107592. * Gets wether the color curves effect is enabled.
  107593. */
  107594. get cameraColorCurvesEnabled(): boolean;
  107595. /**
  107596. * Sets wether the color curves effect is enabled.
  107597. */
  107598. set cameraColorCurvesEnabled(value: boolean);
  107599. /**
  107600. * Gets wether the color grading effect is enabled.
  107601. */
  107602. get cameraColorGradingEnabled(): boolean;
  107603. /**
  107604. * Gets wether the color grading effect is enabled.
  107605. */
  107606. set cameraColorGradingEnabled(value: boolean);
  107607. /**
  107608. * Gets wether tonemapping is enabled or not.
  107609. */
  107610. get cameraToneMappingEnabled(): boolean;
  107611. /**
  107612. * Sets wether tonemapping is enabled or not
  107613. */
  107614. set cameraToneMappingEnabled(value: boolean);
  107615. /**
  107616. * The camera exposure used on this material.
  107617. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107618. * This corresponds to a photographic exposure.
  107619. */
  107620. get cameraExposure(): number;
  107621. /**
  107622. * The camera exposure used on this material.
  107623. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107624. * This corresponds to a photographic exposure.
  107625. */
  107626. set cameraExposure(value: number);
  107627. /**
  107628. * Gets The camera contrast used on this material.
  107629. */
  107630. get cameraContrast(): number;
  107631. /**
  107632. * Sets The camera contrast used on this material.
  107633. */
  107634. set cameraContrast(value: number);
  107635. /**
  107636. * Gets the Color Grading 2D Lookup Texture.
  107637. */
  107638. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107639. /**
  107640. * Sets the Color Grading 2D Lookup Texture.
  107641. */
  107642. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107643. /**
  107644. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107645. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107646. * 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;
  107647. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107648. */
  107649. get cameraColorCurves(): Nullable<ColorCurves>;
  107650. /**
  107651. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107652. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107653. * 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;
  107654. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107655. */
  107656. set cameraColorCurves(value: Nullable<ColorCurves>);
  107657. /**
  107658. * Instantiates a new PBRMaterial instance.
  107659. *
  107660. * @param name The material name
  107661. * @param scene The scene the material will be use in.
  107662. */
  107663. constructor(name: string, scene: Scene);
  107664. /**
  107665. * Returns the name of this material class.
  107666. */
  107667. getClassName(): string;
  107668. /**
  107669. * Makes a duplicate of the current material.
  107670. * @param name - name to use for the new material.
  107671. */
  107672. clone(name: string): PBRMaterial;
  107673. /**
  107674. * Serializes this PBR Material.
  107675. * @returns - An object with the serialized material.
  107676. */
  107677. serialize(): any;
  107678. /**
  107679. * Parses a PBR Material from a serialized object.
  107680. * @param source - Serialized object.
  107681. * @param scene - BJS scene instance.
  107682. * @param rootUrl - url for the scene object
  107683. * @returns - PBRMaterial
  107684. */
  107685. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  107686. }
  107687. }
  107688. declare module BABYLON {
  107689. /** @hidden */
  107690. export var mrtFragmentDeclaration: {
  107691. name: string;
  107692. shader: string;
  107693. };
  107694. }
  107695. declare module BABYLON {
  107696. /** @hidden */
  107697. export var geometryPixelShader: {
  107698. name: string;
  107699. shader: string;
  107700. };
  107701. }
  107702. declare module BABYLON {
  107703. /** @hidden */
  107704. export var geometryVertexShader: {
  107705. name: string;
  107706. shader: string;
  107707. };
  107708. }
  107709. declare module BABYLON {
  107710. /** @hidden */
  107711. interface ISavedTransformationMatrix {
  107712. world: Matrix;
  107713. viewProjection: Matrix;
  107714. }
  107715. /**
  107716. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  107717. */
  107718. export class GeometryBufferRenderer {
  107719. /**
  107720. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  107721. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  107722. */
  107723. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  107724. /**
  107725. * Constant used to retrieve the position texture index in the G-Buffer textures array
  107726. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  107727. */
  107728. static readonly POSITION_TEXTURE_TYPE: number;
  107729. /**
  107730. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  107731. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  107732. */
  107733. static readonly VELOCITY_TEXTURE_TYPE: number;
  107734. /**
  107735. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  107736. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  107737. */
  107738. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  107739. /**
  107740. * Dictionary used to store the previous transformation matrices of each rendered mesh
  107741. * in order to compute objects velocities when enableVelocity is set to "true"
  107742. * @hidden
  107743. */
  107744. _previousTransformationMatrices: {
  107745. [index: number]: ISavedTransformationMatrix;
  107746. };
  107747. /**
  107748. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  107749. * in order to compute objects velocities when enableVelocity is set to "true"
  107750. * @hidden
  107751. */
  107752. _previousBonesTransformationMatrices: {
  107753. [index: number]: Float32Array;
  107754. };
  107755. /**
  107756. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  107757. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  107758. */
  107759. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  107760. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  107761. renderTransparentMeshes: boolean;
  107762. private _scene;
  107763. private _resizeObserver;
  107764. private _multiRenderTarget;
  107765. private _ratio;
  107766. private _enablePosition;
  107767. private _enableVelocity;
  107768. private _enableReflectivity;
  107769. private _positionIndex;
  107770. private _velocityIndex;
  107771. private _reflectivityIndex;
  107772. private _depthNormalIndex;
  107773. private _linkedWithPrePass;
  107774. private _prePassRenderer;
  107775. private _attachments;
  107776. protected _effect: Effect;
  107777. protected _cachedDefines: string;
  107778. /**
  107779. * @hidden
  107780. * Sets up internal structures to share outputs with PrePassRenderer
  107781. * This method should only be called by the PrePassRenderer itself
  107782. */
  107783. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  107784. /**
  107785. * @hidden
  107786. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  107787. * This method should only be called by the PrePassRenderer itself
  107788. */
  107789. _unlinkPrePassRenderer(): void;
  107790. /**
  107791. * @hidden
  107792. * Resets the geometry buffer layout
  107793. */
  107794. _resetLayout(): void;
  107795. /**
  107796. * @hidden
  107797. * Replaces a texture in the geometry buffer renderer
  107798. * Useful when linking textures of the prepass renderer
  107799. */
  107800. _forceTextureType(geometryBufferType: number, index: number): void;
  107801. /**
  107802. * @hidden
  107803. * Sets texture attachments
  107804. * Useful when linking textures of the prepass renderer
  107805. */
  107806. _setAttachments(attachments: number[]): void;
  107807. /**
  107808. * @hidden
  107809. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  107810. * Useful when linking textures of the prepass renderer
  107811. */
  107812. _linkInternalTexture(internalTexture: InternalTexture): void;
  107813. /**
  107814. * Gets the render list (meshes to be rendered) used in the G buffer.
  107815. */
  107816. get renderList(): Nullable<AbstractMesh[]>;
  107817. /**
  107818. * Set the render list (meshes to be rendered) used in the G buffer.
  107819. */
  107820. set renderList(meshes: Nullable<AbstractMesh[]>);
  107821. /**
  107822. * Gets wether or not G buffer are supported by the running hardware.
  107823. * This requires draw buffer supports
  107824. */
  107825. get isSupported(): boolean;
  107826. /**
  107827. * Returns the index of the given texture type in the G-Buffer textures array
  107828. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  107829. * @returns the index of the given texture type in the G-Buffer textures array
  107830. */
  107831. getTextureIndex(textureType: number): number;
  107832. /**
  107833. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  107834. */
  107835. get enablePosition(): boolean;
  107836. /**
  107837. * Sets whether or not objects positions are enabled for the G buffer.
  107838. */
  107839. set enablePosition(enable: boolean);
  107840. /**
  107841. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  107842. */
  107843. get enableVelocity(): boolean;
  107844. /**
  107845. * Sets wether or not objects velocities are enabled for the G buffer.
  107846. */
  107847. set enableVelocity(enable: boolean);
  107848. /**
  107849. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  107850. */
  107851. get enableReflectivity(): boolean;
  107852. /**
  107853. * Sets wether or not objects roughness are enabled for the G buffer.
  107854. */
  107855. set enableReflectivity(enable: boolean);
  107856. /**
  107857. * Gets the scene associated with the buffer.
  107858. */
  107859. get scene(): Scene;
  107860. /**
  107861. * Gets the ratio used by the buffer during its creation.
  107862. * How big is the buffer related to the main canvas.
  107863. */
  107864. get ratio(): number;
  107865. /** @hidden */
  107866. static _SceneComponentInitialization: (scene: Scene) => void;
  107867. /**
  107868. * Creates a new G Buffer for the scene
  107869. * @param scene The scene the buffer belongs to
  107870. * @param ratio How big is the buffer related to the main canvas.
  107871. */
  107872. constructor(scene: Scene, ratio?: number);
  107873. /**
  107874. * Checks wether everything is ready to render a submesh to the G buffer.
  107875. * @param subMesh the submesh to check readiness for
  107876. * @param useInstances is the mesh drawn using instance or not
  107877. * @returns true if ready otherwise false
  107878. */
  107879. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107880. /**
  107881. * Gets the current underlying G Buffer.
  107882. * @returns the buffer
  107883. */
  107884. getGBuffer(): MultiRenderTarget;
  107885. /**
  107886. * Gets the number of samples used to render the buffer (anti aliasing).
  107887. */
  107888. get samples(): number;
  107889. /**
  107890. * Sets the number of samples used to render the buffer (anti aliasing).
  107891. */
  107892. set samples(value: number);
  107893. /**
  107894. * Disposes the renderer and frees up associated resources.
  107895. */
  107896. dispose(): void;
  107897. private _assignRenderTargetIndices;
  107898. protected _createRenderTargets(): void;
  107899. private _copyBonesTransformationMatrices;
  107900. }
  107901. }
  107902. declare module BABYLON {
  107903. /**
  107904. * Renders a pre pass of the scene
  107905. * This means every mesh in the scene will be rendered to a render target texture
  107906. * And then this texture will be composited to the rendering canvas with post processes
  107907. * It is necessary for effects like subsurface scattering or deferred shading
  107908. */
  107909. export class PrePassRenderer {
  107910. /** @hidden */
  107911. static _SceneComponentInitialization: (scene: Scene) => void;
  107912. private _textureFormats;
  107913. /**
  107914. * To save performance, we can excluded skinned meshes from the prepass
  107915. */
  107916. excludedSkinnedMesh: AbstractMesh[];
  107917. /**
  107918. * Force material to be excluded from the prepass
  107919. * Can be useful when `useGeometryBufferFallback` is set to `true`
  107920. * and you don't want a material to show in the effect.
  107921. */
  107922. excludedMaterials: Material[];
  107923. private _textureIndices;
  107924. private _scene;
  107925. private _engine;
  107926. private _isDirty;
  107927. /**
  107928. * Number of textures in the multi render target texture where the scene is directly rendered
  107929. */
  107930. mrtCount: number;
  107931. /**
  107932. * The render target where the scene is directly rendered
  107933. */
  107934. prePassRT: MultiRenderTarget;
  107935. private _multiRenderAttachments;
  107936. private _defaultAttachments;
  107937. private _clearAttachments;
  107938. private _postProcesses;
  107939. private readonly _clearColor;
  107940. /**
  107941. * Image processing post process for composition
  107942. */
  107943. imageProcessingPostProcess: ImageProcessingPostProcess;
  107944. /**
  107945. * Configuration for prepass effects
  107946. */
  107947. private _effectConfigurations;
  107948. private _mrtFormats;
  107949. private _mrtLayout;
  107950. private _enabled;
  107951. /**
  107952. * Indicates if the prepass is enabled
  107953. */
  107954. get enabled(): boolean;
  107955. /**
  107956. * How many samples are used for MSAA of the scene render target
  107957. */
  107958. get samples(): number;
  107959. set samples(n: number);
  107960. private _geometryBuffer;
  107961. private _useGeometryBufferFallback;
  107962. /**
  107963. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  107964. */
  107965. get useGeometryBufferFallback(): boolean;
  107966. set useGeometryBufferFallback(value: boolean);
  107967. /**
  107968. * Instanciates a prepass renderer
  107969. * @param scene The scene
  107970. */
  107971. constructor(scene: Scene);
  107972. private _initializeAttachments;
  107973. private _createCompositionEffect;
  107974. /**
  107975. * Indicates if rendering a prepass is supported
  107976. */
  107977. get isSupported(): boolean;
  107978. /**
  107979. * Sets the proper output textures to draw in the engine.
  107980. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  107981. * @param subMesh Submesh on which the effect is applied
  107982. */
  107983. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  107984. /**
  107985. * @hidden
  107986. */
  107987. _beforeCameraDraw(): void;
  107988. /**
  107989. * @hidden
  107990. */
  107991. _afterCameraDraw(): void;
  107992. private _checkRTSize;
  107993. private _bindFrameBuffer;
  107994. /**
  107995. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  107996. */
  107997. clear(): void;
  107998. private _setState;
  107999. private _updateGeometryBufferLayout;
  108000. /**
  108001. * Adds an effect configuration to the prepass.
  108002. * If an effect has already been added, it won't add it twice and will return the configuration
  108003. * already present.
  108004. * @param cfg the effect configuration
  108005. * @return the effect configuration now used by the prepass
  108006. */
  108007. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  108008. /**
  108009. * Returns the index of a texture in the multi render target texture array.
  108010. * @param type Texture type
  108011. * @return The index
  108012. */
  108013. getIndex(type: number): number;
  108014. private _enable;
  108015. private _disable;
  108016. private _resetLayout;
  108017. private _resetPostProcessChain;
  108018. private _bindPostProcessChain;
  108019. /**
  108020. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  108021. */
  108022. markAsDirty(): void;
  108023. /**
  108024. * Enables a texture on the MultiRenderTarget for prepass
  108025. */
  108026. private _enableTextures;
  108027. private _update;
  108028. private _markAllMaterialsAsPrePassDirty;
  108029. /**
  108030. * Disposes the prepass renderer.
  108031. */
  108032. dispose(): void;
  108033. }
  108034. }
  108035. declare module BABYLON {
  108036. /**
  108037. * Size options for a post process
  108038. */
  108039. export type PostProcessOptions = {
  108040. width: number;
  108041. height: number;
  108042. };
  108043. /**
  108044. * PostProcess can be used to apply a shader to a texture after it has been rendered
  108045. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108046. */
  108047. export class PostProcess {
  108048. /**
  108049. * Gets or sets the unique id of the post process
  108050. */
  108051. uniqueId: number;
  108052. /** Name of the PostProcess. */
  108053. name: string;
  108054. /**
  108055. * Width of the texture to apply the post process on
  108056. */
  108057. width: number;
  108058. /**
  108059. * Height of the texture to apply the post process on
  108060. */
  108061. height: number;
  108062. /**
  108063. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  108064. */
  108065. nodeMaterialSource: Nullable<NodeMaterial>;
  108066. /**
  108067. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  108068. * @hidden
  108069. */
  108070. _outputTexture: Nullable<InternalTexture>;
  108071. /**
  108072. * Sampling mode used by the shader
  108073. * See https://doc.babylonjs.com/classes/3.1/texture
  108074. */
  108075. renderTargetSamplingMode: number;
  108076. /**
  108077. * Clear color to use when screen clearing
  108078. */
  108079. clearColor: Color4;
  108080. /**
  108081. * If the buffer needs to be cleared before applying the post process. (default: true)
  108082. * Should be set to false if shader will overwrite all previous pixels.
  108083. */
  108084. autoClear: boolean;
  108085. /**
  108086. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  108087. */
  108088. alphaMode: number;
  108089. /**
  108090. * Sets the setAlphaBlendConstants of the babylon engine
  108091. */
  108092. alphaConstants: Color4;
  108093. /**
  108094. * Animations to be used for the post processing
  108095. */
  108096. animations: Animation[];
  108097. /**
  108098. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  108099. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  108100. */
  108101. enablePixelPerfectMode: boolean;
  108102. /**
  108103. * Force the postprocess to be applied without taking in account viewport
  108104. */
  108105. forceFullscreenViewport: boolean;
  108106. /**
  108107. * List of inspectable custom properties (used by the Inspector)
  108108. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108109. */
  108110. inspectableCustomProperties: IInspectable[];
  108111. /**
  108112. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  108113. *
  108114. * | Value | Type | Description |
  108115. * | ----- | ----------------------------------- | ----------- |
  108116. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  108117. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  108118. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  108119. *
  108120. */
  108121. scaleMode: number;
  108122. /**
  108123. * Force textures to be a power of two (default: false)
  108124. */
  108125. alwaysForcePOT: boolean;
  108126. private _samples;
  108127. /**
  108128. * Number of sample textures (default: 1)
  108129. */
  108130. get samples(): number;
  108131. set samples(n: number);
  108132. /**
  108133. * Modify the scale of the post process to be the same as the viewport (default: false)
  108134. */
  108135. adaptScaleToCurrentViewport: boolean;
  108136. private _camera;
  108137. protected _scene: Scene;
  108138. private _engine;
  108139. private _options;
  108140. private _reusable;
  108141. private _textureType;
  108142. private _textureFormat;
  108143. /**
  108144. * Smart array of input and output textures for the post process.
  108145. * @hidden
  108146. */
  108147. _textures: SmartArray<InternalTexture>;
  108148. /**
  108149. * The index in _textures that corresponds to the output texture.
  108150. * @hidden
  108151. */
  108152. _currentRenderTextureInd: number;
  108153. private _effect;
  108154. private _samplers;
  108155. private _fragmentUrl;
  108156. private _vertexUrl;
  108157. private _parameters;
  108158. private _scaleRatio;
  108159. protected _indexParameters: any;
  108160. private _shareOutputWithPostProcess;
  108161. private _texelSize;
  108162. private _forcedOutputTexture;
  108163. /**
  108164. * Prepass configuration in case this post process needs a texture from prepass
  108165. * @hidden
  108166. */
  108167. _prePassEffectConfiguration: PrePassEffectConfiguration;
  108168. /**
  108169. * Returns the fragment url or shader name used in the post process.
  108170. * @returns the fragment url or name in the shader store.
  108171. */
  108172. getEffectName(): string;
  108173. /**
  108174. * An event triggered when the postprocess is activated.
  108175. */
  108176. onActivateObservable: Observable<Camera>;
  108177. private _onActivateObserver;
  108178. /**
  108179. * A function that is added to the onActivateObservable
  108180. */
  108181. set onActivate(callback: Nullable<(camera: Camera) => void>);
  108182. /**
  108183. * An event triggered when the postprocess changes its size.
  108184. */
  108185. onSizeChangedObservable: Observable<PostProcess>;
  108186. private _onSizeChangedObserver;
  108187. /**
  108188. * A function that is added to the onSizeChangedObservable
  108189. */
  108190. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  108191. /**
  108192. * An event triggered when the postprocess applies its effect.
  108193. */
  108194. onApplyObservable: Observable<Effect>;
  108195. private _onApplyObserver;
  108196. /**
  108197. * A function that is added to the onApplyObservable
  108198. */
  108199. set onApply(callback: (effect: Effect) => void);
  108200. /**
  108201. * An event triggered before rendering the postprocess
  108202. */
  108203. onBeforeRenderObservable: Observable<Effect>;
  108204. private _onBeforeRenderObserver;
  108205. /**
  108206. * A function that is added to the onBeforeRenderObservable
  108207. */
  108208. set onBeforeRender(callback: (effect: Effect) => void);
  108209. /**
  108210. * An event triggered after rendering the postprocess
  108211. */
  108212. onAfterRenderObservable: Observable<Effect>;
  108213. private _onAfterRenderObserver;
  108214. /**
  108215. * A function that is added to the onAfterRenderObservable
  108216. */
  108217. set onAfterRender(callback: (efect: Effect) => void);
  108218. /**
  108219. * 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
  108220. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  108221. */
  108222. get inputTexture(): InternalTexture;
  108223. set inputTexture(value: InternalTexture);
  108224. /**
  108225. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  108226. * the only way to unset it is to use this function to restore its internal state
  108227. */
  108228. restoreDefaultInputTexture(): void;
  108229. /**
  108230. * Gets the camera which post process is applied to.
  108231. * @returns The camera the post process is applied to.
  108232. */
  108233. getCamera(): Camera;
  108234. /**
  108235. * Gets the texel size of the postprocess.
  108236. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  108237. */
  108238. get texelSize(): Vector2;
  108239. /**
  108240. * Creates a new instance PostProcess
  108241. * @param name The name of the PostProcess.
  108242. * @param fragmentUrl The url of the fragment shader to be used.
  108243. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  108244. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  108245. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108246. * @param camera The camera to apply the render pass to.
  108247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108248. * @param engine The engine which the post process will be applied. (default: current engine)
  108249. * @param reusable If the post process can be reused on the same frame. (default: false)
  108250. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  108251. * @param textureType Type of textures used when performing the post process. (default: 0)
  108252. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  108253. * @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
  108254. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  108255. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  108256. */
  108257. 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);
  108258. /**
  108259. * Gets a string identifying the name of the class
  108260. * @returns "PostProcess" string
  108261. */
  108262. getClassName(): string;
  108263. /**
  108264. * Gets the engine which this post process belongs to.
  108265. * @returns The engine the post process was enabled with.
  108266. */
  108267. getEngine(): Engine;
  108268. /**
  108269. * The effect that is created when initializing the post process.
  108270. * @returns The created effect corresponding the the postprocess.
  108271. */
  108272. getEffect(): Effect;
  108273. /**
  108274. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  108275. * @param postProcess The post process to share the output with.
  108276. * @returns This post process.
  108277. */
  108278. shareOutputWith(postProcess: PostProcess): PostProcess;
  108279. /**
  108280. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  108281. * This should be called if the post process that shares output with this post process is disabled/disposed.
  108282. */
  108283. useOwnOutput(): void;
  108284. /**
  108285. * Updates the effect with the current post process compile time values and recompiles the shader.
  108286. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108287. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108288. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108289. * @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
  108290. * @param onCompiled Called when the shader has been compiled.
  108291. * @param onError Called if there is an error when compiling a shader.
  108292. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  108293. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  108294. */
  108295. 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;
  108296. /**
  108297. * The post process is reusable if it can be used multiple times within one frame.
  108298. * @returns If the post process is reusable
  108299. */
  108300. isReusable(): boolean;
  108301. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  108302. markTextureDirty(): void;
  108303. /**
  108304. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  108305. * 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.
  108306. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  108307. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  108308. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  108309. * @returns The target texture that was bound to be written to.
  108310. */
  108311. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  108312. /**
  108313. * If the post process is supported.
  108314. */
  108315. get isSupported(): boolean;
  108316. /**
  108317. * The aspect ratio of the output texture.
  108318. */
  108319. get aspectRatio(): number;
  108320. /**
  108321. * Get a value indicating if the post-process is ready to be used
  108322. * @returns true if the post-process is ready (shader is compiled)
  108323. */
  108324. isReady(): boolean;
  108325. /**
  108326. * Binds all textures and uniforms to the shader, this will be run on every pass.
  108327. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  108328. */
  108329. apply(): Nullable<Effect>;
  108330. private _disposeTextures;
  108331. /**
  108332. * Sets the required values to the prepass renderer.
  108333. * @param prePassRenderer defines the prepass renderer to setup.
  108334. * @returns true if the pre pass is needed.
  108335. */
  108336. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  108337. /**
  108338. * Disposes the post process.
  108339. * @param camera The camera to dispose the post process on.
  108340. */
  108341. dispose(camera?: Camera): void;
  108342. /**
  108343. * Serializes the particle system to a JSON object
  108344. * @returns the JSON object
  108345. */
  108346. serialize(): any;
  108347. /**
  108348. * Creates a material from parsed material data
  108349. * @param parsedPostProcess defines parsed post process data
  108350. * @param scene defines the hosting scene
  108351. * @param rootUrl defines the root URL to use to load textures
  108352. * @returns a new post process
  108353. */
  108354. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  108355. }
  108356. }
  108357. declare module BABYLON {
  108358. /** @hidden */
  108359. export var kernelBlurVaryingDeclaration: {
  108360. name: string;
  108361. shader: string;
  108362. };
  108363. }
  108364. declare module BABYLON {
  108365. /** @hidden */
  108366. export var kernelBlurFragment: {
  108367. name: string;
  108368. shader: string;
  108369. };
  108370. }
  108371. declare module BABYLON {
  108372. /** @hidden */
  108373. export var kernelBlurFragment2: {
  108374. name: string;
  108375. shader: string;
  108376. };
  108377. }
  108378. declare module BABYLON {
  108379. /** @hidden */
  108380. export var kernelBlurPixelShader: {
  108381. name: string;
  108382. shader: string;
  108383. };
  108384. }
  108385. declare module BABYLON {
  108386. /** @hidden */
  108387. export var kernelBlurVertex: {
  108388. name: string;
  108389. shader: string;
  108390. };
  108391. }
  108392. declare module BABYLON {
  108393. /** @hidden */
  108394. export var kernelBlurVertexShader: {
  108395. name: string;
  108396. shader: string;
  108397. };
  108398. }
  108399. declare module BABYLON {
  108400. /**
  108401. * The Blur Post Process which blurs an image based on a kernel and direction.
  108402. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  108403. */
  108404. export class BlurPostProcess extends PostProcess {
  108405. private blockCompilation;
  108406. protected _kernel: number;
  108407. protected _idealKernel: number;
  108408. protected _packedFloat: boolean;
  108409. private _staticDefines;
  108410. /** The direction in which to blur the image. */
  108411. direction: Vector2;
  108412. /**
  108413. * Sets the length in pixels of the blur sample region
  108414. */
  108415. set kernel(v: number);
  108416. /**
  108417. * Gets the length in pixels of the blur sample region
  108418. */
  108419. get kernel(): number;
  108420. /**
  108421. * Sets wether or not the blur needs to unpack/repack floats
  108422. */
  108423. set packedFloat(v: boolean);
  108424. /**
  108425. * Gets wether or not the blur is unpacking/repacking floats
  108426. */
  108427. get packedFloat(): boolean;
  108428. /**
  108429. * Gets a string identifying the name of the class
  108430. * @returns "BlurPostProcess" string
  108431. */
  108432. getClassName(): string;
  108433. /**
  108434. * Creates a new instance BlurPostProcess
  108435. * @param name The name of the effect.
  108436. * @param direction The direction in which to blur the image.
  108437. * @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.
  108438. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108439. * @param camera The camera to apply the render pass to.
  108440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108441. * @param engine The engine which the post process will be applied. (default: current engine)
  108442. * @param reusable If the post process can be reused on the same frame. (default: false)
  108443. * @param textureType Type of textures used when performing the post process. (default: 0)
  108444. * @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)
  108445. */
  108446. 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);
  108447. /**
  108448. * Updates the effect with the current post process compile time values and recompiles the shader.
  108449. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108450. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108451. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108452. * @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
  108453. * @param onCompiled Called when the shader has been compiled.
  108454. * @param onError Called if there is an error when compiling a shader.
  108455. */
  108456. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108457. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108458. /**
  108459. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  108460. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  108461. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  108462. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  108463. * The gaps between physical kernels are compensated for in the weighting of the samples
  108464. * @param idealKernel Ideal blur kernel.
  108465. * @return Nearest best kernel.
  108466. */
  108467. protected _nearestBestKernel(idealKernel: number): number;
  108468. /**
  108469. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  108470. * @param x The point on the Gaussian distribution to sample.
  108471. * @return the value of the Gaussian function at x.
  108472. */
  108473. protected _gaussianWeight(x: number): number;
  108474. /**
  108475. * Generates a string that can be used as a floating point number in GLSL.
  108476. * @param x Value to print.
  108477. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  108478. * @return GLSL float string.
  108479. */
  108480. protected _glslFloat(x: number, decimalFigures?: number): string;
  108481. /** @hidden */
  108482. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  108483. }
  108484. }
  108485. declare module BABYLON {
  108486. /**
  108487. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108488. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108489. * You can then easily use it as a reflectionTexture on a flat surface.
  108490. * In case the surface is not a plane, please consider relying on reflection probes.
  108491. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108492. */
  108493. export class MirrorTexture extends RenderTargetTexture {
  108494. private scene;
  108495. /**
  108496. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  108497. * 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.
  108498. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108499. */
  108500. mirrorPlane: Plane;
  108501. /**
  108502. * Define the blur ratio used to blur the reflection if needed.
  108503. */
  108504. set blurRatio(value: number);
  108505. get blurRatio(): number;
  108506. /**
  108507. * Define the adaptive blur kernel used to blur the reflection if needed.
  108508. * This will autocompute the closest best match for the `blurKernel`
  108509. */
  108510. set adaptiveBlurKernel(value: number);
  108511. /**
  108512. * Define the blur kernel used to blur the reflection if needed.
  108513. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108514. */
  108515. set blurKernel(value: number);
  108516. /**
  108517. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  108518. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108519. */
  108520. set blurKernelX(value: number);
  108521. get blurKernelX(): number;
  108522. /**
  108523. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  108524. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108525. */
  108526. set blurKernelY(value: number);
  108527. get blurKernelY(): number;
  108528. private _autoComputeBlurKernel;
  108529. protected _onRatioRescale(): void;
  108530. private _updateGammaSpace;
  108531. private _imageProcessingConfigChangeObserver;
  108532. private _transformMatrix;
  108533. private _mirrorMatrix;
  108534. private _savedViewMatrix;
  108535. private _blurX;
  108536. private _blurY;
  108537. private _adaptiveBlurKernel;
  108538. private _blurKernelX;
  108539. private _blurKernelY;
  108540. private _blurRatio;
  108541. /**
  108542. * Instantiates a Mirror Texture.
  108543. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108544. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108545. * You can then easily use it as a reflectionTexture on a flat surface.
  108546. * In case the surface is not a plane, please consider relying on reflection probes.
  108547. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108548. * @param name
  108549. * @param size
  108550. * @param scene
  108551. * @param generateMipMaps
  108552. * @param type
  108553. * @param samplingMode
  108554. * @param generateDepthBuffer
  108555. */
  108556. constructor(name: string, size: number | {
  108557. width: number;
  108558. height: number;
  108559. } | {
  108560. ratio: number;
  108561. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  108562. private _preparePostProcesses;
  108563. /**
  108564. * Clone the mirror texture.
  108565. * @returns the cloned texture
  108566. */
  108567. clone(): MirrorTexture;
  108568. /**
  108569. * Serialize the texture to a JSON representation you could use in Parse later on
  108570. * @returns the serialized JSON representation
  108571. */
  108572. serialize(): any;
  108573. /**
  108574. * Dispose the texture and release its associated resources.
  108575. */
  108576. dispose(): void;
  108577. }
  108578. }
  108579. declare module BABYLON {
  108580. /**
  108581. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108582. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108583. */
  108584. export class Texture extends BaseTexture {
  108585. /**
  108586. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  108587. */
  108588. static SerializeBuffers: boolean;
  108589. /** @hidden */
  108590. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  108591. /** @hidden */
  108592. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  108593. /** @hidden */
  108594. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  108595. /** nearest is mag = nearest and min = nearest and mip = linear */
  108596. static readonly NEAREST_SAMPLINGMODE: number;
  108597. /** nearest is mag = nearest and min = nearest and mip = linear */
  108598. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  108599. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108600. static readonly BILINEAR_SAMPLINGMODE: number;
  108601. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108602. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  108603. /** Trilinear is mag = linear and min = linear and mip = linear */
  108604. static readonly TRILINEAR_SAMPLINGMODE: number;
  108605. /** Trilinear is mag = linear and min = linear and mip = linear */
  108606. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  108607. /** mag = nearest and min = nearest and mip = nearest */
  108608. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  108609. /** mag = nearest and min = linear and mip = nearest */
  108610. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  108611. /** mag = nearest and min = linear and mip = linear */
  108612. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  108613. /** mag = nearest and min = linear and mip = none */
  108614. static readonly NEAREST_LINEAR: number;
  108615. /** mag = nearest and min = nearest and mip = none */
  108616. static readonly NEAREST_NEAREST: number;
  108617. /** mag = linear and min = nearest and mip = nearest */
  108618. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  108619. /** mag = linear and min = nearest and mip = linear */
  108620. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  108621. /** mag = linear and min = linear and mip = none */
  108622. static readonly LINEAR_LINEAR: number;
  108623. /** mag = linear and min = nearest and mip = none */
  108624. static readonly LINEAR_NEAREST: number;
  108625. /** Explicit coordinates mode */
  108626. static readonly EXPLICIT_MODE: number;
  108627. /** Spherical coordinates mode */
  108628. static readonly SPHERICAL_MODE: number;
  108629. /** Planar coordinates mode */
  108630. static readonly PLANAR_MODE: number;
  108631. /** Cubic coordinates mode */
  108632. static readonly CUBIC_MODE: number;
  108633. /** Projection coordinates mode */
  108634. static readonly PROJECTION_MODE: number;
  108635. /** Inverse Cubic coordinates mode */
  108636. static readonly SKYBOX_MODE: number;
  108637. /** Inverse Cubic coordinates mode */
  108638. static readonly INVCUBIC_MODE: number;
  108639. /** Equirectangular coordinates mode */
  108640. static readonly EQUIRECTANGULAR_MODE: number;
  108641. /** Equirectangular Fixed coordinates mode */
  108642. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  108643. /** Equirectangular Fixed Mirrored coordinates mode */
  108644. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  108645. /** Texture is not repeating outside of 0..1 UVs */
  108646. static readonly CLAMP_ADDRESSMODE: number;
  108647. /** Texture is repeating outside of 0..1 UVs */
  108648. static readonly WRAP_ADDRESSMODE: number;
  108649. /** Texture is repeating and mirrored */
  108650. static readonly MIRROR_ADDRESSMODE: number;
  108651. /**
  108652. * 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
  108653. */
  108654. static UseSerializedUrlIfAny: boolean;
  108655. /**
  108656. * Define the url of the texture.
  108657. */
  108658. url: Nullable<string>;
  108659. /**
  108660. * Define an offset on the texture to offset the u coordinates of the UVs
  108661. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108662. */
  108663. uOffset: number;
  108664. /**
  108665. * Define an offset on the texture to offset the v coordinates of the UVs
  108666. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108667. */
  108668. vOffset: number;
  108669. /**
  108670. * Define an offset on the texture to scale the u coordinates of the UVs
  108671. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108672. */
  108673. uScale: number;
  108674. /**
  108675. * Define an offset on the texture to scale the v coordinates of the UVs
  108676. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108677. */
  108678. vScale: number;
  108679. /**
  108680. * Define an offset on the texture to rotate around the u coordinates of the UVs
  108681. * @see https://doc.babylonjs.com/how_to/more_materials
  108682. */
  108683. uAng: number;
  108684. /**
  108685. * Define an offset on the texture to rotate around the v coordinates of the UVs
  108686. * @see https://doc.babylonjs.com/how_to/more_materials
  108687. */
  108688. vAng: number;
  108689. /**
  108690. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  108691. * @see https://doc.babylonjs.com/how_to/more_materials
  108692. */
  108693. wAng: number;
  108694. /**
  108695. * Defines the center of rotation (U)
  108696. */
  108697. uRotationCenter: number;
  108698. /**
  108699. * Defines the center of rotation (V)
  108700. */
  108701. vRotationCenter: number;
  108702. /**
  108703. * Defines the center of rotation (W)
  108704. */
  108705. wRotationCenter: number;
  108706. /**
  108707. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  108708. */
  108709. homogeneousRotationInUVTransform: boolean;
  108710. /**
  108711. * Are mip maps generated for this texture or not.
  108712. */
  108713. get noMipmap(): boolean;
  108714. /**
  108715. * List of inspectable custom properties (used by the Inspector)
  108716. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108717. */
  108718. inspectableCustomProperties: Nullable<IInspectable[]>;
  108719. private _noMipmap;
  108720. /** @hidden */
  108721. _invertY: boolean;
  108722. private _rowGenerationMatrix;
  108723. private _cachedTextureMatrix;
  108724. private _projectionModeMatrix;
  108725. private _t0;
  108726. private _t1;
  108727. private _t2;
  108728. private _cachedUOffset;
  108729. private _cachedVOffset;
  108730. private _cachedUScale;
  108731. private _cachedVScale;
  108732. private _cachedUAng;
  108733. private _cachedVAng;
  108734. private _cachedWAng;
  108735. private _cachedProjectionMatrixId;
  108736. private _cachedURotationCenter;
  108737. private _cachedVRotationCenter;
  108738. private _cachedWRotationCenter;
  108739. private _cachedHomogeneousRotationInUVTransform;
  108740. private _cachedCoordinatesMode;
  108741. /** @hidden */
  108742. protected _initialSamplingMode: number;
  108743. /** @hidden */
  108744. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  108745. private _deleteBuffer;
  108746. protected _format: Nullable<number>;
  108747. private _delayedOnLoad;
  108748. private _delayedOnError;
  108749. private _mimeType?;
  108750. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  108751. get mimeType(): string | undefined;
  108752. /**
  108753. * Observable triggered once the texture has been loaded.
  108754. */
  108755. onLoadObservable: Observable<Texture>;
  108756. protected _isBlocking: boolean;
  108757. /**
  108758. * Is the texture preventing material to render while loading.
  108759. * If false, a default texture will be used instead of the loading one during the preparation step.
  108760. */
  108761. set isBlocking(value: boolean);
  108762. get isBlocking(): boolean;
  108763. /**
  108764. * Get the current sampling mode associated with the texture.
  108765. */
  108766. get samplingMode(): number;
  108767. /**
  108768. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  108769. */
  108770. get invertY(): boolean;
  108771. /**
  108772. * Instantiates a new texture.
  108773. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108774. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108775. * @param url defines the url of the picture to load as a texture
  108776. * @param sceneOrEngine defines the scene or engine the texture will belong to
  108777. * @param noMipmap defines if the texture will require mip maps or not
  108778. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  108779. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108780. * @param onLoad defines a callback triggered when the texture has been loaded
  108781. * @param onError defines a callback triggered when an error occurred during the loading session
  108782. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  108783. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  108784. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108785. * @param mimeType defines an optional mime type information
  108786. */
  108787. 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);
  108788. /**
  108789. * Update the url (and optional buffer) of this texture if url was null during construction.
  108790. * @param url the url of the texture
  108791. * @param buffer the buffer of the texture (defaults to null)
  108792. * @param onLoad callback called when the texture is loaded (defaults to null)
  108793. */
  108794. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  108795. /**
  108796. * Finish the loading sequence of a texture flagged as delayed load.
  108797. * @hidden
  108798. */
  108799. delayLoad(): void;
  108800. private _prepareRowForTextureGeneration;
  108801. /**
  108802. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  108803. * @returns the transform matrix of the texture.
  108804. */
  108805. getTextureMatrix(uBase?: number): Matrix;
  108806. /**
  108807. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  108808. * @returns The reflection texture transform
  108809. */
  108810. getReflectionTextureMatrix(): Matrix;
  108811. /**
  108812. * Clones the texture.
  108813. * @returns the cloned texture
  108814. */
  108815. clone(): Texture;
  108816. /**
  108817. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  108818. * @returns The JSON representation of the texture
  108819. */
  108820. serialize(): any;
  108821. /**
  108822. * Get the current class name of the texture useful for serialization or dynamic coding.
  108823. * @returns "Texture"
  108824. */
  108825. getClassName(): string;
  108826. /**
  108827. * Dispose the texture and release its associated resources.
  108828. */
  108829. dispose(): void;
  108830. /**
  108831. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  108832. * @param parsedTexture Define the JSON representation of the texture
  108833. * @param scene Define the scene the parsed texture should be instantiated in
  108834. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108835. * @returns The parsed texture if successful
  108836. */
  108837. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  108838. /**
  108839. * Creates a texture from its base 64 representation.
  108840. * @param data Define the base64 payload without the data: prefix
  108841. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108842. * @param scene Define the scene the texture should belong to
  108843. * @param noMipmap Forces the texture to not create mip map information if true
  108844. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108845. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108846. * @param onLoad define a callback triggered when the texture has been loaded
  108847. * @param onError define a callback triggered when an error occurred during the loading session
  108848. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108849. * @returns the created texture
  108850. */
  108851. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  108852. /**
  108853. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  108854. * @param data Define the base64 payload without the data: prefix
  108855. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108856. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  108857. * @param scene Define the scene the texture should belong to
  108858. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  108859. * @param noMipmap Forces the texture to not create mip map information if true
  108860. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108861. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108862. * @param onLoad define a callback triggered when the texture has been loaded
  108863. * @param onError define a callback triggered when an error occurred during the loading session
  108864. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108865. * @returns the created texture
  108866. */
  108867. 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;
  108868. }
  108869. }
  108870. declare module BABYLON {
  108871. /**
  108872. * PostProcessManager is used to manage one or more post processes or post process pipelines
  108873. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108874. */
  108875. export class PostProcessManager {
  108876. private _scene;
  108877. private _indexBuffer;
  108878. private _vertexBuffers;
  108879. /**
  108880. * Creates a new instance PostProcess
  108881. * @param scene The scene that the post process is associated with.
  108882. */
  108883. constructor(scene: Scene);
  108884. private _prepareBuffers;
  108885. private _buildIndexBuffer;
  108886. /**
  108887. * Rebuilds the vertex buffers of the manager.
  108888. * @hidden
  108889. */
  108890. _rebuild(): void;
  108891. /**
  108892. * Prepares a frame to be run through a post process.
  108893. * @param sourceTexture The input texture to the post procesess. (default: null)
  108894. * @param postProcesses An array of post processes to be run. (default: null)
  108895. * @returns True if the post processes were able to be run.
  108896. * @hidden
  108897. */
  108898. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  108899. /**
  108900. * Manually render a set of post processes to a texture.
  108901. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  108902. * @param postProcesses An array of post processes to be run.
  108903. * @param targetTexture The target texture to render to.
  108904. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  108905. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  108906. * @param lodLevel defines which lod of the texture to render to
  108907. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  108908. */
  108909. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  108910. /**
  108911. * Finalize the result of the output of the postprocesses.
  108912. * @param doNotPresent If true the result will not be displayed to the screen.
  108913. * @param targetTexture The target texture to render to.
  108914. * @param faceIndex The index of the face to bind the target texture to.
  108915. * @param postProcesses The array of post processes to render.
  108916. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  108917. * @hidden
  108918. */
  108919. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  108920. /**
  108921. * Disposes of the post process manager.
  108922. */
  108923. dispose(): void;
  108924. }
  108925. }
  108926. declare module BABYLON {
  108927. /**
  108928. * This Helps creating a texture that will be created from a camera in your scene.
  108929. * It is basically a dynamic texture that could be used to create special effects for instance.
  108930. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  108931. */
  108932. export class RenderTargetTexture extends Texture {
  108933. /**
  108934. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  108935. */
  108936. static readonly REFRESHRATE_RENDER_ONCE: number;
  108937. /**
  108938. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  108939. */
  108940. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  108941. /**
  108942. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  108943. * the central point of your effect and can save a lot of performances.
  108944. */
  108945. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  108946. /**
  108947. * Use this predicate to dynamically define the list of mesh you want to render.
  108948. * If set, the renderList property will be overwritten.
  108949. */
  108950. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  108951. private _renderList;
  108952. /**
  108953. * Use this list to define the list of mesh you want to render.
  108954. */
  108955. get renderList(): Nullable<Array<AbstractMesh>>;
  108956. set renderList(value: Nullable<Array<AbstractMesh>>);
  108957. /**
  108958. * Use this function to overload the renderList array at rendering time.
  108959. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  108960. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  108961. * the cube (if the RTT is a cube, else layerOrFace=0).
  108962. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  108963. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  108964. * hold dummy elements!
  108965. */
  108966. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  108967. private _hookArray;
  108968. /**
  108969. * Define if particles should be rendered in your texture.
  108970. */
  108971. renderParticles: boolean;
  108972. /**
  108973. * Define if sprites should be rendered in your texture.
  108974. */
  108975. renderSprites: boolean;
  108976. /**
  108977. * Define the camera used to render the texture.
  108978. */
  108979. activeCamera: Nullable<Camera>;
  108980. /**
  108981. * Override the mesh isReady function with your own one.
  108982. */
  108983. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  108984. /**
  108985. * Override the render function of the texture with your own one.
  108986. */
  108987. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  108988. /**
  108989. * Define if camera post processes should be use while rendering the texture.
  108990. */
  108991. useCameraPostProcesses: boolean;
  108992. /**
  108993. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  108994. */
  108995. ignoreCameraViewport: boolean;
  108996. private _postProcessManager;
  108997. private _postProcesses;
  108998. private _resizeObserver;
  108999. /**
  109000. * An event triggered when the texture is unbind.
  109001. */
  109002. onBeforeBindObservable: Observable<RenderTargetTexture>;
  109003. /**
  109004. * An event triggered when the texture is unbind.
  109005. */
  109006. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  109007. private _onAfterUnbindObserver;
  109008. /**
  109009. * Set a after unbind callback in the texture.
  109010. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  109011. */
  109012. set onAfterUnbind(callback: () => void);
  109013. /**
  109014. * An event triggered before rendering the texture
  109015. */
  109016. onBeforeRenderObservable: Observable<number>;
  109017. private _onBeforeRenderObserver;
  109018. /**
  109019. * Set a before render callback in the texture.
  109020. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  109021. */
  109022. set onBeforeRender(callback: (faceIndex: number) => void);
  109023. /**
  109024. * An event triggered after rendering the texture
  109025. */
  109026. onAfterRenderObservable: Observable<number>;
  109027. private _onAfterRenderObserver;
  109028. /**
  109029. * Set a after render callback in the texture.
  109030. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  109031. */
  109032. set onAfterRender(callback: (faceIndex: number) => void);
  109033. /**
  109034. * An event triggered after the texture clear
  109035. */
  109036. onClearObservable: Observable<Engine>;
  109037. private _onClearObserver;
  109038. /**
  109039. * Set a clear callback in the texture.
  109040. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  109041. */
  109042. set onClear(callback: (Engine: Engine) => void);
  109043. /**
  109044. * An event triggered when the texture is resized.
  109045. */
  109046. onResizeObservable: Observable<RenderTargetTexture>;
  109047. /**
  109048. * Define the clear color of the Render Target if it should be different from the scene.
  109049. */
  109050. clearColor: Color4;
  109051. protected _size: number | {
  109052. width: number;
  109053. height: number;
  109054. layers?: number;
  109055. };
  109056. protected _initialSizeParameter: number | {
  109057. width: number;
  109058. height: number;
  109059. } | {
  109060. ratio: number;
  109061. };
  109062. protected _sizeRatio: Nullable<number>;
  109063. /** @hidden */
  109064. _generateMipMaps: boolean;
  109065. protected _renderingManager: RenderingManager;
  109066. /** @hidden */
  109067. _waitingRenderList?: string[];
  109068. protected _doNotChangeAspectRatio: boolean;
  109069. protected _currentRefreshId: number;
  109070. protected _refreshRate: number;
  109071. protected _textureMatrix: Matrix;
  109072. protected _samples: number;
  109073. protected _renderTargetOptions: RenderTargetCreationOptions;
  109074. /**
  109075. * Gets render target creation options that were used.
  109076. */
  109077. get renderTargetOptions(): RenderTargetCreationOptions;
  109078. protected _onRatioRescale(): void;
  109079. /**
  109080. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  109081. * It must define where the camera used to render the texture is set
  109082. */
  109083. boundingBoxPosition: Vector3;
  109084. private _boundingBoxSize;
  109085. /**
  109086. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  109087. * When defined, the cubemap will switch to local mode
  109088. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  109089. * @example https://www.babylonjs-playground.com/#RNASML
  109090. */
  109091. set boundingBoxSize(value: Vector3);
  109092. get boundingBoxSize(): Vector3;
  109093. /**
  109094. * In case the RTT has been created with a depth texture, get the associated
  109095. * depth texture.
  109096. * Otherwise, return null.
  109097. */
  109098. get depthStencilTexture(): Nullable<InternalTexture>;
  109099. /**
  109100. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  109101. * or used a shadow, depth texture...
  109102. * @param name The friendly name of the texture
  109103. * @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)
  109104. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  109105. * @param generateMipMaps True if mip maps need to be generated after render.
  109106. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  109107. * @param type The type of the buffer in the RTT (int, half float, float...)
  109108. * @param isCube True if a cube texture needs to be created
  109109. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  109110. * @param generateDepthBuffer True to generate a depth buffer
  109111. * @param generateStencilBuffer True to generate a stencil buffer
  109112. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  109113. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  109114. * @param delayAllocation if the texture allocation should be delayed (default: false)
  109115. */
  109116. constructor(name: string, size: number | {
  109117. width: number;
  109118. height: number;
  109119. layers?: number;
  109120. } | {
  109121. ratio: number;
  109122. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  109123. /**
  109124. * Creates a depth stencil texture.
  109125. * This is only available in WebGL 2 or with the depth texture extension available.
  109126. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  109127. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  109128. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  109129. */
  109130. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  109131. private _processSizeParameter;
  109132. /**
  109133. * Define the number of samples to use in case of MSAA.
  109134. * It defaults to one meaning no MSAA has been enabled.
  109135. */
  109136. get samples(): number;
  109137. set samples(value: number);
  109138. /**
  109139. * Resets the refresh counter of the texture and start bak from scratch.
  109140. * Could be useful to regenerate the texture if it is setup to render only once.
  109141. */
  109142. resetRefreshCounter(): void;
  109143. /**
  109144. * Define the refresh rate of the texture or the rendering frequency.
  109145. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  109146. */
  109147. get refreshRate(): number;
  109148. set refreshRate(value: number);
  109149. /**
  109150. * Adds a post process to the render target rendering passes.
  109151. * @param postProcess define the post process to add
  109152. */
  109153. addPostProcess(postProcess: PostProcess): void;
  109154. /**
  109155. * Clear all the post processes attached to the render target
  109156. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  109157. */
  109158. clearPostProcesses(dispose?: boolean): void;
  109159. /**
  109160. * Remove one of the post process from the list of attached post processes to the texture
  109161. * @param postProcess define the post process to remove from the list
  109162. */
  109163. removePostProcess(postProcess: PostProcess): void;
  109164. /** @hidden */
  109165. _shouldRender(): boolean;
  109166. /**
  109167. * Gets the actual render size of the texture.
  109168. * @returns the width of the render size
  109169. */
  109170. getRenderSize(): number;
  109171. /**
  109172. * Gets the actual render width of the texture.
  109173. * @returns the width of the render size
  109174. */
  109175. getRenderWidth(): number;
  109176. /**
  109177. * Gets the actual render height of the texture.
  109178. * @returns the height of the render size
  109179. */
  109180. getRenderHeight(): number;
  109181. /**
  109182. * Gets the actual number of layers of the texture.
  109183. * @returns the number of layers
  109184. */
  109185. getRenderLayers(): number;
  109186. /**
  109187. * Get if the texture can be rescaled or not.
  109188. */
  109189. get canRescale(): boolean;
  109190. /**
  109191. * Resize the texture using a ratio.
  109192. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  109193. */
  109194. scale(ratio: number): void;
  109195. /**
  109196. * Get the texture reflection matrix used to rotate/transform the reflection.
  109197. * @returns the reflection matrix
  109198. */
  109199. getReflectionTextureMatrix(): Matrix;
  109200. /**
  109201. * Resize the texture to a new desired size.
  109202. * Be carrefull as it will recreate all the data in the new texture.
  109203. * @param size Define the new size. It can be:
  109204. * - a number for squared texture,
  109205. * - an object containing { width: number, height: number }
  109206. * - or an object containing a ratio { ratio: number }
  109207. */
  109208. resize(size: number | {
  109209. width: number;
  109210. height: number;
  109211. } | {
  109212. ratio: number;
  109213. }): void;
  109214. private _defaultRenderListPrepared;
  109215. /**
  109216. * Renders all the objects from the render list into the texture.
  109217. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  109218. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  109219. */
  109220. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  109221. private _bestReflectionRenderTargetDimension;
  109222. private _prepareRenderingManager;
  109223. /**
  109224. * @hidden
  109225. * @param faceIndex face index to bind to if this is a cubetexture
  109226. * @param layer defines the index of the texture to bind in the array
  109227. */
  109228. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  109229. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109230. private renderToTarget;
  109231. /**
  109232. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  109233. * This allowed control for front to back rendering or reversly depending of the special needs.
  109234. *
  109235. * @param renderingGroupId The rendering group id corresponding to its index
  109236. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  109237. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  109238. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  109239. */
  109240. 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;
  109241. /**
  109242. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  109243. *
  109244. * @param renderingGroupId The rendering group id corresponding to its index
  109245. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109246. */
  109247. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  109248. /**
  109249. * Clones the texture.
  109250. * @returns the cloned texture
  109251. */
  109252. clone(): RenderTargetTexture;
  109253. /**
  109254. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  109255. * @returns The JSON representation of the texture
  109256. */
  109257. serialize(): any;
  109258. /**
  109259. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  109260. */
  109261. disposeFramebufferObjects(): void;
  109262. /**
  109263. * Dispose the texture and release its associated resources.
  109264. */
  109265. dispose(): void;
  109266. /** @hidden */
  109267. _rebuild(): void;
  109268. /**
  109269. * Clear the info related to rendering groups preventing retention point in material dispose.
  109270. */
  109271. freeRenderingGroups(): void;
  109272. /**
  109273. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  109274. * @returns the view count
  109275. */
  109276. getViewCount(): number;
  109277. }
  109278. }
  109279. declare module BABYLON {
  109280. /**
  109281. * Class used to manipulate GUIDs
  109282. */
  109283. export class GUID {
  109284. /**
  109285. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  109286. * Be aware Math.random() could cause collisions, but:
  109287. * "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"
  109288. * @returns a pseudo random id
  109289. */
  109290. static RandomId(): string;
  109291. }
  109292. }
  109293. declare module BABYLON {
  109294. /**
  109295. * Options to be used when creating a shadow depth material
  109296. */
  109297. export interface IIOptionShadowDepthMaterial {
  109298. /** Variables in the vertex shader code that need to have their names remapped.
  109299. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  109300. * "var_name" should be either: worldPos or vNormalW
  109301. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  109302. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  109303. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  109304. */
  109305. remappedVariables?: string[];
  109306. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  109307. standalone?: boolean;
  109308. }
  109309. /**
  109310. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  109311. */
  109312. export class ShadowDepthWrapper {
  109313. private _scene;
  109314. private _options?;
  109315. private _baseMaterial;
  109316. private _onEffectCreatedObserver;
  109317. private _subMeshToEffect;
  109318. private _subMeshToDepthEffect;
  109319. private _meshes;
  109320. /** @hidden */
  109321. _matriceNames: any;
  109322. /** Gets the standalone status of the wrapper */
  109323. get standalone(): boolean;
  109324. /** Gets the base material the wrapper is built upon */
  109325. get baseMaterial(): Material;
  109326. /**
  109327. * Instantiate a new shadow depth wrapper.
  109328. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  109329. * generate the shadow depth map. For more information, please refer to the documentation:
  109330. * https://doc.babylonjs.com/babylon101/shadows
  109331. * @param baseMaterial Material to wrap
  109332. * @param scene Define the scene the material belongs to
  109333. * @param options Options used to create the wrapper
  109334. */
  109335. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  109336. /**
  109337. * Gets the effect to use to generate the depth map
  109338. * @param subMesh subMesh to get the effect for
  109339. * @param shadowGenerator shadow generator to get the effect for
  109340. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  109341. */
  109342. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  109343. /**
  109344. * Specifies that the submesh is ready to be used for depth rendering
  109345. * @param subMesh submesh to check
  109346. * @param defines the list of defines to take into account when checking the effect
  109347. * @param shadowGenerator combined with subMesh, it defines the effect to check
  109348. * @param useInstances specifies that instances should be used
  109349. * @returns a boolean indicating that the submesh is ready or not
  109350. */
  109351. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  109352. /**
  109353. * Disposes the resources
  109354. */
  109355. dispose(): void;
  109356. private _makeEffect;
  109357. }
  109358. }
  109359. declare module BABYLON {
  109360. /**
  109361. * Options for compiling materials.
  109362. */
  109363. export interface IMaterialCompilationOptions {
  109364. /**
  109365. * Defines whether clip planes are enabled.
  109366. */
  109367. clipPlane: boolean;
  109368. /**
  109369. * Defines whether instances are enabled.
  109370. */
  109371. useInstances: boolean;
  109372. }
  109373. /**
  109374. * Options passed when calling customShaderNameResolve
  109375. */
  109376. export interface ICustomShaderNameResolveOptions {
  109377. /**
  109378. * 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
  109379. */
  109380. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  109381. }
  109382. /**
  109383. * Base class for the main features of a material in Babylon.js
  109384. */
  109385. export class Material implements IAnimatable {
  109386. /**
  109387. * Returns the triangle fill mode
  109388. */
  109389. static readonly TriangleFillMode: number;
  109390. /**
  109391. * Returns the wireframe mode
  109392. */
  109393. static readonly WireFrameFillMode: number;
  109394. /**
  109395. * Returns the point fill mode
  109396. */
  109397. static readonly PointFillMode: number;
  109398. /**
  109399. * Returns the point list draw mode
  109400. */
  109401. static readonly PointListDrawMode: number;
  109402. /**
  109403. * Returns the line list draw mode
  109404. */
  109405. static readonly LineListDrawMode: number;
  109406. /**
  109407. * Returns the line loop draw mode
  109408. */
  109409. static readonly LineLoopDrawMode: number;
  109410. /**
  109411. * Returns the line strip draw mode
  109412. */
  109413. static readonly LineStripDrawMode: number;
  109414. /**
  109415. * Returns the triangle strip draw mode
  109416. */
  109417. static readonly TriangleStripDrawMode: number;
  109418. /**
  109419. * Returns the triangle fan draw mode
  109420. */
  109421. static readonly TriangleFanDrawMode: number;
  109422. /**
  109423. * Stores the clock-wise side orientation
  109424. */
  109425. static readonly ClockWiseSideOrientation: number;
  109426. /**
  109427. * Stores the counter clock-wise side orientation
  109428. */
  109429. static readonly CounterClockWiseSideOrientation: number;
  109430. /**
  109431. * The dirty texture flag value
  109432. */
  109433. static readonly TextureDirtyFlag: number;
  109434. /**
  109435. * The dirty light flag value
  109436. */
  109437. static readonly LightDirtyFlag: number;
  109438. /**
  109439. * The dirty fresnel flag value
  109440. */
  109441. static readonly FresnelDirtyFlag: number;
  109442. /**
  109443. * The dirty attribute flag value
  109444. */
  109445. static readonly AttributesDirtyFlag: number;
  109446. /**
  109447. * The dirty misc flag value
  109448. */
  109449. static readonly MiscDirtyFlag: number;
  109450. /**
  109451. * The dirty prepass flag value
  109452. */
  109453. static readonly PrePassDirtyFlag: number;
  109454. /**
  109455. * The all dirty flag value
  109456. */
  109457. static readonly AllDirtyFlag: number;
  109458. /**
  109459. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109460. */
  109461. static readonly MATERIAL_OPAQUE: number;
  109462. /**
  109463. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109464. */
  109465. static readonly MATERIAL_ALPHATEST: number;
  109466. /**
  109467. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109468. */
  109469. static readonly MATERIAL_ALPHABLEND: number;
  109470. /**
  109471. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109472. * They are also discarded below the alpha cutoff threshold to improve performances.
  109473. */
  109474. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  109475. /**
  109476. * The Whiteout method is used to blend normals.
  109477. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109478. */
  109479. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  109480. /**
  109481. * The Reoriented Normal Mapping method is used to blend normals.
  109482. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109483. */
  109484. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  109485. /**
  109486. * Custom callback helping to override the default shader used in the material.
  109487. */
  109488. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  109489. /**
  109490. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  109491. */
  109492. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  109493. /**
  109494. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  109495. * This means that the material can keep using a previous shader while a new one is being compiled.
  109496. * This is mostly used when shader parallel compilation is supported (true by default)
  109497. */
  109498. allowShaderHotSwapping: boolean;
  109499. /**
  109500. * The ID of the material
  109501. */
  109502. id: string;
  109503. /**
  109504. * Gets or sets the unique id of the material
  109505. */
  109506. uniqueId: number;
  109507. /**
  109508. * The name of the material
  109509. */
  109510. name: string;
  109511. /**
  109512. * Gets or sets user defined metadata
  109513. */
  109514. metadata: any;
  109515. /**
  109516. * For internal use only. Please do not use.
  109517. */
  109518. reservedDataStore: any;
  109519. /**
  109520. * Specifies if the ready state should be checked on each call
  109521. */
  109522. checkReadyOnEveryCall: boolean;
  109523. /**
  109524. * Specifies if the ready state should be checked once
  109525. */
  109526. checkReadyOnlyOnce: boolean;
  109527. /**
  109528. * The state of the material
  109529. */
  109530. state: string;
  109531. /**
  109532. * If the material can be rendered to several textures with MRT extension
  109533. */
  109534. get canRenderToMRT(): boolean;
  109535. /**
  109536. * The alpha value of the material
  109537. */
  109538. protected _alpha: number;
  109539. /**
  109540. * List of inspectable custom properties (used by the Inspector)
  109541. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109542. */
  109543. inspectableCustomProperties: IInspectable[];
  109544. /**
  109545. * Sets the alpha value of the material
  109546. */
  109547. set alpha(value: number);
  109548. /**
  109549. * Gets the alpha value of the material
  109550. */
  109551. get alpha(): number;
  109552. /**
  109553. * Specifies if back face culling is enabled
  109554. */
  109555. protected _backFaceCulling: boolean;
  109556. /**
  109557. * Sets the back-face culling state
  109558. */
  109559. set backFaceCulling(value: boolean);
  109560. /**
  109561. * Gets the back-face culling state
  109562. */
  109563. get backFaceCulling(): boolean;
  109564. /**
  109565. * Stores the value for side orientation
  109566. */
  109567. sideOrientation: number;
  109568. /**
  109569. * Callback triggered when the material is compiled
  109570. */
  109571. onCompiled: Nullable<(effect: Effect) => void>;
  109572. /**
  109573. * Callback triggered when an error occurs
  109574. */
  109575. onError: Nullable<(effect: Effect, errors: string) => void>;
  109576. /**
  109577. * Callback triggered to get the render target textures
  109578. */
  109579. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  109580. /**
  109581. * Gets a boolean indicating that current material needs to register RTT
  109582. */
  109583. get hasRenderTargetTextures(): boolean;
  109584. /**
  109585. * Specifies if the material should be serialized
  109586. */
  109587. doNotSerialize: boolean;
  109588. /**
  109589. * @hidden
  109590. */
  109591. _storeEffectOnSubMeshes: boolean;
  109592. /**
  109593. * Stores the animations for the material
  109594. */
  109595. animations: Nullable<Array<Animation>>;
  109596. /**
  109597. * An event triggered when the material is disposed
  109598. */
  109599. onDisposeObservable: Observable<Material>;
  109600. /**
  109601. * An observer which watches for dispose events
  109602. */
  109603. private _onDisposeObserver;
  109604. private _onUnBindObservable;
  109605. /**
  109606. * Called during a dispose event
  109607. */
  109608. set onDispose(callback: () => void);
  109609. private _onBindObservable;
  109610. /**
  109611. * An event triggered when the material is bound
  109612. */
  109613. get onBindObservable(): Observable<AbstractMesh>;
  109614. /**
  109615. * An observer which watches for bind events
  109616. */
  109617. private _onBindObserver;
  109618. /**
  109619. * Called during a bind event
  109620. */
  109621. set onBind(callback: (Mesh: AbstractMesh) => void);
  109622. /**
  109623. * An event triggered when the material is unbound
  109624. */
  109625. get onUnBindObservable(): Observable<Material>;
  109626. protected _onEffectCreatedObservable: Nullable<Observable<{
  109627. effect: Effect;
  109628. subMesh: Nullable<SubMesh>;
  109629. }>>;
  109630. /**
  109631. * An event triggered when the effect is (re)created
  109632. */
  109633. get onEffectCreatedObservable(): Observable<{
  109634. effect: Effect;
  109635. subMesh: Nullable<SubMesh>;
  109636. }>;
  109637. /**
  109638. * Stores the value of the alpha mode
  109639. */
  109640. private _alphaMode;
  109641. /**
  109642. * Sets the value of the alpha mode.
  109643. *
  109644. * | Value | Type | Description |
  109645. * | --- | --- | --- |
  109646. * | 0 | ALPHA_DISABLE | |
  109647. * | 1 | ALPHA_ADD | |
  109648. * | 2 | ALPHA_COMBINE | |
  109649. * | 3 | ALPHA_SUBTRACT | |
  109650. * | 4 | ALPHA_MULTIPLY | |
  109651. * | 5 | ALPHA_MAXIMIZED | |
  109652. * | 6 | ALPHA_ONEONE | |
  109653. * | 7 | ALPHA_PREMULTIPLIED | |
  109654. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  109655. * | 9 | ALPHA_INTERPOLATE | |
  109656. * | 10 | ALPHA_SCREENMODE | |
  109657. *
  109658. */
  109659. set alphaMode(value: number);
  109660. /**
  109661. * Gets the value of the alpha mode
  109662. */
  109663. get alphaMode(): number;
  109664. /**
  109665. * Stores the state of the need depth pre-pass value
  109666. */
  109667. private _needDepthPrePass;
  109668. /**
  109669. * Sets the need depth pre-pass value
  109670. */
  109671. set needDepthPrePass(value: boolean);
  109672. /**
  109673. * Gets the depth pre-pass value
  109674. */
  109675. get needDepthPrePass(): boolean;
  109676. /**
  109677. * Specifies if depth writing should be disabled
  109678. */
  109679. disableDepthWrite: boolean;
  109680. /**
  109681. * Specifies if color writing should be disabled
  109682. */
  109683. disableColorWrite: boolean;
  109684. /**
  109685. * Specifies if depth writing should be forced
  109686. */
  109687. forceDepthWrite: boolean;
  109688. /**
  109689. * Specifies the depth function that should be used. 0 means the default engine function
  109690. */
  109691. depthFunction: number;
  109692. /**
  109693. * Specifies if there should be a separate pass for culling
  109694. */
  109695. separateCullingPass: boolean;
  109696. /**
  109697. * Stores the state specifing if fog should be enabled
  109698. */
  109699. private _fogEnabled;
  109700. /**
  109701. * Sets the state for enabling fog
  109702. */
  109703. set fogEnabled(value: boolean);
  109704. /**
  109705. * Gets the value of the fog enabled state
  109706. */
  109707. get fogEnabled(): boolean;
  109708. /**
  109709. * Stores the size of points
  109710. */
  109711. pointSize: number;
  109712. /**
  109713. * Stores the z offset value
  109714. */
  109715. zOffset: number;
  109716. get wireframe(): boolean;
  109717. /**
  109718. * Sets the state of wireframe mode
  109719. */
  109720. set wireframe(value: boolean);
  109721. /**
  109722. * Gets the value specifying if point clouds are enabled
  109723. */
  109724. get pointsCloud(): boolean;
  109725. /**
  109726. * Sets the state of point cloud mode
  109727. */
  109728. set pointsCloud(value: boolean);
  109729. /**
  109730. * Gets the material fill mode
  109731. */
  109732. get fillMode(): number;
  109733. /**
  109734. * Sets the material fill mode
  109735. */
  109736. set fillMode(value: number);
  109737. /**
  109738. * @hidden
  109739. * Stores the effects for the material
  109740. */
  109741. _effect: Nullable<Effect>;
  109742. /**
  109743. * Specifies if uniform buffers should be used
  109744. */
  109745. private _useUBO;
  109746. /**
  109747. * Stores a reference to the scene
  109748. */
  109749. private _scene;
  109750. /**
  109751. * Stores the fill mode state
  109752. */
  109753. private _fillMode;
  109754. /**
  109755. * Specifies if the depth write state should be cached
  109756. */
  109757. private _cachedDepthWriteState;
  109758. /**
  109759. * Specifies if the color write state should be cached
  109760. */
  109761. private _cachedColorWriteState;
  109762. /**
  109763. * Specifies if the depth function state should be cached
  109764. */
  109765. private _cachedDepthFunctionState;
  109766. /**
  109767. * Stores the uniform buffer
  109768. */
  109769. protected _uniformBuffer: UniformBuffer;
  109770. /** @hidden */
  109771. _indexInSceneMaterialArray: number;
  109772. /** @hidden */
  109773. meshMap: Nullable<{
  109774. [id: string]: AbstractMesh | undefined;
  109775. }>;
  109776. /**
  109777. * Creates a material instance
  109778. * @param name defines the name of the material
  109779. * @param scene defines the scene to reference
  109780. * @param doNotAdd specifies if the material should be added to the scene
  109781. */
  109782. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  109783. /**
  109784. * Returns a string representation of the current material
  109785. * @param fullDetails defines a boolean indicating which levels of logging is desired
  109786. * @returns a string with material information
  109787. */
  109788. toString(fullDetails?: boolean): string;
  109789. /**
  109790. * Gets the class name of the material
  109791. * @returns a string with the class name of the material
  109792. */
  109793. getClassName(): string;
  109794. /**
  109795. * Specifies if updates for the material been locked
  109796. */
  109797. get isFrozen(): boolean;
  109798. /**
  109799. * Locks updates for the material
  109800. */
  109801. freeze(): void;
  109802. /**
  109803. * Unlocks updates for the material
  109804. */
  109805. unfreeze(): void;
  109806. /**
  109807. * Specifies if the material is ready to be used
  109808. * @param mesh defines the mesh to check
  109809. * @param useInstances specifies if instances should be used
  109810. * @returns a boolean indicating if the material is ready to be used
  109811. */
  109812. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  109813. /**
  109814. * Specifies that the submesh is ready to be used
  109815. * @param mesh defines the mesh to check
  109816. * @param subMesh defines which submesh to check
  109817. * @param useInstances specifies that instances should be used
  109818. * @returns a boolean indicating that the submesh is ready or not
  109819. */
  109820. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109821. /**
  109822. * Returns the material effect
  109823. * @returns the effect associated with the material
  109824. */
  109825. getEffect(): Nullable<Effect>;
  109826. /**
  109827. * Returns the current scene
  109828. * @returns a Scene
  109829. */
  109830. getScene(): Scene;
  109831. /**
  109832. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  109833. */
  109834. protected _forceAlphaTest: boolean;
  109835. /**
  109836. * The transparency mode of the material.
  109837. */
  109838. protected _transparencyMode: Nullable<number>;
  109839. /**
  109840. * Gets the current transparency mode.
  109841. */
  109842. get transparencyMode(): Nullable<number>;
  109843. /**
  109844. * Sets the transparency mode of the material.
  109845. *
  109846. * | Value | Type | Description |
  109847. * | ----- | ----------------------------------- | ----------- |
  109848. * | 0 | OPAQUE | |
  109849. * | 1 | ALPHATEST | |
  109850. * | 2 | ALPHABLEND | |
  109851. * | 3 | ALPHATESTANDBLEND | |
  109852. *
  109853. */
  109854. set transparencyMode(value: Nullable<number>);
  109855. /**
  109856. * Returns true if alpha blending should be disabled.
  109857. */
  109858. protected get _disableAlphaBlending(): boolean;
  109859. /**
  109860. * Specifies whether or not this material should be rendered in alpha blend mode.
  109861. * @returns a boolean specifying if alpha blending is needed
  109862. */
  109863. needAlphaBlending(): boolean;
  109864. /**
  109865. * Specifies if the mesh will require alpha blending
  109866. * @param mesh defines the mesh to check
  109867. * @returns a boolean specifying if alpha blending is needed for the mesh
  109868. */
  109869. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  109870. /**
  109871. * Specifies whether or not this material should be rendered in alpha test mode.
  109872. * @returns a boolean specifying if an alpha test is needed.
  109873. */
  109874. needAlphaTesting(): boolean;
  109875. /**
  109876. * Specifies if material alpha testing should be turned on for the mesh
  109877. * @param mesh defines the mesh to check
  109878. */
  109879. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  109880. /**
  109881. * Gets the texture used for the alpha test
  109882. * @returns the texture to use for alpha testing
  109883. */
  109884. getAlphaTestTexture(): Nullable<BaseTexture>;
  109885. /**
  109886. * Marks the material to indicate that it needs to be re-calculated
  109887. */
  109888. markDirty(): void;
  109889. /** @hidden */
  109890. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  109891. /**
  109892. * Binds the material to the mesh
  109893. * @param world defines the world transformation matrix
  109894. * @param mesh defines the mesh to bind the material to
  109895. */
  109896. bind(world: Matrix, mesh?: Mesh): void;
  109897. /**
  109898. * Binds the submesh to the material
  109899. * @param world defines the world transformation matrix
  109900. * @param mesh defines the mesh containing the submesh
  109901. * @param subMesh defines the submesh to bind the material to
  109902. */
  109903. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109904. /**
  109905. * Binds the world matrix to the material
  109906. * @param world defines the world transformation matrix
  109907. */
  109908. bindOnlyWorldMatrix(world: Matrix): void;
  109909. /**
  109910. * Binds the scene's uniform buffer to the effect.
  109911. * @param effect defines the effect to bind to the scene uniform buffer
  109912. * @param sceneUbo defines the uniform buffer storing scene data
  109913. */
  109914. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  109915. /**
  109916. * Binds the view matrix to the effect
  109917. * @param effect defines the effect to bind the view matrix to
  109918. */
  109919. bindView(effect: Effect): void;
  109920. /**
  109921. * Binds the view projection matrix to the effect
  109922. * @param effect defines the effect to bind the view projection matrix to
  109923. */
  109924. bindViewProjection(effect: Effect): void;
  109925. /**
  109926. * Processes to execute after binding the material to a mesh
  109927. * @param mesh defines the rendered mesh
  109928. */
  109929. protected _afterBind(mesh?: Mesh): void;
  109930. /**
  109931. * Unbinds the material from the mesh
  109932. */
  109933. unbind(): void;
  109934. /**
  109935. * Gets the active textures from the material
  109936. * @returns an array of textures
  109937. */
  109938. getActiveTextures(): BaseTexture[];
  109939. /**
  109940. * Specifies if the material uses a texture
  109941. * @param texture defines the texture to check against the material
  109942. * @returns a boolean specifying if the material uses the texture
  109943. */
  109944. hasTexture(texture: BaseTexture): boolean;
  109945. /**
  109946. * Makes a duplicate of the material, and gives it a new name
  109947. * @param name defines the new name for the duplicated material
  109948. * @returns the cloned material
  109949. */
  109950. clone(name: string): Nullable<Material>;
  109951. /**
  109952. * Gets the meshes bound to the material
  109953. * @returns an array of meshes bound to the material
  109954. */
  109955. getBindedMeshes(): AbstractMesh[];
  109956. /**
  109957. * Force shader compilation
  109958. * @param mesh defines the mesh associated with this material
  109959. * @param onCompiled defines a function to execute once the material is compiled
  109960. * @param options defines the options to configure the compilation
  109961. * @param onError defines a function to execute if the material fails compiling
  109962. */
  109963. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  109964. /**
  109965. * Force shader compilation
  109966. * @param mesh defines the mesh that will use this material
  109967. * @param options defines additional options for compiling the shaders
  109968. * @returns a promise that resolves when the compilation completes
  109969. */
  109970. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  109971. private static readonly _AllDirtyCallBack;
  109972. private static readonly _ImageProcessingDirtyCallBack;
  109973. private static readonly _TextureDirtyCallBack;
  109974. private static readonly _FresnelDirtyCallBack;
  109975. private static readonly _MiscDirtyCallBack;
  109976. private static readonly _PrePassDirtyCallBack;
  109977. private static readonly _LightsDirtyCallBack;
  109978. private static readonly _AttributeDirtyCallBack;
  109979. private static _FresnelAndMiscDirtyCallBack;
  109980. private static _TextureAndMiscDirtyCallBack;
  109981. private static readonly _DirtyCallbackArray;
  109982. private static readonly _RunDirtyCallBacks;
  109983. /**
  109984. * Marks a define in the material to indicate that it needs to be re-computed
  109985. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  109986. */
  109987. markAsDirty(flag: number): void;
  109988. /**
  109989. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  109990. * @param func defines a function which checks material defines against the submeshes
  109991. */
  109992. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  109993. /**
  109994. * Indicates that the scene should check if the rendering now needs a prepass
  109995. */
  109996. protected _markScenePrePassDirty(): void;
  109997. /**
  109998. * Indicates that we need to re-calculated for all submeshes
  109999. */
  110000. protected _markAllSubMeshesAsAllDirty(): void;
  110001. /**
  110002. * Indicates that image processing needs to be re-calculated for all submeshes
  110003. */
  110004. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  110005. /**
  110006. * Indicates that textures need to be re-calculated for all submeshes
  110007. */
  110008. protected _markAllSubMeshesAsTexturesDirty(): void;
  110009. /**
  110010. * Indicates that fresnel needs to be re-calculated for all submeshes
  110011. */
  110012. protected _markAllSubMeshesAsFresnelDirty(): void;
  110013. /**
  110014. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  110015. */
  110016. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  110017. /**
  110018. * Indicates that lights need to be re-calculated for all submeshes
  110019. */
  110020. protected _markAllSubMeshesAsLightsDirty(): void;
  110021. /**
  110022. * Indicates that attributes need to be re-calculated for all submeshes
  110023. */
  110024. protected _markAllSubMeshesAsAttributesDirty(): void;
  110025. /**
  110026. * Indicates that misc needs to be re-calculated for all submeshes
  110027. */
  110028. protected _markAllSubMeshesAsMiscDirty(): void;
  110029. /**
  110030. * Indicates that prepass needs to be re-calculated for all submeshes
  110031. */
  110032. protected _markAllSubMeshesAsPrePassDirty(): void;
  110033. /**
  110034. * Indicates that textures and misc need to be re-calculated for all submeshes
  110035. */
  110036. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  110037. /**
  110038. * Sets the required values to the prepass renderer.
  110039. * @param prePassRenderer defines the prepass renderer to setup.
  110040. * @returns true if the pre pass is needed.
  110041. */
  110042. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  110043. /**
  110044. * Disposes the material
  110045. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110046. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110047. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  110048. */
  110049. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  110050. /** @hidden */
  110051. private releaseVertexArrayObject;
  110052. /**
  110053. * Serializes this material
  110054. * @returns the serialized material object
  110055. */
  110056. serialize(): any;
  110057. /**
  110058. * Creates a material from parsed material data
  110059. * @param parsedMaterial defines parsed material data
  110060. * @param scene defines the hosting scene
  110061. * @param rootUrl defines the root URL to use to load textures
  110062. * @returns a new material
  110063. */
  110064. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  110065. }
  110066. }
  110067. declare module BABYLON {
  110068. /**
  110069. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110070. * separate meshes. This can be use to improve performances.
  110071. * @see https://doc.babylonjs.com/how_to/multi_materials
  110072. */
  110073. export class MultiMaterial extends Material {
  110074. private _subMaterials;
  110075. /**
  110076. * Gets or Sets the list of Materials used within the multi material.
  110077. * They need to be ordered according to the submeshes order in the associated mesh
  110078. */
  110079. get subMaterials(): Nullable<Material>[];
  110080. set subMaterials(value: Nullable<Material>[]);
  110081. /**
  110082. * Function used to align with Node.getChildren()
  110083. * @returns the list of Materials used within the multi material
  110084. */
  110085. getChildren(): Nullable<Material>[];
  110086. /**
  110087. * Instantiates a new Multi Material
  110088. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110089. * separate meshes. This can be use to improve performances.
  110090. * @see https://doc.babylonjs.com/how_to/multi_materials
  110091. * @param name Define the name in the scene
  110092. * @param scene Define the scene the material belongs to
  110093. */
  110094. constructor(name: string, scene: Scene);
  110095. private _hookArray;
  110096. /**
  110097. * Get one of the submaterial by its index in the submaterials array
  110098. * @param index The index to look the sub material at
  110099. * @returns The Material if the index has been defined
  110100. */
  110101. getSubMaterial(index: number): Nullable<Material>;
  110102. /**
  110103. * Get the list of active textures for the whole sub materials list.
  110104. * @returns All the textures that will be used during the rendering
  110105. */
  110106. getActiveTextures(): BaseTexture[];
  110107. /**
  110108. * Gets the current class name of the material e.g. "MultiMaterial"
  110109. * Mainly use in serialization.
  110110. * @returns the class name
  110111. */
  110112. getClassName(): string;
  110113. /**
  110114. * Checks if the material is ready to render the requested sub mesh
  110115. * @param mesh Define the mesh the submesh belongs to
  110116. * @param subMesh Define the sub mesh to look readyness for
  110117. * @param useInstances Define whether or not the material is used with instances
  110118. * @returns true if ready, otherwise false
  110119. */
  110120. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110121. /**
  110122. * Clones the current material and its related sub materials
  110123. * @param name Define the name of the newly cloned material
  110124. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  110125. * @returns the cloned material
  110126. */
  110127. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  110128. /**
  110129. * Serializes the materials into a JSON representation.
  110130. * @returns the JSON representation
  110131. */
  110132. serialize(): any;
  110133. /**
  110134. * Dispose the material and release its associated resources
  110135. * @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)
  110136. * @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)
  110137. * @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)
  110138. */
  110139. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  110140. /**
  110141. * Creates a MultiMaterial from parsed MultiMaterial data.
  110142. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  110143. * @param scene defines the hosting scene
  110144. * @returns a new MultiMaterial
  110145. */
  110146. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  110147. }
  110148. }
  110149. declare module BABYLON {
  110150. /**
  110151. * Defines a subdivision inside a mesh
  110152. */
  110153. export class SubMesh implements ICullable {
  110154. /** the material index to use */
  110155. materialIndex: number;
  110156. /** vertex index start */
  110157. verticesStart: number;
  110158. /** vertices count */
  110159. verticesCount: number;
  110160. /** index start */
  110161. indexStart: number;
  110162. /** indices count */
  110163. indexCount: number;
  110164. /** @hidden */
  110165. _materialDefines: Nullable<MaterialDefines>;
  110166. /** @hidden */
  110167. _materialEffect: Nullable<Effect>;
  110168. /** @hidden */
  110169. _effectOverride: Nullable<Effect>;
  110170. /**
  110171. * Gets material defines used by the effect associated to the sub mesh
  110172. */
  110173. get materialDefines(): Nullable<MaterialDefines>;
  110174. /**
  110175. * Sets material defines used by the effect associated to the sub mesh
  110176. */
  110177. set materialDefines(defines: Nullable<MaterialDefines>);
  110178. /**
  110179. * Gets associated effect
  110180. */
  110181. get effect(): Nullable<Effect>;
  110182. /**
  110183. * Sets associated effect (effect used to render this submesh)
  110184. * @param effect defines the effect to associate with
  110185. * @param defines defines the set of defines used to compile this effect
  110186. */
  110187. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  110188. /** @hidden */
  110189. _linesIndexCount: number;
  110190. private _mesh;
  110191. private _renderingMesh;
  110192. private _boundingInfo;
  110193. private _linesIndexBuffer;
  110194. /** @hidden */
  110195. _lastColliderWorldVertices: Nullable<Vector3[]>;
  110196. /** @hidden */
  110197. _trianglePlanes: Plane[];
  110198. /** @hidden */
  110199. _lastColliderTransformMatrix: Nullable<Matrix>;
  110200. /** @hidden */
  110201. _renderId: number;
  110202. /** @hidden */
  110203. _alphaIndex: number;
  110204. /** @hidden */
  110205. _distanceToCamera: number;
  110206. /** @hidden */
  110207. _id: number;
  110208. private _currentMaterial;
  110209. /**
  110210. * Add a new submesh to a mesh
  110211. * @param materialIndex defines the material index to use
  110212. * @param verticesStart defines vertex index start
  110213. * @param verticesCount defines vertices count
  110214. * @param indexStart defines index start
  110215. * @param indexCount defines indices count
  110216. * @param mesh defines the parent mesh
  110217. * @param renderingMesh defines an optional rendering mesh
  110218. * @param createBoundingBox defines if bounding box should be created for this submesh
  110219. * @returns the new submesh
  110220. */
  110221. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  110222. /**
  110223. * Creates a new submesh
  110224. * @param materialIndex defines the material index to use
  110225. * @param verticesStart defines vertex index start
  110226. * @param verticesCount defines vertices count
  110227. * @param indexStart defines index start
  110228. * @param indexCount defines indices count
  110229. * @param mesh defines the parent mesh
  110230. * @param renderingMesh defines an optional rendering mesh
  110231. * @param createBoundingBox defines if bounding box should be created for this submesh
  110232. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  110233. */
  110234. constructor(
  110235. /** the material index to use */
  110236. materialIndex: number,
  110237. /** vertex index start */
  110238. verticesStart: number,
  110239. /** vertices count */
  110240. verticesCount: number,
  110241. /** index start */
  110242. indexStart: number,
  110243. /** indices count */
  110244. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  110245. /**
  110246. * Returns true if this submesh covers the entire parent mesh
  110247. * @ignorenaming
  110248. */
  110249. get IsGlobal(): boolean;
  110250. /**
  110251. * Returns the submesh BoudingInfo object
  110252. * @returns current bounding info (or mesh's one if the submesh is global)
  110253. */
  110254. getBoundingInfo(): BoundingInfo;
  110255. /**
  110256. * Sets the submesh BoundingInfo
  110257. * @param boundingInfo defines the new bounding info to use
  110258. * @returns the SubMesh
  110259. */
  110260. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  110261. /**
  110262. * Returns the mesh of the current submesh
  110263. * @return the parent mesh
  110264. */
  110265. getMesh(): AbstractMesh;
  110266. /**
  110267. * Returns the rendering mesh of the submesh
  110268. * @returns the rendering mesh (could be different from parent mesh)
  110269. */
  110270. getRenderingMesh(): Mesh;
  110271. /**
  110272. * Returns the replacement mesh of the submesh
  110273. * @returns the replacement mesh (could be different from parent mesh)
  110274. */
  110275. getReplacementMesh(): Nullable<AbstractMesh>;
  110276. /**
  110277. * Returns the effective mesh of the submesh
  110278. * @returns the effective mesh (could be different from parent mesh)
  110279. */
  110280. getEffectiveMesh(): AbstractMesh;
  110281. /**
  110282. * Returns the submesh material
  110283. * @returns null or the current material
  110284. */
  110285. getMaterial(): Nullable<Material>;
  110286. private _IsMultiMaterial;
  110287. /**
  110288. * Sets a new updated BoundingInfo object to the submesh
  110289. * @param data defines an optional position array to use to determine the bounding info
  110290. * @returns the SubMesh
  110291. */
  110292. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  110293. /** @hidden */
  110294. _checkCollision(collider: Collider): boolean;
  110295. /**
  110296. * Updates the submesh BoundingInfo
  110297. * @param world defines the world matrix to use to update the bounding info
  110298. * @returns the submesh
  110299. */
  110300. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  110301. /**
  110302. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  110303. * @param frustumPlanes defines the frustum planes
  110304. * @returns true if the submesh is intersecting with the frustum
  110305. */
  110306. isInFrustum(frustumPlanes: Plane[]): boolean;
  110307. /**
  110308. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  110309. * @param frustumPlanes defines the frustum planes
  110310. * @returns true if the submesh is inside the frustum
  110311. */
  110312. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  110313. /**
  110314. * Renders the submesh
  110315. * @param enableAlphaMode defines if alpha needs to be used
  110316. * @returns the submesh
  110317. */
  110318. render(enableAlphaMode: boolean): SubMesh;
  110319. /**
  110320. * @hidden
  110321. */
  110322. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  110323. /**
  110324. * Checks if the submesh intersects with a ray
  110325. * @param ray defines the ray to test
  110326. * @returns true is the passed ray intersects the submesh bounding box
  110327. */
  110328. canIntersects(ray: Ray): boolean;
  110329. /**
  110330. * Intersects current submesh with a ray
  110331. * @param ray defines the ray to test
  110332. * @param positions defines mesh's positions array
  110333. * @param indices defines mesh's indices array
  110334. * @param fastCheck defines if the first intersection will be used (and not the closest)
  110335. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110336. * @returns intersection info or null if no intersection
  110337. */
  110338. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  110339. /** @hidden */
  110340. private _intersectLines;
  110341. /** @hidden */
  110342. private _intersectUnIndexedLines;
  110343. /** @hidden */
  110344. private _intersectTriangles;
  110345. /** @hidden */
  110346. private _intersectUnIndexedTriangles;
  110347. /** @hidden */
  110348. _rebuild(): void;
  110349. /**
  110350. * Creates a new submesh from the passed mesh
  110351. * @param newMesh defines the new hosting mesh
  110352. * @param newRenderingMesh defines an optional rendering mesh
  110353. * @returns the new submesh
  110354. */
  110355. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  110356. /**
  110357. * Release associated resources
  110358. */
  110359. dispose(): void;
  110360. /**
  110361. * Gets the class name
  110362. * @returns the string "SubMesh".
  110363. */
  110364. getClassName(): string;
  110365. /**
  110366. * Creates a new submesh from indices data
  110367. * @param materialIndex the index of the main mesh material
  110368. * @param startIndex the index where to start the copy in the mesh indices array
  110369. * @param indexCount the number of indices to copy then from the startIndex
  110370. * @param mesh the main mesh to create the submesh from
  110371. * @param renderingMesh the optional rendering mesh
  110372. * @returns a new submesh
  110373. */
  110374. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  110375. }
  110376. }
  110377. declare module BABYLON {
  110378. /**
  110379. * Class used to represent data loading progression
  110380. */
  110381. export class SceneLoaderFlags {
  110382. private static _ForceFullSceneLoadingForIncremental;
  110383. private static _ShowLoadingScreen;
  110384. private static _CleanBoneMatrixWeights;
  110385. private static _loggingLevel;
  110386. /**
  110387. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110388. */
  110389. static get ForceFullSceneLoadingForIncremental(): boolean;
  110390. static set ForceFullSceneLoadingForIncremental(value: boolean);
  110391. /**
  110392. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110393. */
  110394. static get ShowLoadingScreen(): boolean;
  110395. static set ShowLoadingScreen(value: boolean);
  110396. /**
  110397. * Defines the current logging level (while loading the scene)
  110398. * @ignorenaming
  110399. */
  110400. static get loggingLevel(): number;
  110401. static set loggingLevel(value: number);
  110402. /**
  110403. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110404. */
  110405. static get CleanBoneMatrixWeights(): boolean;
  110406. static set CleanBoneMatrixWeights(value: boolean);
  110407. }
  110408. }
  110409. declare module BABYLON {
  110410. /**
  110411. * Class used to store geometry data (vertex buffers + index buffer)
  110412. */
  110413. export class Geometry implements IGetSetVerticesData {
  110414. /**
  110415. * Gets or sets the ID of the geometry
  110416. */
  110417. id: string;
  110418. /**
  110419. * Gets or sets the unique ID of the geometry
  110420. */
  110421. uniqueId: number;
  110422. /**
  110423. * Gets the delay loading state of the geometry (none by default which means not delayed)
  110424. */
  110425. delayLoadState: number;
  110426. /**
  110427. * Gets the file containing the data to load when running in delay load state
  110428. */
  110429. delayLoadingFile: Nullable<string>;
  110430. /**
  110431. * Callback called when the geometry is updated
  110432. */
  110433. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  110434. private _scene;
  110435. private _engine;
  110436. private _meshes;
  110437. private _totalVertices;
  110438. /** @hidden */
  110439. _indices: IndicesArray;
  110440. /** @hidden */
  110441. _vertexBuffers: {
  110442. [key: string]: VertexBuffer;
  110443. };
  110444. private _isDisposed;
  110445. private _extend;
  110446. private _boundingBias;
  110447. /** @hidden */
  110448. _delayInfo: Array<string>;
  110449. private _indexBuffer;
  110450. private _indexBufferIsUpdatable;
  110451. /** @hidden */
  110452. _boundingInfo: Nullable<BoundingInfo>;
  110453. /** @hidden */
  110454. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  110455. /** @hidden */
  110456. _softwareSkinningFrameId: number;
  110457. private _vertexArrayObjects;
  110458. private _updatable;
  110459. /** @hidden */
  110460. _positions: Nullable<Vector3[]>;
  110461. /**
  110462. * 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
  110463. */
  110464. get boundingBias(): Vector2;
  110465. /**
  110466. * 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
  110467. */
  110468. set boundingBias(value: Vector2);
  110469. /**
  110470. * Static function used to attach a new empty geometry to a mesh
  110471. * @param mesh defines the mesh to attach the geometry to
  110472. * @returns the new Geometry
  110473. */
  110474. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  110475. /** Get the list of meshes using this geometry */
  110476. get meshes(): Mesh[];
  110477. /**
  110478. * 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
  110479. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  110480. */
  110481. useBoundingInfoFromGeometry: boolean;
  110482. /**
  110483. * Creates a new geometry
  110484. * @param id defines the unique ID
  110485. * @param scene defines the hosting scene
  110486. * @param vertexData defines the VertexData used to get geometry data
  110487. * @param updatable defines if geometry must be updatable (false by default)
  110488. * @param mesh defines the mesh that will be associated with the geometry
  110489. */
  110490. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  110491. /**
  110492. * Gets the current extend of the geometry
  110493. */
  110494. get extend(): {
  110495. minimum: Vector3;
  110496. maximum: Vector3;
  110497. };
  110498. /**
  110499. * Gets the hosting scene
  110500. * @returns the hosting Scene
  110501. */
  110502. getScene(): Scene;
  110503. /**
  110504. * Gets the hosting engine
  110505. * @returns the hosting Engine
  110506. */
  110507. getEngine(): Engine;
  110508. /**
  110509. * Defines if the geometry is ready to use
  110510. * @returns true if the geometry is ready to be used
  110511. */
  110512. isReady(): boolean;
  110513. /**
  110514. * Gets a value indicating that the geometry should not be serialized
  110515. */
  110516. get doNotSerialize(): boolean;
  110517. /** @hidden */
  110518. _rebuild(): void;
  110519. /**
  110520. * Affects all geometry data in one call
  110521. * @param vertexData defines the geometry data
  110522. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  110523. */
  110524. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  110525. /**
  110526. * Set specific vertex data
  110527. * @param kind defines the data kind (Position, normal, etc...)
  110528. * @param data defines the vertex data to use
  110529. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  110530. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  110531. */
  110532. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  110533. /**
  110534. * Removes a specific vertex data
  110535. * @param kind defines the data kind (Position, normal, etc...)
  110536. */
  110537. removeVerticesData(kind: string): void;
  110538. /**
  110539. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  110540. * @param buffer defines the vertex buffer to use
  110541. * @param totalVertices defines the total number of vertices for position kind (could be null)
  110542. */
  110543. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  110544. /**
  110545. * Update a specific vertex buffer
  110546. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  110547. * It will do nothing if the buffer is not updatable
  110548. * @param kind defines the data kind (Position, normal, etc...)
  110549. * @param data defines the data to use
  110550. * @param offset defines the offset in the target buffer where to store the data
  110551. * @param useBytes set to true if the offset is in bytes
  110552. */
  110553. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  110554. /**
  110555. * Update a specific vertex buffer
  110556. * This function will create a new buffer if the current one is not updatable
  110557. * @param kind defines the data kind (Position, normal, etc...)
  110558. * @param data defines the data to use
  110559. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  110560. */
  110561. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  110562. private _updateBoundingInfo;
  110563. /** @hidden */
  110564. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  110565. /**
  110566. * Gets total number of vertices
  110567. * @returns the total number of vertices
  110568. */
  110569. getTotalVertices(): number;
  110570. /**
  110571. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  110572. * @param kind defines the data kind (Position, normal, etc...)
  110573. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110574. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110575. * @returns a float array containing vertex data
  110576. */
  110577. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  110578. /**
  110579. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  110580. * @param kind defines the data kind (Position, normal, etc...)
  110581. * @returns true if the vertex buffer with the specified kind is updatable
  110582. */
  110583. isVertexBufferUpdatable(kind: string): boolean;
  110584. /**
  110585. * Gets a specific vertex buffer
  110586. * @param kind defines the data kind (Position, normal, etc...)
  110587. * @returns a VertexBuffer
  110588. */
  110589. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  110590. /**
  110591. * Returns all vertex buffers
  110592. * @return an object holding all vertex buffers indexed by kind
  110593. */
  110594. getVertexBuffers(): Nullable<{
  110595. [key: string]: VertexBuffer;
  110596. }>;
  110597. /**
  110598. * Gets a boolean indicating if specific vertex buffer is present
  110599. * @param kind defines the data kind (Position, normal, etc...)
  110600. * @returns true if data is present
  110601. */
  110602. isVerticesDataPresent(kind: string): boolean;
  110603. /**
  110604. * Gets a list of all attached data kinds (Position, normal, etc...)
  110605. * @returns a list of string containing all kinds
  110606. */
  110607. getVerticesDataKinds(): string[];
  110608. /**
  110609. * Update index buffer
  110610. * @param indices defines the indices to store in the index buffer
  110611. * @param offset defines the offset in the target buffer where to store the data
  110612. * @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)
  110613. */
  110614. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  110615. /**
  110616. * Creates a new index buffer
  110617. * @param indices defines the indices to store in the index buffer
  110618. * @param totalVertices defines the total number of vertices (could be null)
  110619. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  110620. */
  110621. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  110622. /**
  110623. * Return the total number of indices
  110624. * @returns the total number of indices
  110625. */
  110626. getTotalIndices(): number;
  110627. /**
  110628. * Gets the index buffer array
  110629. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110630. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110631. * @returns the index buffer array
  110632. */
  110633. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  110634. /**
  110635. * Gets the index buffer
  110636. * @return the index buffer
  110637. */
  110638. getIndexBuffer(): Nullable<DataBuffer>;
  110639. /** @hidden */
  110640. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  110641. /**
  110642. * Release the associated resources for a specific mesh
  110643. * @param mesh defines the source mesh
  110644. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  110645. */
  110646. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  110647. /**
  110648. * Apply current geometry to a given mesh
  110649. * @param mesh defines the mesh to apply geometry to
  110650. */
  110651. applyToMesh(mesh: Mesh): void;
  110652. private _updateExtend;
  110653. private _applyToMesh;
  110654. private notifyUpdate;
  110655. /**
  110656. * Load the geometry if it was flagged as delay loaded
  110657. * @param scene defines the hosting scene
  110658. * @param onLoaded defines a callback called when the geometry is loaded
  110659. */
  110660. load(scene: Scene, onLoaded?: () => void): void;
  110661. private _queueLoad;
  110662. /**
  110663. * Invert the geometry to move from a right handed system to a left handed one.
  110664. */
  110665. toLeftHanded(): void;
  110666. /** @hidden */
  110667. _resetPointsArrayCache(): void;
  110668. /** @hidden */
  110669. _generatePointsArray(): boolean;
  110670. /**
  110671. * Gets a value indicating if the geometry is disposed
  110672. * @returns true if the geometry was disposed
  110673. */
  110674. isDisposed(): boolean;
  110675. private _disposeVertexArrayObjects;
  110676. /**
  110677. * Free all associated resources
  110678. */
  110679. dispose(): void;
  110680. /**
  110681. * Clone the current geometry into a new geometry
  110682. * @param id defines the unique ID of the new geometry
  110683. * @returns a new geometry object
  110684. */
  110685. copy(id: string): Geometry;
  110686. /**
  110687. * Serialize the current geometry info (and not the vertices data) into a JSON object
  110688. * @return a JSON representation of the current geometry data (without the vertices data)
  110689. */
  110690. serialize(): any;
  110691. private toNumberArray;
  110692. /**
  110693. * Serialize all vertices data into a JSON oject
  110694. * @returns a JSON representation of the current geometry data
  110695. */
  110696. serializeVerticeData(): any;
  110697. /**
  110698. * Extracts a clone of a mesh geometry
  110699. * @param mesh defines the source mesh
  110700. * @param id defines the unique ID of the new geometry object
  110701. * @returns the new geometry object
  110702. */
  110703. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  110704. /**
  110705. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  110706. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110707. * Be aware Math.random() could cause collisions, but:
  110708. * "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"
  110709. * @returns a string containing a new GUID
  110710. */
  110711. static RandomId(): string;
  110712. /** @hidden */
  110713. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  110714. private static _CleanMatricesWeights;
  110715. /**
  110716. * Create a new geometry from persisted data (Using .babylon file format)
  110717. * @param parsedVertexData defines the persisted data
  110718. * @param scene defines the hosting scene
  110719. * @param rootUrl defines the root url to use to load assets (like delayed data)
  110720. * @returns the new geometry object
  110721. */
  110722. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  110723. }
  110724. }
  110725. declare module BABYLON {
  110726. /**
  110727. * Define an interface for all classes that will get and set the data on vertices
  110728. */
  110729. export interface IGetSetVerticesData {
  110730. /**
  110731. * Gets a boolean indicating if specific vertex data is present
  110732. * @param kind defines the vertex data kind to use
  110733. * @returns true is data kind is present
  110734. */
  110735. isVerticesDataPresent(kind: string): boolean;
  110736. /**
  110737. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  110738. * @param kind defines the data kind (Position, normal, etc...)
  110739. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110740. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110741. * @returns a float array containing vertex data
  110742. */
  110743. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  110744. /**
  110745. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  110746. * @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.
  110747. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110748. * @returns the indices array or an empty array if the mesh has no geometry
  110749. */
  110750. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  110751. /**
  110752. * Set specific vertex data
  110753. * @param kind defines the data kind (Position, normal, etc...)
  110754. * @param data defines the vertex data to use
  110755. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  110756. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  110757. */
  110758. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  110759. /**
  110760. * Update a specific associated vertex buffer
  110761. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  110762. * - VertexBuffer.PositionKind
  110763. * - VertexBuffer.UVKind
  110764. * - VertexBuffer.UV2Kind
  110765. * - VertexBuffer.UV3Kind
  110766. * - VertexBuffer.UV4Kind
  110767. * - VertexBuffer.UV5Kind
  110768. * - VertexBuffer.UV6Kind
  110769. * - VertexBuffer.ColorKind
  110770. * - VertexBuffer.MatricesIndicesKind
  110771. * - VertexBuffer.MatricesIndicesExtraKind
  110772. * - VertexBuffer.MatricesWeightsKind
  110773. * - VertexBuffer.MatricesWeightsExtraKind
  110774. * @param data defines the data source
  110775. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  110776. * @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)
  110777. */
  110778. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  110779. /**
  110780. * Creates a new index buffer
  110781. * @param indices defines the indices to store in the index buffer
  110782. * @param totalVertices defines the total number of vertices (could be null)
  110783. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  110784. */
  110785. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  110786. }
  110787. /**
  110788. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  110789. */
  110790. export class VertexData {
  110791. /**
  110792. * Mesh side orientation : usually the external or front surface
  110793. */
  110794. static readonly FRONTSIDE: number;
  110795. /**
  110796. * Mesh side orientation : usually the internal or back surface
  110797. */
  110798. static readonly BACKSIDE: number;
  110799. /**
  110800. * Mesh side orientation : both internal and external or front and back surfaces
  110801. */
  110802. static readonly DOUBLESIDE: number;
  110803. /**
  110804. * Mesh side orientation : by default, `FRONTSIDE`
  110805. */
  110806. static readonly DEFAULTSIDE: number;
  110807. /**
  110808. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  110809. */
  110810. positions: Nullable<FloatArray>;
  110811. /**
  110812. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  110813. */
  110814. normals: Nullable<FloatArray>;
  110815. /**
  110816. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  110817. */
  110818. tangents: Nullable<FloatArray>;
  110819. /**
  110820. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110821. */
  110822. uvs: Nullable<FloatArray>;
  110823. /**
  110824. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110825. */
  110826. uvs2: Nullable<FloatArray>;
  110827. /**
  110828. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110829. */
  110830. uvs3: Nullable<FloatArray>;
  110831. /**
  110832. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110833. */
  110834. uvs4: Nullable<FloatArray>;
  110835. /**
  110836. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110837. */
  110838. uvs5: Nullable<FloatArray>;
  110839. /**
  110840. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110841. */
  110842. uvs6: Nullable<FloatArray>;
  110843. /**
  110844. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  110845. */
  110846. colors: Nullable<FloatArray>;
  110847. /**
  110848. * 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).
  110849. */
  110850. matricesIndices: Nullable<FloatArray>;
  110851. /**
  110852. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  110853. */
  110854. matricesWeights: Nullable<FloatArray>;
  110855. /**
  110856. * An array extending the number of possible indices
  110857. */
  110858. matricesIndicesExtra: Nullable<FloatArray>;
  110859. /**
  110860. * An array extending the number of possible weights when the number of indices is extended
  110861. */
  110862. matricesWeightsExtra: Nullable<FloatArray>;
  110863. /**
  110864. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  110865. */
  110866. indices: Nullable<IndicesArray>;
  110867. /**
  110868. * Uses the passed data array to set the set the values for the specified kind of data
  110869. * @param data a linear array of floating numbers
  110870. * @param kind the type of data that is being set, eg positions, colors etc
  110871. */
  110872. set(data: FloatArray, kind: string): void;
  110873. /**
  110874. * Associates the vertexData to the passed Mesh.
  110875. * Sets it as updatable or not (default `false`)
  110876. * @param mesh the mesh the vertexData is applied to
  110877. * @param updatable when used and having the value true allows new data to update the vertexData
  110878. * @returns the VertexData
  110879. */
  110880. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  110881. /**
  110882. * Associates the vertexData to the passed Geometry.
  110883. * Sets it as updatable or not (default `false`)
  110884. * @param geometry the geometry the vertexData is applied to
  110885. * @param updatable when used and having the value true allows new data to update the vertexData
  110886. * @returns VertexData
  110887. */
  110888. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  110889. /**
  110890. * Updates the associated mesh
  110891. * @param mesh the mesh to be updated
  110892. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  110893. * @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
  110894. * @returns VertexData
  110895. */
  110896. updateMesh(mesh: Mesh): VertexData;
  110897. /**
  110898. * Updates the associated geometry
  110899. * @param geometry the geometry to be updated
  110900. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  110901. * @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
  110902. * @returns VertexData.
  110903. */
  110904. updateGeometry(geometry: Geometry): VertexData;
  110905. private _applyTo;
  110906. private _update;
  110907. /**
  110908. * Transforms each position and each normal of the vertexData according to the passed Matrix
  110909. * @param matrix the transforming matrix
  110910. * @returns the VertexData
  110911. */
  110912. transform(matrix: Matrix): VertexData;
  110913. /**
  110914. * Merges the passed VertexData into the current one
  110915. * @param other the VertexData to be merged into the current one
  110916. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  110917. * @returns the modified VertexData
  110918. */
  110919. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  110920. private _mergeElement;
  110921. private _validate;
  110922. /**
  110923. * Serializes the VertexData
  110924. * @returns a serialized object
  110925. */
  110926. serialize(): any;
  110927. /**
  110928. * Extracts the vertexData from a mesh
  110929. * @param mesh the mesh from which to extract the VertexData
  110930. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  110931. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  110932. * @returns the object VertexData associated to the passed mesh
  110933. */
  110934. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  110935. /**
  110936. * Extracts the vertexData from the geometry
  110937. * @param geometry the geometry from which to extract the VertexData
  110938. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  110939. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  110940. * @returns the object VertexData associated to the passed mesh
  110941. */
  110942. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  110943. private static _ExtractFrom;
  110944. /**
  110945. * Creates the VertexData for a Ribbon
  110946. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  110947. * * pathArray array of paths, each of which an array of successive Vector3
  110948. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  110949. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  110950. * * 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
  110951. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110952. * * 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)
  110953. * * 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)
  110954. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  110955. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  110956. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  110957. * @returns the VertexData of the ribbon
  110958. */
  110959. static CreateRibbon(options: {
  110960. pathArray: Vector3[][];
  110961. closeArray?: boolean;
  110962. closePath?: boolean;
  110963. offset?: number;
  110964. sideOrientation?: number;
  110965. frontUVs?: Vector4;
  110966. backUVs?: Vector4;
  110967. invertUV?: boolean;
  110968. uvs?: Vector2[];
  110969. colors?: Color4[];
  110970. }): VertexData;
  110971. /**
  110972. * Creates the VertexData for a box
  110973. * @param options an object used to set the following optional parameters for the box, required but can be empty
  110974. * * size sets the width, height and depth of the box to the value of size, optional default 1
  110975. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  110976. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  110977. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  110978. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  110979. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  110980. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110981. * * 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)
  110982. * * 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)
  110983. * @returns the VertexData of the box
  110984. */
  110985. static CreateBox(options: {
  110986. size?: number;
  110987. width?: number;
  110988. height?: number;
  110989. depth?: number;
  110990. faceUV?: Vector4[];
  110991. faceColors?: Color4[];
  110992. sideOrientation?: number;
  110993. frontUVs?: Vector4;
  110994. backUVs?: Vector4;
  110995. }): VertexData;
  110996. /**
  110997. * Creates the VertexData for a tiled box
  110998. * @param options an object used to set the following optional parameters for the box, required but can be empty
  110999. * * faceTiles sets the pattern, tile size and number of tiles for a face
  111000. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111001. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111002. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111003. * @returns the VertexData of the box
  111004. */
  111005. static CreateTiledBox(options: {
  111006. pattern?: number;
  111007. width?: number;
  111008. height?: number;
  111009. depth?: number;
  111010. tileSize?: number;
  111011. tileWidth?: number;
  111012. tileHeight?: number;
  111013. alignHorizontal?: number;
  111014. alignVertical?: number;
  111015. faceUV?: Vector4[];
  111016. faceColors?: Color4[];
  111017. sideOrientation?: number;
  111018. }): VertexData;
  111019. /**
  111020. * Creates the VertexData for a tiled plane
  111021. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111022. * * pattern a limited pattern arrangement depending on the number
  111023. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  111024. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  111025. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  111026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111027. * * 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)
  111028. * * 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)
  111029. * @returns the VertexData of the tiled plane
  111030. */
  111031. static CreateTiledPlane(options: {
  111032. pattern?: number;
  111033. tileSize?: number;
  111034. tileWidth?: number;
  111035. tileHeight?: number;
  111036. size?: number;
  111037. width?: number;
  111038. height?: number;
  111039. alignHorizontal?: number;
  111040. alignVertical?: number;
  111041. sideOrientation?: number;
  111042. frontUVs?: Vector4;
  111043. backUVs?: Vector4;
  111044. }): VertexData;
  111045. /**
  111046. * Creates the VertexData for an ellipsoid, defaults to a sphere
  111047. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111048. * * segments sets the number of horizontal strips optional, default 32
  111049. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  111050. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  111051. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  111052. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  111053. * * 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
  111054. * * 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
  111055. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111056. * * 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)
  111057. * * 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)
  111058. * @returns the VertexData of the ellipsoid
  111059. */
  111060. static CreateSphere(options: {
  111061. segments?: number;
  111062. diameter?: number;
  111063. diameterX?: number;
  111064. diameterY?: number;
  111065. diameterZ?: number;
  111066. arc?: number;
  111067. slice?: number;
  111068. sideOrientation?: number;
  111069. frontUVs?: Vector4;
  111070. backUVs?: Vector4;
  111071. }): VertexData;
  111072. /**
  111073. * Creates the VertexData for a cylinder, cone or prism
  111074. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111075. * * height sets the height (y direction) of the cylinder, optional, default 2
  111076. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  111077. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  111078. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  111079. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111080. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  111081. * * 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
  111082. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111083. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111084. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  111085. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  111086. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111087. * * 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)
  111088. * * 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)
  111089. * @returns the VertexData of the cylinder, cone or prism
  111090. */
  111091. static CreateCylinder(options: {
  111092. height?: number;
  111093. diameterTop?: number;
  111094. diameterBottom?: number;
  111095. diameter?: number;
  111096. tessellation?: number;
  111097. subdivisions?: number;
  111098. arc?: number;
  111099. faceColors?: Color4[];
  111100. faceUV?: Vector4[];
  111101. hasRings?: boolean;
  111102. enclose?: boolean;
  111103. sideOrientation?: number;
  111104. frontUVs?: Vector4;
  111105. backUVs?: Vector4;
  111106. }): VertexData;
  111107. /**
  111108. * Creates the VertexData for a torus
  111109. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111110. * * diameter the diameter of the torus, optional default 1
  111111. * * thickness the diameter of the tube forming the torus, optional default 0.5
  111112. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111113. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111114. * * 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)
  111115. * * 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)
  111116. * @returns the VertexData of the torus
  111117. */
  111118. static CreateTorus(options: {
  111119. diameter?: number;
  111120. thickness?: number;
  111121. tessellation?: number;
  111122. sideOrientation?: number;
  111123. frontUVs?: Vector4;
  111124. backUVs?: Vector4;
  111125. }): VertexData;
  111126. /**
  111127. * Creates the VertexData of the LineSystem
  111128. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  111129. * - lines an array of lines, each line being an array of successive Vector3
  111130. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  111131. * @returns the VertexData of the LineSystem
  111132. */
  111133. static CreateLineSystem(options: {
  111134. lines: Vector3[][];
  111135. colors?: Nullable<Color4[][]>;
  111136. }): VertexData;
  111137. /**
  111138. * Create the VertexData for a DashedLines
  111139. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  111140. * - points an array successive Vector3
  111141. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  111142. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  111143. * - dashNb the intended total number of dashes, optional, default 200
  111144. * @returns the VertexData for the DashedLines
  111145. */
  111146. static CreateDashedLines(options: {
  111147. points: Vector3[];
  111148. dashSize?: number;
  111149. gapSize?: number;
  111150. dashNb?: number;
  111151. }): VertexData;
  111152. /**
  111153. * Creates the VertexData for a Ground
  111154. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111155. * - width the width (x direction) of the ground, optional, default 1
  111156. * - height the height (z direction) of the ground, optional, default 1
  111157. * - subdivisions the number of subdivisions per side, optional, default 1
  111158. * @returns the VertexData of the Ground
  111159. */
  111160. static CreateGround(options: {
  111161. width?: number;
  111162. height?: number;
  111163. subdivisions?: number;
  111164. subdivisionsX?: number;
  111165. subdivisionsY?: number;
  111166. }): VertexData;
  111167. /**
  111168. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  111169. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111170. * * xmin the ground minimum X coordinate, optional, default -1
  111171. * * zmin the ground minimum Z coordinate, optional, default -1
  111172. * * xmax the ground maximum X coordinate, optional, default 1
  111173. * * zmax the ground maximum Z coordinate, optional, default 1
  111174. * * 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}
  111175. * * 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}
  111176. * @returns the VertexData of the TiledGround
  111177. */
  111178. static CreateTiledGround(options: {
  111179. xmin: number;
  111180. zmin: number;
  111181. xmax: number;
  111182. zmax: number;
  111183. subdivisions?: {
  111184. w: number;
  111185. h: number;
  111186. };
  111187. precision?: {
  111188. w: number;
  111189. h: number;
  111190. };
  111191. }): VertexData;
  111192. /**
  111193. * Creates the VertexData of the Ground designed from a heightmap
  111194. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  111195. * * width the width (x direction) of the ground
  111196. * * height the height (z direction) of the ground
  111197. * * subdivisions the number of subdivisions per side
  111198. * * minHeight the minimum altitude on the ground, optional, default 0
  111199. * * maxHeight the maximum altitude on the ground, optional default 1
  111200. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  111201. * * buffer the array holding the image color data
  111202. * * bufferWidth the width of image
  111203. * * bufferHeight the height of image
  111204. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  111205. * @returns the VertexData of the Ground designed from a heightmap
  111206. */
  111207. static CreateGroundFromHeightMap(options: {
  111208. width: number;
  111209. height: number;
  111210. subdivisions: number;
  111211. minHeight: number;
  111212. maxHeight: number;
  111213. colorFilter: Color3;
  111214. buffer: Uint8Array;
  111215. bufferWidth: number;
  111216. bufferHeight: number;
  111217. alphaFilter: number;
  111218. }): VertexData;
  111219. /**
  111220. * Creates the VertexData for a Plane
  111221. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  111222. * * size sets the width and height of the plane to the value of size, optional default 1
  111223. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  111224. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  111225. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111226. * * 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)
  111227. * * 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)
  111228. * @returns the VertexData of the box
  111229. */
  111230. static CreatePlane(options: {
  111231. size?: number;
  111232. width?: number;
  111233. height?: number;
  111234. sideOrientation?: number;
  111235. frontUVs?: Vector4;
  111236. backUVs?: Vector4;
  111237. }): VertexData;
  111238. /**
  111239. * Creates the VertexData of the Disc or regular Polygon
  111240. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  111241. * * radius the radius of the disc, optional default 0.5
  111242. * * tessellation the number of polygon sides, optional, default 64
  111243. * * 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
  111244. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111245. * * 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)
  111246. * * 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)
  111247. * @returns the VertexData of the box
  111248. */
  111249. static CreateDisc(options: {
  111250. radius?: number;
  111251. tessellation?: number;
  111252. arc?: number;
  111253. sideOrientation?: number;
  111254. frontUVs?: Vector4;
  111255. backUVs?: Vector4;
  111256. }): VertexData;
  111257. /**
  111258. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  111259. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  111260. * @param polygon a mesh built from polygonTriangulation.build()
  111261. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111262. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111263. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111264. * @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)
  111265. * @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)
  111266. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  111267. * @returns the VertexData of the Polygon
  111268. */
  111269. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  111270. /**
  111271. * Creates the VertexData of the IcoSphere
  111272. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  111273. * * radius the radius of the IcoSphere, optional default 1
  111274. * * radiusX allows stretching in the x direction, optional, default radius
  111275. * * radiusY allows stretching in the y direction, optional, default radius
  111276. * * radiusZ allows stretching in the z direction, optional, default radius
  111277. * * flat when true creates a flat shaded mesh, optional, default true
  111278. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111279. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111280. * * 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)
  111281. * * 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)
  111282. * @returns the VertexData of the IcoSphere
  111283. */
  111284. static CreateIcoSphere(options: {
  111285. radius?: number;
  111286. radiusX?: number;
  111287. radiusY?: number;
  111288. radiusZ?: number;
  111289. flat?: boolean;
  111290. subdivisions?: number;
  111291. sideOrientation?: number;
  111292. frontUVs?: Vector4;
  111293. backUVs?: Vector4;
  111294. }): VertexData;
  111295. /**
  111296. * Creates the VertexData for a Polyhedron
  111297. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  111298. * * type provided types are:
  111299. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  111300. * * 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)
  111301. * * size the size of the IcoSphere, optional default 1
  111302. * * sizeX allows stretching in the x direction, optional, default size
  111303. * * sizeY allows stretching in the y direction, optional, default size
  111304. * * sizeZ allows stretching in the z direction, optional, default size
  111305. * * 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
  111306. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111307. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111308. * * flat when true creates a flat shaded mesh, optional, default true
  111309. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111310. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111311. * * 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)
  111312. * * 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)
  111313. * @returns the VertexData of the Polyhedron
  111314. */
  111315. static CreatePolyhedron(options: {
  111316. type?: number;
  111317. size?: number;
  111318. sizeX?: number;
  111319. sizeY?: number;
  111320. sizeZ?: number;
  111321. custom?: any;
  111322. faceUV?: Vector4[];
  111323. faceColors?: Color4[];
  111324. flat?: boolean;
  111325. sideOrientation?: number;
  111326. frontUVs?: Vector4;
  111327. backUVs?: Vector4;
  111328. }): VertexData;
  111329. /**
  111330. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  111331. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  111332. * @returns the VertexData of the Capsule
  111333. */
  111334. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  111335. /**
  111336. * Creates the VertexData for a TorusKnot
  111337. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  111338. * * radius the radius of the torus knot, optional, default 2
  111339. * * tube the thickness of the tube, optional, default 0.5
  111340. * * radialSegments the number of sides on each tube segments, optional, default 32
  111341. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  111342. * * p the number of windings around the z axis, optional, default 2
  111343. * * q the number of windings around the x axis, optional, default 3
  111344. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111345. * * 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)
  111346. * * 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)
  111347. * @returns the VertexData of the Torus Knot
  111348. */
  111349. static CreateTorusKnot(options: {
  111350. radius?: number;
  111351. tube?: number;
  111352. radialSegments?: number;
  111353. tubularSegments?: number;
  111354. p?: number;
  111355. q?: number;
  111356. sideOrientation?: number;
  111357. frontUVs?: Vector4;
  111358. backUVs?: Vector4;
  111359. }): VertexData;
  111360. /**
  111361. * Compute normals for given positions and indices
  111362. * @param positions an array of vertex positions, [...., x, y, z, ......]
  111363. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  111364. * @param normals an array of vertex normals, [...., x, y, z, ......]
  111365. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  111366. * * facetNormals : optional array of facet normals (vector3)
  111367. * * facetPositions : optional array of facet positions (vector3)
  111368. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  111369. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  111370. * * bInfo : optional bounding info, required for facetPartitioning computation
  111371. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  111372. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  111373. * * useRightHandedSystem: optional boolean to for right handed system computation
  111374. * * depthSort : optional boolean to enable the facet depth sort computation
  111375. * * distanceTo : optional Vector3 to compute the facet depth from this location
  111376. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  111377. */
  111378. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  111379. facetNormals?: any;
  111380. facetPositions?: any;
  111381. facetPartitioning?: any;
  111382. ratio?: number;
  111383. bInfo?: any;
  111384. bbSize?: Vector3;
  111385. subDiv?: any;
  111386. useRightHandedSystem?: boolean;
  111387. depthSort?: boolean;
  111388. distanceTo?: Vector3;
  111389. depthSortedFacets?: any;
  111390. }): void;
  111391. /** @hidden */
  111392. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  111393. /**
  111394. * Applies VertexData created from the imported parameters to the geometry
  111395. * @param parsedVertexData the parsed data from an imported file
  111396. * @param geometry the geometry to apply the VertexData to
  111397. */
  111398. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  111399. }
  111400. }
  111401. declare module BABYLON {
  111402. /**
  111403. * Defines a target to use with MorphTargetManager
  111404. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111405. */
  111406. export class MorphTarget implements IAnimatable {
  111407. /** defines the name of the target */
  111408. name: string;
  111409. /**
  111410. * Gets or sets the list of animations
  111411. */
  111412. animations: Animation[];
  111413. private _scene;
  111414. private _positions;
  111415. private _normals;
  111416. private _tangents;
  111417. private _uvs;
  111418. private _influence;
  111419. private _uniqueId;
  111420. /**
  111421. * Observable raised when the influence changes
  111422. */
  111423. onInfluenceChanged: Observable<boolean>;
  111424. /** @hidden */
  111425. _onDataLayoutChanged: Observable<void>;
  111426. /**
  111427. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  111428. */
  111429. get influence(): number;
  111430. set influence(influence: number);
  111431. /**
  111432. * Gets or sets the id of the morph Target
  111433. */
  111434. id: string;
  111435. private _animationPropertiesOverride;
  111436. /**
  111437. * Gets or sets the animation properties override
  111438. */
  111439. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111440. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111441. /**
  111442. * Creates a new MorphTarget
  111443. * @param name defines the name of the target
  111444. * @param influence defines the influence to use
  111445. * @param scene defines the scene the morphtarget belongs to
  111446. */
  111447. constructor(
  111448. /** defines the name of the target */
  111449. name: string, influence?: number, scene?: Nullable<Scene>);
  111450. /**
  111451. * Gets the unique ID of this manager
  111452. */
  111453. get uniqueId(): number;
  111454. /**
  111455. * Gets a boolean defining if the target contains position data
  111456. */
  111457. get hasPositions(): boolean;
  111458. /**
  111459. * Gets a boolean defining if the target contains normal data
  111460. */
  111461. get hasNormals(): boolean;
  111462. /**
  111463. * Gets a boolean defining if the target contains tangent data
  111464. */
  111465. get hasTangents(): boolean;
  111466. /**
  111467. * Gets a boolean defining if the target contains texture coordinates data
  111468. */
  111469. get hasUVs(): boolean;
  111470. /**
  111471. * Affects position data to this target
  111472. * @param data defines the position data to use
  111473. */
  111474. setPositions(data: Nullable<FloatArray>): void;
  111475. /**
  111476. * Gets the position data stored in this target
  111477. * @returns a FloatArray containing the position data (or null if not present)
  111478. */
  111479. getPositions(): Nullable<FloatArray>;
  111480. /**
  111481. * Affects normal data to this target
  111482. * @param data defines the normal data to use
  111483. */
  111484. setNormals(data: Nullable<FloatArray>): void;
  111485. /**
  111486. * Gets the normal data stored in this target
  111487. * @returns a FloatArray containing the normal data (or null if not present)
  111488. */
  111489. getNormals(): Nullable<FloatArray>;
  111490. /**
  111491. * Affects tangent data to this target
  111492. * @param data defines the tangent data to use
  111493. */
  111494. setTangents(data: Nullable<FloatArray>): void;
  111495. /**
  111496. * Gets the tangent data stored in this target
  111497. * @returns a FloatArray containing the tangent data (or null if not present)
  111498. */
  111499. getTangents(): Nullable<FloatArray>;
  111500. /**
  111501. * Affects texture coordinates data to this target
  111502. * @param data defines the texture coordinates data to use
  111503. */
  111504. setUVs(data: Nullable<FloatArray>): void;
  111505. /**
  111506. * Gets the texture coordinates data stored in this target
  111507. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  111508. */
  111509. getUVs(): Nullable<FloatArray>;
  111510. /**
  111511. * Clone the current target
  111512. * @returns a new MorphTarget
  111513. */
  111514. clone(): MorphTarget;
  111515. /**
  111516. * Serializes the current target into a Serialization object
  111517. * @returns the serialized object
  111518. */
  111519. serialize(): any;
  111520. /**
  111521. * Returns the string "MorphTarget"
  111522. * @returns "MorphTarget"
  111523. */
  111524. getClassName(): string;
  111525. /**
  111526. * Creates a new target from serialized data
  111527. * @param serializationObject defines the serialized data to use
  111528. * @returns a new MorphTarget
  111529. */
  111530. static Parse(serializationObject: any): MorphTarget;
  111531. /**
  111532. * Creates a MorphTarget from mesh data
  111533. * @param mesh defines the source mesh
  111534. * @param name defines the name to use for the new target
  111535. * @param influence defines the influence to attach to the target
  111536. * @returns a new MorphTarget
  111537. */
  111538. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  111539. }
  111540. }
  111541. declare module BABYLON {
  111542. /**
  111543. * This class is used to deform meshes using morphing between different targets
  111544. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111545. */
  111546. export class MorphTargetManager {
  111547. private _targets;
  111548. private _targetInfluenceChangedObservers;
  111549. private _targetDataLayoutChangedObservers;
  111550. private _activeTargets;
  111551. private _scene;
  111552. private _influences;
  111553. private _supportsNormals;
  111554. private _supportsTangents;
  111555. private _supportsUVs;
  111556. private _vertexCount;
  111557. private _uniqueId;
  111558. private _tempInfluences;
  111559. /**
  111560. * Gets or sets a boolean indicating if normals must be morphed
  111561. */
  111562. enableNormalMorphing: boolean;
  111563. /**
  111564. * Gets or sets a boolean indicating if tangents must be morphed
  111565. */
  111566. enableTangentMorphing: boolean;
  111567. /**
  111568. * Gets or sets a boolean indicating if UV must be morphed
  111569. */
  111570. enableUVMorphing: boolean;
  111571. /**
  111572. * Creates a new MorphTargetManager
  111573. * @param scene defines the current scene
  111574. */
  111575. constructor(scene?: Nullable<Scene>);
  111576. /**
  111577. * Gets the unique ID of this manager
  111578. */
  111579. get uniqueId(): number;
  111580. /**
  111581. * Gets the number of vertices handled by this manager
  111582. */
  111583. get vertexCount(): number;
  111584. /**
  111585. * Gets a boolean indicating if this manager supports morphing of normals
  111586. */
  111587. get supportsNormals(): boolean;
  111588. /**
  111589. * Gets a boolean indicating if this manager supports morphing of tangents
  111590. */
  111591. get supportsTangents(): boolean;
  111592. /**
  111593. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  111594. */
  111595. get supportsUVs(): boolean;
  111596. /**
  111597. * Gets the number of targets stored in this manager
  111598. */
  111599. get numTargets(): number;
  111600. /**
  111601. * Gets the number of influencers (ie. the number of targets with influences > 0)
  111602. */
  111603. get numInfluencers(): number;
  111604. /**
  111605. * Gets the list of influences (one per target)
  111606. */
  111607. get influences(): Float32Array;
  111608. /**
  111609. * Gets the active target at specified index. An active target is a target with an influence > 0
  111610. * @param index defines the index to check
  111611. * @returns the requested target
  111612. */
  111613. getActiveTarget(index: number): MorphTarget;
  111614. /**
  111615. * Gets the target at specified index
  111616. * @param index defines the index to check
  111617. * @returns the requested target
  111618. */
  111619. getTarget(index: number): MorphTarget;
  111620. /**
  111621. * Add a new target to this manager
  111622. * @param target defines the target to add
  111623. */
  111624. addTarget(target: MorphTarget): void;
  111625. /**
  111626. * Removes a target from the manager
  111627. * @param target defines the target to remove
  111628. */
  111629. removeTarget(target: MorphTarget): void;
  111630. /**
  111631. * Clone the current manager
  111632. * @returns a new MorphTargetManager
  111633. */
  111634. clone(): MorphTargetManager;
  111635. /**
  111636. * Serializes the current manager into a Serialization object
  111637. * @returns the serialized object
  111638. */
  111639. serialize(): any;
  111640. private _syncActiveTargets;
  111641. /**
  111642. * Syncrhonize the targets with all the meshes using this morph target manager
  111643. */
  111644. synchronize(): void;
  111645. /**
  111646. * Creates a new MorphTargetManager from serialized data
  111647. * @param serializationObject defines the serialized data
  111648. * @param scene defines the hosting scene
  111649. * @returns the new MorphTargetManager
  111650. */
  111651. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  111652. }
  111653. }
  111654. declare module BABYLON {
  111655. /**
  111656. * Class used to represent a specific level of detail of a mesh
  111657. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  111658. */
  111659. export class MeshLODLevel {
  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. * Creates a new LOD level
  111666. * @param distance defines the distance where this level should star being displayed
  111667. * @param mesh defines the mesh to use to render this level
  111668. */
  111669. constructor(
  111670. /** Defines the distance where this level should start being displayed */
  111671. distance: number,
  111672. /** Defines the mesh to use to render this level */
  111673. mesh: Nullable<Mesh>);
  111674. }
  111675. }
  111676. declare module BABYLON {
  111677. /**
  111678. * Helper class used to generate a canvas to manipulate images
  111679. */
  111680. export class CanvasGenerator {
  111681. /**
  111682. * Create a new canvas (or offscreen canvas depending on the context)
  111683. * @param width defines the expected width
  111684. * @param height defines the expected height
  111685. * @return a new canvas or offscreen canvas
  111686. */
  111687. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  111688. }
  111689. }
  111690. declare module BABYLON {
  111691. /**
  111692. * Mesh representing the gorund
  111693. */
  111694. export class GroundMesh extends Mesh {
  111695. /** If octree should be generated */
  111696. generateOctree: boolean;
  111697. private _heightQuads;
  111698. /** @hidden */
  111699. _subdivisionsX: number;
  111700. /** @hidden */
  111701. _subdivisionsY: number;
  111702. /** @hidden */
  111703. _width: number;
  111704. /** @hidden */
  111705. _height: number;
  111706. /** @hidden */
  111707. _minX: number;
  111708. /** @hidden */
  111709. _maxX: number;
  111710. /** @hidden */
  111711. _minZ: number;
  111712. /** @hidden */
  111713. _maxZ: number;
  111714. constructor(name: string, scene: Scene);
  111715. /**
  111716. * "GroundMesh"
  111717. * @returns "GroundMesh"
  111718. */
  111719. getClassName(): string;
  111720. /**
  111721. * The minimum of x and y subdivisions
  111722. */
  111723. get subdivisions(): number;
  111724. /**
  111725. * X subdivisions
  111726. */
  111727. get subdivisionsX(): number;
  111728. /**
  111729. * Y subdivisions
  111730. */
  111731. get subdivisionsY(): number;
  111732. /**
  111733. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  111734. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111735. * @param chunksCount the number of subdivisions for x and y
  111736. * @param octreeBlocksSize (Default: 32)
  111737. */
  111738. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  111739. /**
  111740. * Returns a height (y) value in the Worl system :
  111741. * the ground altitude at the coordinates (x, z) expressed in the World system.
  111742. * @param x x coordinate
  111743. * @param z z coordinate
  111744. * @returns the ground y position if (x, z) are outside the ground surface.
  111745. */
  111746. getHeightAtCoordinates(x: number, z: number): number;
  111747. /**
  111748. * Returns a normalized vector (Vector3) orthogonal to the ground
  111749. * at the ground coordinates (x, z) expressed in the World system.
  111750. * @param x x coordinate
  111751. * @param z z coordinate
  111752. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  111753. */
  111754. getNormalAtCoordinates(x: number, z: number): Vector3;
  111755. /**
  111756. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  111757. * at the ground coordinates (x, z) expressed in the World system.
  111758. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  111759. * @param x x coordinate
  111760. * @param z z coordinate
  111761. * @param ref vector to store the result
  111762. * @returns the GroundMesh.
  111763. */
  111764. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  111765. /**
  111766. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  111767. * if the ground has been updated.
  111768. * This can be used in the render loop.
  111769. * @returns the GroundMesh.
  111770. */
  111771. updateCoordinateHeights(): GroundMesh;
  111772. private _getFacetAt;
  111773. private _initHeightQuads;
  111774. private _computeHeightQuads;
  111775. /**
  111776. * Serializes this ground mesh
  111777. * @param serializationObject object to write serialization to
  111778. */
  111779. serialize(serializationObject: any): void;
  111780. /**
  111781. * Parses a serialized ground mesh
  111782. * @param parsedMesh the serialized mesh
  111783. * @param scene the scene to create the ground mesh in
  111784. * @returns the created ground mesh
  111785. */
  111786. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  111787. }
  111788. }
  111789. declare module BABYLON {
  111790. /**
  111791. * Interface for Physics-Joint data
  111792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111793. */
  111794. export interface PhysicsJointData {
  111795. /**
  111796. * The main pivot of the joint
  111797. */
  111798. mainPivot?: Vector3;
  111799. /**
  111800. * The connected pivot of the joint
  111801. */
  111802. connectedPivot?: Vector3;
  111803. /**
  111804. * The main axis of the joint
  111805. */
  111806. mainAxis?: Vector3;
  111807. /**
  111808. * The connected axis of the joint
  111809. */
  111810. connectedAxis?: Vector3;
  111811. /**
  111812. * The collision of the joint
  111813. */
  111814. collision?: boolean;
  111815. /**
  111816. * Native Oimo/Cannon/Energy data
  111817. */
  111818. nativeParams?: any;
  111819. }
  111820. /**
  111821. * This is a holder class for the physics joint created by the physics plugin
  111822. * It holds a set of functions to control the underlying joint
  111823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111824. */
  111825. export class PhysicsJoint {
  111826. /**
  111827. * The type of the physics joint
  111828. */
  111829. type: number;
  111830. /**
  111831. * The data for the physics joint
  111832. */
  111833. jointData: PhysicsJointData;
  111834. private _physicsJoint;
  111835. protected _physicsPlugin: IPhysicsEnginePlugin;
  111836. /**
  111837. * Initializes the physics joint
  111838. * @param type The type of the physics joint
  111839. * @param jointData The data for the physics joint
  111840. */
  111841. constructor(
  111842. /**
  111843. * The type of the physics joint
  111844. */
  111845. type: number,
  111846. /**
  111847. * The data for the physics joint
  111848. */
  111849. jointData: PhysicsJointData);
  111850. /**
  111851. * Gets the physics joint
  111852. */
  111853. get physicsJoint(): any;
  111854. /**
  111855. * Sets the physics joint
  111856. */
  111857. set physicsJoint(newJoint: any);
  111858. /**
  111859. * Sets the physics plugin
  111860. */
  111861. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  111862. /**
  111863. * Execute a function that is physics-plugin specific.
  111864. * @param {Function} func the function that will be executed.
  111865. * It accepts two parameters: the physics world and the physics joint
  111866. */
  111867. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  111868. /**
  111869. * Distance-Joint type
  111870. */
  111871. static DistanceJoint: number;
  111872. /**
  111873. * Hinge-Joint type
  111874. */
  111875. static HingeJoint: number;
  111876. /**
  111877. * Ball-and-Socket joint type
  111878. */
  111879. static BallAndSocketJoint: number;
  111880. /**
  111881. * Wheel-Joint type
  111882. */
  111883. static WheelJoint: number;
  111884. /**
  111885. * Slider-Joint type
  111886. */
  111887. static SliderJoint: number;
  111888. /**
  111889. * Prismatic-Joint type
  111890. */
  111891. static PrismaticJoint: number;
  111892. /**
  111893. * Universal-Joint type
  111894. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  111895. */
  111896. static UniversalJoint: number;
  111897. /**
  111898. * Hinge-Joint 2 type
  111899. */
  111900. static Hinge2Joint: number;
  111901. /**
  111902. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  111903. */
  111904. static PointToPointJoint: number;
  111905. /**
  111906. * Spring-Joint type
  111907. */
  111908. static SpringJoint: number;
  111909. /**
  111910. * Lock-Joint type
  111911. */
  111912. static LockJoint: number;
  111913. }
  111914. /**
  111915. * A class representing a physics distance joint
  111916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111917. */
  111918. export class DistanceJoint extends PhysicsJoint {
  111919. /**
  111920. *
  111921. * @param jointData The data for the Distance-Joint
  111922. */
  111923. constructor(jointData: DistanceJointData);
  111924. /**
  111925. * Update the predefined distance.
  111926. * @param maxDistance The maximum preferred distance
  111927. * @param minDistance The minimum preferred distance
  111928. */
  111929. updateDistance(maxDistance: number, minDistance?: number): void;
  111930. }
  111931. /**
  111932. * Represents a Motor-Enabled Joint
  111933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111934. */
  111935. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  111936. /**
  111937. * Initializes the Motor-Enabled Joint
  111938. * @param type The type of the joint
  111939. * @param jointData The physica joint data for the joint
  111940. */
  111941. constructor(type: number, jointData: PhysicsJointData);
  111942. /**
  111943. * Set the motor values.
  111944. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111945. * @param force the force to apply
  111946. * @param maxForce max force for this motor.
  111947. */
  111948. setMotor(force?: number, maxForce?: number): void;
  111949. /**
  111950. * Set the motor's limits.
  111951. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111952. * @param upperLimit The upper limit of the motor
  111953. * @param lowerLimit The lower limit of the motor
  111954. */
  111955. setLimit(upperLimit: number, lowerLimit?: number): void;
  111956. }
  111957. /**
  111958. * This class represents a single physics Hinge-Joint
  111959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111960. */
  111961. export class HingeJoint extends MotorEnabledJoint {
  111962. /**
  111963. * Initializes the Hinge-Joint
  111964. * @param jointData The joint data for the Hinge-Joint
  111965. */
  111966. constructor(jointData: PhysicsJointData);
  111967. /**
  111968. * Set the motor values.
  111969. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111970. * @param {number} force the force to apply
  111971. * @param {number} maxForce max force for this motor.
  111972. */
  111973. setMotor(force?: number, maxForce?: number): void;
  111974. /**
  111975. * Set the motor's limits.
  111976. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111977. * @param upperLimit The upper limit of the motor
  111978. * @param lowerLimit The lower limit of the motor
  111979. */
  111980. setLimit(upperLimit: number, lowerLimit?: number): void;
  111981. }
  111982. /**
  111983. * This class represents a dual hinge physics joint (same as wheel joint)
  111984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111985. */
  111986. export class Hinge2Joint extends MotorEnabledJoint {
  111987. /**
  111988. * Initializes the Hinge2-Joint
  111989. * @param jointData The joint data for the Hinge2-Joint
  111990. */
  111991. constructor(jointData: PhysicsJointData);
  111992. /**
  111993. * Set the motor values.
  111994. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111995. * @param {number} targetSpeed the speed the motor is to reach
  111996. * @param {number} maxForce max force for this motor.
  111997. * @param {motorIndex} the motor's index, 0 or 1.
  111998. */
  111999. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112000. /**
  112001. * Set the motor limits.
  112002. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112003. * @param {number} upperLimit the upper limit
  112004. * @param {number} lowerLimit lower limit
  112005. * @param {motorIndex} the motor's index, 0 or 1.
  112006. */
  112007. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112008. }
  112009. /**
  112010. * Interface for a motor enabled joint
  112011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112012. */
  112013. export interface IMotorEnabledJoint {
  112014. /**
  112015. * Physics joint
  112016. */
  112017. physicsJoint: any;
  112018. /**
  112019. * Sets the motor of the motor-enabled joint
  112020. * @param force The force of the motor
  112021. * @param maxForce The maximum force of the motor
  112022. * @param motorIndex The index of the motor
  112023. */
  112024. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112025. /**
  112026. * Sets the limit of the motor
  112027. * @param upperLimit The upper limit of the motor
  112028. * @param lowerLimit The lower limit of the motor
  112029. * @param motorIndex The index of the motor
  112030. */
  112031. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112032. }
  112033. /**
  112034. * Joint data for a Distance-Joint
  112035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112036. */
  112037. export interface DistanceJointData extends PhysicsJointData {
  112038. /**
  112039. * Max distance the 2 joint objects can be apart
  112040. */
  112041. maxDistance: number;
  112042. }
  112043. /**
  112044. * Joint data from a spring joint
  112045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112046. */
  112047. export interface SpringJointData extends PhysicsJointData {
  112048. /**
  112049. * Length of the spring
  112050. */
  112051. length: number;
  112052. /**
  112053. * Stiffness of the spring
  112054. */
  112055. stiffness: number;
  112056. /**
  112057. * Damping of the spring
  112058. */
  112059. damping: number;
  112060. /** this callback will be called when applying the force to the impostors. */
  112061. forceApplicationCallback: () => void;
  112062. }
  112063. }
  112064. declare module BABYLON {
  112065. /**
  112066. * Holds the data for the raycast result
  112067. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112068. */
  112069. export class PhysicsRaycastResult {
  112070. private _hasHit;
  112071. private _hitDistance;
  112072. private _hitNormalWorld;
  112073. private _hitPointWorld;
  112074. private _rayFromWorld;
  112075. private _rayToWorld;
  112076. /**
  112077. * Gets if there was a hit
  112078. */
  112079. get hasHit(): boolean;
  112080. /**
  112081. * Gets the distance from the hit
  112082. */
  112083. get hitDistance(): number;
  112084. /**
  112085. * Gets the hit normal/direction in the world
  112086. */
  112087. get hitNormalWorld(): Vector3;
  112088. /**
  112089. * Gets the hit point in the world
  112090. */
  112091. get hitPointWorld(): Vector3;
  112092. /**
  112093. * Gets the ray "start point" of the ray in the world
  112094. */
  112095. get rayFromWorld(): Vector3;
  112096. /**
  112097. * Gets the ray "end point" of the ray in the world
  112098. */
  112099. get rayToWorld(): Vector3;
  112100. /**
  112101. * Sets the hit data (normal & point in world space)
  112102. * @param hitNormalWorld defines the normal in world space
  112103. * @param hitPointWorld defines the point in world space
  112104. */
  112105. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  112106. /**
  112107. * Sets the distance from the start point to the hit point
  112108. * @param distance
  112109. */
  112110. setHitDistance(distance: number): void;
  112111. /**
  112112. * Calculates the distance manually
  112113. */
  112114. calculateHitDistance(): void;
  112115. /**
  112116. * Resets all the values to default
  112117. * @param from The from point on world space
  112118. * @param to The to point on world space
  112119. */
  112120. reset(from?: Vector3, to?: Vector3): void;
  112121. }
  112122. /**
  112123. * Interface for the size containing width and height
  112124. */
  112125. interface IXYZ {
  112126. /**
  112127. * X
  112128. */
  112129. x: number;
  112130. /**
  112131. * Y
  112132. */
  112133. y: number;
  112134. /**
  112135. * Z
  112136. */
  112137. z: number;
  112138. }
  112139. }
  112140. declare module BABYLON {
  112141. /**
  112142. * Interface used to describe a physics joint
  112143. */
  112144. export interface PhysicsImpostorJoint {
  112145. /** Defines the main impostor to which the joint is linked */
  112146. mainImpostor: PhysicsImpostor;
  112147. /** Defines the impostor that is connected to the main impostor using this joint */
  112148. connectedImpostor: PhysicsImpostor;
  112149. /** Defines the joint itself */
  112150. joint: PhysicsJoint;
  112151. }
  112152. /** @hidden */
  112153. export interface IPhysicsEnginePlugin {
  112154. world: any;
  112155. name: string;
  112156. setGravity(gravity: Vector3): void;
  112157. setTimeStep(timeStep: number): void;
  112158. getTimeStep(): number;
  112159. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112160. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112161. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112162. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112163. removePhysicsBody(impostor: PhysicsImpostor): void;
  112164. generateJoint(joint: PhysicsImpostorJoint): void;
  112165. removeJoint(joint: PhysicsImpostorJoint): void;
  112166. isSupported(): boolean;
  112167. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112168. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112169. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112170. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112171. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112172. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112173. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112174. getBodyMass(impostor: PhysicsImpostor): number;
  112175. getBodyFriction(impostor: PhysicsImpostor): number;
  112176. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112177. getBodyRestitution(impostor: PhysicsImpostor): number;
  112178. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112179. getBodyPressure?(impostor: PhysicsImpostor): number;
  112180. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  112181. getBodyStiffness?(impostor: PhysicsImpostor): number;
  112182. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  112183. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  112184. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  112185. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  112186. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  112187. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112188. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112189. sleepBody(impostor: PhysicsImpostor): void;
  112190. wakeUpBody(impostor: PhysicsImpostor): void;
  112191. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112192. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112193. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  112194. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112195. getRadius(impostor: PhysicsImpostor): number;
  112196. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112197. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112198. dispose(): void;
  112199. }
  112200. /**
  112201. * Interface used to define a physics engine
  112202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112203. */
  112204. export interface IPhysicsEngine {
  112205. /**
  112206. * Gets the gravity vector used by the simulation
  112207. */
  112208. gravity: Vector3;
  112209. /**
  112210. * Sets the gravity vector used by the simulation
  112211. * @param gravity defines the gravity vector to use
  112212. */
  112213. setGravity(gravity: Vector3): void;
  112214. /**
  112215. * Set the time step of the physics engine.
  112216. * Default is 1/60.
  112217. * To slow it down, enter 1/600 for example.
  112218. * To speed it up, 1/30
  112219. * @param newTimeStep the new timestep to apply to this world.
  112220. */
  112221. setTimeStep(newTimeStep: number): void;
  112222. /**
  112223. * Get the time step of the physics engine.
  112224. * @returns the current time step
  112225. */
  112226. getTimeStep(): number;
  112227. /**
  112228. * Set the sub time step of the physics engine.
  112229. * Default is 0 meaning there is no sub steps
  112230. * To increase physics resolution precision, set a small value (like 1 ms)
  112231. * @param subTimeStep defines the new sub timestep used for physics resolution.
  112232. */
  112233. setSubTimeStep(subTimeStep: number): void;
  112234. /**
  112235. * Get the sub time step of the physics engine.
  112236. * @returns the current sub time step
  112237. */
  112238. getSubTimeStep(): number;
  112239. /**
  112240. * Release all resources
  112241. */
  112242. dispose(): void;
  112243. /**
  112244. * Gets the name of the current physics plugin
  112245. * @returns the name of the plugin
  112246. */
  112247. getPhysicsPluginName(): string;
  112248. /**
  112249. * Adding a new impostor for the impostor tracking.
  112250. * This will be done by the impostor itself.
  112251. * @param impostor the impostor to add
  112252. */
  112253. addImpostor(impostor: PhysicsImpostor): void;
  112254. /**
  112255. * Remove an impostor from the engine.
  112256. * This impostor and its mesh will not longer be updated by the physics engine.
  112257. * @param impostor the impostor to remove
  112258. */
  112259. removeImpostor(impostor: PhysicsImpostor): void;
  112260. /**
  112261. * Add a joint to the physics engine
  112262. * @param mainImpostor defines the main impostor to which the joint is added.
  112263. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  112264. * @param joint defines the joint that will connect both impostors.
  112265. */
  112266. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112267. /**
  112268. * Removes a joint from the simulation
  112269. * @param mainImpostor defines the impostor used with the joint
  112270. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  112271. * @param joint defines the joint to remove
  112272. */
  112273. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112274. /**
  112275. * Gets the current plugin used to run the simulation
  112276. * @returns current plugin
  112277. */
  112278. getPhysicsPlugin(): IPhysicsEnginePlugin;
  112279. /**
  112280. * Gets the list of physic impostors
  112281. * @returns an array of PhysicsImpostor
  112282. */
  112283. getImpostors(): Array<PhysicsImpostor>;
  112284. /**
  112285. * Gets the impostor for a physics enabled object
  112286. * @param object defines the object impersonated by the impostor
  112287. * @returns the PhysicsImpostor or null if not found
  112288. */
  112289. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112290. /**
  112291. * Gets the impostor for a physics body object
  112292. * @param body defines physics body used by the impostor
  112293. * @returns the PhysicsImpostor or null if not found
  112294. */
  112295. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112296. /**
  112297. * Does a raycast in the physics world
  112298. * @param from when should the ray start?
  112299. * @param to when should the ray end?
  112300. * @returns PhysicsRaycastResult
  112301. */
  112302. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112303. /**
  112304. * Called by the scene. No need to call it.
  112305. * @param delta defines the timespam between frames
  112306. */
  112307. _step(delta: number): void;
  112308. }
  112309. }
  112310. declare module BABYLON {
  112311. /**
  112312. * The interface for the physics imposter parameters
  112313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112314. */
  112315. export interface PhysicsImpostorParameters {
  112316. /**
  112317. * The mass of the physics imposter
  112318. */
  112319. mass: number;
  112320. /**
  112321. * The friction of the physics imposter
  112322. */
  112323. friction?: number;
  112324. /**
  112325. * The coefficient of restitution of the physics imposter
  112326. */
  112327. restitution?: number;
  112328. /**
  112329. * The native options of the physics imposter
  112330. */
  112331. nativeOptions?: any;
  112332. /**
  112333. * Specifies if the parent should be ignored
  112334. */
  112335. ignoreParent?: boolean;
  112336. /**
  112337. * Specifies if bi-directional transformations should be disabled
  112338. */
  112339. disableBidirectionalTransformation?: boolean;
  112340. /**
  112341. * The pressure inside the physics imposter, soft object only
  112342. */
  112343. pressure?: number;
  112344. /**
  112345. * The stiffness the physics imposter, soft object only
  112346. */
  112347. stiffness?: number;
  112348. /**
  112349. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  112350. */
  112351. velocityIterations?: number;
  112352. /**
  112353. * The number of iterations used in maintaining consistent vertex positions, soft object only
  112354. */
  112355. positionIterations?: number;
  112356. /**
  112357. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  112358. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  112359. * Add to fix multiple points
  112360. */
  112361. fixedPoints?: number;
  112362. /**
  112363. * The collision margin around a soft object
  112364. */
  112365. margin?: number;
  112366. /**
  112367. * The collision margin around a soft object
  112368. */
  112369. damping?: number;
  112370. /**
  112371. * The path for a rope based on an extrusion
  112372. */
  112373. path?: any;
  112374. /**
  112375. * The shape of an extrusion used for a rope based on an extrusion
  112376. */
  112377. shape?: any;
  112378. }
  112379. /**
  112380. * Interface for a physics-enabled object
  112381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112382. */
  112383. export interface IPhysicsEnabledObject {
  112384. /**
  112385. * The position of the physics-enabled object
  112386. */
  112387. position: Vector3;
  112388. /**
  112389. * The rotation of the physics-enabled object
  112390. */
  112391. rotationQuaternion: Nullable<Quaternion>;
  112392. /**
  112393. * The scale of the physics-enabled object
  112394. */
  112395. scaling: Vector3;
  112396. /**
  112397. * The rotation of the physics-enabled object
  112398. */
  112399. rotation?: Vector3;
  112400. /**
  112401. * The parent of the physics-enabled object
  112402. */
  112403. parent?: any;
  112404. /**
  112405. * The bounding info of the physics-enabled object
  112406. * @returns The bounding info of the physics-enabled object
  112407. */
  112408. getBoundingInfo(): BoundingInfo;
  112409. /**
  112410. * Computes the world matrix
  112411. * @param force Specifies if the world matrix should be computed by force
  112412. * @returns A world matrix
  112413. */
  112414. computeWorldMatrix(force: boolean): Matrix;
  112415. /**
  112416. * Gets the world matrix
  112417. * @returns A world matrix
  112418. */
  112419. getWorldMatrix?(): Matrix;
  112420. /**
  112421. * Gets the child meshes
  112422. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  112423. * @returns An array of abstract meshes
  112424. */
  112425. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  112426. /**
  112427. * Gets the vertex data
  112428. * @param kind The type of vertex data
  112429. * @returns A nullable array of numbers, or a float32 array
  112430. */
  112431. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  112432. /**
  112433. * Gets the indices from the mesh
  112434. * @returns A nullable array of index arrays
  112435. */
  112436. getIndices?(): Nullable<IndicesArray>;
  112437. /**
  112438. * Gets the scene from the mesh
  112439. * @returns the indices array or null
  112440. */
  112441. getScene?(): Scene;
  112442. /**
  112443. * Gets the absolute position from the mesh
  112444. * @returns the absolute position
  112445. */
  112446. getAbsolutePosition(): Vector3;
  112447. /**
  112448. * Gets the absolute pivot point from the mesh
  112449. * @returns the absolute pivot point
  112450. */
  112451. getAbsolutePivotPoint(): Vector3;
  112452. /**
  112453. * Rotates the mesh
  112454. * @param axis The axis of rotation
  112455. * @param amount The amount of rotation
  112456. * @param space The space of the rotation
  112457. * @returns The rotation transform node
  112458. */
  112459. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  112460. /**
  112461. * Translates the mesh
  112462. * @param axis The axis of translation
  112463. * @param distance The distance of translation
  112464. * @param space The space of the translation
  112465. * @returns The transform node
  112466. */
  112467. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  112468. /**
  112469. * Sets the absolute position of the mesh
  112470. * @param absolutePosition The absolute position of the mesh
  112471. * @returns The transform node
  112472. */
  112473. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  112474. /**
  112475. * Gets the class name of the mesh
  112476. * @returns The class name
  112477. */
  112478. getClassName(): string;
  112479. }
  112480. /**
  112481. * Represents a physics imposter
  112482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112483. */
  112484. export class PhysicsImpostor {
  112485. /**
  112486. * The physics-enabled object used as the physics imposter
  112487. */
  112488. object: IPhysicsEnabledObject;
  112489. /**
  112490. * The type of the physics imposter
  112491. */
  112492. type: number;
  112493. private _options;
  112494. private _scene?;
  112495. /**
  112496. * The default object size of the imposter
  112497. */
  112498. static DEFAULT_OBJECT_SIZE: Vector3;
  112499. /**
  112500. * The identity quaternion of the imposter
  112501. */
  112502. static IDENTITY_QUATERNION: Quaternion;
  112503. /** @hidden */
  112504. _pluginData: any;
  112505. private _physicsEngine;
  112506. private _physicsBody;
  112507. private _bodyUpdateRequired;
  112508. private _onBeforePhysicsStepCallbacks;
  112509. private _onAfterPhysicsStepCallbacks;
  112510. /** @hidden */
  112511. _onPhysicsCollideCallbacks: Array<{
  112512. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  112513. otherImpostors: Array<PhysicsImpostor>;
  112514. }>;
  112515. private _deltaPosition;
  112516. private _deltaRotation;
  112517. private _deltaRotationConjugated;
  112518. /** @hidden */
  112519. _isFromLine: boolean;
  112520. private _parent;
  112521. private _isDisposed;
  112522. private static _tmpVecs;
  112523. private static _tmpQuat;
  112524. /**
  112525. * Specifies if the physics imposter is disposed
  112526. */
  112527. get isDisposed(): boolean;
  112528. /**
  112529. * Gets the mass of the physics imposter
  112530. */
  112531. get mass(): number;
  112532. set mass(value: number);
  112533. /**
  112534. * Gets the coefficient of friction
  112535. */
  112536. get friction(): number;
  112537. /**
  112538. * Sets the coefficient of friction
  112539. */
  112540. set friction(value: number);
  112541. /**
  112542. * Gets the coefficient of restitution
  112543. */
  112544. get restitution(): number;
  112545. /**
  112546. * Sets the coefficient of restitution
  112547. */
  112548. set restitution(value: number);
  112549. /**
  112550. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  112551. */
  112552. get pressure(): number;
  112553. /**
  112554. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  112555. */
  112556. set pressure(value: number);
  112557. /**
  112558. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112559. */
  112560. get stiffness(): number;
  112561. /**
  112562. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112563. */
  112564. set stiffness(value: number);
  112565. /**
  112566. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112567. */
  112568. get velocityIterations(): number;
  112569. /**
  112570. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112571. */
  112572. set velocityIterations(value: number);
  112573. /**
  112574. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112575. */
  112576. get positionIterations(): number;
  112577. /**
  112578. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112579. */
  112580. set positionIterations(value: number);
  112581. /**
  112582. * The unique id of the physics imposter
  112583. * set by the physics engine when adding this impostor to the array
  112584. */
  112585. uniqueId: number;
  112586. /**
  112587. * @hidden
  112588. */
  112589. soft: boolean;
  112590. /**
  112591. * @hidden
  112592. */
  112593. segments: number;
  112594. private _joints;
  112595. /**
  112596. * Initializes the physics imposter
  112597. * @param object The physics-enabled object used as the physics imposter
  112598. * @param type The type of the physics imposter
  112599. * @param _options The options for the physics imposter
  112600. * @param _scene The Babylon scene
  112601. */
  112602. constructor(
  112603. /**
  112604. * The physics-enabled object used as the physics imposter
  112605. */
  112606. object: IPhysicsEnabledObject,
  112607. /**
  112608. * The type of the physics imposter
  112609. */
  112610. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  112611. /**
  112612. * This function will completly initialize this impostor.
  112613. * It will create a new body - but only if this mesh has no parent.
  112614. * If it has, this impostor will not be used other than to define the impostor
  112615. * of the child mesh.
  112616. * @hidden
  112617. */
  112618. _init(): void;
  112619. private _getPhysicsParent;
  112620. /**
  112621. * Should a new body be generated.
  112622. * @returns boolean specifying if body initialization is required
  112623. */
  112624. isBodyInitRequired(): boolean;
  112625. /**
  112626. * Sets the updated scaling
  112627. * @param updated Specifies if the scaling is updated
  112628. */
  112629. setScalingUpdated(): void;
  112630. /**
  112631. * Force a regeneration of this or the parent's impostor's body.
  112632. * Use under cautious - This will remove all joints already implemented.
  112633. */
  112634. forceUpdate(): void;
  112635. /**
  112636. * Gets the body that holds this impostor. Either its own, or its parent.
  112637. */
  112638. get physicsBody(): any;
  112639. /**
  112640. * Get the parent of the physics imposter
  112641. * @returns Physics imposter or null
  112642. */
  112643. get parent(): Nullable<PhysicsImpostor>;
  112644. /**
  112645. * Sets the parent of the physics imposter
  112646. */
  112647. set parent(value: Nullable<PhysicsImpostor>);
  112648. /**
  112649. * Set the physics body. Used mainly by the physics engine/plugin
  112650. */
  112651. set physicsBody(physicsBody: any);
  112652. /**
  112653. * Resets the update flags
  112654. */
  112655. resetUpdateFlags(): void;
  112656. /**
  112657. * Gets the object extend size
  112658. * @returns the object extend size
  112659. */
  112660. getObjectExtendSize(): Vector3;
  112661. /**
  112662. * Gets the object center
  112663. * @returns The object center
  112664. */
  112665. getObjectCenter(): Vector3;
  112666. /**
  112667. * Get a specific parameter from the options parameters
  112668. * @param paramName The object parameter name
  112669. * @returns The object parameter
  112670. */
  112671. getParam(paramName: string): any;
  112672. /**
  112673. * Sets a specific parameter in the options given to the physics plugin
  112674. * @param paramName The parameter name
  112675. * @param value The value of the parameter
  112676. */
  112677. setParam(paramName: string, value: number): void;
  112678. /**
  112679. * Specifically change the body's mass option. Won't recreate the physics body object
  112680. * @param mass The mass of the physics imposter
  112681. */
  112682. setMass(mass: number): void;
  112683. /**
  112684. * Gets the linear velocity
  112685. * @returns linear velocity or null
  112686. */
  112687. getLinearVelocity(): Nullable<Vector3>;
  112688. /**
  112689. * Sets the linear velocity
  112690. * @param velocity linear velocity or null
  112691. */
  112692. setLinearVelocity(velocity: Nullable<Vector3>): void;
  112693. /**
  112694. * Gets the angular velocity
  112695. * @returns angular velocity or null
  112696. */
  112697. getAngularVelocity(): Nullable<Vector3>;
  112698. /**
  112699. * Sets the angular velocity
  112700. * @param velocity The velocity or null
  112701. */
  112702. setAngularVelocity(velocity: Nullable<Vector3>): void;
  112703. /**
  112704. * Execute a function with the physics plugin native code
  112705. * Provide a function the will have two variables - the world object and the physics body object
  112706. * @param func The function to execute with the physics plugin native code
  112707. */
  112708. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  112709. /**
  112710. * Register a function that will be executed before the physics world is stepping forward
  112711. * @param func The function to execute before the physics world is stepped forward
  112712. */
  112713. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112714. /**
  112715. * Unregister a function that will be executed before the physics world is stepping forward
  112716. * @param func The function to execute before the physics world is stepped forward
  112717. */
  112718. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112719. /**
  112720. * Register a function that will be executed after the physics step
  112721. * @param func The function to execute after physics step
  112722. */
  112723. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112724. /**
  112725. * Unregisters a function that will be executed after the physics step
  112726. * @param func The function to execute after physics step
  112727. */
  112728. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112729. /**
  112730. * register a function that will be executed when this impostor collides against a different body
  112731. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  112732. * @param func Callback that is executed on collision
  112733. */
  112734. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  112735. /**
  112736. * Unregisters the physics imposter on contact
  112737. * @param collideAgainst The physics object to collide against
  112738. * @param func Callback to execute on collision
  112739. */
  112740. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  112741. private _tmpQuat;
  112742. private _tmpQuat2;
  112743. /**
  112744. * Get the parent rotation
  112745. * @returns The parent rotation
  112746. */
  112747. getParentsRotation(): Quaternion;
  112748. /**
  112749. * this function is executed by the physics engine.
  112750. */
  112751. beforeStep: () => void;
  112752. /**
  112753. * this function is executed by the physics engine
  112754. */
  112755. afterStep: () => void;
  112756. /**
  112757. * Legacy collision detection event support
  112758. */
  112759. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  112760. /**
  112761. * event and body object due to cannon's event-based architecture.
  112762. */
  112763. onCollide: (e: {
  112764. body: any;
  112765. }) => void;
  112766. /**
  112767. * Apply a force
  112768. * @param force The force to apply
  112769. * @param contactPoint The contact point for the force
  112770. * @returns The physics imposter
  112771. */
  112772. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  112773. /**
  112774. * Apply an impulse
  112775. * @param force The impulse force
  112776. * @param contactPoint The contact point for the impulse force
  112777. * @returns The physics imposter
  112778. */
  112779. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  112780. /**
  112781. * A help function to create a joint
  112782. * @param otherImpostor A physics imposter used to create a joint
  112783. * @param jointType The type of joint
  112784. * @param jointData The data for the joint
  112785. * @returns The physics imposter
  112786. */
  112787. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  112788. /**
  112789. * Add a joint to this impostor with a different impostor
  112790. * @param otherImpostor A physics imposter used to add a joint
  112791. * @param joint The joint to add
  112792. * @returns The physics imposter
  112793. */
  112794. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  112795. /**
  112796. * Add an anchor to a cloth impostor
  112797. * @param otherImpostor rigid impostor to anchor to
  112798. * @param width ratio across width from 0 to 1
  112799. * @param height ratio up height from 0 to 1
  112800. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112801. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  112802. * @returns impostor the soft imposter
  112803. */
  112804. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  112805. /**
  112806. * Add a hook to a rope impostor
  112807. * @param otherImpostor rigid impostor to anchor to
  112808. * @param length ratio across rope from 0 to 1
  112809. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  112810. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112811. * @returns impostor the rope imposter
  112812. */
  112813. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  112814. /**
  112815. * Will keep this body still, in a sleep mode.
  112816. * @returns the physics imposter
  112817. */
  112818. sleep(): PhysicsImpostor;
  112819. /**
  112820. * Wake the body up.
  112821. * @returns The physics imposter
  112822. */
  112823. wakeUp(): PhysicsImpostor;
  112824. /**
  112825. * Clones the physics imposter
  112826. * @param newObject The physics imposter clones to this physics-enabled object
  112827. * @returns A nullable physics imposter
  112828. */
  112829. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112830. /**
  112831. * Disposes the physics imposter
  112832. */
  112833. dispose(): void;
  112834. /**
  112835. * Sets the delta position
  112836. * @param position The delta position amount
  112837. */
  112838. setDeltaPosition(position: Vector3): void;
  112839. /**
  112840. * Sets the delta rotation
  112841. * @param rotation The delta rotation amount
  112842. */
  112843. setDeltaRotation(rotation: Quaternion): void;
  112844. /**
  112845. * Gets the box size of the physics imposter and stores the result in the input parameter
  112846. * @param result Stores the box size
  112847. * @returns The physics imposter
  112848. */
  112849. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  112850. /**
  112851. * Gets the radius of the physics imposter
  112852. * @returns Radius of the physics imposter
  112853. */
  112854. getRadius(): number;
  112855. /**
  112856. * Sync a bone with this impostor
  112857. * @param bone The bone to sync to the impostor.
  112858. * @param boneMesh The mesh that the bone is influencing.
  112859. * @param jointPivot The pivot of the joint / bone in local space.
  112860. * @param distToJoint Optional distance from the impostor to the joint.
  112861. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112862. */
  112863. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  112864. /**
  112865. * Sync impostor to a bone
  112866. * @param bone The bone that the impostor will be synced to.
  112867. * @param boneMesh The mesh that the bone is influencing.
  112868. * @param jointPivot The pivot of the joint / bone in local space.
  112869. * @param distToJoint Optional distance from the impostor to the joint.
  112870. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112871. * @param boneAxis Optional vector3 axis the bone is aligned with
  112872. */
  112873. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  112874. /**
  112875. * No-Imposter type
  112876. */
  112877. static NoImpostor: number;
  112878. /**
  112879. * Sphere-Imposter type
  112880. */
  112881. static SphereImpostor: number;
  112882. /**
  112883. * Box-Imposter type
  112884. */
  112885. static BoxImpostor: number;
  112886. /**
  112887. * Plane-Imposter type
  112888. */
  112889. static PlaneImpostor: number;
  112890. /**
  112891. * Mesh-imposter type
  112892. */
  112893. static MeshImpostor: number;
  112894. /**
  112895. * Capsule-Impostor type (Ammo.js plugin only)
  112896. */
  112897. static CapsuleImpostor: number;
  112898. /**
  112899. * Cylinder-Imposter type
  112900. */
  112901. static CylinderImpostor: number;
  112902. /**
  112903. * Particle-Imposter type
  112904. */
  112905. static ParticleImpostor: number;
  112906. /**
  112907. * Heightmap-Imposter type
  112908. */
  112909. static HeightmapImpostor: number;
  112910. /**
  112911. * ConvexHull-Impostor type (Ammo.js plugin only)
  112912. */
  112913. static ConvexHullImpostor: number;
  112914. /**
  112915. * Custom-Imposter type (Ammo.js plugin only)
  112916. */
  112917. static CustomImpostor: number;
  112918. /**
  112919. * Rope-Imposter type
  112920. */
  112921. static RopeImpostor: number;
  112922. /**
  112923. * Cloth-Imposter type
  112924. */
  112925. static ClothImpostor: number;
  112926. /**
  112927. * Softbody-Imposter type
  112928. */
  112929. static SoftbodyImpostor: number;
  112930. }
  112931. }
  112932. declare module BABYLON {
  112933. /**
  112934. * @hidden
  112935. **/
  112936. export class _CreationDataStorage {
  112937. closePath?: boolean;
  112938. closeArray?: boolean;
  112939. idx: number[];
  112940. dashSize: number;
  112941. gapSize: number;
  112942. path3D: Path3D;
  112943. pathArray: Vector3[][];
  112944. arc: number;
  112945. radius: number;
  112946. cap: number;
  112947. tessellation: number;
  112948. }
  112949. /**
  112950. * @hidden
  112951. **/
  112952. class _InstanceDataStorage {
  112953. visibleInstances: any;
  112954. batchCache: _InstancesBatch;
  112955. instancesBufferSize: number;
  112956. instancesBuffer: Nullable<Buffer>;
  112957. instancesData: Float32Array;
  112958. overridenInstanceCount: number;
  112959. isFrozen: boolean;
  112960. previousBatch: Nullable<_InstancesBatch>;
  112961. hardwareInstancedRendering: boolean;
  112962. sideOrientation: number;
  112963. manualUpdate: boolean;
  112964. previousRenderId: number;
  112965. }
  112966. /**
  112967. * @hidden
  112968. **/
  112969. export class _InstancesBatch {
  112970. mustReturn: boolean;
  112971. visibleInstances: Nullable<InstancedMesh[]>[];
  112972. renderSelf: boolean[];
  112973. hardwareInstancedRendering: boolean[];
  112974. }
  112975. /**
  112976. * @hidden
  112977. **/
  112978. class _ThinInstanceDataStorage {
  112979. instancesCount: number;
  112980. matrixBuffer: Nullable<Buffer>;
  112981. matrixBufferSize: number;
  112982. matrixData: Nullable<Float32Array>;
  112983. boundingVectors: Array<Vector3>;
  112984. worldMatrices: Nullable<Matrix[]>;
  112985. }
  112986. /**
  112987. * Class used to represent renderable models
  112988. */
  112989. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  112990. /**
  112991. * Mesh side orientation : usually the external or front surface
  112992. */
  112993. static readonly FRONTSIDE: number;
  112994. /**
  112995. * Mesh side orientation : usually the internal or back surface
  112996. */
  112997. static readonly BACKSIDE: number;
  112998. /**
  112999. * Mesh side orientation : both internal and external or front and back surfaces
  113000. */
  113001. static readonly DOUBLESIDE: number;
  113002. /**
  113003. * Mesh side orientation : by default, `FRONTSIDE`
  113004. */
  113005. static readonly DEFAULTSIDE: number;
  113006. /**
  113007. * Mesh cap setting : no cap
  113008. */
  113009. static readonly NO_CAP: number;
  113010. /**
  113011. * Mesh cap setting : one cap at the beginning of the mesh
  113012. */
  113013. static readonly CAP_START: number;
  113014. /**
  113015. * Mesh cap setting : one cap at the end of the mesh
  113016. */
  113017. static readonly CAP_END: number;
  113018. /**
  113019. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113020. */
  113021. static readonly CAP_ALL: number;
  113022. /**
  113023. * Mesh pattern setting : no flip or rotate
  113024. */
  113025. static readonly NO_FLIP: number;
  113026. /**
  113027. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113028. */
  113029. static readonly FLIP_TILE: number;
  113030. /**
  113031. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113032. */
  113033. static readonly ROTATE_TILE: number;
  113034. /**
  113035. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113036. */
  113037. static readonly FLIP_ROW: number;
  113038. /**
  113039. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113040. */
  113041. static readonly ROTATE_ROW: number;
  113042. /**
  113043. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113044. */
  113045. static readonly FLIP_N_ROTATE_TILE: number;
  113046. /**
  113047. * Mesh pattern setting : rotate pattern and rotate
  113048. */
  113049. static readonly FLIP_N_ROTATE_ROW: number;
  113050. /**
  113051. * Mesh tile positioning : part tiles same on left/right or top/bottom
  113052. */
  113053. static readonly CENTER: number;
  113054. /**
  113055. * Mesh tile positioning : part tiles on left
  113056. */
  113057. static readonly LEFT: number;
  113058. /**
  113059. * Mesh tile positioning : part tiles on right
  113060. */
  113061. static readonly RIGHT: number;
  113062. /**
  113063. * Mesh tile positioning : part tiles on top
  113064. */
  113065. static readonly TOP: number;
  113066. /**
  113067. * Mesh tile positioning : part tiles on bottom
  113068. */
  113069. static readonly BOTTOM: number;
  113070. /**
  113071. * Gets the default side orientation.
  113072. * @param orientation the orientation to value to attempt to get
  113073. * @returns the default orientation
  113074. * @hidden
  113075. */
  113076. static _GetDefaultSideOrientation(orientation?: number): number;
  113077. private _internalMeshDataInfo;
  113078. get computeBonesUsingShaders(): boolean;
  113079. set computeBonesUsingShaders(value: boolean);
  113080. /**
  113081. * An event triggered before rendering the mesh
  113082. */
  113083. get onBeforeRenderObservable(): Observable<Mesh>;
  113084. /**
  113085. * An event triggered before binding the mesh
  113086. */
  113087. get onBeforeBindObservable(): Observable<Mesh>;
  113088. /**
  113089. * An event triggered after rendering the mesh
  113090. */
  113091. get onAfterRenderObservable(): Observable<Mesh>;
  113092. /**
  113093. * An event triggered before drawing the mesh
  113094. */
  113095. get onBeforeDrawObservable(): Observable<Mesh>;
  113096. private _onBeforeDrawObserver;
  113097. /**
  113098. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  113099. */
  113100. set onBeforeDraw(callback: () => void);
  113101. get hasInstances(): boolean;
  113102. get hasThinInstances(): boolean;
  113103. /**
  113104. * Gets the delay loading state of the mesh (when delay loading is turned on)
  113105. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  113106. */
  113107. delayLoadState: number;
  113108. /**
  113109. * Gets the list of instances created from this mesh
  113110. * it is not supposed to be modified manually.
  113111. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  113112. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113113. */
  113114. instances: InstancedMesh[];
  113115. /**
  113116. * Gets the file containing delay loading data for this mesh
  113117. */
  113118. delayLoadingFile: string;
  113119. /** @hidden */
  113120. _binaryInfo: any;
  113121. /**
  113122. * User defined function used to change how LOD level selection is done
  113123. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113124. */
  113125. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  113126. /**
  113127. * Gets or sets the morph target manager
  113128. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  113129. */
  113130. get morphTargetManager(): Nullable<MorphTargetManager>;
  113131. set morphTargetManager(value: Nullable<MorphTargetManager>);
  113132. /** @hidden */
  113133. _creationDataStorage: Nullable<_CreationDataStorage>;
  113134. /** @hidden */
  113135. _geometry: Nullable<Geometry>;
  113136. /** @hidden */
  113137. _delayInfo: Array<string>;
  113138. /** @hidden */
  113139. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  113140. /** @hidden */
  113141. _instanceDataStorage: _InstanceDataStorage;
  113142. /** @hidden */
  113143. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  113144. private _effectiveMaterial;
  113145. /** @hidden */
  113146. _shouldGenerateFlatShading: boolean;
  113147. /** @hidden */
  113148. _originalBuilderSideOrientation: number;
  113149. /**
  113150. * Use this property to change the original side orientation defined at construction time
  113151. */
  113152. overrideMaterialSideOrientation: Nullable<number>;
  113153. /**
  113154. * Gets the source mesh (the one used to clone this one from)
  113155. */
  113156. get source(): Nullable<Mesh>;
  113157. /**
  113158. * Gets the list of clones of this mesh
  113159. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  113160. * Note that useClonedMeshMap=true is the default setting
  113161. */
  113162. get cloneMeshMap(): Nullable<{
  113163. [id: string]: Mesh | undefined;
  113164. }>;
  113165. /**
  113166. * Gets or sets a boolean indicating that this mesh does not use index buffer
  113167. */
  113168. get isUnIndexed(): boolean;
  113169. set isUnIndexed(value: boolean);
  113170. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  113171. get worldMatrixInstancedBuffer(): Float32Array;
  113172. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  113173. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  113174. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  113175. /**
  113176. * @constructor
  113177. * @param name The value used by scene.getMeshByName() to do a lookup.
  113178. * @param scene The scene to add this mesh to.
  113179. * @param parent The parent of this mesh, if it has one
  113180. * @param source An optional Mesh from which geometry is shared, cloned.
  113181. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  113182. * When false, achieved by calling a clone(), also passing False.
  113183. * This will make creation of children, recursive.
  113184. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  113185. */
  113186. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  113187. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  113188. doNotInstantiate: boolean;
  113189. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  113190. /**
  113191. * Gets the class name
  113192. * @returns the string "Mesh".
  113193. */
  113194. getClassName(): string;
  113195. /** @hidden */
  113196. get _isMesh(): boolean;
  113197. /**
  113198. * Returns a description of this mesh
  113199. * @param fullDetails define if full details about this mesh must be used
  113200. * @returns a descriptive string representing this mesh
  113201. */
  113202. toString(fullDetails?: boolean): string;
  113203. /** @hidden */
  113204. _unBindEffect(): void;
  113205. /**
  113206. * Gets a boolean indicating if this mesh has LOD
  113207. */
  113208. get hasLODLevels(): boolean;
  113209. /**
  113210. * Gets the list of MeshLODLevel associated with the current mesh
  113211. * @returns an array of MeshLODLevel
  113212. */
  113213. getLODLevels(): MeshLODLevel[];
  113214. private _sortLODLevels;
  113215. /**
  113216. * Add a mesh as LOD level triggered at the given distance.
  113217. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113218. * @param distance The distance from the center of the object to show this level
  113219. * @param mesh The mesh to be added as LOD level (can be null)
  113220. * @return This mesh (for chaining)
  113221. */
  113222. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  113223. /**
  113224. * Returns the LOD level mesh at the passed distance or null if not found.
  113225. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113226. * @param distance The distance from the center of the object to show this level
  113227. * @returns a Mesh or `null`
  113228. */
  113229. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  113230. /**
  113231. * Remove a mesh from the LOD array
  113232. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113233. * @param mesh defines the mesh to be removed
  113234. * @return This mesh (for chaining)
  113235. */
  113236. removeLODLevel(mesh: Mesh): Mesh;
  113237. /**
  113238. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  113239. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113240. * @param camera defines the camera to use to compute distance
  113241. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  113242. * @return This mesh (for chaining)
  113243. */
  113244. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  113245. /**
  113246. * Gets the mesh internal Geometry object
  113247. */
  113248. get geometry(): Nullable<Geometry>;
  113249. /**
  113250. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  113251. * @returns the total number of vertices
  113252. */
  113253. getTotalVertices(): number;
  113254. /**
  113255. * Returns the content of an associated vertex buffer
  113256. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113257. * - VertexBuffer.PositionKind
  113258. * - VertexBuffer.UVKind
  113259. * - VertexBuffer.UV2Kind
  113260. * - VertexBuffer.UV3Kind
  113261. * - VertexBuffer.UV4Kind
  113262. * - VertexBuffer.UV5Kind
  113263. * - VertexBuffer.UV6Kind
  113264. * - VertexBuffer.ColorKind
  113265. * - VertexBuffer.MatricesIndicesKind
  113266. * - VertexBuffer.MatricesIndicesExtraKind
  113267. * - VertexBuffer.MatricesWeightsKind
  113268. * - VertexBuffer.MatricesWeightsExtraKind
  113269. * @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
  113270. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  113271. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  113272. */
  113273. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  113274. /**
  113275. * Returns the mesh VertexBuffer object from the requested `kind`
  113276. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113277. * - VertexBuffer.PositionKind
  113278. * - VertexBuffer.NormalKind
  113279. * - VertexBuffer.UVKind
  113280. * - VertexBuffer.UV2Kind
  113281. * - VertexBuffer.UV3Kind
  113282. * - VertexBuffer.UV4Kind
  113283. * - VertexBuffer.UV5Kind
  113284. * - VertexBuffer.UV6Kind
  113285. * - VertexBuffer.ColorKind
  113286. * - VertexBuffer.MatricesIndicesKind
  113287. * - VertexBuffer.MatricesIndicesExtraKind
  113288. * - VertexBuffer.MatricesWeightsKind
  113289. * - VertexBuffer.MatricesWeightsExtraKind
  113290. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  113291. */
  113292. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  113293. /**
  113294. * Tests if a specific vertex buffer is associated with this mesh
  113295. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113296. * - VertexBuffer.PositionKind
  113297. * - VertexBuffer.NormalKind
  113298. * - VertexBuffer.UVKind
  113299. * - VertexBuffer.UV2Kind
  113300. * - VertexBuffer.UV3Kind
  113301. * - VertexBuffer.UV4Kind
  113302. * - VertexBuffer.UV5Kind
  113303. * - VertexBuffer.UV6Kind
  113304. * - VertexBuffer.ColorKind
  113305. * - VertexBuffer.MatricesIndicesKind
  113306. * - VertexBuffer.MatricesIndicesExtraKind
  113307. * - VertexBuffer.MatricesWeightsKind
  113308. * - VertexBuffer.MatricesWeightsExtraKind
  113309. * @returns a boolean
  113310. */
  113311. isVerticesDataPresent(kind: string): boolean;
  113312. /**
  113313. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  113314. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113315. * - VertexBuffer.PositionKind
  113316. * - VertexBuffer.UVKind
  113317. * - VertexBuffer.UV2Kind
  113318. * - VertexBuffer.UV3Kind
  113319. * - VertexBuffer.UV4Kind
  113320. * - VertexBuffer.UV5Kind
  113321. * - VertexBuffer.UV6Kind
  113322. * - VertexBuffer.ColorKind
  113323. * - VertexBuffer.MatricesIndicesKind
  113324. * - VertexBuffer.MatricesIndicesExtraKind
  113325. * - VertexBuffer.MatricesWeightsKind
  113326. * - VertexBuffer.MatricesWeightsExtraKind
  113327. * @returns a boolean
  113328. */
  113329. isVertexBufferUpdatable(kind: string): boolean;
  113330. /**
  113331. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  113332. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113333. * - VertexBuffer.PositionKind
  113334. * - VertexBuffer.NormalKind
  113335. * - VertexBuffer.UVKind
  113336. * - VertexBuffer.UV2Kind
  113337. * - VertexBuffer.UV3Kind
  113338. * - VertexBuffer.UV4Kind
  113339. * - VertexBuffer.UV5Kind
  113340. * - VertexBuffer.UV6Kind
  113341. * - VertexBuffer.ColorKind
  113342. * - VertexBuffer.MatricesIndicesKind
  113343. * - VertexBuffer.MatricesIndicesExtraKind
  113344. * - VertexBuffer.MatricesWeightsKind
  113345. * - VertexBuffer.MatricesWeightsExtraKind
  113346. * @returns an array of strings
  113347. */
  113348. getVerticesDataKinds(): string[];
  113349. /**
  113350. * Returns a positive integer : the total number of indices in this mesh geometry.
  113351. * @returns the numner of indices or zero if the mesh has no geometry.
  113352. */
  113353. getTotalIndices(): number;
  113354. /**
  113355. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  113356. * @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.
  113357. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  113358. * @returns the indices array or an empty array if the mesh has no geometry
  113359. */
  113360. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  113361. get isBlocked(): boolean;
  113362. /**
  113363. * Determine if the current mesh is ready to be rendered
  113364. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113365. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  113366. * @returns true if all associated assets are ready (material, textures, shaders)
  113367. */
  113368. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  113369. /**
  113370. * 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.
  113371. */
  113372. get areNormalsFrozen(): boolean;
  113373. /**
  113374. * 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.
  113375. * @returns the current mesh
  113376. */
  113377. freezeNormals(): Mesh;
  113378. /**
  113379. * 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
  113380. * @returns the current mesh
  113381. */
  113382. unfreezeNormals(): Mesh;
  113383. /**
  113384. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  113385. */
  113386. set overridenInstanceCount(count: number);
  113387. /** @hidden */
  113388. _preActivate(): Mesh;
  113389. /** @hidden */
  113390. _preActivateForIntermediateRendering(renderId: number): Mesh;
  113391. /** @hidden */
  113392. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  113393. protected _afterComputeWorldMatrix(): void;
  113394. /** @hidden */
  113395. _postActivate(): void;
  113396. /**
  113397. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  113398. * This means the mesh underlying bounding box and sphere are recomputed.
  113399. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  113400. * @returns the current mesh
  113401. */
  113402. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  113403. /** @hidden */
  113404. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  113405. /**
  113406. * This function will subdivide the mesh into multiple submeshes
  113407. * @param count defines the expected number of submeshes
  113408. */
  113409. subdivide(count: number): void;
  113410. /**
  113411. * Copy a FloatArray into a specific associated vertex buffer
  113412. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113413. * - VertexBuffer.PositionKind
  113414. * - VertexBuffer.UVKind
  113415. * - VertexBuffer.UV2Kind
  113416. * - VertexBuffer.UV3Kind
  113417. * - VertexBuffer.UV4Kind
  113418. * - VertexBuffer.UV5Kind
  113419. * - VertexBuffer.UV6Kind
  113420. * - VertexBuffer.ColorKind
  113421. * - VertexBuffer.MatricesIndicesKind
  113422. * - VertexBuffer.MatricesIndicesExtraKind
  113423. * - VertexBuffer.MatricesWeightsKind
  113424. * - VertexBuffer.MatricesWeightsExtraKind
  113425. * @param data defines the data source
  113426. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113427. * @param stride defines the data stride size (can be null)
  113428. * @returns the current mesh
  113429. */
  113430. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  113431. /**
  113432. * Delete a vertex buffer associated with this mesh
  113433. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  113434. * - VertexBuffer.PositionKind
  113435. * - VertexBuffer.UVKind
  113436. * - VertexBuffer.UV2Kind
  113437. * - VertexBuffer.UV3Kind
  113438. * - VertexBuffer.UV4Kind
  113439. * - VertexBuffer.UV5Kind
  113440. * - VertexBuffer.UV6Kind
  113441. * - VertexBuffer.ColorKind
  113442. * - VertexBuffer.MatricesIndicesKind
  113443. * - VertexBuffer.MatricesIndicesExtraKind
  113444. * - VertexBuffer.MatricesWeightsKind
  113445. * - VertexBuffer.MatricesWeightsExtraKind
  113446. */
  113447. removeVerticesData(kind: string): void;
  113448. /**
  113449. * Flags an associated vertex buffer as updatable
  113450. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  113451. * - VertexBuffer.PositionKind
  113452. * - VertexBuffer.UVKind
  113453. * - VertexBuffer.UV2Kind
  113454. * - VertexBuffer.UV3Kind
  113455. * - VertexBuffer.UV4Kind
  113456. * - VertexBuffer.UV5Kind
  113457. * - VertexBuffer.UV6Kind
  113458. * - VertexBuffer.ColorKind
  113459. * - VertexBuffer.MatricesIndicesKind
  113460. * - VertexBuffer.MatricesIndicesExtraKind
  113461. * - VertexBuffer.MatricesWeightsKind
  113462. * - VertexBuffer.MatricesWeightsExtraKind
  113463. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113464. */
  113465. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  113466. /**
  113467. * Sets the mesh global Vertex Buffer
  113468. * @param buffer defines the buffer to use
  113469. * @returns the current mesh
  113470. */
  113471. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  113472. /**
  113473. * Update a specific associated vertex buffer
  113474. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113475. * - VertexBuffer.PositionKind
  113476. * - VertexBuffer.UVKind
  113477. * - VertexBuffer.UV2Kind
  113478. * - VertexBuffer.UV3Kind
  113479. * - VertexBuffer.UV4Kind
  113480. * - VertexBuffer.UV5Kind
  113481. * - VertexBuffer.UV6Kind
  113482. * - VertexBuffer.ColorKind
  113483. * - VertexBuffer.MatricesIndicesKind
  113484. * - VertexBuffer.MatricesIndicesExtraKind
  113485. * - VertexBuffer.MatricesWeightsKind
  113486. * - VertexBuffer.MatricesWeightsExtraKind
  113487. * @param data defines the data source
  113488. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  113489. * @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)
  113490. * @returns the current mesh
  113491. */
  113492. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  113493. /**
  113494. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  113495. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  113496. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  113497. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  113498. * @returns the current mesh
  113499. */
  113500. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  113501. /**
  113502. * Creates a un-shared specific occurence of the geometry for the mesh.
  113503. * @returns the current mesh
  113504. */
  113505. makeGeometryUnique(): Mesh;
  113506. /**
  113507. * Set the index buffer of this mesh
  113508. * @param indices defines the source data
  113509. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  113510. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  113511. * @returns the current mesh
  113512. */
  113513. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  113514. /**
  113515. * Update the current index buffer
  113516. * @param indices defines the source data
  113517. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113518. * @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)
  113519. * @returns the current mesh
  113520. */
  113521. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113522. /**
  113523. * Invert the geometry to move from a right handed system to a left handed one.
  113524. * @returns the current mesh
  113525. */
  113526. toLeftHanded(): Mesh;
  113527. /** @hidden */
  113528. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  113529. /** @hidden */
  113530. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  113531. /**
  113532. * Registers for this mesh a javascript function called just before the rendering process
  113533. * @param func defines the function to call before rendering this mesh
  113534. * @returns the current mesh
  113535. */
  113536. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113537. /**
  113538. * Disposes a previously registered javascript function called before the rendering
  113539. * @param func defines the function to remove
  113540. * @returns the current mesh
  113541. */
  113542. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113543. /**
  113544. * Registers for this mesh a javascript function called just after the rendering is complete
  113545. * @param func defines the function to call after rendering this mesh
  113546. * @returns the current mesh
  113547. */
  113548. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113549. /**
  113550. * Disposes a previously registered javascript function called after the rendering.
  113551. * @param func defines the function to remove
  113552. * @returns the current mesh
  113553. */
  113554. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113555. /** @hidden */
  113556. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  113557. /** @hidden */
  113558. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  113559. /** @hidden */
  113560. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  113561. /** @hidden */
  113562. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  113563. /** @hidden */
  113564. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  113565. /** @hidden */
  113566. _rebuild(): void;
  113567. /** @hidden */
  113568. _freeze(): void;
  113569. /** @hidden */
  113570. _unFreeze(): void;
  113571. /**
  113572. * 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
  113573. * @param subMesh defines the subMesh to render
  113574. * @param enableAlphaMode defines if alpha mode can be changed
  113575. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  113576. * @returns the current mesh
  113577. */
  113578. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  113579. private _onBeforeDraw;
  113580. /**
  113581. * Renormalize the mesh and patch it up if there are no weights
  113582. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  113583. * However in the case of zero weights then we set just a single influence to 1.
  113584. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  113585. */
  113586. cleanMatrixWeights(): void;
  113587. private normalizeSkinFourWeights;
  113588. private normalizeSkinWeightsAndExtra;
  113589. /**
  113590. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  113591. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  113592. * the user know there was an issue with importing the mesh
  113593. * @returns a validation object with skinned, valid and report string
  113594. */
  113595. validateSkinning(): {
  113596. skinned: boolean;
  113597. valid: boolean;
  113598. report: string;
  113599. };
  113600. /** @hidden */
  113601. _checkDelayState(): Mesh;
  113602. private _queueLoad;
  113603. /**
  113604. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  113605. * A mesh is in the frustum if its bounding box intersects the frustum
  113606. * @param frustumPlanes defines the frustum to test
  113607. * @returns true if the mesh is in the frustum planes
  113608. */
  113609. isInFrustum(frustumPlanes: Plane[]): boolean;
  113610. /**
  113611. * Sets the mesh material by the material or multiMaterial `id` property
  113612. * @param id is a string identifying the material or the multiMaterial
  113613. * @returns the current mesh
  113614. */
  113615. setMaterialByID(id: string): Mesh;
  113616. /**
  113617. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  113618. * @returns an array of IAnimatable
  113619. */
  113620. getAnimatables(): IAnimatable[];
  113621. /**
  113622. * Modifies the mesh geometry according to the passed transformation matrix.
  113623. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  113624. * The mesh normals are modified using the same transformation.
  113625. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113626. * @param transform defines the transform matrix to use
  113627. * @see https://doc.babylonjs.com/resources/baking_transformations
  113628. * @returns the current mesh
  113629. */
  113630. bakeTransformIntoVertices(transform: Matrix): Mesh;
  113631. /**
  113632. * Modifies the mesh geometry according to its own current World Matrix.
  113633. * The mesh World Matrix is then reset.
  113634. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  113635. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113636. * @see https://doc.babylonjs.com/resources/baking_transformations
  113637. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  113638. * @returns the current mesh
  113639. */
  113640. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  113641. /** @hidden */
  113642. get _positions(): Nullable<Vector3[]>;
  113643. /** @hidden */
  113644. _resetPointsArrayCache(): Mesh;
  113645. /** @hidden */
  113646. _generatePointsArray(): boolean;
  113647. /**
  113648. * Returns a new Mesh object generated from the current mesh properties.
  113649. * This method must not get confused with createInstance()
  113650. * @param name is a string, the name given to the new mesh
  113651. * @param newParent can be any Node object (default `null`)
  113652. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  113653. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  113654. * @returns a new mesh
  113655. */
  113656. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  113657. /**
  113658. * Releases resources associated with this mesh.
  113659. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113660. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113661. */
  113662. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113663. /** @hidden */
  113664. _disposeInstanceSpecificData(): void;
  113665. /** @hidden */
  113666. _disposeThinInstanceSpecificData(): void;
  113667. /**
  113668. * Modifies the mesh geometry according to a displacement map.
  113669. * 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.
  113670. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113671. * @param url is a string, the URL from the image file is to be downloaded.
  113672. * @param minHeight is the lower limit of the displacement.
  113673. * @param maxHeight is the upper limit of the displacement.
  113674. * @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.
  113675. * @param uvOffset is an optional vector2 used to offset UV.
  113676. * @param uvScale is an optional vector2 used to scale UV.
  113677. * @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.
  113678. * @returns the Mesh.
  113679. */
  113680. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113681. /**
  113682. * Modifies the mesh geometry according to a displacementMap buffer.
  113683. * 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.
  113684. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113685. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  113686. * @param heightMapWidth is the width of the buffer image.
  113687. * @param heightMapHeight is the height of the buffer image.
  113688. * @param minHeight is the lower limit of the displacement.
  113689. * @param maxHeight is the upper limit of the displacement.
  113690. * @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.
  113691. * @param uvOffset is an optional vector2 used to offset UV.
  113692. * @param uvScale is an optional vector2 used to scale UV.
  113693. * @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.
  113694. * @returns the Mesh.
  113695. */
  113696. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113697. /**
  113698. * Modify the mesh to get a flat shading rendering.
  113699. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  113700. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  113701. * @returns current mesh
  113702. */
  113703. convertToFlatShadedMesh(): Mesh;
  113704. /**
  113705. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  113706. * In other words, more vertices, no more indices and a single bigger VBO.
  113707. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  113708. * @returns current mesh
  113709. */
  113710. convertToUnIndexedMesh(): Mesh;
  113711. /**
  113712. * Inverses facet orientations.
  113713. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113714. * @param flipNormals will also inverts the normals
  113715. * @returns current mesh
  113716. */
  113717. flipFaces(flipNormals?: boolean): Mesh;
  113718. /**
  113719. * Increase the number of facets and hence vertices in a mesh
  113720. * Vertex normals are interpolated from existing vertex normals
  113721. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113722. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  113723. */
  113724. increaseVertices(numberPerEdge: number): void;
  113725. /**
  113726. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  113727. * This will undo any application of covertToFlatShadedMesh
  113728. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113729. */
  113730. forceSharedVertices(): void;
  113731. /** @hidden */
  113732. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  113733. /** @hidden */
  113734. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  113735. /**
  113736. * Creates a new InstancedMesh object from the mesh model.
  113737. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113738. * @param name defines the name of the new instance
  113739. * @returns a new InstancedMesh
  113740. */
  113741. createInstance(name: string): InstancedMesh;
  113742. /**
  113743. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  113744. * After this call, all the mesh instances have the same submeshes than the current mesh.
  113745. * @returns the current mesh
  113746. */
  113747. synchronizeInstances(): Mesh;
  113748. /**
  113749. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  113750. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  113751. * This should be used together with the simplification to avoid disappearing triangles.
  113752. * @param successCallback an optional success callback to be called after the optimization finished.
  113753. * @returns the current mesh
  113754. */
  113755. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  113756. /**
  113757. * Serialize current mesh
  113758. * @param serializationObject defines the object which will receive the serialization data
  113759. */
  113760. serialize(serializationObject: any): void;
  113761. /** @hidden */
  113762. _syncGeometryWithMorphTargetManager(): void;
  113763. /** @hidden */
  113764. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  113765. /**
  113766. * Returns a new Mesh object parsed from the source provided.
  113767. * @param parsedMesh is the source
  113768. * @param scene defines the hosting scene
  113769. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  113770. * @returns a new Mesh
  113771. */
  113772. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  113773. /**
  113774. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  113775. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113776. * @param name defines the name of the mesh to create
  113777. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  113778. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  113779. * @param closePath creates a seam between the first and the last points of each path of the path array
  113780. * @param offset is taken in account only if the `pathArray` is containing a single path
  113781. * @param scene defines the hosting scene
  113782. * @param updatable defines if the mesh must be flagged as updatable
  113783. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113784. * @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)
  113785. * @returns a new Mesh
  113786. */
  113787. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  113788. /**
  113789. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  113790. * @param name defines the name of the mesh to create
  113791. * @param radius sets the radius size (float) of the polygon (default 0.5)
  113792. * @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
  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 CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  113799. /**
  113800. * Creates a box 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 size sets the size (float) of each box side (default 1)
  113803. * @param scene defines the hosting scene
  113804. * @param updatable defines if the mesh must be flagged as updatable
  113805. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113806. * @returns a new Mesh
  113807. */
  113808. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  113809. /**
  113810. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  113811. * @param name defines the name of the mesh to create
  113812. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  113813. * @param diameter sets the diameter size (float) of the sphere (default 1)
  113814. * @param scene defines the hosting scene
  113815. * @param updatable defines if the mesh must be flagged as updatable
  113816. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113817. * @returns a new Mesh
  113818. */
  113819. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  113820. /**
  113821. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  113822. * @param name defines the name of the mesh to create
  113823. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  113824. * @param diameter sets the diameter size (float) of the sphere (default 1)
  113825. * @param scene defines the hosting scene
  113826. * @returns a new Mesh
  113827. */
  113828. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  113829. /**
  113830. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  113831. * @param name defines the name of the mesh to create
  113832. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  113833. * @param diameterTop set the top cap diameter (floats, default 1)
  113834. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  113835. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  113836. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  113837. * @param scene defines the hosting scene
  113838. * @param updatable defines if the mesh must be flagged as updatable
  113839. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113840. * @returns a new Mesh
  113841. */
  113842. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  113843. /**
  113844. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  113845. * @param name defines the name of the mesh to create
  113846. * @param diameter sets the diameter size (float) of the torus (default 1)
  113847. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  113848. * @param tessellation sets the number of torus sides (postive integer, default 16)
  113849. * @param scene defines the hosting scene
  113850. * @param updatable defines if the mesh must be flagged as updatable
  113851. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113852. * @returns a new Mesh
  113853. */
  113854. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  113855. /**
  113856. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  113857. * @param name defines the name of the mesh to create
  113858. * @param radius sets the global radius size (float) of the torus knot (default 2)
  113859. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  113860. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  113861. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  113862. * @param p the number of windings on X axis (positive integers, default 2)
  113863. * @param q the number of windings on Y axis (positive integers, default 3)
  113864. * @param scene defines the hosting scene
  113865. * @param updatable defines if the mesh must be flagged as updatable
  113866. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113867. * @returns a new Mesh
  113868. */
  113869. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  113870. /**
  113871. * Creates a 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 scene defines the hosting scene
  113875. * @param updatable defines if the mesh must be flagged as updatable
  113876. * @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).
  113877. * @returns a new Mesh
  113878. */
  113879. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  113880. /**
  113881. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  113882. * @param name defines the name of the mesh to create
  113883. * @param points is an array successive Vector3
  113884. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  113885. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  113886. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  113887. * @param scene defines the hosting scene
  113888. * @param updatable defines if the mesh must be flagged as updatable
  113889. * @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)
  113890. * @returns a new Mesh
  113891. */
  113892. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  113893. /**
  113894. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  113895. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  113896. * 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.
  113897. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  113898. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113899. * Remember you can only change the shape positions, not their number when updating a polygon.
  113900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  113901. * @param name defines the name of the mesh to create
  113902. * @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
  113903. * @param scene defines the hosting scene
  113904. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  113905. * @param updatable defines if the mesh must be flagged as updatable
  113906. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113907. * @param earcutInjection can be used to inject your own earcut reference
  113908. * @returns a new Mesh
  113909. */
  113910. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  113911. /**
  113912. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  113913. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  113914. * @param name defines the name of the mesh to create
  113915. * @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
  113916. * @param depth defines the height of extrusion
  113917. * @param scene defines the hosting scene
  113918. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  113919. * @param updatable defines if the mesh must be flagged as updatable
  113920. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113921. * @param earcutInjection can be used to inject your own earcut reference
  113922. * @returns a new Mesh
  113923. */
  113924. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  113925. /**
  113926. * Creates an extruded shape mesh.
  113927. * 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
  113928. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113929. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113930. * @param name defines the name of the mesh to create
  113931. * @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
  113932. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  113933. * @param scale is the value to scale the shape
  113934. * @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
  113935. * @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
  113936. * @param scene defines the hosting scene
  113937. * @param updatable defines if the mesh must be flagged as updatable
  113938. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113939. * @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)
  113940. * @returns a new Mesh
  113941. */
  113942. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  113943. /**
  113944. * Creates an custom extruded shape mesh.
  113945. * The custom extrusion is a parametric shape.
  113946. * It has no predefined shape. Its final shape will depend on the input parameters.
  113947. * Please consider using the same method from the MeshBuilder class instead
  113948. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113949. * @param name defines the name of the mesh to create
  113950. * @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
  113951. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  113952. * @param scaleFunction is a custom Javascript function called on each path point
  113953. * @param rotationFunction is a custom Javascript function called on each path point
  113954. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  113955. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  113956. * @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
  113957. * @param scene defines the hosting scene
  113958. * @param updatable defines if the mesh must be flagged as updatable
  113959. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113960. * @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)
  113961. * @returns a new Mesh
  113962. */
  113963. 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;
  113964. /**
  113965. * Creates lathe mesh.
  113966. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  113967. * Please consider using the same method from the MeshBuilder class instead
  113968. * @param name defines the name of the mesh to create
  113969. * @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
  113970. * @param radius is the radius value of the lathe
  113971. * @param tessellation is the side number of the lathe.
  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 CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  113978. /**
  113979. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  113980. * @param name defines the name of the mesh to create
  113981. * @param size sets the size (float) of both sides of the plane at once (default 1)
  113982. * @param scene defines the hosting scene
  113983. * @param updatable defines if the mesh must be flagged as updatable
  113984. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113985. * @returns a new Mesh
  113986. */
  113987. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  113988. /**
  113989. * Creates a ground mesh.
  113990. * Please consider using the same method from the MeshBuilder class instead
  113991. * @param name defines the name of the mesh to create
  113992. * @param width set the width of the ground
  113993. * @param height set the height of the ground
  113994. * @param subdivisions sets the number of subdivisions per side
  113995. * @param scene defines the hosting scene
  113996. * @param updatable defines if the mesh must be flagged as updatable
  113997. * @returns a new Mesh
  113998. */
  113999. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114000. /**
  114001. * Creates a tiled ground mesh.
  114002. * Please consider using the same method from the MeshBuilder class instead
  114003. * @param name defines the name of the mesh to create
  114004. * @param xmin set the ground minimum X coordinate
  114005. * @param zmin set the ground minimum Y coordinate
  114006. * @param xmax set the ground maximum X coordinate
  114007. * @param zmax set the ground maximum Z coordinate
  114008. * @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
  114009. * @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
  114010. * @param scene defines the hosting scene
  114011. * @param updatable defines if the mesh must be flagged as updatable
  114012. * @returns a new Mesh
  114013. */
  114014. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114015. w: number;
  114016. h: number;
  114017. }, precision: {
  114018. w: number;
  114019. h: number;
  114020. }, scene: Scene, updatable?: boolean): Mesh;
  114021. /**
  114022. * Creates a ground mesh from a height map.
  114023. * Please consider using the same method from the MeshBuilder class instead
  114024. * @see https://doc.babylonjs.com/babylon101/height_map
  114025. * @param name defines the name of the mesh to create
  114026. * @param url sets the URL of the height map image resource
  114027. * @param width set the ground width size
  114028. * @param height set the ground height size
  114029. * @param subdivisions sets the number of subdivision per side
  114030. * @param minHeight is the minimum altitude on the ground
  114031. * @param maxHeight is the maximum altitude on the ground
  114032. * @param scene defines the hosting scene
  114033. * @param updatable defines if the mesh must be flagged as updatable
  114034. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114035. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114036. * @returns a new Mesh
  114037. */
  114038. 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;
  114039. /**
  114040. * Creates a tube mesh.
  114041. * The tube is a parametric shape.
  114042. * It has no predefined shape. Its final shape will depend on the input parameters.
  114043. * Please consider using the same method from the MeshBuilder class instead
  114044. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114045. * @param name defines the name of the mesh to create
  114046. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114047. * @param radius sets the tube radius size
  114048. * @param tessellation is the number of sides on the tubular surface
  114049. * @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
  114050. * @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
  114051. * @param scene defines the hosting scene
  114052. * @param updatable defines if the mesh must be flagged as updatable
  114053. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114054. * @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)
  114055. * @returns a new Mesh
  114056. */
  114057. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  114058. (i: number, distance: number): number;
  114059. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114060. /**
  114061. * Creates a polyhedron mesh.
  114062. * Please consider using the same method from the MeshBuilder class instead.
  114063. * * 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
  114064. * * The parameter `size` (positive float, default 1) sets the polygon size
  114065. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114066. * * 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`
  114067. * * 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
  114068. * * 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)`)
  114069. * * 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
  114070. * * 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
  114071. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114074. * @param name defines the name of the mesh to create
  114075. * @param options defines the options used to create the mesh
  114076. * @param scene defines the hosting scene
  114077. * @returns a new Mesh
  114078. */
  114079. static CreatePolyhedron(name: string, options: {
  114080. type?: number;
  114081. size?: number;
  114082. sizeX?: number;
  114083. sizeY?: number;
  114084. sizeZ?: number;
  114085. custom?: any;
  114086. faceUV?: Vector4[];
  114087. faceColors?: Color4[];
  114088. updatable?: boolean;
  114089. sideOrientation?: number;
  114090. }, scene: Scene): Mesh;
  114091. /**
  114092. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114093. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114094. * * 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`)
  114095. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114096. * * 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
  114097. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114100. * @param name defines the name of the mesh
  114101. * @param options defines the options used to create the mesh
  114102. * @param scene defines the hosting scene
  114103. * @returns a new Mesh
  114104. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114105. */
  114106. static CreateIcoSphere(name: string, options: {
  114107. radius?: number;
  114108. flat?: boolean;
  114109. subdivisions?: number;
  114110. sideOrientation?: number;
  114111. updatable?: boolean;
  114112. }, scene: Scene): Mesh;
  114113. /**
  114114. * Creates a decal mesh.
  114115. * Please consider using the same method from the MeshBuilder class instead.
  114116. * A decal is a mesh usually applied as a model onto the surface of another mesh
  114117. * @param name defines the name of the mesh
  114118. * @param sourceMesh defines the mesh receiving the decal
  114119. * @param position sets the position of the decal in world coordinates
  114120. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  114121. * @param size sets the decal scaling
  114122. * @param angle sets the angle to rotate the decal
  114123. * @returns a new Mesh
  114124. */
  114125. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  114126. /** Creates a Capsule Mesh
  114127. * @param name defines the name of the mesh.
  114128. * @param options the constructors options used to shape the mesh.
  114129. * @param scene defines the scene the mesh is scoped to.
  114130. * @returns the capsule mesh
  114131. * @see https://doc.babylonjs.com/how_to/capsule_shape
  114132. */
  114133. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  114134. /**
  114135. * Prepare internal position array for software CPU skinning
  114136. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  114137. */
  114138. setPositionsForCPUSkinning(): Float32Array;
  114139. /**
  114140. * Prepare internal normal array for software CPU skinning
  114141. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  114142. */
  114143. setNormalsForCPUSkinning(): Float32Array;
  114144. /**
  114145. * Updates the vertex buffer by applying transformation from the bones
  114146. * @param skeleton defines the skeleton to apply to current mesh
  114147. * @returns the current mesh
  114148. */
  114149. applySkeleton(skeleton: Skeleton): Mesh;
  114150. /**
  114151. * 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
  114152. * @param meshes defines the list of meshes to scan
  114153. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  114154. */
  114155. static MinMax(meshes: AbstractMesh[]): {
  114156. min: Vector3;
  114157. max: Vector3;
  114158. };
  114159. /**
  114160. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  114161. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  114162. * @returns a vector3
  114163. */
  114164. static Center(meshesOrMinMaxVector: {
  114165. min: Vector3;
  114166. max: Vector3;
  114167. } | AbstractMesh[]): Vector3;
  114168. /**
  114169. * Merge the array of meshes into a single mesh for performance reasons.
  114170. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  114171. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  114172. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  114173. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  114174. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  114175. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  114176. * @returns a new mesh
  114177. */
  114178. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  114179. /** @hidden */
  114180. addInstance(instance: InstancedMesh): void;
  114181. /** @hidden */
  114182. removeInstance(instance: InstancedMesh): void;
  114183. }
  114184. }
  114185. declare module BABYLON {
  114186. /**
  114187. * This is the base class of all the camera used in the application.
  114188. * @see https://doc.babylonjs.com/features/cameras
  114189. */
  114190. export class Camera extends Node {
  114191. /** @hidden */
  114192. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  114193. /**
  114194. * This is the default projection mode used by the cameras.
  114195. * It helps recreating a feeling of perspective and better appreciate depth.
  114196. * This is the best way to simulate real life cameras.
  114197. */
  114198. static readonly PERSPECTIVE_CAMERA: number;
  114199. /**
  114200. * This helps creating camera with an orthographic mode.
  114201. * 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.
  114202. */
  114203. static readonly ORTHOGRAPHIC_CAMERA: number;
  114204. /**
  114205. * This is the default FOV mode for perspective cameras.
  114206. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  114207. */
  114208. static readonly FOVMODE_VERTICAL_FIXED: number;
  114209. /**
  114210. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  114211. */
  114212. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  114213. /**
  114214. * This specifies ther is no need for a camera rig.
  114215. * Basically only one eye is rendered corresponding to the camera.
  114216. */
  114217. static readonly RIG_MODE_NONE: number;
  114218. /**
  114219. * Simulates a camera Rig with one blue eye and one red eye.
  114220. * This can be use with 3d blue and red glasses.
  114221. */
  114222. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  114223. /**
  114224. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  114225. */
  114226. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  114227. /**
  114228. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  114229. */
  114230. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  114231. /**
  114232. * Defines that both eyes of the camera will be rendered over under each other.
  114233. */
  114234. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  114235. /**
  114236. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  114237. */
  114238. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  114239. /**
  114240. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  114241. */
  114242. static readonly RIG_MODE_VR: number;
  114243. /**
  114244. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  114245. */
  114246. static readonly RIG_MODE_WEBVR: number;
  114247. /**
  114248. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  114249. */
  114250. static readonly RIG_MODE_CUSTOM: number;
  114251. /**
  114252. * Defines if by default attaching controls should prevent the default javascript event to continue.
  114253. */
  114254. static ForceAttachControlToAlwaysPreventDefault: boolean;
  114255. /**
  114256. * Define the input manager associated with the camera.
  114257. */
  114258. inputs: CameraInputsManager<Camera>;
  114259. /** @hidden */
  114260. _position: Vector3;
  114261. /**
  114262. * Define the current local position of the camera in the scene
  114263. */
  114264. get position(): Vector3;
  114265. set position(newPosition: Vector3);
  114266. protected _upVector: Vector3;
  114267. /**
  114268. * The vector the camera should consider as up.
  114269. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  114270. */
  114271. set upVector(vec: Vector3);
  114272. get upVector(): Vector3;
  114273. /**
  114274. * Define the current limit on the left side for an orthographic camera
  114275. * In scene unit
  114276. */
  114277. orthoLeft: Nullable<number>;
  114278. /**
  114279. * Define the current limit on the right side for an orthographic camera
  114280. * In scene unit
  114281. */
  114282. orthoRight: Nullable<number>;
  114283. /**
  114284. * Define the current limit on the bottom side for an orthographic camera
  114285. * In scene unit
  114286. */
  114287. orthoBottom: Nullable<number>;
  114288. /**
  114289. * Define the current limit on the top side for an orthographic camera
  114290. * In scene unit
  114291. */
  114292. orthoTop: Nullable<number>;
  114293. /**
  114294. * Field Of View is set in Radians. (default is 0.8)
  114295. */
  114296. fov: number;
  114297. /**
  114298. * Define the minimum distance the camera can see from.
  114299. * This is important to note that the depth buffer are not infinite and the closer it starts
  114300. * the more your scene might encounter depth fighting issue.
  114301. */
  114302. minZ: number;
  114303. /**
  114304. * Define the maximum distance the camera can see to.
  114305. * This is important to note that the depth buffer are not infinite and the further it end
  114306. * the more your scene might encounter depth fighting issue.
  114307. */
  114308. maxZ: number;
  114309. /**
  114310. * Define the default inertia of the camera.
  114311. * This helps giving a smooth feeling to the camera movement.
  114312. */
  114313. inertia: number;
  114314. /**
  114315. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  114316. */
  114317. mode: number;
  114318. /**
  114319. * Define whether the camera is intermediate.
  114320. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  114321. */
  114322. isIntermediate: boolean;
  114323. /**
  114324. * Define the viewport of the camera.
  114325. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  114326. */
  114327. viewport: Viewport;
  114328. /**
  114329. * Restricts the camera to viewing objects with the same layerMask.
  114330. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  114331. */
  114332. layerMask: number;
  114333. /**
  114334. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  114335. */
  114336. fovMode: number;
  114337. /**
  114338. * Rig mode of the camera.
  114339. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  114340. * This is normally controlled byt the camera themselves as internal use.
  114341. */
  114342. cameraRigMode: number;
  114343. /**
  114344. * Defines the distance between both "eyes" in case of a RIG
  114345. */
  114346. interaxialDistance: number;
  114347. /**
  114348. * Defines if stereoscopic rendering is done side by side or over under.
  114349. */
  114350. isStereoscopicSideBySide: boolean;
  114351. /**
  114352. * 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
  114353. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  114354. * else in the scene. (Eg. security camera)
  114355. *
  114356. * 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)
  114357. */
  114358. customRenderTargets: RenderTargetTexture[];
  114359. /**
  114360. * When set, the camera will render to this render target instead of the default canvas
  114361. *
  114362. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  114363. */
  114364. outputRenderTarget: Nullable<RenderTargetTexture>;
  114365. /**
  114366. * Observable triggered when the camera view matrix has changed.
  114367. */
  114368. onViewMatrixChangedObservable: Observable<Camera>;
  114369. /**
  114370. * Observable triggered when the camera Projection matrix has changed.
  114371. */
  114372. onProjectionMatrixChangedObservable: Observable<Camera>;
  114373. /**
  114374. * Observable triggered when the inputs have been processed.
  114375. */
  114376. onAfterCheckInputsObservable: Observable<Camera>;
  114377. /**
  114378. * Observable triggered when reset has been called and applied to the camera.
  114379. */
  114380. onRestoreStateObservable: Observable<Camera>;
  114381. /**
  114382. * Is this camera a part of a rig system?
  114383. */
  114384. isRigCamera: boolean;
  114385. /**
  114386. * If isRigCamera set to true this will be set with the parent camera.
  114387. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  114388. */
  114389. rigParent?: Camera;
  114390. /** @hidden */
  114391. _cameraRigParams: any;
  114392. /** @hidden */
  114393. _rigCameras: Camera[];
  114394. /** @hidden */
  114395. _rigPostProcess: Nullable<PostProcess>;
  114396. protected _webvrViewMatrix: Matrix;
  114397. /** @hidden */
  114398. _skipRendering: boolean;
  114399. /** @hidden */
  114400. _projectionMatrix: Matrix;
  114401. /** @hidden */
  114402. _postProcesses: Nullable<PostProcess>[];
  114403. /** @hidden */
  114404. _activeMeshes: SmartArray<AbstractMesh>;
  114405. protected _globalPosition: Vector3;
  114406. /** @hidden */
  114407. _computedViewMatrix: Matrix;
  114408. private _doNotComputeProjectionMatrix;
  114409. private _transformMatrix;
  114410. private _frustumPlanes;
  114411. private _refreshFrustumPlanes;
  114412. private _storedFov;
  114413. private _stateStored;
  114414. /**
  114415. * Instantiates a new camera object.
  114416. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  114417. * @see https://doc.babylonjs.com/features/cameras
  114418. * @param name Defines the name of the camera in the scene
  114419. * @param position Defines the position of the camera
  114420. * @param scene Defines the scene the camera belongs too
  114421. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  114422. */
  114423. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  114424. /**
  114425. * Store current camera state (fov, position, etc..)
  114426. * @returns the camera
  114427. */
  114428. storeState(): Camera;
  114429. /**
  114430. * Restores the camera state values if it has been stored. You must call storeState() first
  114431. */
  114432. protected _restoreStateValues(): boolean;
  114433. /**
  114434. * Restored camera state. You must call storeState() first.
  114435. * @returns true if restored and false otherwise
  114436. */
  114437. restoreState(): boolean;
  114438. /**
  114439. * Gets the class name of the camera.
  114440. * @returns the class name
  114441. */
  114442. getClassName(): string;
  114443. /** @hidden */
  114444. readonly _isCamera: boolean;
  114445. /**
  114446. * Gets a string representation of the camera useful for debug purpose.
  114447. * @param fullDetails Defines that a more verboe level of logging is required
  114448. * @returns the string representation
  114449. */
  114450. toString(fullDetails?: boolean): string;
  114451. /**
  114452. * Gets the current world space position of the camera.
  114453. */
  114454. get globalPosition(): Vector3;
  114455. /**
  114456. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  114457. * @returns the active meshe list
  114458. */
  114459. getActiveMeshes(): SmartArray<AbstractMesh>;
  114460. /**
  114461. * Check whether a mesh is part of the current active mesh list of the camera
  114462. * @param mesh Defines the mesh to check
  114463. * @returns true if active, false otherwise
  114464. */
  114465. isActiveMesh(mesh: Mesh): boolean;
  114466. /**
  114467. * Is this camera ready to be used/rendered
  114468. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  114469. * @return true if the camera is ready
  114470. */
  114471. isReady(completeCheck?: boolean): boolean;
  114472. /** @hidden */
  114473. _initCache(): void;
  114474. /** @hidden */
  114475. _updateCache(ignoreParentClass?: boolean): void;
  114476. /** @hidden */
  114477. _isSynchronized(): boolean;
  114478. /** @hidden */
  114479. _isSynchronizedViewMatrix(): boolean;
  114480. /** @hidden */
  114481. _isSynchronizedProjectionMatrix(): boolean;
  114482. /**
  114483. * Attach the input controls to a specific dom element to get the input from.
  114484. * @param element Defines the element the controls should be listened from
  114485. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114486. */
  114487. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114488. /**
  114489. * Detach the current controls from the specified dom element.
  114490. * @param element Defines the element to stop listening the inputs from
  114491. */
  114492. detachControl(element: HTMLElement): void;
  114493. /**
  114494. * Update the camera state according to the different inputs gathered during the frame.
  114495. */
  114496. update(): void;
  114497. /** @hidden */
  114498. _checkInputs(): void;
  114499. /** @hidden */
  114500. get rigCameras(): Camera[];
  114501. /**
  114502. * Gets the post process used by the rig cameras
  114503. */
  114504. get rigPostProcess(): Nullable<PostProcess>;
  114505. /**
  114506. * Internal, gets the first post proces.
  114507. * @returns the first post process to be run on this camera.
  114508. */
  114509. _getFirstPostProcess(): Nullable<PostProcess>;
  114510. private _cascadePostProcessesToRigCams;
  114511. /**
  114512. * Attach a post process to the camera.
  114513. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114514. * @param postProcess The post process to attach to the camera
  114515. * @param insertAt The position of the post process in case several of them are in use in the scene
  114516. * @returns the position the post process has been inserted at
  114517. */
  114518. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  114519. /**
  114520. * Detach a post process to the camera.
  114521. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114522. * @param postProcess The post process to detach from the camera
  114523. */
  114524. detachPostProcess(postProcess: PostProcess): void;
  114525. /**
  114526. * Gets the current world matrix of the camera
  114527. */
  114528. getWorldMatrix(): Matrix;
  114529. /** @hidden */
  114530. _getViewMatrix(): Matrix;
  114531. /**
  114532. * Gets the current view matrix of the camera.
  114533. * @param force forces the camera to recompute the matrix without looking at the cached state
  114534. * @returns the view matrix
  114535. */
  114536. getViewMatrix(force?: boolean): Matrix;
  114537. /**
  114538. * Freeze the projection matrix.
  114539. * It will prevent the cache check of the camera projection compute and can speed up perf
  114540. * if no parameter of the camera are meant to change
  114541. * @param projection Defines manually a projection if necessary
  114542. */
  114543. freezeProjectionMatrix(projection?: Matrix): void;
  114544. /**
  114545. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  114546. */
  114547. unfreezeProjectionMatrix(): void;
  114548. /**
  114549. * Gets the current projection matrix of the camera.
  114550. * @param force forces the camera to recompute the matrix without looking at the cached state
  114551. * @returns the projection matrix
  114552. */
  114553. getProjectionMatrix(force?: boolean): Matrix;
  114554. /**
  114555. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  114556. * @returns a Matrix
  114557. */
  114558. getTransformationMatrix(): Matrix;
  114559. private _updateFrustumPlanes;
  114560. /**
  114561. * Checks if a cullable object (mesh...) is in the camera frustum
  114562. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  114563. * @param target The object to check
  114564. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  114565. * @returns true if the object is in frustum otherwise false
  114566. */
  114567. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  114568. /**
  114569. * Checks if a cullable object (mesh...) is in the camera frustum
  114570. * Unlike isInFrustum this cheks the full bounding box
  114571. * @param target The object to check
  114572. * @returns true if the object is in frustum otherwise false
  114573. */
  114574. isCompletelyInFrustum(target: ICullable): boolean;
  114575. /**
  114576. * Gets a ray in the forward direction from the camera.
  114577. * @param length Defines the length of the ray to create
  114578. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114579. * @param origin Defines the start point of the ray which defaults to the camera position
  114580. * @returns the forward ray
  114581. */
  114582. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114583. /**
  114584. * Gets a ray in the forward direction from the camera.
  114585. * @param refRay the ray to (re)use when setting the values
  114586. * @param length Defines the length of the ray to create
  114587. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114588. * @param origin Defines the start point of the ray which defaults to the camera position
  114589. * @returns the forward ray
  114590. */
  114591. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114592. /**
  114593. * Releases resources associated with this node.
  114594. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114595. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114596. */
  114597. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114598. /** @hidden */
  114599. _isLeftCamera: boolean;
  114600. /**
  114601. * Gets the left camera of a rig setup in case of Rigged Camera
  114602. */
  114603. get isLeftCamera(): boolean;
  114604. /** @hidden */
  114605. _isRightCamera: boolean;
  114606. /**
  114607. * Gets the right camera of a rig setup in case of Rigged Camera
  114608. */
  114609. get isRightCamera(): boolean;
  114610. /**
  114611. * Gets the left camera of a rig setup in case of Rigged Camera
  114612. */
  114613. get leftCamera(): Nullable<FreeCamera>;
  114614. /**
  114615. * Gets the right camera of a rig setup in case of Rigged Camera
  114616. */
  114617. get rightCamera(): Nullable<FreeCamera>;
  114618. /**
  114619. * Gets the left camera target of a rig setup in case of Rigged Camera
  114620. * @returns the target position
  114621. */
  114622. getLeftTarget(): Nullable<Vector3>;
  114623. /**
  114624. * Gets the right camera target of a rig setup in case of Rigged Camera
  114625. * @returns the target position
  114626. */
  114627. getRightTarget(): Nullable<Vector3>;
  114628. /**
  114629. * @hidden
  114630. */
  114631. setCameraRigMode(mode: number, rigParams: any): void;
  114632. /** @hidden */
  114633. static _setStereoscopicRigMode(camera: Camera): void;
  114634. /** @hidden */
  114635. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  114636. /** @hidden */
  114637. static _setVRRigMode(camera: Camera, rigParams: any): void;
  114638. /** @hidden */
  114639. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  114640. /** @hidden */
  114641. _getVRProjectionMatrix(): Matrix;
  114642. protected _updateCameraRotationMatrix(): void;
  114643. protected _updateWebVRCameraRotationMatrix(): void;
  114644. /**
  114645. * This function MUST be overwritten by the different WebVR cameras available.
  114646. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114647. * @hidden
  114648. */
  114649. _getWebVRProjectionMatrix(): Matrix;
  114650. /**
  114651. * This function MUST be overwritten by the different WebVR cameras available.
  114652. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114653. * @hidden
  114654. */
  114655. _getWebVRViewMatrix(): Matrix;
  114656. /** @hidden */
  114657. setCameraRigParameter(name: string, value: any): void;
  114658. /**
  114659. * needs to be overridden by children so sub has required properties to be copied
  114660. * @hidden
  114661. */
  114662. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  114663. /**
  114664. * May need to be overridden by children
  114665. * @hidden
  114666. */
  114667. _updateRigCameras(): void;
  114668. /** @hidden */
  114669. _setupInputs(): void;
  114670. /**
  114671. * Serialiaze the camera setup to a json represention
  114672. * @returns the JSON representation
  114673. */
  114674. serialize(): any;
  114675. /**
  114676. * Clones the current camera.
  114677. * @param name The cloned camera name
  114678. * @returns the cloned camera
  114679. */
  114680. clone(name: string): Camera;
  114681. /**
  114682. * Gets the direction of the camera relative to a given local axis.
  114683. * @param localAxis Defines the reference axis to provide a relative direction.
  114684. * @return the direction
  114685. */
  114686. getDirection(localAxis: Vector3): Vector3;
  114687. /**
  114688. * Returns the current camera absolute rotation
  114689. */
  114690. get absoluteRotation(): Quaternion;
  114691. /**
  114692. * Gets the direction of the camera relative to a given local axis into a passed vector.
  114693. * @param localAxis Defines the reference axis to provide a relative direction.
  114694. * @param result Defines the vector to store the result in
  114695. */
  114696. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  114697. /**
  114698. * Gets a camera constructor for a given camera type
  114699. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  114700. * @param name The name of the camera the result will be able to instantiate
  114701. * @param scene The scene the result will construct the camera in
  114702. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  114703. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  114704. * @returns a factory method to construc the camera
  114705. */
  114706. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  114707. /**
  114708. * Compute the world matrix of the camera.
  114709. * @returns the camera world matrix
  114710. */
  114711. computeWorldMatrix(): Matrix;
  114712. /**
  114713. * Parse a JSON and creates the camera from the parsed information
  114714. * @param parsedCamera The JSON to parse
  114715. * @param scene The scene to instantiate the camera in
  114716. * @returns the newly constructed camera
  114717. */
  114718. static Parse(parsedCamera: any, scene: Scene): Camera;
  114719. }
  114720. }
  114721. declare module BABYLON {
  114722. /**
  114723. * Class containing static functions to help procedurally build meshes
  114724. */
  114725. export class DiscBuilder {
  114726. /**
  114727. * Creates a plane polygonal mesh. By default, this is a disc
  114728. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  114729. * * 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
  114730. * * 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
  114731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114734. * @param name defines the name of the mesh
  114735. * @param options defines the options used to create the mesh
  114736. * @param scene defines the hosting scene
  114737. * @returns the plane polygonal mesh
  114738. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  114739. */
  114740. static CreateDisc(name: string, options: {
  114741. radius?: number;
  114742. tessellation?: number;
  114743. arc?: number;
  114744. updatable?: boolean;
  114745. sideOrientation?: number;
  114746. frontUVs?: Vector4;
  114747. backUVs?: Vector4;
  114748. }, scene?: Nullable<Scene>): Mesh;
  114749. }
  114750. }
  114751. declare module BABYLON {
  114752. /**
  114753. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  114754. *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.
  114755. * The SPS is also a particle system. It provides some methods to manage the particles.
  114756. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  114757. *
  114758. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  114759. */
  114760. export class SolidParticleSystem implements IDisposable {
  114761. /**
  114762. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  114763. * Example : var p = SPS.particles[i];
  114764. */
  114765. particles: SolidParticle[];
  114766. /**
  114767. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  114768. */
  114769. nbParticles: number;
  114770. /**
  114771. * If the particles must ever face the camera (default false). Useful for planar particles.
  114772. */
  114773. billboard: boolean;
  114774. /**
  114775. * Recompute normals when adding a shape
  114776. */
  114777. recomputeNormals: boolean;
  114778. /**
  114779. * This a counter ofr your own usage. It's not set by any SPS functions.
  114780. */
  114781. counter: number;
  114782. /**
  114783. * The SPS name. This name is also given to the underlying mesh.
  114784. */
  114785. name: string;
  114786. /**
  114787. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  114788. */
  114789. mesh: Mesh;
  114790. /**
  114791. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  114792. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  114793. */
  114794. vars: any;
  114795. /**
  114796. * This array is populated when the SPS is set as 'pickable'.
  114797. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  114798. * Each element of this array is an object `{idx: int, faceId: int}`.
  114799. * `idx` is the picked particle index in the `SPS.particles` array
  114800. * `faceId` is the picked face index counted within this particle.
  114801. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  114802. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  114803. * Use the method SPS.pickedParticle(pickingInfo) instead.
  114804. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  114805. */
  114806. pickedParticles: {
  114807. idx: number;
  114808. faceId: number;
  114809. }[];
  114810. /**
  114811. * This array is populated when the SPS is set as 'pickable'
  114812. * Each key of this array is a submesh index.
  114813. * Each element of this array is a second array defined like this :
  114814. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  114815. * Each element of this second array is an object `{idx: int, faceId: int}`.
  114816. * `idx` is the picked particle index in the `SPS.particles` array
  114817. * `faceId` is the picked face index counted within this particle.
  114818. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  114819. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  114820. */
  114821. pickedBySubMesh: {
  114822. idx: number;
  114823. faceId: number;
  114824. }[][];
  114825. /**
  114826. * This array is populated when `enableDepthSort` is set to true.
  114827. * Each element of this array is an instance of the class DepthSortedParticle.
  114828. */
  114829. depthSortedParticles: DepthSortedParticle[];
  114830. /**
  114831. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  114832. * @hidden
  114833. */
  114834. _bSphereOnly: boolean;
  114835. /**
  114836. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  114837. * @hidden
  114838. */
  114839. _bSphereRadiusFactor: number;
  114840. private _scene;
  114841. private _positions;
  114842. private _indices;
  114843. private _normals;
  114844. private _colors;
  114845. private _uvs;
  114846. private _indices32;
  114847. private _positions32;
  114848. private _normals32;
  114849. private _fixedNormal32;
  114850. private _colors32;
  114851. private _uvs32;
  114852. private _index;
  114853. private _updatable;
  114854. private _pickable;
  114855. private _isVisibilityBoxLocked;
  114856. private _alwaysVisible;
  114857. private _depthSort;
  114858. private _expandable;
  114859. private _shapeCounter;
  114860. private _copy;
  114861. private _color;
  114862. private _computeParticleColor;
  114863. private _computeParticleTexture;
  114864. private _computeParticleRotation;
  114865. private _computeParticleVertex;
  114866. private _computeBoundingBox;
  114867. private _depthSortParticles;
  114868. private _camera;
  114869. private _mustUnrotateFixedNormals;
  114870. private _particlesIntersect;
  114871. private _needs32Bits;
  114872. private _isNotBuilt;
  114873. private _lastParticleId;
  114874. private _idxOfId;
  114875. private _multimaterialEnabled;
  114876. private _useModelMaterial;
  114877. private _indicesByMaterial;
  114878. private _materialIndexes;
  114879. private _depthSortFunction;
  114880. private _materialSortFunction;
  114881. private _materials;
  114882. private _multimaterial;
  114883. private _materialIndexesById;
  114884. private _defaultMaterial;
  114885. private _autoUpdateSubMeshes;
  114886. private _tmpVertex;
  114887. /**
  114888. * Creates a SPS (Solid Particle System) object.
  114889. * @param name (String) is the SPS name, this will be the underlying mesh name.
  114890. * @param scene (Scene) is the scene in which the SPS is added.
  114891. * @param options defines the options of the sps e.g.
  114892. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  114893. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  114894. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  114895. * * 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.
  114896. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  114897. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  114898. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  114899. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  114900. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  114901. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  114902. */
  114903. constructor(name: string, scene: Scene, options?: {
  114904. updatable?: boolean;
  114905. isPickable?: boolean;
  114906. enableDepthSort?: boolean;
  114907. particleIntersection?: boolean;
  114908. boundingSphereOnly?: boolean;
  114909. bSphereRadiusFactor?: number;
  114910. expandable?: boolean;
  114911. useModelMaterial?: boolean;
  114912. enableMultiMaterial?: boolean;
  114913. });
  114914. /**
  114915. * Builds the SPS underlying mesh. Returns a standard Mesh.
  114916. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  114917. * @returns the created mesh
  114918. */
  114919. buildMesh(): Mesh;
  114920. /**
  114921. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  114922. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  114923. * Thus the particles generated from `digest()` have their property `position` set yet.
  114924. * @param mesh ( Mesh ) is the mesh to be digested
  114925. * @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
  114926. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  114927. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  114928. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  114929. * @returns the current SPS
  114930. */
  114931. digest(mesh: Mesh, options?: {
  114932. facetNb?: number;
  114933. number?: number;
  114934. delta?: number;
  114935. storage?: [];
  114936. }): SolidParticleSystem;
  114937. /**
  114938. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  114939. * @hidden
  114940. */
  114941. private _unrotateFixedNormals;
  114942. /**
  114943. * Resets the temporary working copy particle
  114944. * @hidden
  114945. */
  114946. private _resetCopy;
  114947. /**
  114948. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  114949. * @param p the current index in the positions array to be updated
  114950. * @param ind the current index in the indices array
  114951. * @param shape a Vector3 array, the shape geometry
  114952. * @param positions the positions array to be updated
  114953. * @param meshInd the shape indices array
  114954. * @param indices the indices array to be updated
  114955. * @param meshUV the shape uv array
  114956. * @param uvs the uv array to be updated
  114957. * @param meshCol the shape color array
  114958. * @param colors the color array to be updated
  114959. * @param meshNor the shape normals array
  114960. * @param normals the normals array to be updated
  114961. * @param idx the particle index
  114962. * @param idxInShape the particle index in its shape
  114963. * @param options the addShape() method passed options
  114964. * @model the particle model
  114965. * @hidden
  114966. */
  114967. private _meshBuilder;
  114968. /**
  114969. * Returns a shape Vector3 array from positions float array
  114970. * @param positions float array
  114971. * @returns a vector3 array
  114972. * @hidden
  114973. */
  114974. private _posToShape;
  114975. /**
  114976. * Returns a shapeUV array from a float uvs (array deep copy)
  114977. * @param uvs as a float array
  114978. * @returns a shapeUV array
  114979. * @hidden
  114980. */
  114981. private _uvsToShapeUV;
  114982. /**
  114983. * Adds a new particle object in the particles array
  114984. * @param idx particle index in particles array
  114985. * @param id particle id
  114986. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  114987. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  114988. * @param model particle ModelShape object
  114989. * @param shapeId model shape identifier
  114990. * @param idxInShape index of the particle in the current model
  114991. * @param bInfo model bounding info object
  114992. * @param storage target storage array, if any
  114993. * @hidden
  114994. */
  114995. private _addParticle;
  114996. /**
  114997. * Adds some particles to the SPS from the model shape. Returns the shape id.
  114998. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  114999. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  115000. * @param nb (positive integer) the number of particles to be created from this model
  115001. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  115002. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  115003. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115004. * @returns the number of shapes in the system
  115005. */
  115006. addShape(mesh: Mesh, nb: number, options?: {
  115007. positionFunction?: any;
  115008. vertexFunction?: any;
  115009. storage?: [];
  115010. }): number;
  115011. /**
  115012. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  115013. * @hidden
  115014. */
  115015. private _rebuildParticle;
  115016. /**
  115017. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  115018. * @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.
  115019. * @returns the SPS.
  115020. */
  115021. rebuildMesh(reset?: boolean): SolidParticleSystem;
  115022. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  115023. * Returns an array with the removed particles.
  115024. * 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.
  115025. * The SPS can't be empty so at least one particle needs to remain in place.
  115026. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  115027. * @param start index of the first particle to remove
  115028. * @param end index of the last particle to remove (included)
  115029. * @returns an array populated with the removed particles
  115030. */
  115031. removeParticles(start: number, end: number): SolidParticle[];
  115032. /**
  115033. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  115034. * @param solidParticleArray an array populated with Solid Particles objects
  115035. * @returns the SPS
  115036. */
  115037. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  115038. /**
  115039. * Creates a new particle and modifies the SPS mesh geometry :
  115040. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  115041. * - calls _addParticle() to populate the particle array
  115042. * factorized code from addShape() and insertParticlesFromArray()
  115043. * @param idx particle index in the particles array
  115044. * @param i particle index in its shape
  115045. * @param modelShape particle ModelShape object
  115046. * @param shape shape vertex array
  115047. * @param meshInd shape indices array
  115048. * @param meshUV shape uv array
  115049. * @param meshCol shape color array
  115050. * @param meshNor shape normals array
  115051. * @param bbInfo shape bounding info
  115052. * @param storage target particle storage
  115053. * @options addShape() passed options
  115054. * @hidden
  115055. */
  115056. private _insertNewParticle;
  115057. /**
  115058. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  115059. * This method calls `updateParticle()` for each particle of the SPS.
  115060. * For an animated SPS, it is usually called within the render loop.
  115061. * 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.
  115062. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  115063. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  115064. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  115065. * @returns the SPS.
  115066. */
  115067. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  115068. /**
  115069. * Disposes the SPS.
  115070. */
  115071. dispose(): void;
  115072. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  115073. * idx is the particle index in the SPS
  115074. * faceId is the picked face index counted within this particle.
  115075. * Returns null if the pickInfo can't identify a picked particle.
  115076. * @param pickingInfo (PickingInfo object)
  115077. * @returns {idx: number, faceId: number} or null
  115078. */
  115079. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  115080. idx: number;
  115081. faceId: number;
  115082. }>;
  115083. /**
  115084. * Returns a SolidParticle object from its identifier : particle.id
  115085. * @param id (integer) the particle Id
  115086. * @returns the searched particle or null if not found in the SPS.
  115087. */
  115088. getParticleById(id: number): Nullable<SolidParticle>;
  115089. /**
  115090. * Returns a new array populated with the particles having the passed shapeId.
  115091. * @param shapeId (integer) the shape identifier
  115092. * @returns a new solid particle array
  115093. */
  115094. getParticlesByShapeId(shapeId: number): SolidParticle[];
  115095. /**
  115096. * Populates the passed array "ref" with the particles having the passed shapeId.
  115097. * @param shapeId the shape identifier
  115098. * @returns the SPS
  115099. * @param ref
  115100. */
  115101. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  115102. /**
  115103. * Computes the required SubMeshes according the materials assigned to the particles.
  115104. * @returns the solid particle system.
  115105. * Does nothing if called before the SPS mesh is built.
  115106. */
  115107. computeSubMeshes(): SolidParticleSystem;
  115108. /**
  115109. * Sorts the solid particles by material when MultiMaterial is enabled.
  115110. * Updates the indices32 array.
  115111. * Updates the indicesByMaterial array.
  115112. * Updates the mesh indices array.
  115113. * @returns the SPS
  115114. * @hidden
  115115. */
  115116. private _sortParticlesByMaterial;
  115117. /**
  115118. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  115119. * @hidden
  115120. */
  115121. private _setMaterialIndexesById;
  115122. /**
  115123. * Returns an array with unique values of Materials from the passed array
  115124. * @param array the material array to be checked and filtered
  115125. * @hidden
  115126. */
  115127. private _filterUniqueMaterialId;
  115128. /**
  115129. * Sets a new Standard Material as _defaultMaterial if not already set.
  115130. * @hidden
  115131. */
  115132. private _setDefaultMaterial;
  115133. /**
  115134. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  115135. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115136. * @returns the SPS.
  115137. */
  115138. refreshVisibleSize(): SolidParticleSystem;
  115139. /**
  115140. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  115141. * @param size the size (float) of the visibility box
  115142. * note : this doesn't lock the SPS mesh bounding box.
  115143. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115144. */
  115145. setVisibilityBox(size: number): void;
  115146. /**
  115147. * Gets whether the SPS as always visible or not
  115148. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115149. */
  115150. get isAlwaysVisible(): boolean;
  115151. /**
  115152. * Sets the SPS as always visible or not
  115153. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115154. */
  115155. set isAlwaysVisible(val: boolean);
  115156. /**
  115157. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115158. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115159. */
  115160. set isVisibilityBoxLocked(val: boolean);
  115161. /**
  115162. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115163. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115164. */
  115165. get isVisibilityBoxLocked(): boolean;
  115166. /**
  115167. * Tells to `setParticles()` to compute the particle rotations or not.
  115168. * Default value : true. The SPS is faster when it's set to false.
  115169. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115170. */
  115171. set computeParticleRotation(val: boolean);
  115172. /**
  115173. * Tells to `setParticles()` to compute the particle colors or not.
  115174. * Default value : true. The SPS is faster when it's set to false.
  115175. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115176. */
  115177. set computeParticleColor(val: boolean);
  115178. set computeParticleTexture(val: boolean);
  115179. /**
  115180. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  115181. * Default value : false. The SPS is faster when it's set to false.
  115182. * Note : the particle custom vertex positions aren't stored values.
  115183. */
  115184. set computeParticleVertex(val: boolean);
  115185. /**
  115186. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  115187. */
  115188. set computeBoundingBox(val: boolean);
  115189. /**
  115190. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  115191. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115192. * Default : `true`
  115193. */
  115194. set depthSortParticles(val: boolean);
  115195. /**
  115196. * Gets if `setParticles()` computes the particle rotations or not.
  115197. * Default value : true. The SPS is faster when it's set to false.
  115198. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115199. */
  115200. get computeParticleRotation(): boolean;
  115201. /**
  115202. * Gets if `setParticles()` computes the particle colors or not.
  115203. * Default value : true. The SPS is faster when it's set to false.
  115204. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115205. */
  115206. get computeParticleColor(): boolean;
  115207. /**
  115208. * Gets if `setParticles()` computes the particle textures or not.
  115209. * Default value : true. The SPS is faster when it's set to false.
  115210. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  115211. */
  115212. get computeParticleTexture(): boolean;
  115213. /**
  115214. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  115215. * Default value : false. The SPS is faster when it's set to false.
  115216. * Note : the particle custom vertex positions aren't stored values.
  115217. */
  115218. get computeParticleVertex(): boolean;
  115219. /**
  115220. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  115221. */
  115222. get computeBoundingBox(): boolean;
  115223. /**
  115224. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  115225. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115226. * Default : `true`
  115227. */
  115228. get depthSortParticles(): boolean;
  115229. /**
  115230. * Gets if the SPS is created as expandable at construction time.
  115231. * Default : `false`
  115232. */
  115233. get expandable(): boolean;
  115234. /**
  115235. * Gets if the SPS supports the Multi Materials
  115236. */
  115237. get multimaterialEnabled(): boolean;
  115238. /**
  115239. * Gets if the SPS uses the model materials for its own multimaterial.
  115240. */
  115241. get useModelMaterial(): boolean;
  115242. /**
  115243. * The SPS used material array.
  115244. */
  115245. get materials(): Material[];
  115246. /**
  115247. * Sets the SPS MultiMaterial from the passed materials.
  115248. * Note : the passed array is internally copied and not used then by reference.
  115249. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  115250. */
  115251. setMultiMaterial(materials: Material[]): void;
  115252. /**
  115253. * The SPS computed multimaterial object
  115254. */
  115255. get multimaterial(): MultiMaterial;
  115256. set multimaterial(mm: MultiMaterial);
  115257. /**
  115258. * If the subMeshes must be updated on the next call to setParticles()
  115259. */
  115260. get autoUpdateSubMeshes(): boolean;
  115261. set autoUpdateSubMeshes(val: boolean);
  115262. /**
  115263. * This function does nothing. It may be overwritten to set all the particle first values.
  115264. * The SPS doesn't call this function, you may have to call it by your own.
  115265. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115266. */
  115267. initParticles(): void;
  115268. /**
  115269. * This function does nothing. It may be overwritten to recycle a particle.
  115270. * The SPS doesn't call this function, you may have to call it by your own.
  115271. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115272. * @param particle The particle to recycle
  115273. * @returns the recycled particle
  115274. */
  115275. recycleParticle(particle: SolidParticle): SolidParticle;
  115276. /**
  115277. * Updates a particle : this function should be overwritten by the user.
  115278. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  115279. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115280. * @example : just set a particle position or velocity and recycle conditions
  115281. * @param particle The particle to update
  115282. * @returns the updated particle
  115283. */
  115284. updateParticle(particle: SolidParticle): SolidParticle;
  115285. /**
  115286. * Updates a vertex of a particle : it can be overwritten by the user.
  115287. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  115288. * @param particle the current particle
  115289. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  115290. * @param pt the index of the current vertex in the particle shape
  115291. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  115292. * @example : just set a vertex particle position or color
  115293. * @returns the sps
  115294. */
  115295. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  115296. /**
  115297. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  115298. * This does nothing and may be overwritten by the user.
  115299. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115300. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115301. * @param update the boolean update value actually passed to setParticles()
  115302. */
  115303. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115304. /**
  115305. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  115306. * This will be passed three parameters.
  115307. * This does nothing and may be overwritten by the user.
  115308. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115309. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115310. * @param update the boolean update value actually passed to setParticles()
  115311. */
  115312. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115313. }
  115314. }
  115315. declare module BABYLON {
  115316. /**
  115317. * Represents one particle of a solid particle system.
  115318. */
  115319. export class SolidParticle {
  115320. /**
  115321. * particle global index
  115322. */
  115323. idx: number;
  115324. /**
  115325. * particle identifier
  115326. */
  115327. id: number;
  115328. /**
  115329. * The color of the particle
  115330. */
  115331. color: Nullable<Color4>;
  115332. /**
  115333. * The world space position of the particle.
  115334. */
  115335. position: Vector3;
  115336. /**
  115337. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  115338. */
  115339. rotation: Vector3;
  115340. /**
  115341. * The world space rotation quaternion of the particle.
  115342. */
  115343. rotationQuaternion: Nullable<Quaternion>;
  115344. /**
  115345. * The scaling of the particle.
  115346. */
  115347. scaling: Vector3;
  115348. /**
  115349. * The uvs of the particle.
  115350. */
  115351. uvs: Vector4;
  115352. /**
  115353. * The current speed of the particle.
  115354. */
  115355. velocity: Vector3;
  115356. /**
  115357. * The pivot point in the particle local space.
  115358. */
  115359. pivot: Vector3;
  115360. /**
  115361. * Must the particle be translated from its pivot point in its local space ?
  115362. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  115363. * Default : false
  115364. */
  115365. translateFromPivot: boolean;
  115366. /**
  115367. * Is the particle active or not ?
  115368. */
  115369. alive: boolean;
  115370. /**
  115371. * Is the particle visible or not ?
  115372. */
  115373. isVisible: boolean;
  115374. /**
  115375. * Index of this particle in the global "positions" array (Internal use)
  115376. * @hidden
  115377. */
  115378. _pos: number;
  115379. /**
  115380. * @hidden Index of this particle in the global "indices" array (Internal use)
  115381. */
  115382. _ind: number;
  115383. /**
  115384. * @hidden ModelShape of this particle (Internal use)
  115385. */
  115386. _model: ModelShape;
  115387. /**
  115388. * ModelShape id of this particle
  115389. */
  115390. shapeId: number;
  115391. /**
  115392. * Index of the particle in its shape id
  115393. */
  115394. idxInShape: number;
  115395. /**
  115396. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  115397. */
  115398. _modelBoundingInfo: BoundingInfo;
  115399. /**
  115400. * @hidden Particle BoundingInfo object (Internal use)
  115401. */
  115402. _boundingInfo: BoundingInfo;
  115403. /**
  115404. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  115405. */
  115406. _sps: SolidParticleSystem;
  115407. /**
  115408. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  115409. */
  115410. _stillInvisible: boolean;
  115411. /**
  115412. * @hidden Last computed particle rotation matrix
  115413. */
  115414. _rotationMatrix: number[];
  115415. /**
  115416. * Parent particle Id, if any.
  115417. * Default null.
  115418. */
  115419. parentId: Nullable<number>;
  115420. /**
  115421. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  115422. */
  115423. materialIndex: Nullable<number>;
  115424. /**
  115425. * Custom object or properties.
  115426. */
  115427. props: Nullable<any>;
  115428. /**
  115429. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  115430. * The possible values are :
  115431. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  115432. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115433. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  115434. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  115435. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115436. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  115437. * */
  115438. cullingStrategy: number;
  115439. /**
  115440. * @hidden Internal global position in the SPS.
  115441. */
  115442. _globalPosition: Vector3;
  115443. /**
  115444. * Creates a Solid Particle object.
  115445. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  115446. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  115447. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  115448. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  115449. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  115450. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  115451. * @param shapeId (integer) is the model shape identifier in the SPS.
  115452. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  115453. * @param sps defines the sps it is associated to
  115454. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  115455. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  115456. */
  115457. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  115458. /**
  115459. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  115460. * @param target the particle target
  115461. * @returns the current particle
  115462. */
  115463. copyToRef(target: SolidParticle): SolidParticle;
  115464. /**
  115465. * Legacy support, changed scale to scaling
  115466. */
  115467. get scale(): Vector3;
  115468. /**
  115469. * Legacy support, changed scale to scaling
  115470. */
  115471. set scale(scale: Vector3);
  115472. /**
  115473. * Legacy support, changed quaternion to rotationQuaternion
  115474. */
  115475. get quaternion(): Nullable<Quaternion>;
  115476. /**
  115477. * Legacy support, changed quaternion to rotationQuaternion
  115478. */
  115479. set quaternion(q: Nullable<Quaternion>);
  115480. /**
  115481. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  115482. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  115483. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  115484. * @returns true if it intersects
  115485. */
  115486. intersectsMesh(target: Mesh | SolidParticle): boolean;
  115487. /**
  115488. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  115489. * A particle is in the frustum if its bounding box intersects the frustum
  115490. * @param frustumPlanes defines the frustum to test
  115491. * @returns true if the particle is in the frustum planes
  115492. */
  115493. isInFrustum(frustumPlanes: Plane[]): boolean;
  115494. /**
  115495. * get the rotation matrix of the particle
  115496. * @hidden
  115497. */
  115498. getRotationMatrix(m: Matrix): void;
  115499. }
  115500. /**
  115501. * Represents the shape of the model used by one particle of a solid particle system.
  115502. * SPS internal tool, don't use it manually.
  115503. */
  115504. export class ModelShape {
  115505. /**
  115506. * The shape id
  115507. * @hidden
  115508. */
  115509. shapeID: number;
  115510. /**
  115511. * flat array of model positions (internal use)
  115512. * @hidden
  115513. */
  115514. _shape: Vector3[];
  115515. /**
  115516. * flat array of model UVs (internal use)
  115517. * @hidden
  115518. */
  115519. _shapeUV: number[];
  115520. /**
  115521. * color array of the model
  115522. * @hidden
  115523. */
  115524. _shapeColors: number[];
  115525. /**
  115526. * indices array of the model
  115527. * @hidden
  115528. */
  115529. _indices: number[];
  115530. /**
  115531. * normals array of the model
  115532. * @hidden
  115533. */
  115534. _normals: number[];
  115535. /**
  115536. * length of the shape in the model indices array (internal use)
  115537. * @hidden
  115538. */
  115539. _indicesLength: number;
  115540. /**
  115541. * Custom position function (internal use)
  115542. * @hidden
  115543. */
  115544. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  115545. /**
  115546. * Custom vertex function (internal use)
  115547. * @hidden
  115548. */
  115549. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  115550. /**
  115551. * Model material (internal use)
  115552. * @hidden
  115553. */
  115554. _material: Nullable<Material>;
  115555. /**
  115556. * 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.
  115557. * SPS internal tool, don't use it manually.
  115558. * @hidden
  115559. */
  115560. 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>);
  115561. }
  115562. /**
  115563. * Represents a Depth Sorted Particle in the solid particle system.
  115564. * @hidden
  115565. */
  115566. export class DepthSortedParticle {
  115567. /**
  115568. * Particle index
  115569. */
  115570. idx: number;
  115571. /**
  115572. * Index of the particle in the "indices" array
  115573. */
  115574. ind: number;
  115575. /**
  115576. * Length of the particle shape in the "indices" array
  115577. */
  115578. indicesLength: number;
  115579. /**
  115580. * Squared distance from the particle to the camera
  115581. */
  115582. sqDistance: number;
  115583. /**
  115584. * Material index when used with MultiMaterials
  115585. */
  115586. materialIndex: number;
  115587. /**
  115588. * Creates a new sorted particle
  115589. * @param materialIndex
  115590. */
  115591. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  115592. }
  115593. /**
  115594. * Represents a solid particle vertex
  115595. */
  115596. export class SolidParticleVertex {
  115597. /**
  115598. * Vertex position
  115599. */
  115600. position: Vector3;
  115601. /**
  115602. * Vertex color
  115603. */
  115604. color: Color4;
  115605. /**
  115606. * Vertex UV
  115607. */
  115608. uv: Vector2;
  115609. /**
  115610. * Creates a new solid particle vertex
  115611. */
  115612. constructor();
  115613. /** Vertex x coordinate */
  115614. get x(): number;
  115615. set x(val: number);
  115616. /** Vertex y coordinate */
  115617. get y(): number;
  115618. set y(val: number);
  115619. /** Vertex z coordinate */
  115620. get z(): number;
  115621. set z(val: number);
  115622. }
  115623. }
  115624. declare module BABYLON {
  115625. /**
  115626. * @hidden
  115627. */
  115628. export class _MeshCollisionData {
  115629. _checkCollisions: boolean;
  115630. _collisionMask: number;
  115631. _collisionGroup: number;
  115632. _surroundingMeshes: Nullable<AbstractMesh[]>;
  115633. _collider: Nullable<Collider>;
  115634. _oldPositionForCollisions: Vector3;
  115635. _diffPositionForCollisions: Vector3;
  115636. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  115637. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  115638. _collisionResponse: boolean;
  115639. }
  115640. }
  115641. declare module BABYLON {
  115642. /** @hidden */
  115643. class _FacetDataStorage {
  115644. facetPositions: Vector3[];
  115645. facetNormals: Vector3[];
  115646. facetPartitioning: number[][];
  115647. facetNb: number;
  115648. partitioningSubdivisions: number;
  115649. partitioningBBoxRatio: number;
  115650. facetDataEnabled: boolean;
  115651. facetParameters: any;
  115652. bbSize: Vector3;
  115653. subDiv: {
  115654. max: number;
  115655. X: number;
  115656. Y: number;
  115657. Z: number;
  115658. };
  115659. facetDepthSort: boolean;
  115660. facetDepthSortEnabled: boolean;
  115661. depthSortedIndices: IndicesArray;
  115662. depthSortedFacets: {
  115663. ind: number;
  115664. sqDistance: number;
  115665. }[];
  115666. facetDepthSortFunction: (f1: {
  115667. ind: number;
  115668. sqDistance: number;
  115669. }, f2: {
  115670. ind: number;
  115671. sqDistance: number;
  115672. }) => number;
  115673. facetDepthSortFrom: Vector3;
  115674. facetDepthSortOrigin: Vector3;
  115675. invertedMatrix: Matrix;
  115676. }
  115677. /**
  115678. * @hidden
  115679. **/
  115680. class _InternalAbstractMeshDataInfo {
  115681. _hasVertexAlpha: boolean;
  115682. _useVertexColors: boolean;
  115683. _numBoneInfluencers: number;
  115684. _applyFog: boolean;
  115685. _receiveShadows: boolean;
  115686. _facetData: _FacetDataStorage;
  115687. _visibility: number;
  115688. _skeleton: Nullable<Skeleton>;
  115689. _layerMask: number;
  115690. _computeBonesUsingShaders: boolean;
  115691. _isActive: boolean;
  115692. _onlyForInstances: boolean;
  115693. _isActiveIntermediate: boolean;
  115694. _onlyForInstancesIntermediate: boolean;
  115695. _actAsRegularMesh: boolean;
  115696. }
  115697. /**
  115698. * Class used to store all common mesh properties
  115699. */
  115700. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  115701. /** No occlusion */
  115702. static OCCLUSION_TYPE_NONE: number;
  115703. /** Occlusion set to optimisitic */
  115704. static OCCLUSION_TYPE_OPTIMISTIC: number;
  115705. /** Occlusion set to strict */
  115706. static OCCLUSION_TYPE_STRICT: number;
  115707. /** Use an accurante occlusion algorithm */
  115708. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  115709. /** Use a conservative occlusion algorithm */
  115710. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  115711. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  115712. * Test order :
  115713. * Is the bounding sphere outside the frustum ?
  115714. * If not, are the bounding box vertices outside the frustum ?
  115715. * It not, then the cullable object is in the frustum.
  115716. */
  115717. static readonly CULLINGSTRATEGY_STANDARD: number;
  115718. /** Culling strategy : Bounding Sphere Only.
  115719. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  115720. * It's also less accurate than the standard because some not visible objects can still be selected.
  115721. * Test : is the bounding sphere outside the frustum ?
  115722. * If not, then the cullable object is in the frustum.
  115723. */
  115724. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  115725. /** Culling strategy : Optimistic Inclusion.
  115726. * This in an inclusion test first, then the standard exclusion test.
  115727. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  115728. * 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.
  115729. * Anyway, it's as accurate as the standard strategy.
  115730. * Test :
  115731. * Is the cullable object bounding sphere center in the frustum ?
  115732. * If not, apply the default culling strategy.
  115733. */
  115734. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  115735. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  115736. * This in an inclusion test first, then the bounding sphere only exclusion test.
  115737. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  115738. * 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.
  115739. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  115740. * Test :
  115741. * Is the cullable object bounding sphere center in the frustum ?
  115742. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  115743. */
  115744. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  115745. /**
  115746. * No billboard
  115747. */
  115748. static get BILLBOARDMODE_NONE(): number;
  115749. /** Billboard on X axis */
  115750. static get BILLBOARDMODE_X(): number;
  115751. /** Billboard on Y axis */
  115752. static get BILLBOARDMODE_Y(): number;
  115753. /** Billboard on Z axis */
  115754. static get BILLBOARDMODE_Z(): number;
  115755. /** Billboard on all axes */
  115756. static get BILLBOARDMODE_ALL(): number;
  115757. /** Billboard on using position instead of orientation */
  115758. static get BILLBOARDMODE_USE_POSITION(): number;
  115759. /** @hidden */
  115760. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  115761. /**
  115762. * The culling strategy to use to check whether the mesh must be rendered or not.
  115763. * This value can be changed at any time and will be used on the next render mesh selection.
  115764. * The possible values are :
  115765. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  115766. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115767. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  115768. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  115769. * Please read each static variable documentation to get details about the culling process.
  115770. * */
  115771. cullingStrategy: number;
  115772. /**
  115773. * Gets the number of facets in the mesh
  115774. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  115775. */
  115776. get facetNb(): number;
  115777. /**
  115778. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  115779. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  115780. */
  115781. get partitioningSubdivisions(): number;
  115782. set partitioningSubdivisions(nb: number);
  115783. /**
  115784. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  115785. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  115786. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  115787. */
  115788. get partitioningBBoxRatio(): number;
  115789. set partitioningBBoxRatio(ratio: number);
  115790. /**
  115791. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  115792. * Works only for updatable meshes.
  115793. * Doesn't work with multi-materials
  115794. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  115795. */
  115796. get mustDepthSortFacets(): boolean;
  115797. set mustDepthSortFacets(sort: boolean);
  115798. /**
  115799. * The location (Vector3) where the facet depth sort must be computed from.
  115800. * By default, the active camera position.
  115801. * Used only when facet depth sort is enabled
  115802. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  115803. */
  115804. get facetDepthSortFrom(): Vector3;
  115805. set facetDepthSortFrom(location: Vector3);
  115806. /**
  115807. * gets a boolean indicating if facetData is enabled
  115808. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  115809. */
  115810. get isFacetDataEnabled(): boolean;
  115811. /** @hidden */
  115812. _updateNonUniformScalingState(value: boolean): boolean;
  115813. /**
  115814. * An event triggered when this mesh collides with another one
  115815. */
  115816. onCollideObservable: Observable<AbstractMesh>;
  115817. /** Set a function to call when this mesh collides with another one */
  115818. set onCollide(callback: () => void);
  115819. /**
  115820. * An event triggered when the collision's position changes
  115821. */
  115822. onCollisionPositionChangeObservable: Observable<Vector3>;
  115823. /** Set a function to call when the collision's position changes */
  115824. set onCollisionPositionChange(callback: () => void);
  115825. /**
  115826. * An event triggered when material is changed
  115827. */
  115828. onMaterialChangedObservable: Observable<AbstractMesh>;
  115829. /**
  115830. * Gets or sets the orientation for POV movement & rotation
  115831. */
  115832. definedFacingForward: boolean;
  115833. /** @hidden */
  115834. _occlusionQuery: Nullable<WebGLQuery>;
  115835. /** @hidden */
  115836. _renderingGroup: Nullable<RenderingGroup>;
  115837. /**
  115838. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  115839. */
  115840. get visibility(): number;
  115841. /**
  115842. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  115843. */
  115844. set visibility(value: number);
  115845. /** Gets or sets the alpha index used to sort transparent meshes
  115846. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  115847. */
  115848. alphaIndex: number;
  115849. /**
  115850. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  115851. */
  115852. isVisible: boolean;
  115853. /**
  115854. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  115855. */
  115856. isPickable: boolean;
  115857. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  115858. showSubMeshesBoundingBox: boolean;
  115859. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  115860. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115861. */
  115862. isBlocker: boolean;
  115863. /**
  115864. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  115865. */
  115866. enablePointerMoveEvents: boolean;
  115867. private _renderingGroupId;
  115868. /**
  115869. * Specifies the rendering group id for this mesh (0 by default)
  115870. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  115871. */
  115872. get renderingGroupId(): number;
  115873. set renderingGroupId(value: number);
  115874. private _material;
  115875. /** Gets or sets current material */
  115876. get material(): Nullable<Material>;
  115877. set material(value: Nullable<Material>);
  115878. /**
  115879. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  115880. * @see https://doc.babylonjs.com/babylon101/shadows
  115881. */
  115882. get receiveShadows(): boolean;
  115883. set receiveShadows(value: boolean);
  115884. /** Defines color to use when rendering outline */
  115885. outlineColor: Color3;
  115886. /** Define width to use when rendering outline */
  115887. outlineWidth: number;
  115888. /** Defines color to use when rendering overlay */
  115889. overlayColor: Color3;
  115890. /** Defines alpha to use when rendering overlay */
  115891. overlayAlpha: number;
  115892. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  115893. get hasVertexAlpha(): boolean;
  115894. set hasVertexAlpha(value: boolean);
  115895. /** 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) */
  115896. get useVertexColors(): boolean;
  115897. set useVertexColors(value: boolean);
  115898. /**
  115899. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  115900. */
  115901. get computeBonesUsingShaders(): boolean;
  115902. set computeBonesUsingShaders(value: boolean);
  115903. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  115904. get numBoneInfluencers(): number;
  115905. set numBoneInfluencers(value: number);
  115906. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  115907. get applyFog(): boolean;
  115908. set applyFog(value: boolean);
  115909. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  115910. useOctreeForRenderingSelection: boolean;
  115911. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  115912. useOctreeForPicking: boolean;
  115913. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  115914. useOctreeForCollisions: boolean;
  115915. /**
  115916. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  115917. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  115918. */
  115919. get layerMask(): number;
  115920. set layerMask(value: number);
  115921. /**
  115922. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  115923. */
  115924. alwaysSelectAsActiveMesh: boolean;
  115925. /**
  115926. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  115927. */
  115928. doNotSyncBoundingInfo: boolean;
  115929. /**
  115930. * Gets or sets the current action manager
  115931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  115932. */
  115933. actionManager: Nullable<AbstractActionManager>;
  115934. private _meshCollisionData;
  115935. /**
  115936. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  115937. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  115938. */
  115939. ellipsoid: Vector3;
  115940. /**
  115941. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  115942. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  115943. */
  115944. ellipsoidOffset: Vector3;
  115945. /**
  115946. * Gets or sets a collision mask used to mask collisions (default is -1).
  115947. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  115948. */
  115949. get collisionMask(): number;
  115950. set collisionMask(mask: number);
  115951. /**
  115952. * Gets or sets a collision response flag (default is true).
  115953. * when collisionResponse is false, events are still triggered but colliding entity has no response
  115954. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  115955. * to respond to the collision.
  115956. */
  115957. get collisionResponse(): boolean;
  115958. set collisionResponse(response: boolean);
  115959. /**
  115960. * Gets or sets the current collision group mask (-1 by default).
  115961. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  115962. */
  115963. get collisionGroup(): number;
  115964. set collisionGroup(mask: number);
  115965. /**
  115966. * Gets or sets current surrounding meshes (null by default).
  115967. *
  115968. * By default collision detection is tested against every mesh in the scene.
  115969. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  115970. * meshes will be tested for the collision.
  115971. *
  115972. * Note: if set to an empty array no collision will happen when this mesh is moved.
  115973. */
  115974. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  115975. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  115976. /**
  115977. * Defines edge width used when edgesRenderer is enabled
  115978. * @see https://www.babylonjs-playground.com/#10OJSG#13
  115979. */
  115980. edgesWidth: number;
  115981. /**
  115982. * Defines edge color used when edgesRenderer is enabled
  115983. * @see https://www.babylonjs-playground.com/#10OJSG#13
  115984. */
  115985. edgesColor: Color4;
  115986. /** @hidden */
  115987. _edgesRenderer: Nullable<IEdgesRenderer>;
  115988. /** @hidden */
  115989. _masterMesh: Nullable<AbstractMesh>;
  115990. /** @hidden */
  115991. _boundingInfo: Nullable<BoundingInfo>;
  115992. /** @hidden */
  115993. _renderId: number;
  115994. /**
  115995. * Gets or sets the list of subMeshes
  115996. * @see https://doc.babylonjs.com/how_to/multi_materials
  115997. */
  115998. subMeshes: SubMesh[];
  115999. /** @hidden */
  116000. _intersectionsInProgress: AbstractMesh[];
  116001. /** @hidden */
  116002. _unIndexed: boolean;
  116003. /** @hidden */
  116004. _lightSources: Light[];
  116005. /** Gets the list of lights affecting that mesh */
  116006. get lightSources(): Light[];
  116007. /** @hidden */
  116008. get _positions(): Nullable<Vector3[]>;
  116009. /** @hidden */
  116010. _waitingData: {
  116011. lods: Nullable<any>;
  116012. actions: Nullable<any>;
  116013. freezeWorldMatrix: Nullable<boolean>;
  116014. };
  116015. /** @hidden */
  116016. _bonesTransformMatrices: Nullable<Float32Array>;
  116017. /** @hidden */
  116018. _transformMatrixTexture: Nullable<RawTexture>;
  116019. /**
  116020. * Gets or sets a skeleton to apply skining transformations
  116021. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  116022. */
  116023. set skeleton(value: Nullable<Skeleton>);
  116024. get skeleton(): Nullable<Skeleton>;
  116025. /**
  116026. * An event triggered when the mesh is rebuilt.
  116027. */
  116028. onRebuildObservable: Observable<AbstractMesh>;
  116029. /**
  116030. * Creates a new AbstractMesh
  116031. * @param name defines the name of the mesh
  116032. * @param scene defines the hosting scene
  116033. */
  116034. constructor(name: string, scene?: Nullable<Scene>);
  116035. /**
  116036. * Returns the string "AbstractMesh"
  116037. * @returns "AbstractMesh"
  116038. */
  116039. getClassName(): string;
  116040. /**
  116041. * Gets a string representation of the current mesh
  116042. * @param fullDetails defines a boolean indicating if full details must be included
  116043. * @returns a string representation of the current mesh
  116044. */
  116045. toString(fullDetails?: boolean): string;
  116046. /**
  116047. * @hidden
  116048. */
  116049. protected _getEffectiveParent(): Nullable<Node>;
  116050. /** @hidden */
  116051. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  116052. /** @hidden */
  116053. _rebuild(): void;
  116054. /** @hidden */
  116055. _resyncLightSources(): void;
  116056. /** @hidden */
  116057. _resyncLightSource(light: Light): void;
  116058. /** @hidden */
  116059. _unBindEffect(): void;
  116060. /** @hidden */
  116061. _removeLightSource(light: Light, dispose: boolean): void;
  116062. private _markSubMeshesAsDirty;
  116063. /** @hidden */
  116064. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  116065. /** @hidden */
  116066. _markSubMeshesAsAttributesDirty(): void;
  116067. /** @hidden */
  116068. _markSubMeshesAsMiscDirty(): void;
  116069. /**
  116070. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  116071. */
  116072. get scaling(): Vector3;
  116073. set scaling(newScaling: Vector3);
  116074. /**
  116075. * Returns true if the mesh is blocked. Implemented by child classes
  116076. */
  116077. get isBlocked(): boolean;
  116078. /**
  116079. * Returns the mesh itself by default. Implemented by child classes
  116080. * @param camera defines the camera to use to pick the right LOD level
  116081. * @returns the currentAbstractMesh
  116082. */
  116083. getLOD(camera: Camera): Nullable<AbstractMesh>;
  116084. /**
  116085. * Returns 0 by default. Implemented by child classes
  116086. * @returns an integer
  116087. */
  116088. getTotalVertices(): number;
  116089. /**
  116090. * Returns a positive integer : the total number of indices in this mesh geometry.
  116091. * @returns the numner of indices or zero if the mesh has no geometry.
  116092. */
  116093. getTotalIndices(): number;
  116094. /**
  116095. * Returns null by default. Implemented by child classes
  116096. * @returns null
  116097. */
  116098. getIndices(): Nullable<IndicesArray>;
  116099. /**
  116100. * Returns the array of the requested vertex data kind. Implemented by child classes
  116101. * @param kind defines the vertex data kind to use
  116102. * @returns null
  116103. */
  116104. getVerticesData(kind: string): Nullable<FloatArray>;
  116105. /**
  116106. * Sets the vertex data of the mesh geometry for the requested `kind`.
  116107. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  116108. * Note that a new underlying VertexBuffer object is created each call.
  116109. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  116110. * @param kind defines vertex data kind:
  116111. * * VertexBuffer.PositionKind
  116112. * * VertexBuffer.UVKind
  116113. * * VertexBuffer.UV2Kind
  116114. * * VertexBuffer.UV3Kind
  116115. * * VertexBuffer.UV4Kind
  116116. * * VertexBuffer.UV5Kind
  116117. * * VertexBuffer.UV6Kind
  116118. * * VertexBuffer.ColorKind
  116119. * * VertexBuffer.MatricesIndicesKind
  116120. * * VertexBuffer.MatricesIndicesExtraKind
  116121. * * VertexBuffer.MatricesWeightsKind
  116122. * * VertexBuffer.MatricesWeightsExtraKind
  116123. * @param data defines the data source
  116124. * @param updatable defines if the data must be flagged as updatable (or static)
  116125. * @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
  116126. * @returns the current mesh
  116127. */
  116128. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  116129. /**
  116130. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  116131. * If the mesh has no geometry, it is simply returned as it is.
  116132. * @param kind defines vertex data kind:
  116133. * * VertexBuffer.PositionKind
  116134. * * VertexBuffer.UVKind
  116135. * * VertexBuffer.UV2Kind
  116136. * * VertexBuffer.UV3Kind
  116137. * * VertexBuffer.UV4Kind
  116138. * * VertexBuffer.UV5Kind
  116139. * * VertexBuffer.UV6Kind
  116140. * * VertexBuffer.ColorKind
  116141. * * VertexBuffer.MatricesIndicesKind
  116142. * * VertexBuffer.MatricesIndicesExtraKind
  116143. * * VertexBuffer.MatricesWeightsKind
  116144. * * VertexBuffer.MatricesWeightsExtraKind
  116145. * @param data defines the data source
  116146. * @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
  116147. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  116148. * @returns the current mesh
  116149. */
  116150. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  116151. /**
  116152. * Sets the mesh indices,
  116153. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  116154. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  116155. * @param totalVertices Defines the total number of vertices
  116156. * @returns the current mesh
  116157. */
  116158. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  116159. /**
  116160. * Gets a boolean indicating if specific vertex data is present
  116161. * @param kind defines the vertex data kind to use
  116162. * @returns true is data kind is present
  116163. */
  116164. isVerticesDataPresent(kind: string): boolean;
  116165. /**
  116166. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  116167. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  116168. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  116169. * @returns a BoundingInfo
  116170. */
  116171. getBoundingInfo(): BoundingInfo;
  116172. /**
  116173. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  116174. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  116175. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  116176. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  116177. * @returns the current mesh
  116178. */
  116179. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  116180. /**
  116181. * Overwrite the current bounding info
  116182. * @param boundingInfo defines the new bounding info
  116183. * @returns the current mesh
  116184. */
  116185. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  116186. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  116187. get useBones(): boolean;
  116188. /** @hidden */
  116189. _preActivate(): void;
  116190. /** @hidden */
  116191. _preActivateForIntermediateRendering(renderId: number): void;
  116192. /** @hidden */
  116193. _activate(renderId: number, intermediateRendering: boolean): boolean;
  116194. /** @hidden */
  116195. _postActivate(): void;
  116196. /** @hidden */
  116197. _freeze(): void;
  116198. /** @hidden */
  116199. _unFreeze(): void;
  116200. /**
  116201. * Gets the current world matrix
  116202. * @returns a Matrix
  116203. */
  116204. getWorldMatrix(): Matrix;
  116205. /** @hidden */
  116206. _getWorldMatrixDeterminant(): number;
  116207. /**
  116208. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  116209. */
  116210. get isAnInstance(): boolean;
  116211. /**
  116212. * Gets a boolean indicating if this mesh has instances
  116213. */
  116214. get hasInstances(): boolean;
  116215. /**
  116216. * Gets a boolean indicating if this mesh has thin instances
  116217. */
  116218. get hasThinInstances(): boolean;
  116219. /**
  116220. * Perform 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 current mesh
  116227. */
  116228. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  116229. /**
  116230. * Calculate relative position change from the point of view of behind the front of the mesh.
  116231. * This is performed taking into account the meshes current rotation, so you do not have to care.
  116232. * Supports definition of mesh facing forward or backward
  116233. * @param amountRight defines the distance on the right axis
  116234. * @param amountUp defines the distance on the up axis
  116235. * @param amountForward defines the distance on the forward axis
  116236. * @returns the new displacement vector
  116237. */
  116238. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  116239. /**
  116240. * Perform relative rotation change from the point of view of behind the front of the mesh.
  116241. * Supports definition of mesh facing forward or backward
  116242. * @param flipBack defines the flip
  116243. * @param twirlClockwise defines the twirl
  116244. * @param tiltRight defines the tilt
  116245. * @returns the current mesh
  116246. */
  116247. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  116248. /**
  116249. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  116250. * Supports definition of mesh facing forward or backward.
  116251. * @param flipBack defines the flip
  116252. * @param twirlClockwise defines the twirl
  116253. * @param tiltRight defines the tilt
  116254. * @returns the new rotation vector
  116255. */
  116256. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  116257. /**
  116258. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  116259. * This means the mesh underlying bounding box and sphere are recomputed.
  116260. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  116261. * @returns the current mesh
  116262. */
  116263. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  116264. /** @hidden */
  116265. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  116266. /** @hidden */
  116267. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  116268. /** @hidden */
  116269. _updateBoundingInfo(): AbstractMesh;
  116270. /** @hidden */
  116271. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  116272. /** @hidden */
  116273. protected _afterComputeWorldMatrix(): void;
  116274. /** @hidden */
  116275. get _effectiveMesh(): AbstractMesh;
  116276. /**
  116277. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  116278. * A mesh is in the frustum if its bounding box intersects the frustum
  116279. * @param frustumPlanes defines the frustum to test
  116280. * @returns true if the mesh is in the frustum planes
  116281. */
  116282. isInFrustum(frustumPlanes: Plane[]): boolean;
  116283. /**
  116284. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  116285. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  116286. * @param frustumPlanes defines the frustum to test
  116287. * @returns true if the mesh is completely in the frustum planes
  116288. */
  116289. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  116290. /**
  116291. * True if the mesh intersects another mesh or a SolidParticle object
  116292. * @param mesh defines a target mesh or SolidParticle to test
  116293. * @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)
  116294. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  116295. * @returns true if there is an intersection
  116296. */
  116297. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  116298. /**
  116299. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  116300. * @param point defines the point to test
  116301. * @returns true if there is an intersection
  116302. */
  116303. intersectsPoint(point: Vector3): boolean;
  116304. /**
  116305. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  116306. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116307. */
  116308. get checkCollisions(): boolean;
  116309. set checkCollisions(collisionEnabled: boolean);
  116310. /**
  116311. * Gets Collider object used to compute collisions (not physics)
  116312. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116313. */
  116314. get collider(): Nullable<Collider>;
  116315. /**
  116316. * Move the mesh using collision engine
  116317. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116318. * @param displacement defines the requested displacement vector
  116319. * @returns the current mesh
  116320. */
  116321. moveWithCollisions(displacement: Vector3): AbstractMesh;
  116322. private _onCollisionPositionChange;
  116323. /** @hidden */
  116324. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  116325. /** @hidden */
  116326. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  116327. /** @hidden */
  116328. _checkCollision(collider: Collider): AbstractMesh;
  116329. /** @hidden */
  116330. _generatePointsArray(): boolean;
  116331. /**
  116332. * Checks if the passed Ray intersects with the mesh
  116333. * @param ray defines the ray to use
  116334. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  116335. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116336. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  116337. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  116338. * @returns the picking info
  116339. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  116340. */
  116341. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  116342. /**
  116343. * Clones the current mesh
  116344. * @param name defines the mesh name
  116345. * @param newParent defines the new mesh parent
  116346. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  116347. * @returns the new mesh
  116348. */
  116349. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  116350. /**
  116351. * Disposes all the submeshes of the current meshnp
  116352. * @returns the current mesh
  116353. */
  116354. releaseSubMeshes(): AbstractMesh;
  116355. /**
  116356. * Releases resources associated with this abstract mesh.
  116357. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116358. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116359. */
  116360. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116361. /**
  116362. * Adds the passed mesh as a child to the current mesh
  116363. * @param mesh defines the child mesh
  116364. * @returns the current mesh
  116365. */
  116366. addChild(mesh: AbstractMesh): AbstractMesh;
  116367. /**
  116368. * Removes the passed mesh from the current mesh children list
  116369. * @param mesh defines the child mesh
  116370. * @returns the current mesh
  116371. */
  116372. removeChild(mesh: AbstractMesh): AbstractMesh;
  116373. /** @hidden */
  116374. private _initFacetData;
  116375. /**
  116376. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  116377. * This method can be called within the render loop.
  116378. * 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
  116379. * @returns the current mesh
  116380. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116381. */
  116382. updateFacetData(): AbstractMesh;
  116383. /**
  116384. * Returns the facetLocalNormals array.
  116385. * The normals are expressed in the mesh local spac
  116386. * @returns an array of Vector3
  116387. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116388. */
  116389. getFacetLocalNormals(): Vector3[];
  116390. /**
  116391. * Returns the facetLocalPositions array.
  116392. * The facet positions are expressed in the mesh local space
  116393. * @returns an array of Vector3
  116394. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116395. */
  116396. getFacetLocalPositions(): Vector3[];
  116397. /**
  116398. * Returns the facetLocalPartioning array
  116399. * @returns an array of array of numbers
  116400. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116401. */
  116402. getFacetLocalPartitioning(): number[][];
  116403. /**
  116404. * Returns the i-th facet position in the world system.
  116405. * This method allocates a new Vector3 per call
  116406. * @param i defines the facet index
  116407. * @returns a new Vector3
  116408. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116409. */
  116410. getFacetPosition(i: number): Vector3;
  116411. /**
  116412. * Sets the reference Vector3 with the i-th facet position in the world system
  116413. * @param i defines the facet index
  116414. * @param ref defines the target vector
  116415. * @returns the current mesh
  116416. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116417. */
  116418. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  116419. /**
  116420. * Returns the i-th facet normal in the world system.
  116421. * This method allocates a new Vector3 per call
  116422. * @param i defines the facet index
  116423. * @returns a new Vector3
  116424. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116425. */
  116426. getFacetNormal(i: number): Vector3;
  116427. /**
  116428. * Sets the reference Vector3 with the i-th facet normal in the world system
  116429. * @param i defines the facet index
  116430. * @param ref defines the target vector
  116431. * @returns the current mesh
  116432. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116433. */
  116434. getFacetNormalToRef(i: number, ref: Vector3): this;
  116435. /**
  116436. * 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)
  116437. * @param x defines x coordinate
  116438. * @param y defines y coordinate
  116439. * @param z defines z coordinate
  116440. * @returns the array of facet indexes
  116441. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116442. */
  116443. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  116444. /**
  116445. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  116446. * @param projected sets as the (x,y,z) world projection on the facet
  116447. * @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
  116448. * @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
  116449. * @param x defines x coordinate
  116450. * @param y defines y coordinate
  116451. * @param z defines z coordinate
  116452. * @returns the face index if found (or null instead)
  116453. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116454. */
  116455. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116456. /**
  116457. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  116458. * @param projected sets as the (x,y,z) local projection on the facet
  116459. * @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
  116460. * @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
  116461. * @param x defines x coordinate
  116462. * @param y defines y coordinate
  116463. * @param z defines z coordinate
  116464. * @returns the face index if found (or null instead)
  116465. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116466. */
  116467. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116468. /**
  116469. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  116470. * @returns the parameters
  116471. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116472. */
  116473. getFacetDataParameters(): any;
  116474. /**
  116475. * Disables the feature FacetData and frees the related memory
  116476. * @returns the current mesh
  116477. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116478. */
  116479. disableFacetData(): AbstractMesh;
  116480. /**
  116481. * Updates the AbstractMesh indices array
  116482. * @param indices defines the data source
  116483. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  116484. * @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)
  116485. * @returns the current mesh
  116486. */
  116487. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  116488. /**
  116489. * Creates new normals data for the mesh
  116490. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  116491. * @returns the current mesh
  116492. */
  116493. createNormals(updatable: boolean): AbstractMesh;
  116494. /**
  116495. * Align the mesh with a normal
  116496. * @param normal defines the normal to use
  116497. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  116498. * @returns the current mesh
  116499. */
  116500. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  116501. /** @hidden */
  116502. _checkOcclusionQuery(): boolean;
  116503. /**
  116504. * Disables the mesh edge rendering mode
  116505. * @returns the currentAbstractMesh
  116506. */
  116507. disableEdgesRendering(): AbstractMesh;
  116508. /**
  116509. * Enables the edge rendering mode on the mesh.
  116510. * This mode makes the mesh edges visible
  116511. * @param epsilon defines the maximal distance between two angles to detect a face
  116512. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  116513. * @returns the currentAbstractMesh
  116514. * @see https://www.babylonjs-playground.com/#19O9TU#0
  116515. */
  116516. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  116517. /**
  116518. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  116519. * @returns an array of particle systems in the scene that use the mesh as an emitter
  116520. */
  116521. getConnectedParticleSystems(): IParticleSystem[];
  116522. }
  116523. }
  116524. declare module BABYLON {
  116525. /**
  116526. * Interface used to define ActionEvent
  116527. */
  116528. export interface IActionEvent {
  116529. /** The mesh or sprite that triggered the action */
  116530. source: any;
  116531. /** The X mouse cursor position at the time of the event */
  116532. pointerX: number;
  116533. /** The Y mouse cursor position at the time of the event */
  116534. pointerY: number;
  116535. /** The mesh that is currently pointed at (can be null) */
  116536. meshUnderPointer: Nullable<AbstractMesh>;
  116537. /** the original (browser) event that triggered the ActionEvent */
  116538. sourceEvent?: any;
  116539. /** additional data for the event */
  116540. additionalData?: any;
  116541. }
  116542. /**
  116543. * ActionEvent is the event being sent when an action is triggered.
  116544. */
  116545. export class ActionEvent implements IActionEvent {
  116546. /** The mesh or sprite that triggered the action */
  116547. source: any;
  116548. /** The X mouse cursor position at the time of the event */
  116549. pointerX: number;
  116550. /** The Y mouse cursor position at the time of the event */
  116551. pointerY: number;
  116552. /** The mesh that is currently pointed at (can be null) */
  116553. meshUnderPointer: Nullable<AbstractMesh>;
  116554. /** the original (browser) event that triggered the ActionEvent */
  116555. sourceEvent?: any;
  116556. /** additional data for the event */
  116557. additionalData?: any;
  116558. /**
  116559. * Creates a new ActionEvent
  116560. * @param source The mesh or sprite that triggered the action
  116561. * @param pointerX The X mouse cursor position at the time of the event
  116562. * @param pointerY The Y mouse cursor position at the time of the event
  116563. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  116564. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  116565. * @param additionalData additional data for the event
  116566. */
  116567. constructor(
  116568. /** The mesh or sprite that triggered the action */
  116569. source: any,
  116570. /** The X mouse cursor position at the time of the event */
  116571. pointerX: number,
  116572. /** The Y mouse cursor position at the time of the event */
  116573. pointerY: number,
  116574. /** The mesh that is currently pointed at (can be null) */
  116575. meshUnderPointer: Nullable<AbstractMesh>,
  116576. /** the original (browser) event that triggered the ActionEvent */
  116577. sourceEvent?: any,
  116578. /** additional data for the event */
  116579. additionalData?: any);
  116580. /**
  116581. * Helper function to auto-create an ActionEvent from a source mesh.
  116582. * @param source The source mesh that triggered the event
  116583. * @param evt The original (browser) event
  116584. * @param additionalData additional data for the event
  116585. * @returns the new ActionEvent
  116586. */
  116587. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  116588. /**
  116589. * Helper function to auto-create an ActionEvent from a source sprite
  116590. * @param source The source sprite that triggered the event
  116591. * @param scene Scene associated with the sprite
  116592. * @param evt The original (browser) event
  116593. * @param additionalData additional data for the event
  116594. * @returns the new ActionEvent
  116595. */
  116596. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  116597. /**
  116598. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  116599. * @param scene the scene where the event occurred
  116600. * @param evt The original (browser) event
  116601. * @returns the new ActionEvent
  116602. */
  116603. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  116604. /**
  116605. * Helper function to auto-create an ActionEvent from a primitive
  116606. * @param prim defines the target primitive
  116607. * @param pointerPos defines the pointer position
  116608. * @param evt The original (browser) event
  116609. * @param additionalData additional data for the event
  116610. * @returns the new ActionEvent
  116611. */
  116612. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  116613. }
  116614. }
  116615. declare module BABYLON {
  116616. /**
  116617. * Abstract class used to decouple action Manager from scene and meshes.
  116618. * Do not instantiate.
  116619. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116620. */
  116621. export abstract class AbstractActionManager implements IDisposable {
  116622. /** Gets the list of active triggers */
  116623. static Triggers: {
  116624. [key: string]: number;
  116625. };
  116626. /** Gets the cursor to use when hovering items */
  116627. hoverCursor: string;
  116628. /** Gets the list of actions */
  116629. actions: IAction[];
  116630. /**
  116631. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  116632. */
  116633. isRecursive: boolean;
  116634. /**
  116635. * Releases all associated resources
  116636. */
  116637. abstract dispose(): void;
  116638. /**
  116639. * Does this action manager has pointer triggers
  116640. */
  116641. abstract get hasPointerTriggers(): boolean;
  116642. /**
  116643. * Does this action manager has pick triggers
  116644. */
  116645. abstract get hasPickTriggers(): boolean;
  116646. /**
  116647. * Process a specific trigger
  116648. * @param trigger defines the trigger to process
  116649. * @param evt defines the event details to be processed
  116650. */
  116651. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  116652. /**
  116653. * Does this action manager handles actions of any of the given triggers
  116654. * @param triggers defines the triggers to be tested
  116655. * @return a boolean indicating whether one (or more) of the triggers is handled
  116656. */
  116657. abstract hasSpecificTriggers(triggers: number[]): boolean;
  116658. /**
  116659. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  116660. * speed.
  116661. * @param triggerA defines the trigger to be tested
  116662. * @param triggerB defines the trigger to be tested
  116663. * @return a boolean indicating whether one (or more) of the triggers is handled
  116664. */
  116665. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  116666. /**
  116667. * Does this action manager handles actions of a given trigger
  116668. * @param trigger defines the trigger to be tested
  116669. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  116670. * @return whether the trigger is handled
  116671. */
  116672. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  116673. /**
  116674. * Serialize this manager to a JSON object
  116675. * @param name defines the property name to store this manager
  116676. * @returns a JSON representation of this manager
  116677. */
  116678. abstract serialize(name: string): any;
  116679. /**
  116680. * Registers an action to this action manager
  116681. * @param action defines the action to be registered
  116682. * @return the action amended (prepared) after registration
  116683. */
  116684. abstract registerAction(action: IAction): Nullable<IAction>;
  116685. /**
  116686. * Unregisters an action to this action manager
  116687. * @param action defines the action to be unregistered
  116688. * @return a boolean indicating whether the action has been unregistered
  116689. */
  116690. abstract unregisterAction(action: IAction): Boolean;
  116691. /**
  116692. * Does exist one action manager with at least one trigger
  116693. **/
  116694. static get HasTriggers(): boolean;
  116695. /**
  116696. * Does exist one action manager with at least one pick trigger
  116697. **/
  116698. static get HasPickTriggers(): boolean;
  116699. /**
  116700. * Does exist one action manager that handles actions of a given trigger
  116701. * @param trigger defines the trigger to be tested
  116702. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  116703. **/
  116704. static HasSpecificTrigger(trigger: number): boolean;
  116705. }
  116706. }
  116707. declare module BABYLON {
  116708. /**
  116709. * Defines how a node can be built from a string name.
  116710. */
  116711. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  116712. /**
  116713. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  116714. */
  116715. export class Node implements IBehaviorAware<Node> {
  116716. /** @hidden */
  116717. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  116718. private static _NodeConstructors;
  116719. /**
  116720. * Add a new node constructor
  116721. * @param type defines the type name of the node to construct
  116722. * @param constructorFunc defines the constructor function
  116723. */
  116724. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  116725. /**
  116726. * Returns a node constructor based on type name
  116727. * @param type defines the type name
  116728. * @param name defines the new node name
  116729. * @param scene defines the hosting scene
  116730. * @param options defines optional options to transmit to constructors
  116731. * @returns the new constructor or null
  116732. */
  116733. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  116734. /**
  116735. * Gets or sets the name of the node
  116736. */
  116737. name: string;
  116738. /**
  116739. * Gets or sets the id of the node
  116740. */
  116741. id: string;
  116742. /**
  116743. * Gets or sets the unique id of the node
  116744. */
  116745. uniqueId: number;
  116746. /**
  116747. * Gets or sets a string used to store user defined state for the node
  116748. */
  116749. state: string;
  116750. /**
  116751. * Gets or sets an object used to store user defined information for the node
  116752. */
  116753. metadata: any;
  116754. /**
  116755. * For internal use only. Please do not use.
  116756. */
  116757. reservedDataStore: any;
  116758. /**
  116759. * List of inspectable custom properties (used by the Inspector)
  116760. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  116761. */
  116762. inspectableCustomProperties: IInspectable[];
  116763. private _doNotSerialize;
  116764. /**
  116765. * Gets or sets a boolean used to define if the node must be serialized
  116766. */
  116767. get doNotSerialize(): boolean;
  116768. set doNotSerialize(value: boolean);
  116769. /** @hidden */
  116770. _isDisposed: boolean;
  116771. /**
  116772. * Gets a list of Animations associated with the node
  116773. */
  116774. animations: Animation[];
  116775. protected _ranges: {
  116776. [name: string]: Nullable<AnimationRange>;
  116777. };
  116778. /**
  116779. * Callback raised when the node is ready to be used
  116780. */
  116781. onReady: Nullable<(node: Node) => void>;
  116782. private _isEnabled;
  116783. private _isParentEnabled;
  116784. private _isReady;
  116785. /** @hidden */
  116786. _currentRenderId: number;
  116787. private _parentUpdateId;
  116788. /** @hidden */
  116789. _childUpdateId: number;
  116790. /** @hidden */
  116791. _waitingParentId: Nullable<string>;
  116792. /** @hidden */
  116793. _scene: Scene;
  116794. /** @hidden */
  116795. _cache: any;
  116796. private _parentNode;
  116797. private _children;
  116798. /** @hidden */
  116799. _worldMatrix: Matrix;
  116800. /** @hidden */
  116801. _worldMatrixDeterminant: number;
  116802. /** @hidden */
  116803. _worldMatrixDeterminantIsDirty: boolean;
  116804. /** @hidden */
  116805. private _sceneRootNodesIndex;
  116806. /**
  116807. * Gets a boolean indicating if the node has been disposed
  116808. * @returns true if the node was disposed
  116809. */
  116810. isDisposed(): boolean;
  116811. /**
  116812. * Gets or sets the parent of the node (without keeping the current position in the scene)
  116813. * @see https://doc.babylonjs.com/how_to/parenting
  116814. */
  116815. set parent(parent: Nullable<Node>);
  116816. get parent(): Nullable<Node>;
  116817. /** @hidden */
  116818. _addToSceneRootNodes(): void;
  116819. /** @hidden */
  116820. _removeFromSceneRootNodes(): void;
  116821. private _animationPropertiesOverride;
  116822. /**
  116823. * Gets or sets the animation properties override
  116824. */
  116825. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116826. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116827. /**
  116828. * Gets a string identifying the name of the class
  116829. * @returns "Node" string
  116830. */
  116831. getClassName(): string;
  116832. /** @hidden */
  116833. readonly _isNode: boolean;
  116834. /**
  116835. * An event triggered when the mesh is disposed
  116836. */
  116837. onDisposeObservable: Observable<Node>;
  116838. private _onDisposeObserver;
  116839. /**
  116840. * Sets a callback that will be raised when the node will be disposed
  116841. */
  116842. set onDispose(callback: () => void);
  116843. /**
  116844. * Creates a new Node
  116845. * @param name the name and id to be given to this node
  116846. * @param scene the scene this node will be added to
  116847. */
  116848. constructor(name: string, scene?: Nullable<Scene>);
  116849. /**
  116850. * Gets the scene of the node
  116851. * @returns a scene
  116852. */
  116853. getScene(): Scene;
  116854. /**
  116855. * Gets the engine of the node
  116856. * @returns a Engine
  116857. */
  116858. getEngine(): Engine;
  116859. private _behaviors;
  116860. /**
  116861. * Attach a behavior to the node
  116862. * @see https://doc.babylonjs.com/features/behaviour
  116863. * @param behavior defines the behavior to attach
  116864. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  116865. * @returns the current Node
  116866. */
  116867. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  116868. /**
  116869. * Remove an attached behavior
  116870. * @see https://doc.babylonjs.com/features/behaviour
  116871. * @param behavior defines the behavior to attach
  116872. * @returns the current Node
  116873. */
  116874. removeBehavior(behavior: Behavior<Node>): Node;
  116875. /**
  116876. * Gets the list of attached behaviors
  116877. * @see https://doc.babylonjs.com/features/behaviour
  116878. */
  116879. get behaviors(): Behavior<Node>[];
  116880. /**
  116881. * Gets an attached behavior by name
  116882. * @param name defines the name of the behavior to look for
  116883. * @see https://doc.babylonjs.com/features/behaviour
  116884. * @returns null if behavior was not found else the requested behavior
  116885. */
  116886. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  116887. /**
  116888. * Returns the latest update of the World matrix
  116889. * @returns a Matrix
  116890. */
  116891. getWorldMatrix(): Matrix;
  116892. /** @hidden */
  116893. _getWorldMatrixDeterminant(): number;
  116894. /**
  116895. * Returns directly the latest state of the mesh World matrix.
  116896. * A Matrix is returned.
  116897. */
  116898. get worldMatrixFromCache(): Matrix;
  116899. /** @hidden */
  116900. _initCache(): void;
  116901. /** @hidden */
  116902. updateCache(force?: boolean): void;
  116903. /** @hidden */
  116904. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  116905. /** @hidden */
  116906. _updateCache(ignoreParentClass?: boolean): void;
  116907. /** @hidden */
  116908. _isSynchronized(): boolean;
  116909. /** @hidden */
  116910. _markSyncedWithParent(): void;
  116911. /** @hidden */
  116912. isSynchronizedWithParent(): boolean;
  116913. /** @hidden */
  116914. isSynchronized(): boolean;
  116915. /**
  116916. * Is this node ready to be used/rendered
  116917. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  116918. * @return true if the node is ready
  116919. */
  116920. isReady(completeCheck?: boolean): boolean;
  116921. /**
  116922. * Is this node enabled?
  116923. * 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
  116924. * @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
  116925. * @return whether this node (and its parent) is enabled
  116926. */
  116927. isEnabled(checkAncestors?: boolean): boolean;
  116928. /** @hidden */
  116929. protected _syncParentEnabledState(): void;
  116930. /**
  116931. * Set the enabled state of this node
  116932. * @param value defines the new enabled state
  116933. */
  116934. setEnabled(value: boolean): void;
  116935. /**
  116936. * Is this node a descendant of the given node?
  116937. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  116938. * @param ancestor defines the parent node to inspect
  116939. * @returns a boolean indicating if this node is a descendant of the given node
  116940. */
  116941. isDescendantOf(ancestor: Node): boolean;
  116942. /** @hidden */
  116943. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  116944. /**
  116945. * Will return all nodes that have this node as ascendant
  116946. * @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
  116947. * @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
  116948. * @return all children nodes of all types
  116949. */
  116950. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  116951. /**
  116952. * Get all child-meshes of this node
  116953. * @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)
  116954. * @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
  116955. * @returns an array of AbstractMesh
  116956. */
  116957. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  116958. /**
  116959. * Get all direct children of this node
  116960. * @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
  116961. * @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)
  116962. * @returns an array of Node
  116963. */
  116964. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  116965. /** @hidden */
  116966. _setReady(state: boolean): void;
  116967. /**
  116968. * Get an animation by name
  116969. * @param name defines the name of the animation to look for
  116970. * @returns null if not found else the requested animation
  116971. */
  116972. getAnimationByName(name: string): Nullable<Animation>;
  116973. /**
  116974. * Creates an animation range for this node
  116975. * @param name defines the name of the range
  116976. * @param from defines the starting key
  116977. * @param to defines the end key
  116978. */
  116979. createAnimationRange(name: string, from: number, to: number): void;
  116980. /**
  116981. * Delete a specific animation range
  116982. * @param name defines the name of the range to delete
  116983. * @param deleteFrames defines if animation frames from the range must be deleted as well
  116984. */
  116985. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  116986. /**
  116987. * Get an animation range by name
  116988. * @param name defines the name of the animation range to look for
  116989. * @returns null if not found else the requested animation range
  116990. */
  116991. getAnimationRange(name: string): Nullable<AnimationRange>;
  116992. /**
  116993. * Gets the list of all animation ranges defined on this node
  116994. * @returns an array
  116995. */
  116996. getAnimationRanges(): Nullable<AnimationRange>[];
  116997. /**
  116998. * Will start the animation sequence
  116999. * @param name defines the range frames for animation sequence
  117000. * @param loop defines if the animation should loop (false by default)
  117001. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  117002. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  117003. * @returns the object created for this animation. If range does not exist, it will return null
  117004. */
  117005. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  117006. /**
  117007. * Serialize animation ranges into a JSON compatible object
  117008. * @returns serialization object
  117009. */
  117010. serializeAnimationRanges(): any;
  117011. /**
  117012. * Computes the world matrix of the node
  117013. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  117014. * @returns the world matrix
  117015. */
  117016. computeWorldMatrix(force?: boolean): Matrix;
  117017. /**
  117018. * Releases resources associated with this node.
  117019. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117020. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117021. */
  117022. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117023. /**
  117024. * Parse animation range data from a serialization object and store them into a given node
  117025. * @param node defines where to store the animation ranges
  117026. * @param parsedNode defines the serialization object to read data from
  117027. * @param scene defines the hosting scene
  117028. */
  117029. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  117030. /**
  117031. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  117032. * @param includeDescendants Include bounding info from descendants as well (true by default)
  117033. * @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
  117034. * @returns the new bounding vectors
  117035. */
  117036. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  117037. min: Vector3;
  117038. max: Vector3;
  117039. };
  117040. }
  117041. }
  117042. declare module BABYLON {
  117043. /**
  117044. * @hidden
  117045. */
  117046. export class _IAnimationState {
  117047. key: number;
  117048. repeatCount: number;
  117049. workValue?: any;
  117050. loopMode?: number;
  117051. offsetValue?: any;
  117052. highLimitValue?: any;
  117053. }
  117054. /**
  117055. * Class used to store any kind of animation
  117056. */
  117057. export class Animation {
  117058. /**Name of the animation */
  117059. name: string;
  117060. /**Property to animate */
  117061. targetProperty: string;
  117062. /**The frames per second of the animation */
  117063. framePerSecond: number;
  117064. /**The data type of the animation */
  117065. dataType: number;
  117066. /**The loop mode of the animation */
  117067. loopMode?: number | undefined;
  117068. /**Specifies if blending should be enabled */
  117069. enableBlending?: boolean | undefined;
  117070. /**
  117071. * Use matrix interpolation instead of using direct key value when animating matrices
  117072. */
  117073. static AllowMatricesInterpolation: boolean;
  117074. /**
  117075. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  117076. */
  117077. static AllowMatrixDecomposeForInterpolation: boolean;
  117078. /** Define the Url to load snippets */
  117079. static SnippetUrl: string;
  117080. /** Snippet ID if the animation was created from the snippet server */
  117081. snippetId: string;
  117082. /**
  117083. * Stores the key frames of the animation
  117084. */
  117085. private _keys;
  117086. /**
  117087. * Stores the easing function of the animation
  117088. */
  117089. private _easingFunction;
  117090. /**
  117091. * @hidden Internal use only
  117092. */
  117093. _runtimeAnimations: RuntimeAnimation[];
  117094. /**
  117095. * The set of event that will be linked to this animation
  117096. */
  117097. private _events;
  117098. /**
  117099. * Stores an array of target property paths
  117100. */
  117101. targetPropertyPath: string[];
  117102. /**
  117103. * Stores the blending speed of the animation
  117104. */
  117105. blendingSpeed: number;
  117106. /**
  117107. * Stores the animation ranges for the animation
  117108. */
  117109. private _ranges;
  117110. /**
  117111. * @hidden Internal use
  117112. */
  117113. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  117114. /**
  117115. * Sets up an animation
  117116. * @param property The property to animate
  117117. * @param animationType The animation type to apply
  117118. * @param framePerSecond The frames per second of the animation
  117119. * @param easingFunction The easing function used in the animation
  117120. * @returns The created animation
  117121. */
  117122. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  117123. /**
  117124. * Create and start an animation on a node
  117125. * @param name defines the name of the global animation that will be run on all nodes
  117126. * @param node defines the root node where the animation will take place
  117127. * @param targetProperty defines property to animate
  117128. * @param framePerSecond defines the number of frame per second yo use
  117129. * @param totalFrame defines the number of frames in total
  117130. * @param from defines the initial value
  117131. * @param to defines the final value
  117132. * @param loopMode defines which loop mode you want to use (off by default)
  117133. * @param easingFunction defines the easing function to use (linear by default)
  117134. * @param onAnimationEnd defines the callback to call when animation end
  117135. * @returns the animatable created for this animation
  117136. */
  117137. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117138. /**
  117139. * Create and start an animation on a node and its descendants
  117140. * @param name defines the name of the global animation that will be run on all nodes
  117141. * @param node defines the root node where the animation will take place
  117142. * @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
  117143. * @param targetProperty defines property to animate
  117144. * @param framePerSecond defines the number of frame per second to use
  117145. * @param totalFrame defines the number of frames in total
  117146. * @param from defines the initial value
  117147. * @param to defines the final value
  117148. * @param loopMode defines which loop mode you want to use (off by default)
  117149. * @param easingFunction defines the easing function to use (linear by default)
  117150. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  117151. * @returns the list of animatables created for all nodes
  117152. * @example https://www.babylonjs-playground.com/#MH0VLI
  117153. */
  117154. 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[]>;
  117155. /**
  117156. * Creates a new animation, merges it with the existing animations and starts it
  117157. * @param name Name of the animation
  117158. * @param node Node which contains the scene that begins the animations
  117159. * @param targetProperty Specifies which property to animate
  117160. * @param framePerSecond The frames per second of the animation
  117161. * @param totalFrame The total number of frames
  117162. * @param from The frame at the beginning of the animation
  117163. * @param to The frame at the end of the animation
  117164. * @param loopMode Specifies the loop mode of the animation
  117165. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  117166. * @param onAnimationEnd Callback to run once the animation is complete
  117167. * @returns Nullable animation
  117168. */
  117169. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117170. /**
  117171. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  117172. * @param sourceAnimation defines the Animation containing keyframes to convert
  117173. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  117174. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  117175. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  117176. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  117177. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  117178. */
  117179. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  117180. /**
  117181. * Transition property of an host to the target Value
  117182. * @param property The property to transition
  117183. * @param targetValue The target Value of the property
  117184. * @param host The object where the property to animate belongs
  117185. * @param scene Scene used to run the animation
  117186. * @param frameRate Framerate (in frame/s) to use
  117187. * @param transition The transition type we want to use
  117188. * @param duration The duration of the animation, in milliseconds
  117189. * @param onAnimationEnd Callback trigger at the end of the animation
  117190. * @returns Nullable animation
  117191. */
  117192. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  117193. /**
  117194. * Return the array of runtime animations currently using this animation
  117195. */
  117196. get runtimeAnimations(): RuntimeAnimation[];
  117197. /**
  117198. * Specifies if any of the runtime animations are currently running
  117199. */
  117200. get hasRunningRuntimeAnimations(): boolean;
  117201. /**
  117202. * Initializes the animation
  117203. * @param name Name of the animation
  117204. * @param targetProperty Property to animate
  117205. * @param framePerSecond The frames per second of the animation
  117206. * @param dataType The data type of the animation
  117207. * @param loopMode The loop mode of the animation
  117208. * @param enableBlending Specifies if blending should be enabled
  117209. */
  117210. constructor(
  117211. /**Name of the animation */
  117212. name: string,
  117213. /**Property to animate */
  117214. targetProperty: string,
  117215. /**The frames per second of the animation */
  117216. framePerSecond: number,
  117217. /**The data type of the animation */
  117218. dataType: number,
  117219. /**The loop mode of the animation */
  117220. loopMode?: number | undefined,
  117221. /**Specifies if blending should be enabled */
  117222. enableBlending?: boolean | undefined);
  117223. /**
  117224. * Converts the animation to a string
  117225. * @param fullDetails support for multiple levels of logging within scene loading
  117226. * @returns String form of the animation
  117227. */
  117228. toString(fullDetails?: boolean): string;
  117229. /**
  117230. * Add an event to this animation
  117231. * @param event Event to add
  117232. */
  117233. addEvent(event: AnimationEvent): void;
  117234. /**
  117235. * Remove all events found at the given frame
  117236. * @param frame The frame to remove events from
  117237. */
  117238. removeEvents(frame: number): void;
  117239. /**
  117240. * Retrieves all the events from the animation
  117241. * @returns Events from the animation
  117242. */
  117243. getEvents(): AnimationEvent[];
  117244. /**
  117245. * Creates an animation range
  117246. * @param name Name of the animation range
  117247. * @param from Starting frame of the animation range
  117248. * @param to Ending frame of the animation
  117249. */
  117250. createRange(name: string, from: number, to: number): void;
  117251. /**
  117252. * Deletes an animation range by name
  117253. * @param name Name of the animation range to delete
  117254. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  117255. */
  117256. deleteRange(name: string, deleteFrames?: boolean): void;
  117257. /**
  117258. * Gets the animation range by name, or null if not defined
  117259. * @param name Name of the animation range
  117260. * @returns Nullable animation range
  117261. */
  117262. getRange(name: string): Nullable<AnimationRange>;
  117263. /**
  117264. * Gets the key frames from the animation
  117265. * @returns The key frames of the animation
  117266. */
  117267. getKeys(): Array<IAnimationKey>;
  117268. /**
  117269. * Gets the highest frame rate of the animation
  117270. * @returns Highest frame rate of the animation
  117271. */
  117272. getHighestFrame(): number;
  117273. /**
  117274. * Gets the easing function of the animation
  117275. * @returns Easing function of the animation
  117276. */
  117277. getEasingFunction(): IEasingFunction;
  117278. /**
  117279. * Sets the easing function of the animation
  117280. * @param easingFunction A custom mathematical formula for animation
  117281. */
  117282. setEasingFunction(easingFunction: EasingFunction): void;
  117283. /**
  117284. * Interpolates a scalar linearly
  117285. * @param startValue Start value of the animation curve
  117286. * @param endValue End value of the animation curve
  117287. * @param gradient Scalar amount to interpolate
  117288. * @returns Interpolated scalar value
  117289. */
  117290. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  117291. /**
  117292. * Interpolates a scalar cubically
  117293. * @param startValue Start value of the animation curve
  117294. * @param outTangent End tangent of the animation
  117295. * @param endValue End value of the animation curve
  117296. * @param inTangent Start tangent of the animation curve
  117297. * @param gradient Scalar amount to interpolate
  117298. * @returns Interpolated scalar value
  117299. */
  117300. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  117301. /**
  117302. * Interpolates a quaternion using a spherical linear interpolation
  117303. * @param startValue Start value of the animation curve
  117304. * @param endValue End value of the animation curve
  117305. * @param gradient Scalar amount to interpolate
  117306. * @returns Interpolated quaternion value
  117307. */
  117308. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  117309. /**
  117310. * Interpolates a quaternion cubically
  117311. * @param startValue Start value of the animation curve
  117312. * @param outTangent End tangent of the animation curve
  117313. * @param endValue End value of the animation curve
  117314. * @param inTangent Start tangent of the animation curve
  117315. * @param gradient Scalar amount to interpolate
  117316. * @returns Interpolated quaternion value
  117317. */
  117318. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  117319. /**
  117320. * Interpolates a Vector3 linearl
  117321. * @param startValue Start value of the animation curve
  117322. * @param endValue End value of the animation curve
  117323. * @param gradient Scalar amount to interpolate
  117324. * @returns Interpolated scalar value
  117325. */
  117326. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  117327. /**
  117328. * Interpolates a Vector3 cubically
  117329. * @param startValue Start value of the animation curve
  117330. * @param outTangent End tangent of the animation
  117331. * @param endValue End value of the animation curve
  117332. * @param inTangent Start tangent of the animation curve
  117333. * @param gradient Scalar amount to interpolate
  117334. * @returns InterpolatedVector3 value
  117335. */
  117336. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  117337. /**
  117338. * Interpolates a Vector2 linearly
  117339. * @param startValue Start value of the animation curve
  117340. * @param endValue End value of the animation curve
  117341. * @param gradient Scalar amount to interpolate
  117342. * @returns Interpolated Vector2 value
  117343. */
  117344. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  117345. /**
  117346. * Interpolates a Vector2 cubically
  117347. * @param startValue Start value of the animation curve
  117348. * @param outTangent End tangent of the animation
  117349. * @param endValue End value of the animation curve
  117350. * @param inTangent Start tangent of the animation curve
  117351. * @param gradient Scalar amount to interpolate
  117352. * @returns Interpolated Vector2 value
  117353. */
  117354. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  117355. /**
  117356. * Interpolates a size linearly
  117357. * @param startValue Start value of the animation curve
  117358. * @param endValue End value of the animation curve
  117359. * @param gradient Scalar amount to interpolate
  117360. * @returns Interpolated Size value
  117361. */
  117362. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  117363. /**
  117364. * Interpolates a Color3 linearly
  117365. * @param startValue Start value of the animation curve
  117366. * @param endValue End value of the animation curve
  117367. * @param gradient Scalar amount to interpolate
  117368. * @returns Interpolated Color3 value
  117369. */
  117370. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  117371. /**
  117372. * Interpolates a Color4 linearly
  117373. * @param startValue Start value of the animation curve
  117374. * @param endValue End value of the animation curve
  117375. * @param gradient Scalar amount to interpolate
  117376. * @returns Interpolated Color3 value
  117377. */
  117378. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  117379. /**
  117380. * @hidden Internal use only
  117381. */
  117382. _getKeyValue(value: any): any;
  117383. /**
  117384. * @hidden Internal use only
  117385. */
  117386. _interpolate(currentFrame: number, state: _IAnimationState): any;
  117387. /**
  117388. * Defines the function to use to interpolate matrices
  117389. * @param startValue defines the start matrix
  117390. * @param endValue defines the end matrix
  117391. * @param gradient defines the gradient between both matrices
  117392. * @param result defines an optional target matrix where to store the interpolation
  117393. * @returns the interpolated matrix
  117394. */
  117395. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  117396. /**
  117397. * Makes a copy of the animation
  117398. * @returns Cloned animation
  117399. */
  117400. clone(): Animation;
  117401. /**
  117402. * Sets the key frames of the animation
  117403. * @param values The animation key frames to set
  117404. */
  117405. setKeys(values: Array<IAnimationKey>): void;
  117406. /**
  117407. * Serializes the animation to an object
  117408. * @returns Serialized object
  117409. */
  117410. serialize(): any;
  117411. /**
  117412. * Float animation type
  117413. */
  117414. static readonly ANIMATIONTYPE_FLOAT: number;
  117415. /**
  117416. * Vector3 animation type
  117417. */
  117418. static readonly ANIMATIONTYPE_VECTOR3: number;
  117419. /**
  117420. * Quaternion animation type
  117421. */
  117422. static readonly ANIMATIONTYPE_QUATERNION: number;
  117423. /**
  117424. * Matrix animation type
  117425. */
  117426. static readonly ANIMATIONTYPE_MATRIX: number;
  117427. /**
  117428. * Color3 animation type
  117429. */
  117430. static readonly ANIMATIONTYPE_COLOR3: number;
  117431. /**
  117432. * Color3 animation type
  117433. */
  117434. static readonly ANIMATIONTYPE_COLOR4: number;
  117435. /**
  117436. * Vector2 animation type
  117437. */
  117438. static readonly ANIMATIONTYPE_VECTOR2: number;
  117439. /**
  117440. * Size animation type
  117441. */
  117442. static readonly ANIMATIONTYPE_SIZE: number;
  117443. /**
  117444. * Relative Loop Mode
  117445. */
  117446. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  117447. /**
  117448. * Cycle Loop Mode
  117449. */
  117450. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  117451. /**
  117452. * Constant Loop Mode
  117453. */
  117454. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  117455. /** @hidden */
  117456. static _UniversalLerp(left: any, right: any, amount: number): any;
  117457. /**
  117458. * Parses an animation object and creates an animation
  117459. * @param parsedAnimation Parsed animation object
  117460. * @returns Animation object
  117461. */
  117462. static Parse(parsedAnimation: any): Animation;
  117463. /**
  117464. * Appends the serialized animations from the source animations
  117465. * @param source Source containing the animations
  117466. * @param destination Target to store the animations
  117467. */
  117468. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117469. /**
  117470. * Creates a new animation or an array of animations from a snippet saved in a remote file
  117471. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  117472. * @param url defines the url to load from
  117473. * @returns a promise that will resolve to the new animation or an array of animations
  117474. */
  117475. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  117476. /**
  117477. * Creates an animation or an array of animations from a snippet saved by the Inspector
  117478. * @param snippetId defines the snippet to load
  117479. * @returns a promise that will resolve to the new animation or a new array of animations
  117480. */
  117481. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  117482. }
  117483. }
  117484. declare module BABYLON {
  117485. /**
  117486. * Interface containing an array of animations
  117487. */
  117488. export interface IAnimatable {
  117489. /**
  117490. * Array of animations
  117491. */
  117492. animations: Nullable<Array<Animation>>;
  117493. }
  117494. }
  117495. declare module BABYLON {
  117496. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  117497. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117498. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117499. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117500. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117501. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117502. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117503. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117504. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117505. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117506. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117507. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117508. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117509. /**
  117510. * Decorator used to define property that can be serialized as reference to a camera
  117511. * @param sourceName defines the name of the property to decorate
  117512. */
  117513. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117514. /**
  117515. * Class used to help serialization objects
  117516. */
  117517. export class SerializationHelper {
  117518. /** @hidden */
  117519. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  117520. /** @hidden */
  117521. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  117522. /** @hidden */
  117523. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  117524. /** @hidden */
  117525. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  117526. /**
  117527. * Appends the serialized animations from the source animations
  117528. * @param source Source containing the animations
  117529. * @param destination Target to store the animations
  117530. */
  117531. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117532. /**
  117533. * Static function used to serialized a specific entity
  117534. * @param entity defines the entity to serialize
  117535. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  117536. * @returns a JSON compatible object representing the serialization of the entity
  117537. */
  117538. static Serialize<T>(entity: T, serializationObject?: any): any;
  117539. /**
  117540. * Creates a new entity from a serialization data object
  117541. * @param creationFunction defines a function used to instanciated the new entity
  117542. * @param source defines the source serialization data
  117543. * @param scene defines the hosting scene
  117544. * @param rootUrl defines the root url for resources
  117545. * @returns a new entity
  117546. */
  117547. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  117548. /**
  117549. * Clones an object
  117550. * @param creationFunction defines the function used to instanciate the new object
  117551. * @param source defines the source object
  117552. * @returns the cloned object
  117553. */
  117554. static Clone<T>(creationFunction: () => T, source: T): T;
  117555. /**
  117556. * Instanciates a new object based on a source one (some data will be shared between both object)
  117557. * @param creationFunction defines the function used to instanciate the new object
  117558. * @param source defines the source object
  117559. * @returns the new object
  117560. */
  117561. static Instanciate<T>(creationFunction: () => T, source: T): T;
  117562. }
  117563. }
  117564. declare module BABYLON {
  117565. /**
  117566. * Base class of all the textures in babylon.
  117567. * It groups all the common properties the materials, post process, lights... might need
  117568. * in order to make a correct use of the texture.
  117569. */
  117570. export class BaseTexture implements IAnimatable {
  117571. /**
  117572. * Default anisotropic filtering level for the application.
  117573. * It is set to 4 as a good tradeoff between perf and quality.
  117574. */
  117575. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  117576. /**
  117577. * Gets or sets the unique id of the texture
  117578. */
  117579. uniqueId: number;
  117580. /**
  117581. * Define the name of the texture.
  117582. */
  117583. name: string;
  117584. /**
  117585. * Gets or sets an object used to store user defined information.
  117586. */
  117587. metadata: any;
  117588. /**
  117589. * For internal use only. Please do not use.
  117590. */
  117591. reservedDataStore: any;
  117592. private _hasAlpha;
  117593. /**
  117594. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  117595. */
  117596. set hasAlpha(value: boolean);
  117597. get hasAlpha(): boolean;
  117598. /**
  117599. * Defines if the alpha value should be determined via the rgb values.
  117600. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  117601. */
  117602. getAlphaFromRGB: boolean;
  117603. /**
  117604. * Intensity or strength of the texture.
  117605. * It is commonly used by materials to fine tune the intensity of the texture
  117606. */
  117607. level: number;
  117608. /**
  117609. * Define the UV chanel to use starting from 0 and defaulting to 0.
  117610. * This is part of the texture as textures usually maps to one uv set.
  117611. */
  117612. coordinatesIndex: number;
  117613. protected _coordinatesMode: number;
  117614. /**
  117615. * How a texture is mapped.
  117616. *
  117617. * | Value | Type | Description |
  117618. * | ----- | ----------------------------------- | ----------- |
  117619. * | 0 | EXPLICIT_MODE | |
  117620. * | 1 | SPHERICAL_MODE | |
  117621. * | 2 | PLANAR_MODE | |
  117622. * | 3 | CUBIC_MODE | |
  117623. * | 4 | PROJECTION_MODE | |
  117624. * | 5 | SKYBOX_MODE | |
  117625. * | 6 | INVCUBIC_MODE | |
  117626. * | 7 | EQUIRECTANGULAR_MODE | |
  117627. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  117628. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  117629. */
  117630. set coordinatesMode(value: number);
  117631. get coordinatesMode(): number;
  117632. private _wrapU;
  117633. /**
  117634. * | Value | Type | Description |
  117635. * | ----- | ------------------ | ----------- |
  117636. * | 0 | CLAMP_ADDRESSMODE | |
  117637. * | 1 | WRAP_ADDRESSMODE | |
  117638. * | 2 | MIRROR_ADDRESSMODE | |
  117639. */
  117640. get wrapU(): number;
  117641. set wrapU(value: number);
  117642. private _wrapV;
  117643. /**
  117644. * | Value | Type | Description |
  117645. * | ----- | ------------------ | ----------- |
  117646. * | 0 | CLAMP_ADDRESSMODE | |
  117647. * | 1 | WRAP_ADDRESSMODE | |
  117648. * | 2 | MIRROR_ADDRESSMODE | |
  117649. */
  117650. get wrapV(): number;
  117651. set wrapV(value: number);
  117652. /**
  117653. * | Value | Type | Description |
  117654. * | ----- | ------------------ | ----------- |
  117655. * | 0 | CLAMP_ADDRESSMODE | |
  117656. * | 1 | WRAP_ADDRESSMODE | |
  117657. * | 2 | MIRROR_ADDRESSMODE | |
  117658. */
  117659. wrapR: number;
  117660. /**
  117661. * With compliant hardware and browser (supporting anisotropic filtering)
  117662. * this defines the level of anisotropic filtering in the texture.
  117663. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  117664. */
  117665. anisotropicFilteringLevel: number;
  117666. /**
  117667. * Define if the texture is a cube texture or if false a 2d texture.
  117668. */
  117669. get isCube(): boolean;
  117670. set isCube(value: boolean);
  117671. /**
  117672. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  117673. */
  117674. get is3D(): boolean;
  117675. set is3D(value: boolean);
  117676. /**
  117677. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  117678. */
  117679. get is2DArray(): boolean;
  117680. set is2DArray(value: boolean);
  117681. private _gammaSpace;
  117682. /**
  117683. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  117684. * HDR texture are usually stored in linear space.
  117685. * This only impacts the PBR and Background materials
  117686. */
  117687. get gammaSpace(): boolean;
  117688. set gammaSpace(gamma: boolean);
  117689. /**
  117690. * Gets or sets whether or not the texture contains RGBD data.
  117691. */
  117692. get isRGBD(): boolean;
  117693. set isRGBD(value: boolean);
  117694. /**
  117695. * Is Z inverted in the texture (useful in a cube texture).
  117696. */
  117697. invertZ: boolean;
  117698. /**
  117699. * Are mip maps generated for this texture or not.
  117700. */
  117701. get noMipmap(): boolean;
  117702. /**
  117703. * @hidden
  117704. */
  117705. lodLevelInAlpha: boolean;
  117706. /**
  117707. * With prefiltered texture, defined the offset used during the prefiltering steps.
  117708. */
  117709. get lodGenerationOffset(): number;
  117710. set lodGenerationOffset(value: number);
  117711. /**
  117712. * With prefiltered texture, defined the scale used during the prefiltering steps.
  117713. */
  117714. get lodGenerationScale(): number;
  117715. set lodGenerationScale(value: number);
  117716. /**
  117717. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  117718. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  117719. * average roughness values.
  117720. */
  117721. get linearSpecularLOD(): boolean;
  117722. set linearSpecularLOD(value: boolean);
  117723. /**
  117724. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  117725. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  117726. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  117727. */
  117728. get irradianceTexture(): Nullable<BaseTexture>;
  117729. set irradianceTexture(value: Nullable<BaseTexture>);
  117730. /**
  117731. * Define if the texture is a render target.
  117732. */
  117733. isRenderTarget: boolean;
  117734. /**
  117735. * Define the unique id of the texture in the scene.
  117736. */
  117737. get uid(): string;
  117738. /** @hidden */
  117739. _prefiltered: boolean;
  117740. /**
  117741. * Return a string representation of the texture.
  117742. * @returns the texture as a string
  117743. */
  117744. toString(): string;
  117745. /**
  117746. * Get the class name of the texture.
  117747. * @returns "BaseTexture"
  117748. */
  117749. getClassName(): string;
  117750. /**
  117751. * Define the list of animation attached to the texture.
  117752. */
  117753. animations: Animation[];
  117754. /**
  117755. * An event triggered when the texture is disposed.
  117756. */
  117757. onDisposeObservable: Observable<BaseTexture>;
  117758. private _onDisposeObserver;
  117759. /**
  117760. * Callback triggered when the texture has been disposed.
  117761. * Kept for back compatibility, you can use the onDisposeObservable instead.
  117762. */
  117763. set onDispose(callback: () => void);
  117764. /**
  117765. * Define the current state of the loading sequence when in delayed load mode.
  117766. */
  117767. delayLoadState: number;
  117768. protected _scene: Nullable<Scene>;
  117769. protected _engine: Nullable<ThinEngine>;
  117770. /** @hidden */
  117771. _texture: Nullable<InternalTexture>;
  117772. private _uid;
  117773. /**
  117774. * Define if the texture is preventinga material to render or not.
  117775. * If not and the texture is not ready, the engine will use a default black texture instead.
  117776. */
  117777. get isBlocking(): boolean;
  117778. /**
  117779. * Instantiates a new BaseTexture.
  117780. * Base class of all the textures in babylon.
  117781. * It groups all the common properties the materials, post process, lights... might need
  117782. * in order to make a correct use of the texture.
  117783. * @param sceneOrEngine Define the scene or engine the texture blongs to
  117784. */
  117785. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  117786. /**
  117787. * Get the scene the texture belongs to.
  117788. * @returns the scene or null if undefined
  117789. */
  117790. getScene(): Nullable<Scene>;
  117791. /** @hidden */
  117792. protected _getEngine(): Nullable<ThinEngine>;
  117793. /**
  117794. * Get the texture transform matrix used to offset tile the texture for istance.
  117795. * @returns the transformation matrix
  117796. */
  117797. getTextureMatrix(): Matrix;
  117798. /**
  117799. * Get the texture reflection matrix used to rotate/transform the reflection.
  117800. * @returns the reflection matrix
  117801. */
  117802. getReflectionTextureMatrix(): Matrix;
  117803. /**
  117804. * Get the underlying lower level texture from Babylon.
  117805. * @returns the insternal texture
  117806. */
  117807. getInternalTexture(): Nullable<InternalTexture>;
  117808. /**
  117809. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  117810. * @returns true if ready or not blocking
  117811. */
  117812. isReadyOrNotBlocking(): boolean;
  117813. /**
  117814. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  117815. * @returns true if fully ready
  117816. */
  117817. isReady(): boolean;
  117818. private _cachedSize;
  117819. /**
  117820. * Get the size of the texture.
  117821. * @returns the texture size.
  117822. */
  117823. getSize(): ISize;
  117824. /**
  117825. * Get the base size of the texture.
  117826. * It can be different from the size if the texture has been resized for POT for instance
  117827. * @returns the base size
  117828. */
  117829. getBaseSize(): ISize;
  117830. /**
  117831. * Update the sampling mode of the texture.
  117832. * Default is Trilinear mode.
  117833. *
  117834. * | Value | Type | Description |
  117835. * | ----- | ------------------ | ----------- |
  117836. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  117837. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  117838. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  117839. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  117840. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  117841. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  117842. * | 7 | NEAREST_LINEAR | |
  117843. * | 8 | NEAREST_NEAREST | |
  117844. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  117845. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  117846. * | 11 | LINEAR_LINEAR | |
  117847. * | 12 | LINEAR_NEAREST | |
  117848. *
  117849. * > _mag_: magnification filter (close to the viewer)
  117850. * > _min_: minification filter (far from the viewer)
  117851. * > _mip_: filter used between mip map levels
  117852. *@param samplingMode Define the new sampling mode of the texture
  117853. */
  117854. updateSamplingMode(samplingMode: number): void;
  117855. /**
  117856. * Scales the texture if is `canRescale()`
  117857. * @param ratio the resize factor we want to use to rescale
  117858. */
  117859. scale(ratio: number): void;
  117860. /**
  117861. * Get if the texture can rescale.
  117862. */
  117863. get canRescale(): boolean;
  117864. /** @hidden */
  117865. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  117866. /** @hidden */
  117867. _rebuild(): void;
  117868. /**
  117869. * Triggers the load sequence in delayed load mode.
  117870. */
  117871. delayLoad(): void;
  117872. /**
  117873. * Clones the texture.
  117874. * @returns the cloned texture
  117875. */
  117876. clone(): Nullable<BaseTexture>;
  117877. /**
  117878. * Get the texture underlying type (INT, FLOAT...)
  117879. */
  117880. get textureType(): number;
  117881. /**
  117882. * Get the texture underlying format (RGB, RGBA...)
  117883. */
  117884. get textureFormat(): number;
  117885. /**
  117886. * Indicates that textures need to be re-calculated for all materials
  117887. */
  117888. protected _markAllSubMeshesAsTexturesDirty(): void;
  117889. /**
  117890. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  117891. * This will returns an RGBA array buffer containing either in values (0-255) or
  117892. * float values (0-1) depending of the underlying buffer type.
  117893. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  117894. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  117895. * @param buffer defines a user defined buffer to fill with data (can be null)
  117896. * @returns The Array buffer containing the pixels data.
  117897. */
  117898. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  117899. /**
  117900. * Release and destroy the underlying lower level texture aka internalTexture.
  117901. */
  117902. releaseInternalTexture(): void;
  117903. /** @hidden */
  117904. get _lodTextureHigh(): Nullable<BaseTexture>;
  117905. /** @hidden */
  117906. get _lodTextureMid(): Nullable<BaseTexture>;
  117907. /** @hidden */
  117908. get _lodTextureLow(): Nullable<BaseTexture>;
  117909. /**
  117910. * Dispose the texture and release its associated resources.
  117911. */
  117912. dispose(): void;
  117913. /**
  117914. * Serialize the texture into a JSON representation that can be parsed later on.
  117915. * @returns the JSON representation of the texture
  117916. */
  117917. serialize(): any;
  117918. /**
  117919. * Helper function to be called back once a list of texture contains only ready textures.
  117920. * @param textures Define the list of textures to wait for
  117921. * @param callback Define the callback triggered once the entire list will be ready
  117922. */
  117923. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  117924. private static _isScene;
  117925. }
  117926. }
  117927. declare module BABYLON {
  117928. /**
  117929. * Options to be used when creating an effect.
  117930. */
  117931. export interface IEffectCreationOptions {
  117932. /**
  117933. * Atrributes that will be used in the shader.
  117934. */
  117935. attributes: string[];
  117936. /**
  117937. * Uniform varible names that will be set in the shader.
  117938. */
  117939. uniformsNames: string[];
  117940. /**
  117941. * Uniform buffer variable names that will be set in the shader.
  117942. */
  117943. uniformBuffersNames: string[];
  117944. /**
  117945. * Sampler texture variable names that will be set in the shader.
  117946. */
  117947. samplers: string[];
  117948. /**
  117949. * Define statements that will be set in the shader.
  117950. */
  117951. defines: any;
  117952. /**
  117953. * Possible fallbacks for this effect to improve performance when needed.
  117954. */
  117955. fallbacks: Nullable<IEffectFallbacks>;
  117956. /**
  117957. * Callback that will be called when the shader is compiled.
  117958. */
  117959. onCompiled: Nullable<(effect: Effect) => void>;
  117960. /**
  117961. * Callback that will be called if an error occurs during shader compilation.
  117962. */
  117963. onError: Nullable<(effect: Effect, errors: string) => void>;
  117964. /**
  117965. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  117966. */
  117967. indexParameters?: any;
  117968. /**
  117969. * Max number of lights that can be used in the shader.
  117970. */
  117971. maxSimultaneousLights?: number;
  117972. /**
  117973. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  117974. */
  117975. transformFeedbackVaryings?: Nullable<string[]>;
  117976. /**
  117977. * 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
  117978. */
  117979. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  117980. /**
  117981. * Is this effect rendering to several color attachments ?
  117982. */
  117983. multiTarget?: boolean;
  117984. }
  117985. /**
  117986. * Effect containing vertex and fragment shader that can be executed on an object.
  117987. */
  117988. export class Effect implements IDisposable {
  117989. /**
  117990. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  117991. */
  117992. static ShadersRepository: string;
  117993. /**
  117994. * Enable logging of the shader code when a compilation error occurs
  117995. */
  117996. static LogShaderCodeOnCompilationError: boolean;
  117997. /**
  117998. * Name of the effect.
  117999. */
  118000. name: any;
  118001. /**
  118002. * String container all the define statements that should be set on the shader.
  118003. */
  118004. defines: string;
  118005. /**
  118006. * Callback that will be called when the shader is compiled.
  118007. */
  118008. onCompiled: Nullable<(effect: Effect) => void>;
  118009. /**
  118010. * Callback that will be called if an error occurs during shader compilation.
  118011. */
  118012. onError: Nullable<(effect: Effect, errors: string) => void>;
  118013. /**
  118014. * Callback that will be called when effect is bound.
  118015. */
  118016. onBind: Nullable<(effect: Effect) => void>;
  118017. /**
  118018. * Unique ID of the effect.
  118019. */
  118020. uniqueId: number;
  118021. /**
  118022. * Observable that will be called when the shader is compiled.
  118023. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  118024. */
  118025. onCompileObservable: Observable<Effect>;
  118026. /**
  118027. * Observable that will be called if an error occurs during shader compilation.
  118028. */
  118029. onErrorObservable: Observable<Effect>;
  118030. /** @hidden */
  118031. _onBindObservable: Nullable<Observable<Effect>>;
  118032. /**
  118033. * @hidden
  118034. * Specifies if the effect was previously ready
  118035. */
  118036. _wasPreviouslyReady: boolean;
  118037. /**
  118038. * Observable that will be called when effect is bound.
  118039. */
  118040. get onBindObservable(): Observable<Effect>;
  118041. /** @hidden */
  118042. _bonesComputationForcedToCPU: boolean;
  118043. /** @hidden */
  118044. _multiTarget: boolean;
  118045. private static _uniqueIdSeed;
  118046. private _engine;
  118047. private _uniformBuffersNames;
  118048. private _uniformBuffersNamesList;
  118049. private _uniformsNames;
  118050. private _samplerList;
  118051. private _samplers;
  118052. private _isReady;
  118053. private _compilationError;
  118054. private _allFallbacksProcessed;
  118055. private _attributesNames;
  118056. private _attributes;
  118057. private _attributeLocationByName;
  118058. private _uniforms;
  118059. /**
  118060. * Key for the effect.
  118061. * @hidden
  118062. */
  118063. _key: string;
  118064. private _indexParameters;
  118065. private _fallbacks;
  118066. private _vertexSourceCode;
  118067. private _fragmentSourceCode;
  118068. private _vertexSourceCodeOverride;
  118069. private _fragmentSourceCodeOverride;
  118070. private _transformFeedbackVaryings;
  118071. /**
  118072. * Compiled shader to webGL program.
  118073. * @hidden
  118074. */
  118075. _pipelineContext: Nullable<IPipelineContext>;
  118076. private _valueCache;
  118077. private static _baseCache;
  118078. /**
  118079. * Instantiates an effect.
  118080. * An effect can be used to create/manage/execute vertex and fragment shaders.
  118081. * @param baseName Name of the effect.
  118082. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  118083. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  118084. * @param samplers List of sampler variables that will be passed to the shader.
  118085. * @param engine Engine to be used to render the effect
  118086. * @param defines Define statements to be added to the shader.
  118087. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  118088. * @param onCompiled Callback that will be called when the shader is compiled.
  118089. * @param onError Callback that will be called if an error occurs during shader compilation.
  118090. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118091. */
  118092. 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);
  118093. private _useFinalCode;
  118094. /**
  118095. * Unique key for this effect
  118096. */
  118097. get key(): string;
  118098. /**
  118099. * If the effect has been compiled and prepared.
  118100. * @returns if the effect is compiled and prepared.
  118101. */
  118102. isReady(): boolean;
  118103. private _isReadyInternal;
  118104. /**
  118105. * The engine the effect was initialized with.
  118106. * @returns the engine.
  118107. */
  118108. getEngine(): Engine;
  118109. /**
  118110. * The pipeline context for this effect
  118111. * @returns the associated pipeline context
  118112. */
  118113. getPipelineContext(): Nullable<IPipelineContext>;
  118114. /**
  118115. * The set of names of attribute variables for the shader.
  118116. * @returns An array of attribute names.
  118117. */
  118118. getAttributesNames(): string[];
  118119. /**
  118120. * Returns the attribute at the given index.
  118121. * @param index The index of the attribute.
  118122. * @returns The location of the attribute.
  118123. */
  118124. getAttributeLocation(index: number): number;
  118125. /**
  118126. * Returns the attribute based on the name of the variable.
  118127. * @param name of the attribute to look up.
  118128. * @returns the attribute location.
  118129. */
  118130. getAttributeLocationByName(name: string): number;
  118131. /**
  118132. * The number of attributes.
  118133. * @returns the numnber of attributes.
  118134. */
  118135. getAttributesCount(): number;
  118136. /**
  118137. * Gets the index of a uniform variable.
  118138. * @param uniformName of the uniform to look up.
  118139. * @returns the index.
  118140. */
  118141. getUniformIndex(uniformName: string): number;
  118142. /**
  118143. * Returns the attribute based on the name of the variable.
  118144. * @param uniformName of the uniform to look up.
  118145. * @returns the location of the uniform.
  118146. */
  118147. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  118148. /**
  118149. * Returns an array of sampler variable names
  118150. * @returns The array of sampler variable names.
  118151. */
  118152. getSamplers(): string[];
  118153. /**
  118154. * Returns an array of uniform variable names
  118155. * @returns The array of uniform variable names.
  118156. */
  118157. getUniformNames(): string[];
  118158. /**
  118159. * Returns an array of uniform buffer variable names
  118160. * @returns The array of uniform buffer variable names.
  118161. */
  118162. getUniformBuffersNames(): string[];
  118163. /**
  118164. * Returns the index parameters used to create the effect
  118165. * @returns The index parameters object
  118166. */
  118167. getIndexParameters(): any;
  118168. /**
  118169. * The error from the last compilation.
  118170. * @returns the error string.
  118171. */
  118172. getCompilationError(): string;
  118173. /**
  118174. * Gets a boolean indicating that all fallbacks were used during compilation
  118175. * @returns true if all fallbacks were used
  118176. */
  118177. allFallbacksProcessed(): boolean;
  118178. /**
  118179. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  118180. * @param func The callback to be used.
  118181. */
  118182. executeWhenCompiled(func: (effect: Effect) => void): void;
  118183. private _checkIsReady;
  118184. private _loadShader;
  118185. /**
  118186. * Gets the vertex shader source code of this effect
  118187. */
  118188. get vertexSourceCode(): string;
  118189. /**
  118190. * Gets the fragment shader source code of this effect
  118191. */
  118192. get fragmentSourceCode(): string;
  118193. /**
  118194. * Recompiles the webGL program
  118195. * @param vertexSourceCode The source code for the vertex shader.
  118196. * @param fragmentSourceCode The source code for the fragment shader.
  118197. * @param onCompiled Callback called when completed.
  118198. * @param onError Callback called on error.
  118199. * @hidden
  118200. */
  118201. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  118202. /**
  118203. * Prepares the effect
  118204. * @hidden
  118205. */
  118206. _prepareEffect(): void;
  118207. private _getShaderCodeAndErrorLine;
  118208. private _processCompilationErrors;
  118209. /**
  118210. * Checks if the effect is supported. (Must be called after compilation)
  118211. */
  118212. get isSupported(): boolean;
  118213. /**
  118214. * Binds a texture to the engine to be used as output of the shader.
  118215. * @param channel Name of the output variable.
  118216. * @param texture Texture to bind.
  118217. * @hidden
  118218. */
  118219. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  118220. /**
  118221. * Sets a texture on the engine to be used in the shader.
  118222. * @param channel Name of the sampler variable.
  118223. * @param texture Texture to set.
  118224. */
  118225. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  118226. /**
  118227. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  118228. * @param channel Name of the sampler variable.
  118229. * @param texture Texture to set.
  118230. */
  118231. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  118232. /**
  118233. * Sets an array of textures on the engine to be used in the shader.
  118234. * @param channel Name of the variable.
  118235. * @param textures Textures to set.
  118236. */
  118237. setTextureArray(channel: string, textures: BaseTexture[]): void;
  118238. /**
  118239. * 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)
  118240. * @param channel Name of the sampler variable.
  118241. * @param postProcess Post process to get the input texture from.
  118242. */
  118243. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  118244. /**
  118245. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  118246. * 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)
  118247. * @param channel Name of the sampler variable.
  118248. * @param postProcess Post process to get the output texture from.
  118249. */
  118250. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  118251. /** @hidden */
  118252. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  118253. /** @hidden */
  118254. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  118255. /** @hidden */
  118256. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  118257. /** @hidden */
  118258. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  118259. /**
  118260. * Binds a buffer to a uniform.
  118261. * @param buffer Buffer to bind.
  118262. * @param name Name of the uniform variable to bind to.
  118263. */
  118264. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  118265. /**
  118266. * Binds block to a uniform.
  118267. * @param blockName Name of the block to bind.
  118268. * @param index Index to bind.
  118269. */
  118270. bindUniformBlock(blockName: string, index: number): void;
  118271. /**
  118272. * Sets an interger value on a uniform variable.
  118273. * @param uniformName Name of the variable.
  118274. * @param value Value to be set.
  118275. * @returns this effect.
  118276. */
  118277. setInt(uniformName: string, value: number): Effect;
  118278. /**
  118279. * Sets an int array on a uniform variable.
  118280. * @param uniformName Name of the variable.
  118281. * @param array array to be set.
  118282. * @returns this effect.
  118283. */
  118284. setIntArray(uniformName: string, array: Int32Array): Effect;
  118285. /**
  118286. * 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)
  118287. * @param uniformName Name of the variable.
  118288. * @param array array to be set.
  118289. * @returns this effect.
  118290. */
  118291. setIntArray2(uniformName: string, array: Int32Array): Effect;
  118292. /**
  118293. * 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)
  118294. * @param uniformName Name of the variable.
  118295. * @param array array to be set.
  118296. * @returns this effect.
  118297. */
  118298. setIntArray3(uniformName: string, array: Int32Array): Effect;
  118299. /**
  118300. * 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)
  118301. * @param uniformName Name of the variable.
  118302. * @param array array to be set.
  118303. * @returns this effect.
  118304. */
  118305. setIntArray4(uniformName: string, array: Int32Array): Effect;
  118306. /**
  118307. * Sets an float array on a uniform variable.
  118308. * @param uniformName Name of the variable.
  118309. * @param array array to be set.
  118310. * @returns this effect.
  118311. */
  118312. setFloatArray(uniformName: string, array: Float32Array): Effect;
  118313. /**
  118314. * 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)
  118315. * @param uniformName Name of the variable.
  118316. * @param array array to be set.
  118317. * @returns this effect.
  118318. */
  118319. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  118320. /**
  118321. * 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)
  118322. * @param uniformName Name of the variable.
  118323. * @param array array to be set.
  118324. * @returns this effect.
  118325. */
  118326. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  118327. /**
  118328. * 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)
  118329. * @param uniformName Name of the variable.
  118330. * @param array array to be set.
  118331. * @returns this effect.
  118332. */
  118333. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  118334. /**
  118335. * Sets an array on a uniform variable.
  118336. * @param uniformName Name of the variable.
  118337. * @param array array to be set.
  118338. * @returns this effect.
  118339. */
  118340. setArray(uniformName: string, array: number[]): Effect;
  118341. /**
  118342. * 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)
  118343. * @param uniformName Name of the variable.
  118344. * @param array array to be set.
  118345. * @returns this effect.
  118346. */
  118347. setArray2(uniformName: string, array: number[]): Effect;
  118348. /**
  118349. * 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)
  118350. * @param uniformName Name of the variable.
  118351. * @param array array to be set.
  118352. * @returns this effect.
  118353. */
  118354. setArray3(uniformName: string, array: number[]): Effect;
  118355. /**
  118356. * 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)
  118357. * @param uniformName Name of the variable.
  118358. * @param array array to be set.
  118359. * @returns this effect.
  118360. */
  118361. setArray4(uniformName: string, array: number[]): Effect;
  118362. /**
  118363. * Sets matrices on a uniform variable.
  118364. * @param uniformName Name of the variable.
  118365. * @param matrices matrices to be set.
  118366. * @returns this effect.
  118367. */
  118368. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  118369. /**
  118370. * Sets matrix on a uniform variable.
  118371. * @param uniformName Name of the variable.
  118372. * @param matrix matrix to be set.
  118373. * @returns this effect.
  118374. */
  118375. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  118376. /**
  118377. * 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)
  118378. * @param uniformName Name of the variable.
  118379. * @param matrix matrix to be set.
  118380. * @returns this effect.
  118381. */
  118382. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118383. /**
  118384. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  118385. * @param uniformName Name of the variable.
  118386. * @param matrix matrix to be set.
  118387. * @returns this effect.
  118388. */
  118389. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118390. /**
  118391. * Sets a float on a uniform variable.
  118392. * @param uniformName Name of the variable.
  118393. * @param value value to be set.
  118394. * @returns this effect.
  118395. */
  118396. setFloat(uniformName: string, value: number): Effect;
  118397. /**
  118398. * Sets a boolean on a uniform variable.
  118399. * @param uniformName Name of the variable.
  118400. * @param bool value to be set.
  118401. * @returns this effect.
  118402. */
  118403. setBool(uniformName: string, bool: boolean): Effect;
  118404. /**
  118405. * Sets a Vector2 on a uniform variable.
  118406. * @param uniformName Name of the variable.
  118407. * @param vector2 vector2 to be set.
  118408. * @returns this effect.
  118409. */
  118410. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  118411. /**
  118412. * Sets a float2 on a uniform variable.
  118413. * @param uniformName Name of the variable.
  118414. * @param x First float in float2.
  118415. * @param y Second float in float2.
  118416. * @returns this effect.
  118417. */
  118418. setFloat2(uniformName: string, x: number, y: number): Effect;
  118419. /**
  118420. * Sets a Vector3 on a uniform variable.
  118421. * @param uniformName Name of the variable.
  118422. * @param vector3 Value to be set.
  118423. * @returns this effect.
  118424. */
  118425. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  118426. /**
  118427. * Sets a float3 on a uniform variable.
  118428. * @param uniformName Name of the variable.
  118429. * @param x First float in float3.
  118430. * @param y Second float in float3.
  118431. * @param z Third float in float3.
  118432. * @returns this effect.
  118433. */
  118434. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  118435. /**
  118436. * Sets a Vector4 on a uniform variable.
  118437. * @param uniformName Name of the variable.
  118438. * @param vector4 Value to be set.
  118439. * @returns this effect.
  118440. */
  118441. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  118442. /**
  118443. * Sets a float4 on a uniform variable.
  118444. * @param uniformName Name of the variable.
  118445. * @param x First float in float4.
  118446. * @param y Second float in float4.
  118447. * @param z Third float in float4.
  118448. * @param w Fourth float in float4.
  118449. * @returns this effect.
  118450. */
  118451. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  118452. /**
  118453. * Sets a Color3 on a uniform variable.
  118454. * @param uniformName Name of the variable.
  118455. * @param color3 Value to be set.
  118456. * @returns this effect.
  118457. */
  118458. setColor3(uniformName: string, color3: IColor3Like): Effect;
  118459. /**
  118460. * Sets a Color4 on a uniform variable.
  118461. * @param uniformName Name of the variable.
  118462. * @param color3 Value to be set.
  118463. * @param alpha Alpha value to be set.
  118464. * @returns this effect.
  118465. */
  118466. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  118467. /**
  118468. * Sets a Color4 on a uniform variable
  118469. * @param uniformName defines the name of the variable
  118470. * @param color4 defines the value to be set
  118471. * @returns this effect.
  118472. */
  118473. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  118474. /** Release all associated resources */
  118475. dispose(): void;
  118476. /**
  118477. * This function will add a new shader to the shader store
  118478. * @param name the name of the shader
  118479. * @param pixelShader optional pixel shader content
  118480. * @param vertexShader optional vertex shader content
  118481. */
  118482. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  118483. /**
  118484. * Store of each shader (The can be looked up using effect.key)
  118485. */
  118486. static ShadersStore: {
  118487. [key: string]: string;
  118488. };
  118489. /**
  118490. * Store of each included file for a shader (The can be looked up using effect.key)
  118491. */
  118492. static IncludesShadersStore: {
  118493. [key: string]: string;
  118494. };
  118495. /**
  118496. * Resets the cache of effects.
  118497. */
  118498. static ResetCache(): void;
  118499. }
  118500. }
  118501. declare module BABYLON {
  118502. /**
  118503. * Interface used to describe the capabilities of the engine relatively to the current browser
  118504. */
  118505. export interface EngineCapabilities {
  118506. /** Maximum textures units per fragment shader */
  118507. maxTexturesImageUnits: number;
  118508. /** Maximum texture units per vertex shader */
  118509. maxVertexTextureImageUnits: number;
  118510. /** Maximum textures units in the entire pipeline */
  118511. maxCombinedTexturesImageUnits: number;
  118512. /** Maximum texture size */
  118513. maxTextureSize: number;
  118514. /** Maximum texture samples */
  118515. maxSamples?: number;
  118516. /** Maximum cube texture size */
  118517. maxCubemapTextureSize: number;
  118518. /** Maximum render texture size */
  118519. maxRenderTextureSize: number;
  118520. /** Maximum number of vertex attributes */
  118521. maxVertexAttribs: number;
  118522. /** Maximum number of varyings */
  118523. maxVaryingVectors: number;
  118524. /** Maximum number of uniforms per vertex shader */
  118525. maxVertexUniformVectors: number;
  118526. /** Maximum number of uniforms per fragment shader */
  118527. maxFragmentUniformVectors: number;
  118528. /** Defines if standard derivates (dx/dy) are supported */
  118529. standardDerivatives: boolean;
  118530. /** Defines if s3tc texture compression is supported */
  118531. s3tc?: WEBGL_compressed_texture_s3tc;
  118532. /** Defines if pvrtc texture compression is supported */
  118533. pvrtc: any;
  118534. /** Defines if etc1 texture compression is supported */
  118535. etc1: any;
  118536. /** Defines if etc2 texture compression is supported */
  118537. etc2: any;
  118538. /** Defines if astc texture compression is supported */
  118539. astc: any;
  118540. /** Defines if bptc texture compression is supported */
  118541. bptc: any;
  118542. /** Defines if float textures are supported */
  118543. textureFloat: boolean;
  118544. /** Defines if vertex array objects are supported */
  118545. vertexArrayObject: boolean;
  118546. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  118547. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  118548. /** Gets the maximum level of anisotropy supported */
  118549. maxAnisotropy: number;
  118550. /** Defines if instancing is supported */
  118551. instancedArrays: boolean;
  118552. /** Defines if 32 bits indices are supported */
  118553. uintIndices: boolean;
  118554. /** Defines if high precision shaders are supported */
  118555. highPrecisionShaderSupported: boolean;
  118556. /** Defines if depth reading in the fragment shader is supported */
  118557. fragmentDepthSupported: boolean;
  118558. /** Defines if float texture linear filtering is supported*/
  118559. textureFloatLinearFiltering: boolean;
  118560. /** Defines if rendering to float textures is supported */
  118561. textureFloatRender: boolean;
  118562. /** Defines if half float textures are supported*/
  118563. textureHalfFloat: boolean;
  118564. /** Defines if half float texture linear filtering is supported*/
  118565. textureHalfFloatLinearFiltering: boolean;
  118566. /** Defines if rendering to half float textures is supported */
  118567. textureHalfFloatRender: boolean;
  118568. /** Defines if textureLOD shader command is supported */
  118569. textureLOD: boolean;
  118570. /** Defines if draw buffers extension is supported */
  118571. drawBuffersExtension: boolean;
  118572. /** Defines if depth textures are supported */
  118573. depthTextureExtension: boolean;
  118574. /** Defines if float color buffer are supported */
  118575. colorBufferFloat: boolean;
  118576. /** Gets disjoint timer query extension (null if not supported) */
  118577. timerQuery?: EXT_disjoint_timer_query;
  118578. /** Defines if timestamp can be used with timer query */
  118579. canUseTimestampForTimerQuery: boolean;
  118580. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  118581. multiview?: any;
  118582. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  118583. oculusMultiview?: any;
  118584. /** Function used to let the system compiles shaders in background */
  118585. parallelShaderCompile?: {
  118586. COMPLETION_STATUS_KHR: number;
  118587. };
  118588. /** Max number of texture samples for MSAA */
  118589. maxMSAASamples: number;
  118590. /** Defines if the blend min max extension is supported */
  118591. blendMinMax: boolean;
  118592. }
  118593. }
  118594. declare module BABYLON {
  118595. /**
  118596. * @hidden
  118597. **/
  118598. export class DepthCullingState {
  118599. private _isDepthTestDirty;
  118600. private _isDepthMaskDirty;
  118601. private _isDepthFuncDirty;
  118602. private _isCullFaceDirty;
  118603. private _isCullDirty;
  118604. private _isZOffsetDirty;
  118605. private _isFrontFaceDirty;
  118606. private _depthTest;
  118607. private _depthMask;
  118608. private _depthFunc;
  118609. private _cull;
  118610. private _cullFace;
  118611. private _zOffset;
  118612. private _frontFace;
  118613. /**
  118614. * Initializes the state.
  118615. */
  118616. constructor();
  118617. get isDirty(): boolean;
  118618. get zOffset(): number;
  118619. set zOffset(value: number);
  118620. get cullFace(): Nullable<number>;
  118621. set cullFace(value: Nullable<number>);
  118622. get cull(): Nullable<boolean>;
  118623. set cull(value: Nullable<boolean>);
  118624. get depthFunc(): Nullable<number>;
  118625. set depthFunc(value: Nullable<number>);
  118626. get depthMask(): boolean;
  118627. set depthMask(value: boolean);
  118628. get depthTest(): boolean;
  118629. set depthTest(value: boolean);
  118630. get frontFace(): Nullable<number>;
  118631. set frontFace(value: Nullable<number>);
  118632. reset(): void;
  118633. apply(gl: WebGLRenderingContext): void;
  118634. }
  118635. }
  118636. declare module BABYLON {
  118637. /**
  118638. * @hidden
  118639. **/
  118640. export class StencilState {
  118641. /** 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 */
  118642. static readonly ALWAYS: number;
  118643. /** Passed to stencilOperation to specify that stencil value must be kept */
  118644. static readonly KEEP: number;
  118645. /** Passed to stencilOperation to specify that stencil value must be replaced */
  118646. static readonly REPLACE: number;
  118647. private _isStencilTestDirty;
  118648. private _isStencilMaskDirty;
  118649. private _isStencilFuncDirty;
  118650. private _isStencilOpDirty;
  118651. private _stencilTest;
  118652. private _stencilMask;
  118653. private _stencilFunc;
  118654. private _stencilFuncRef;
  118655. private _stencilFuncMask;
  118656. private _stencilOpStencilFail;
  118657. private _stencilOpDepthFail;
  118658. private _stencilOpStencilDepthPass;
  118659. get isDirty(): boolean;
  118660. get stencilFunc(): number;
  118661. set stencilFunc(value: number);
  118662. get stencilFuncRef(): number;
  118663. set stencilFuncRef(value: number);
  118664. get stencilFuncMask(): number;
  118665. set stencilFuncMask(value: number);
  118666. get stencilOpStencilFail(): number;
  118667. set stencilOpStencilFail(value: number);
  118668. get stencilOpDepthFail(): number;
  118669. set stencilOpDepthFail(value: number);
  118670. get stencilOpStencilDepthPass(): number;
  118671. set stencilOpStencilDepthPass(value: number);
  118672. get stencilMask(): number;
  118673. set stencilMask(value: number);
  118674. get stencilTest(): boolean;
  118675. set stencilTest(value: boolean);
  118676. constructor();
  118677. reset(): void;
  118678. apply(gl: WebGLRenderingContext): void;
  118679. }
  118680. }
  118681. declare module BABYLON {
  118682. /**
  118683. * @hidden
  118684. **/
  118685. export class AlphaState {
  118686. private _isAlphaBlendDirty;
  118687. private _isBlendFunctionParametersDirty;
  118688. private _isBlendEquationParametersDirty;
  118689. private _isBlendConstantsDirty;
  118690. private _alphaBlend;
  118691. private _blendFunctionParameters;
  118692. private _blendEquationParameters;
  118693. private _blendConstants;
  118694. /**
  118695. * Initializes the state.
  118696. */
  118697. constructor();
  118698. get isDirty(): boolean;
  118699. get alphaBlend(): boolean;
  118700. set alphaBlend(value: boolean);
  118701. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  118702. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  118703. setAlphaEquationParameters(rgb: number, alpha: number): void;
  118704. reset(): void;
  118705. apply(gl: WebGLRenderingContext): void;
  118706. }
  118707. }
  118708. declare module BABYLON {
  118709. /** @hidden */
  118710. export class WebGL2ShaderProcessor implements IShaderProcessor {
  118711. attributeProcessor(attribute: string): string;
  118712. varyingProcessor(varying: string, isFragment: boolean): string;
  118713. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  118714. }
  118715. }
  118716. declare module BABYLON {
  118717. /**
  118718. * Interface for attribute information associated with buffer instanciation
  118719. */
  118720. export interface InstancingAttributeInfo {
  118721. /**
  118722. * Name of the GLSL attribute
  118723. * if attribute index is not specified, this is used to retrieve the index from the effect
  118724. */
  118725. attributeName: string;
  118726. /**
  118727. * Index/offset of the attribute in the vertex shader
  118728. * if not specified, this will be computes from the name.
  118729. */
  118730. index?: number;
  118731. /**
  118732. * size of the attribute, 1, 2, 3 or 4
  118733. */
  118734. attributeSize: number;
  118735. /**
  118736. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  118737. */
  118738. offset: number;
  118739. /**
  118740. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  118741. * default to 1
  118742. */
  118743. divisor?: number;
  118744. /**
  118745. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  118746. * default is FLOAT
  118747. */
  118748. attributeType?: number;
  118749. /**
  118750. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  118751. */
  118752. normalized?: boolean;
  118753. }
  118754. }
  118755. declare module BABYLON {
  118756. interface ThinEngine {
  118757. /**
  118758. * Update a video texture
  118759. * @param texture defines the texture to update
  118760. * @param video defines the video element to use
  118761. * @param invertY defines if data must be stored with Y axis inverted
  118762. */
  118763. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  118764. }
  118765. }
  118766. declare module BABYLON {
  118767. interface ThinEngine {
  118768. /**
  118769. * Creates a dynamic texture
  118770. * @param width defines the width of the texture
  118771. * @param height defines the height of the texture
  118772. * @param generateMipMaps defines if the engine should generate the mip levels
  118773. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  118774. * @returns the dynamic texture inside an InternalTexture
  118775. */
  118776. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  118777. /**
  118778. * Update the content of a dynamic texture
  118779. * @param texture defines the texture to update
  118780. * @param canvas defines the canvas containing the source
  118781. * @param invertY defines if data must be stored with Y axis inverted
  118782. * @param premulAlpha defines if alpha is stored as premultiplied
  118783. * @param format defines the format of the data
  118784. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  118785. */
  118786. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  118787. }
  118788. }
  118789. declare module BABYLON {
  118790. /**
  118791. * Settings for finer control over video usage
  118792. */
  118793. export interface VideoTextureSettings {
  118794. /**
  118795. * Applies `autoplay` to video, if specified
  118796. */
  118797. autoPlay?: boolean;
  118798. /**
  118799. * Applies `muted` to video, if specified
  118800. */
  118801. muted?: boolean;
  118802. /**
  118803. * Applies `loop` to video, if specified
  118804. */
  118805. loop?: boolean;
  118806. /**
  118807. * Automatically updates internal texture from video at every frame in the render loop
  118808. */
  118809. autoUpdateTexture: boolean;
  118810. /**
  118811. * Image src displayed during the video loading or until the user interacts with the video.
  118812. */
  118813. poster?: string;
  118814. }
  118815. /**
  118816. * If you want to display a video in your scene, this is the special texture for that.
  118817. * This special texture works similar to other textures, with the exception of a few parameters.
  118818. * @see https://doc.babylonjs.com/how_to/video_texture
  118819. */
  118820. export class VideoTexture extends Texture {
  118821. /**
  118822. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  118823. */
  118824. readonly autoUpdateTexture: boolean;
  118825. /**
  118826. * The video instance used by the texture internally
  118827. */
  118828. readonly video: HTMLVideoElement;
  118829. private _onUserActionRequestedObservable;
  118830. /**
  118831. * Event triggerd when a dom action is required by the user to play the video.
  118832. * This happens due to recent changes in browser policies preventing video to auto start.
  118833. */
  118834. get onUserActionRequestedObservable(): Observable<Texture>;
  118835. private _generateMipMaps;
  118836. private _stillImageCaptured;
  118837. private _displayingPosterTexture;
  118838. private _settings;
  118839. private _createInternalTextureOnEvent;
  118840. private _frameId;
  118841. private _currentSrc;
  118842. /**
  118843. * Creates a video texture.
  118844. * If you want to display a video in your scene, this is the special texture for that.
  118845. * This special texture works similar to other textures, with the exception of a few parameters.
  118846. * @see https://doc.babylonjs.com/how_to/video_texture
  118847. * @param name optional name, will detect from video source, if not defined
  118848. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  118849. * @param scene is obviously the current scene.
  118850. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  118851. * @param invertY is false by default but can be used to invert video on Y axis
  118852. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  118853. * @param settings allows finer control over video usage
  118854. */
  118855. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  118856. private _getName;
  118857. private _getVideo;
  118858. private _createInternalTexture;
  118859. private reset;
  118860. /**
  118861. * @hidden Internal method to initiate `update`.
  118862. */
  118863. _rebuild(): void;
  118864. /**
  118865. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  118866. */
  118867. update(): void;
  118868. /**
  118869. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  118870. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  118871. */
  118872. updateTexture(isVisible: boolean): void;
  118873. protected _updateInternalTexture: () => void;
  118874. /**
  118875. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  118876. * @param url New url.
  118877. */
  118878. updateURL(url: string): void;
  118879. /**
  118880. * Clones the texture.
  118881. * @returns the cloned texture
  118882. */
  118883. clone(): VideoTexture;
  118884. /**
  118885. * Dispose the texture and release its associated resources.
  118886. */
  118887. dispose(): void;
  118888. /**
  118889. * Creates a video texture straight from a stream.
  118890. * @param scene Define the scene the texture should be created in
  118891. * @param stream Define the stream the texture should be created from
  118892. * @returns The created video texture as a promise
  118893. */
  118894. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  118895. /**
  118896. * Creates a video texture straight from your WebCam video feed.
  118897. * @param scene Define the scene the texture should be created in
  118898. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  118899. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  118900. * @returns The created video texture as a promise
  118901. */
  118902. static CreateFromWebCamAsync(scene: Scene, constraints: {
  118903. minWidth: number;
  118904. maxWidth: number;
  118905. minHeight: number;
  118906. maxHeight: number;
  118907. deviceId: string;
  118908. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  118909. /**
  118910. * Creates a video texture straight from your WebCam video feed.
  118911. * @param scene Define the scene the texture should be created in
  118912. * @param onReady Define a callback to triggered once the texture will be ready
  118913. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  118914. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  118915. */
  118916. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  118917. minWidth: number;
  118918. maxWidth: number;
  118919. minHeight: number;
  118920. maxHeight: number;
  118921. deviceId: string;
  118922. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  118923. }
  118924. }
  118925. declare module BABYLON {
  118926. /**
  118927. * Defines the interface used by objects working like Scene
  118928. * @hidden
  118929. */
  118930. export interface ISceneLike {
  118931. _addPendingData(data: any): void;
  118932. _removePendingData(data: any): void;
  118933. offlineProvider: IOfflineProvider;
  118934. }
  118935. /**
  118936. * Information about the current host
  118937. */
  118938. export interface HostInformation {
  118939. /**
  118940. * Defines if the current host is a mobile
  118941. */
  118942. isMobile: boolean;
  118943. }
  118944. /** Interface defining initialization parameters for Engine class */
  118945. export interface EngineOptions extends WebGLContextAttributes {
  118946. /**
  118947. * Defines if the engine should no exceed a specified device ratio
  118948. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  118949. */
  118950. limitDeviceRatio?: number;
  118951. /**
  118952. * Defines if webvr should be enabled automatically
  118953. * @see https://doc.babylonjs.com/how_to/webvr_camera
  118954. */
  118955. autoEnableWebVR?: boolean;
  118956. /**
  118957. * Defines if webgl2 should be turned off even if supported
  118958. * @see https://doc.babylonjs.com/features/webgl2
  118959. */
  118960. disableWebGL2Support?: boolean;
  118961. /**
  118962. * Defines if webaudio should be initialized as well
  118963. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  118964. */
  118965. audioEngine?: boolean;
  118966. /**
  118967. * Defines if animations should run using a deterministic lock step
  118968. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118969. */
  118970. deterministicLockstep?: boolean;
  118971. /** Defines the maximum steps to use with deterministic lock step mode */
  118972. lockstepMaxSteps?: number;
  118973. /** Defines the seconds between each deterministic lock step */
  118974. timeStep?: number;
  118975. /**
  118976. * Defines that engine should ignore context lost events
  118977. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  118978. */
  118979. doNotHandleContextLost?: boolean;
  118980. /**
  118981. * Defines that engine should ignore modifying touch action attribute and style
  118982. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  118983. */
  118984. doNotHandleTouchAction?: boolean;
  118985. /**
  118986. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  118987. */
  118988. useHighPrecisionFloats?: boolean;
  118989. /**
  118990. * Make the canvas XR Compatible for XR sessions
  118991. */
  118992. xrCompatible?: boolean;
  118993. /**
  118994. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  118995. */
  118996. useHighPrecisionMatrix?: boolean;
  118997. /**
  118998. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  118999. */
  119000. failIfMajorPerformanceCaveat?: boolean;
  119001. }
  119002. /**
  119003. * The base engine class (root of all engines)
  119004. */
  119005. export class ThinEngine {
  119006. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  119007. static ExceptionList: ({
  119008. key: string;
  119009. capture: string;
  119010. captureConstraint: number;
  119011. targets: string[];
  119012. } | {
  119013. key: string;
  119014. capture: null;
  119015. captureConstraint: null;
  119016. targets: string[];
  119017. })[];
  119018. /** @hidden */
  119019. static _TextureLoaders: IInternalTextureLoader[];
  119020. /**
  119021. * Returns the current npm package of the sdk
  119022. */
  119023. static get NpmPackage(): string;
  119024. /**
  119025. * Returns the current version of the framework
  119026. */
  119027. static get Version(): string;
  119028. /**
  119029. * Returns a string describing the current engine
  119030. */
  119031. get description(): string;
  119032. /**
  119033. * Gets or sets the epsilon value used by collision engine
  119034. */
  119035. static CollisionsEpsilon: number;
  119036. /**
  119037. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  119038. */
  119039. static get ShadersRepository(): string;
  119040. static set ShadersRepository(value: string);
  119041. /** @hidden */
  119042. _shaderProcessor: IShaderProcessor;
  119043. /**
  119044. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  119045. */
  119046. forcePOTTextures: boolean;
  119047. /**
  119048. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  119049. */
  119050. isFullscreen: boolean;
  119051. /**
  119052. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  119053. */
  119054. cullBackFaces: boolean;
  119055. /**
  119056. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  119057. */
  119058. renderEvenInBackground: boolean;
  119059. /**
  119060. * Gets or sets a boolean indicating that cache can be kept between frames
  119061. */
  119062. preventCacheWipeBetweenFrames: boolean;
  119063. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  119064. validateShaderPrograms: boolean;
  119065. /**
  119066. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  119067. * This can provide greater z depth for distant objects.
  119068. */
  119069. useReverseDepthBuffer: boolean;
  119070. /**
  119071. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  119072. */
  119073. disableUniformBuffers: boolean;
  119074. /** @hidden */
  119075. _uniformBuffers: UniformBuffer[];
  119076. /**
  119077. * Gets a boolean indicating that the engine supports uniform buffers
  119078. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  119079. */
  119080. get supportsUniformBuffers(): boolean;
  119081. /** @hidden */
  119082. _gl: WebGLRenderingContext;
  119083. /** @hidden */
  119084. _webGLVersion: number;
  119085. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  119086. protected _windowIsBackground: boolean;
  119087. protected _creationOptions: EngineOptions;
  119088. protected _highPrecisionShadersAllowed: boolean;
  119089. /** @hidden */
  119090. get _shouldUseHighPrecisionShader(): boolean;
  119091. /**
  119092. * Gets a boolean indicating that only power of 2 textures are supported
  119093. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  119094. */
  119095. get needPOTTextures(): boolean;
  119096. /** @hidden */
  119097. _badOS: boolean;
  119098. /** @hidden */
  119099. _badDesktopOS: boolean;
  119100. private _hardwareScalingLevel;
  119101. /** @hidden */
  119102. _caps: EngineCapabilities;
  119103. private _isStencilEnable;
  119104. private _glVersion;
  119105. private _glRenderer;
  119106. private _glVendor;
  119107. /** @hidden */
  119108. _videoTextureSupported: boolean;
  119109. protected _renderingQueueLaunched: boolean;
  119110. protected _activeRenderLoops: (() => void)[];
  119111. /**
  119112. * Observable signaled when a context lost event is raised
  119113. */
  119114. onContextLostObservable: Observable<ThinEngine>;
  119115. /**
  119116. * Observable signaled when a context restored event is raised
  119117. */
  119118. onContextRestoredObservable: Observable<ThinEngine>;
  119119. private _onContextLost;
  119120. private _onContextRestored;
  119121. protected _contextWasLost: boolean;
  119122. /** @hidden */
  119123. _doNotHandleContextLost: boolean;
  119124. /**
  119125. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  119126. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  119127. */
  119128. get doNotHandleContextLost(): boolean;
  119129. set doNotHandleContextLost(value: boolean);
  119130. /**
  119131. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  119132. */
  119133. disableVertexArrayObjects: boolean;
  119134. /** @hidden */
  119135. protected _colorWrite: boolean;
  119136. /** @hidden */
  119137. protected _colorWriteChanged: boolean;
  119138. /** @hidden */
  119139. protected _depthCullingState: DepthCullingState;
  119140. /** @hidden */
  119141. protected _stencilState: StencilState;
  119142. /** @hidden */
  119143. _alphaState: AlphaState;
  119144. /** @hidden */
  119145. _alphaMode: number;
  119146. /** @hidden */
  119147. _alphaEquation: number;
  119148. /** @hidden */
  119149. _internalTexturesCache: InternalTexture[];
  119150. /** @hidden */
  119151. protected _activeChannel: number;
  119152. private _currentTextureChannel;
  119153. /** @hidden */
  119154. protected _boundTexturesCache: {
  119155. [key: string]: Nullable<InternalTexture>;
  119156. };
  119157. /** @hidden */
  119158. protected _currentEffect: Nullable<Effect>;
  119159. /** @hidden */
  119160. protected _currentProgram: Nullable<WebGLProgram>;
  119161. private _compiledEffects;
  119162. private _vertexAttribArraysEnabled;
  119163. /** @hidden */
  119164. protected _cachedViewport: Nullable<IViewportLike>;
  119165. private _cachedVertexArrayObject;
  119166. /** @hidden */
  119167. protected _cachedVertexBuffers: any;
  119168. /** @hidden */
  119169. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  119170. /** @hidden */
  119171. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  119172. /** @hidden */
  119173. _currentRenderTarget: Nullable<InternalTexture>;
  119174. private _uintIndicesCurrentlySet;
  119175. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  119176. /** @hidden */
  119177. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  119178. /** @hidden */
  119179. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  119180. private _currentBufferPointers;
  119181. private _currentInstanceLocations;
  119182. private _currentInstanceBuffers;
  119183. private _textureUnits;
  119184. /** @hidden */
  119185. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  119186. /** @hidden */
  119187. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  119188. /** @hidden */
  119189. _boundRenderFunction: any;
  119190. private _vaoRecordInProgress;
  119191. private _mustWipeVertexAttributes;
  119192. private _emptyTexture;
  119193. private _emptyCubeTexture;
  119194. private _emptyTexture3D;
  119195. private _emptyTexture2DArray;
  119196. /** @hidden */
  119197. _frameHandler: number;
  119198. private _nextFreeTextureSlots;
  119199. private _maxSimultaneousTextures;
  119200. private _activeRequests;
  119201. /** @hidden */
  119202. _transformTextureUrl: Nullable<(url: string) => string>;
  119203. /**
  119204. * Gets information about the current host
  119205. */
  119206. hostInformation: HostInformation;
  119207. protected get _supportsHardwareTextureRescaling(): boolean;
  119208. private _framebufferDimensionsObject;
  119209. /**
  119210. * sets the object from which width and height will be taken from when getting render width and height
  119211. * Will fallback to the gl object
  119212. * @param dimensions the framebuffer width and height that will be used.
  119213. */
  119214. set framebufferDimensionsObject(dimensions: Nullable<{
  119215. framebufferWidth: number;
  119216. framebufferHeight: number;
  119217. }>);
  119218. /**
  119219. * Gets the current viewport
  119220. */
  119221. get currentViewport(): Nullable<IViewportLike>;
  119222. /**
  119223. * Gets the default empty texture
  119224. */
  119225. get emptyTexture(): InternalTexture;
  119226. /**
  119227. * Gets the default empty 3D texture
  119228. */
  119229. get emptyTexture3D(): InternalTexture;
  119230. /**
  119231. * Gets the default empty 2D array texture
  119232. */
  119233. get emptyTexture2DArray(): InternalTexture;
  119234. /**
  119235. * Gets the default empty cube texture
  119236. */
  119237. get emptyCubeTexture(): InternalTexture;
  119238. /**
  119239. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  119240. */
  119241. readonly premultipliedAlpha: boolean;
  119242. /**
  119243. * Observable event triggered before each texture is initialized
  119244. */
  119245. onBeforeTextureInitObservable: Observable<Texture>;
  119246. /**
  119247. * Creates a new engine
  119248. * @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
  119249. * @param antialias defines enable antialiasing (default: false)
  119250. * @param options defines further options to be sent to the getContext() function
  119251. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  119252. */
  119253. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  119254. private _rebuildInternalTextures;
  119255. private _rebuildEffects;
  119256. /**
  119257. * Gets a boolean indicating if all created effects are ready
  119258. * @returns true if all effects are ready
  119259. */
  119260. areAllEffectsReady(): boolean;
  119261. protected _rebuildBuffers(): void;
  119262. protected _initGLContext(): void;
  119263. /**
  119264. * Gets version of the current webGL context
  119265. */
  119266. get webGLVersion(): number;
  119267. /**
  119268. * Gets a string identifying the name of the class
  119269. * @returns "Engine" string
  119270. */
  119271. getClassName(): string;
  119272. /**
  119273. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  119274. */
  119275. get isStencilEnable(): boolean;
  119276. /** @hidden */
  119277. _prepareWorkingCanvas(): void;
  119278. /**
  119279. * Reset the texture cache to empty state
  119280. */
  119281. resetTextureCache(): void;
  119282. /**
  119283. * Gets an object containing information about the current webGL context
  119284. * @returns an object containing the vender, the renderer and the version of the current webGL context
  119285. */
  119286. getGlInfo(): {
  119287. vendor: string;
  119288. renderer: string;
  119289. version: string;
  119290. };
  119291. /**
  119292. * Defines the hardware scaling level.
  119293. * By default the hardware scaling level is computed from the window device ratio.
  119294. * 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.
  119295. * @param level defines the level to use
  119296. */
  119297. setHardwareScalingLevel(level: number): void;
  119298. /**
  119299. * Gets the current hardware scaling level.
  119300. * By default the hardware scaling level is computed from the window device ratio.
  119301. * 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.
  119302. * @returns a number indicating the current hardware scaling level
  119303. */
  119304. getHardwareScalingLevel(): number;
  119305. /**
  119306. * Gets the list of loaded textures
  119307. * @returns an array containing all loaded textures
  119308. */
  119309. getLoadedTexturesCache(): InternalTexture[];
  119310. /**
  119311. * Gets the object containing all engine capabilities
  119312. * @returns the EngineCapabilities object
  119313. */
  119314. getCaps(): EngineCapabilities;
  119315. /**
  119316. * stop executing a render loop function and remove it from the execution array
  119317. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  119318. */
  119319. stopRenderLoop(renderFunction?: () => void): void;
  119320. /** @hidden */
  119321. _renderLoop(): void;
  119322. /**
  119323. * Gets the HTML canvas attached with the current webGL context
  119324. * @returns a HTML canvas
  119325. */
  119326. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  119327. /**
  119328. * Gets host window
  119329. * @returns the host window object
  119330. */
  119331. getHostWindow(): Nullable<Window>;
  119332. /**
  119333. * Gets the current render width
  119334. * @param useScreen defines if screen size must be used (or the current render target if any)
  119335. * @returns a number defining the current render width
  119336. */
  119337. getRenderWidth(useScreen?: boolean): number;
  119338. /**
  119339. * Gets the current render height
  119340. * @param useScreen defines if screen size must be used (or the current render target if any)
  119341. * @returns a number defining the current render height
  119342. */
  119343. getRenderHeight(useScreen?: boolean): number;
  119344. /**
  119345. * Can be used to override the current requestAnimationFrame requester.
  119346. * @hidden
  119347. */
  119348. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  119349. /**
  119350. * Register and execute a render loop. The engine can have more than one render function
  119351. * @param renderFunction defines the function to continuously execute
  119352. */
  119353. runRenderLoop(renderFunction: () => void): void;
  119354. /**
  119355. * Clear the current render buffer or the current render target (if any is set up)
  119356. * @param color defines the color to use
  119357. * @param backBuffer defines if the back buffer must be cleared
  119358. * @param depth defines if the depth buffer must be cleared
  119359. * @param stencil defines if the stencil buffer must be cleared
  119360. */
  119361. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119362. private _viewportCached;
  119363. /** @hidden */
  119364. _viewport(x: number, y: number, width: number, height: number): void;
  119365. /**
  119366. * Set the WebGL's viewport
  119367. * @param viewport defines the viewport element to be used
  119368. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119369. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119370. */
  119371. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119372. /**
  119373. * Begin a new frame
  119374. */
  119375. beginFrame(): void;
  119376. /**
  119377. * Enf the current frame
  119378. */
  119379. endFrame(): void;
  119380. /**
  119381. * Resize the view according to the canvas' size
  119382. */
  119383. resize(): void;
  119384. /**
  119385. * Force a specific size of the canvas
  119386. * @param width defines the new canvas' width
  119387. * @param height defines the new canvas' height
  119388. * @returns true if the size was changed
  119389. */
  119390. setSize(width: number, height: number): boolean;
  119391. /**
  119392. * Binds the frame buffer to the specified texture.
  119393. * @param texture The texture to render to or null for the default canvas
  119394. * @param faceIndex The face of the texture to render to in case of cube texture
  119395. * @param requiredWidth The width of the target to render to
  119396. * @param requiredHeight The height of the target to render to
  119397. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119398. * @param lodLevel defines the lod level to bind to the frame buffer
  119399. * @param layer defines the 2d array index to bind to frame buffer to
  119400. */
  119401. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  119402. /** @hidden */
  119403. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  119404. /**
  119405. * Unbind the current render target texture from the webGL context
  119406. * @param texture defines the render target texture to unbind
  119407. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119408. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119409. */
  119410. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119411. /**
  119412. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  119413. */
  119414. flushFramebuffer(): void;
  119415. /**
  119416. * Unbind the current render target and bind the default framebuffer
  119417. */
  119418. restoreDefaultFramebuffer(): void;
  119419. /** @hidden */
  119420. protected _resetVertexBufferBinding(): void;
  119421. /**
  119422. * Creates a vertex buffer
  119423. * @param data the data for the vertex buffer
  119424. * @returns the new WebGL static buffer
  119425. */
  119426. createVertexBuffer(data: DataArray): DataBuffer;
  119427. private _createVertexBuffer;
  119428. /**
  119429. * Creates a dynamic vertex buffer
  119430. * @param data the data for the dynamic vertex buffer
  119431. * @returns the new WebGL dynamic buffer
  119432. */
  119433. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  119434. protected _resetIndexBufferBinding(): void;
  119435. /**
  119436. * Creates a new index buffer
  119437. * @param indices defines the content of the index buffer
  119438. * @param updatable defines if the index buffer must be updatable
  119439. * @returns a new webGL buffer
  119440. */
  119441. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  119442. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  119443. /**
  119444. * Bind a webGL buffer to the webGL context
  119445. * @param buffer defines the buffer to bind
  119446. */
  119447. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  119448. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  119449. private bindBuffer;
  119450. /**
  119451. * update the bound buffer with the given data
  119452. * @param data defines the data to update
  119453. */
  119454. updateArrayBuffer(data: Float32Array): void;
  119455. private _vertexAttribPointer;
  119456. /** @hidden */
  119457. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  119458. private _bindVertexBuffersAttributes;
  119459. /**
  119460. * Records a vertex array object
  119461. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119462. * @param vertexBuffers defines the list of vertex buffers to store
  119463. * @param indexBuffer defines the index buffer to store
  119464. * @param effect defines the effect to store
  119465. * @returns the new vertex array object
  119466. */
  119467. recordVertexArrayObject(vertexBuffers: {
  119468. [key: string]: VertexBuffer;
  119469. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  119470. /**
  119471. * Bind a specific vertex array object
  119472. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119473. * @param vertexArrayObject defines the vertex array object to bind
  119474. * @param indexBuffer defines the index buffer to bind
  119475. */
  119476. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  119477. /**
  119478. * Bind webGl buffers directly to the webGL context
  119479. * @param vertexBuffer defines the vertex buffer to bind
  119480. * @param indexBuffer defines the index buffer to bind
  119481. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119482. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119483. * @param effect defines the effect associated with the vertex buffer
  119484. */
  119485. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  119486. private _unbindVertexArrayObject;
  119487. /**
  119488. * Bind a list of vertex buffers to the webGL context
  119489. * @param vertexBuffers defines the list of vertex buffers to bind
  119490. * @param indexBuffer defines the index buffer to bind
  119491. * @param effect defines the effect associated with the vertex buffers
  119492. */
  119493. bindBuffers(vertexBuffers: {
  119494. [key: string]: Nullable<VertexBuffer>;
  119495. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  119496. /**
  119497. * Unbind all instance attributes
  119498. */
  119499. unbindInstanceAttributes(): void;
  119500. /**
  119501. * Release and free the memory of a vertex array object
  119502. * @param vao defines the vertex array object to delete
  119503. */
  119504. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  119505. /** @hidden */
  119506. _releaseBuffer(buffer: DataBuffer): boolean;
  119507. protected _deleteBuffer(buffer: DataBuffer): void;
  119508. /**
  119509. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  119510. * @param instancesBuffer defines the webGL buffer to update and bind
  119511. * @param data defines the data to store in the buffer
  119512. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  119513. */
  119514. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  119515. /**
  119516. * Bind the content of a webGL buffer used with instantiation
  119517. * @param instancesBuffer defines the webGL buffer to bind
  119518. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  119519. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  119520. */
  119521. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  119522. /**
  119523. * Disable the instance attribute corresponding to the name in parameter
  119524. * @param name defines the name of the attribute to disable
  119525. */
  119526. disableInstanceAttributeByName(name: string): void;
  119527. /**
  119528. * Disable the instance attribute corresponding to the location in parameter
  119529. * @param attributeLocation defines the attribute location of the attribute to disable
  119530. */
  119531. disableInstanceAttribute(attributeLocation: number): void;
  119532. /**
  119533. * Disable the attribute corresponding to the location in parameter
  119534. * @param attributeLocation defines the attribute location of the attribute to disable
  119535. */
  119536. disableAttributeByIndex(attributeLocation: number): void;
  119537. /**
  119538. * Send a draw order
  119539. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119540. * @param indexStart defines the starting index
  119541. * @param indexCount defines the number of index to draw
  119542. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119543. */
  119544. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119545. /**
  119546. * Draw a list of points
  119547. * @param verticesStart defines the index of first vertex to draw
  119548. * @param verticesCount defines the count of vertices to draw
  119549. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119550. */
  119551. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119552. /**
  119553. * Draw a list of unindexed primitives
  119554. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119555. * @param verticesStart defines the index of first vertex to draw
  119556. * @param verticesCount defines the count of vertices to draw
  119557. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119558. */
  119559. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119560. /**
  119561. * Draw a list of indexed primitives
  119562. * @param fillMode defines the primitive to use
  119563. * @param indexStart defines the starting index
  119564. * @param indexCount defines the number of index to draw
  119565. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119566. */
  119567. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119568. /**
  119569. * Draw a list of unindexed primitives
  119570. * @param fillMode defines the primitive to use
  119571. * @param verticesStart defines the index of first vertex to draw
  119572. * @param verticesCount defines the count of vertices to draw
  119573. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119574. */
  119575. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119576. private _drawMode;
  119577. /** @hidden */
  119578. protected _reportDrawCall(): void;
  119579. /** @hidden */
  119580. _releaseEffect(effect: Effect): void;
  119581. /** @hidden */
  119582. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  119583. /**
  119584. * Create a new effect (used to store vertex/fragment shaders)
  119585. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  119586. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  119587. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  119588. * @param samplers defines an array of string used to represent textures
  119589. * @param defines defines the string containing the defines to use to compile the shaders
  119590. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  119591. * @param onCompiled defines a function to call when the effect creation is successful
  119592. * @param onError defines a function to call when the effect creation has failed
  119593. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  119594. * @returns the new Effect
  119595. */
  119596. 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;
  119597. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  119598. private _compileShader;
  119599. private _compileRawShader;
  119600. /** @hidden */
  119601. _getShaderSource(shader: WebGLShader): Nullable<string>;
  119602. /**
  119603. * Directly 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 context defines the webGL context to use (if not set, the current one will be used)
  119608. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119609. * @returns the new webGL program
  119610. */
  119611. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119612. /**
  119613. * Creates a webGL program
  119614. * @param pipelineContext defines the pipeline context to attach to
  119615. * @param vertexCode defines the vertex shader code to use
  119616. * @param fragmentCode defines the fragment shader code to use
  119617. * @param defines defines the string containing the defines to use to compile the shaders
  119618. * @param context defines the webGL context to use (if not set, the current one will be used)
  119619. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119620. * @returns the new webGL program
  119621. */
  119622. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119623. /**
  119624. * Creates a new pipeline context
  119625. * @returns the new pipeline
  119626. */
  119627. createPipelineContext(): IPipelineContext;
  119628. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119629. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  119630. /** @hidden */
  119631. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  119632. /** @hidden */
  119633. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  119634. /** @hidden */
  119635. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  119636. /**
  119637. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119638. * @param pipelineContext defines the pipeline context to use
  119639. * @param uniformsNames defines the list of uniform names
  119640. * @returns an array of webGL uniform locations
  119641. */
  119642. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119643. /**
  119644. * Gets the lsit of active attributes for a given webGL program
  119645. * @param pipelineContext defines the pipeline context to use
  119646. * @param attributesNames defines the list of attribute names to get
  119647. * @returns an array of indices indicating the offset of each attribute
  119648. */
  119649. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119650. /**
  119651. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119652. * @param effect defines the effect to activate
  119653. */
  119654. enableEffect(effect: Nullable<Effect>): void;
  119655. /**
  119656. * Set the value of an uniform to a number (int)
  119657. * @param uniform defines the webGL uniform location where to store the value
  119658. * @param value defines the int number to store
  119659. * @returns true if the value was set
  119660. */
  119661. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  119662. /**
  119663. * Set the value of an uniform to an array of int32
  119664. * @param uniform defines the webGL uniform location where to store the value
  119665. * @param array defines the array of int32 to store
  119666. * @returns true if the value was set
  119667. */
  119668. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119669. /**
  119670. * Set the value of an uniform to an array of int32 (stored as vec2)
  119671. * @param uniform defines the webGL uniform location where to store the value
  119672. * @param array defines the array of int32 to store
  119673. * @returns true if the value was set
  119674. */
  119675. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119676. /**
  119677. * Set the value of an uniform to an array of int32 (stored as vec3)
  119678. * @param uniform defines the webGL uniform location where to store the value
  119679. * @param array defines the array of int32 to store
  119680. * @returns true if the value was set
  119681. */
  119682. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119683. /**
  119684. * Set the value of an uniform to an array of int32 (stored as vec4)
  119685. * @param uniform defines the webGL uniform location where to store the value
  119686. * @param array defines the array of int32 to store
  119687. * @returns true if the value was set
  119688. */
  119689. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119690. /**
  119691. * Set the value of an uniform to an array of number
  119692. * @param uniform defines the webGL uniform location where to store the value
  119693. * @param array defines the array of number to store
  119694. * @returns true if the value was set
  119695. */
  119696. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119697. /**
  119698. * Set the value of an uniform to an array of number (stored as vec2)
  119699. * @param uniform defines the webGL uniform location where to store the value
  119700. * @param array defines the array of number to store
  119701. * @returns true if the value was set
  119702. */
  119703. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119704. /**
  119705. * Set the value of an uniform to an array of number (stored as vec3)
  119706. * @param uniform defines the webGL uniform location where to store the value
  119707. * @param array defines the array of number to store
  119708. * @returns true if the value was set
  119709. */
  119710. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119711. /**
  119712. * Set the value of an uniform to an array of number (stored as vec4)
  119713. * @param uniform defines the webGL uniform location where to store the value
  119714. * @param array defines the array of number to store
  119715. * @returns true if the value was set
  119716. */
  119717. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119718. /**
  119719. * Set the value of an uniform to an array of float32 (stored as matrices)
  119720. * @param uniform defines the webGL uniform location where to store the value
  119721. * @param matrices defines the array of float32 to store
  119722. * @returns true if the value was set
  119723. */
  119724. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  119725. /**
  119726. * Set the value of an uniform to a matrix (3x3)
  119727. * @param uniform defines the webGL uniform location where to store the value
  119728. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119729. * @returns true if the value was set
  119730. */
  119731. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  119732. /**
  119733. * Set the value of an uniform to a matrix (2x2)
  119734. * @param uniform defines the webGL uniform location where to store the value
  119735. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119736. * @returns true if the value was set
  119737. */
  119738. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  119739. /**
  119740. * Set the value of an uniform to a number (float)
  119741. * @param uniform defines the webGL uniform location where to store the value
  119742. * @param value defines the float number to store
  119743. * @returns true if the value was transfered
  119744. */
  119745. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  119746. /**
  119747. * Set the value of an uniform to a vec2
  119748. * @param uniform defines the webGL uniform location where to store the value
  119749. * @param x defines the 1st component of the value
  119750. * @param y defines the 2nd component of the value
  119751. * @returns true if the value was set
  119752. */
  119753. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  119754. /**
  119755. * Set the value of an uniform to a vec3
  119756. * @param uniform defines the webGL uniform location where to store the value
  119757. * @param x defines the 1st component of the value
  119758. * @param y defines the 2nd component of the value
  119759. * @param z defines the 3rd component of the value
  119760. * @returns true if the value was set
  119761. */
  119762. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  119763. /**
  119764. * Set the value of an uniform to a vec4
  119765. * @param uniform defines the webGL uniform location where to store the value
  119766. * @param x defines the 1st component of the value
  119767. * @param y defines the 2nd component of the value
  119768. * @param z defines the 3rd component of the value
  119769. * @param w defines the 4th component of the value
  119770. * @returns true if the value was set
  119771. */
  119772. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  119773. /**
  119774. * Apply all cached states (depth, culling, stencil and alpha)
  119775. */
  119776. applyStates(): void;
  119777. /**
  119778. * Enable or disable color writing
  119779. * @param enable defines the state to set
  119780. */
  119781. setColorWrite(enable: boolean): void;
  119782. /**
  119783. * Gets a boolean indicating if color writing is enabled
  119784. * @returns the current color writing state
  119785. */
  119786. getColorWrite(): boolean;
  119787. /**
  119788. * Gets the depth culling state manager
  119789. */
  119790. get depthCullingState(): DepthCullingState;
  119791. /**
  119792. * Gets the alpha state manager
  119793. */
  119794. get alphaState(): AlphaState;
  119795. /**
  119796. * Gets the stencil state manager
  119797. */
  119798. get stencilState(): StencilState;
  119799. /**
  119800. * Clears the list of texture accessible through engine.
  119801. * This can help preventing texture load conflict due to name collision.
  119802. */
  119803. clearInternalTexturesCache(): void;
  119804. /**
  119805. * Force the entire cache to be cleared
  119806. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119807. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119808. */
  119809. wipeCaches(bruteForce?: boolean): void;
  119810. /** @hidden */
  119811. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  119812. min: number;
  119813. mag: number;
  119814. };
  119815. /** @hidden */
  119816. _createTexture(): WebGLTexture;
  119817. /**
  119818. * Usually called from Texture.ts.
  119819. * Passed information to create a WebGLTexture
  119820. * @param url defines a value which contains one of the following:
  119821. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119822. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119823. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119824. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119825. * @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)
  119826. * @param scene needed for loading to the correct scene
  119827. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119828. * @param onLoad optional callback to be called upon successful completion
  119829. * @param onError optional callback to be called upon failure
  119830. * @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
  119831. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119832. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119833. * @param forcedExtension defines the extension to use to pick the right loader
  119834. * @param mimeType defines an optional mime type
  119835. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119836. */
  119837. 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;
  119838. /**
  119839. * Loads an image as an HTMLImageElement.
  119840. * @param input url string, ArrayBuffer, or Blob to load
  119841. * @param onLoad callback called when the image successfully loads
  119842. * @param onError callback called when the image fails to load
  119843. * @param offlineProvider offline provider for caching
  119844. * @param mimeType optional mime type
  119845. * @returns the HTMLImageElement of the loaded image
  119846. * @hidden
  119847. */
  119848. 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>;
  119849. /**
  119850. * @hidden
  119851. */
  119852. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  119853. private _unpackFlipYCached;
  119854. /**
  119855. * In case you are sharing the context with other applications, it might
  119856. * be interested to not cache the unpack flip y state to ensure a consistent
  119857. * value would be set.
  119858. */
  119859. enableUnpackFlipYCached: boolean;
  119860. /** @hidden */
  119861. _unpackFlipY(value: boolean): void;
  119862. /** @hidden */
  119863. _getUnpackAlignement(): number;
  119864. private _getTextureTarget;
  119865. /**
  119866. * Update the sampling mode of a given texture
  119867. * @param samplingMode defines the required sampling mode
  119868. * @param texture defines the texture to update
  119869. * @param generateMipMaps defines whether to generate mipmaps for the texture
  119870. */
  119871. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  119872. /**
  119873. * Update the sampling mode of a given texture
  119874. * @param texture defines the texture to update
  119875. * @param wrapU defines the texture wrap mode of the u coordinates
  119876. * @param wrapV defines the texture wrap mode of the v coordinates
  119877. * @param wrapR defines the texture wrap mode of the r coordinates
  119878. */
  119879. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  119880. /** @hidden */
  119881. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  119882. width: number;
  119883. height: number;
  119884. layers?: number;
  119885. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  119886. /** @hidden */
  119887. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119888. /** @hidden */
  119889. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  119890. /**
  119891. * Update a portion of an internal texture
  119892. * @param texture defines the texture to update
  119893. * @param imageData defines the data to store into the texture
  119894. * @param xOffset defines the x coordinates of the update rectangle
  119895. * @param yOffset defines the y coordinates of the update rectangle
  119896. * @param width defines the width of the update rectangle
  119897. * @param height defines the height of the update rectangle
  119898. * @param faceIndex defines the face index if texture is a cube (0 by default)
  119899. * @param lod defines the lod level to update (0 by default)
  119900. */
  119901. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  119902. /** @hidden */
  119903. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119904. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  119905. private _prepareWebGLTexture;
  119906. /** @hidden */
  119907. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  119908. private _getDepthStencilBuffer;
  119909. /** @hidden */
  119910. _releaseFramebufferObjects(texture: InternalTexture): void;
  119911. /** @hidden */
  119912. _releaseTexture(texture: InternalTexture): void;
  119913. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  119914. protected _setProgram(program: WebGLProgram): void;
  119915. protected _boundUniforms: {
  119916. [key: number]: WebGLUniformLocation;
  119917. };
  119918. /**
  119919. * Binds an effect to the webGL context
  119920. * @param effect defines the effect to bind
  119921. */
  119922. bindSamplers(effect: Effect): void;
  119923. private _activateCurrentTexture;
  119924. /** @hidden */
  119925. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  119926. /** @hidden */
  119927. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  119928. /**
  119929. * Unbind all textures from the webGL context
  119930. */
  119931. unbindAllTextures(): void;
  119932. /**
  119933. * Sets a texture to the according uniform.
  119934. * @param channel The texture channel
  119935. * @param uniform The uniform to set
  119936. * @param texture The texture to apply
  119937. */
  119938. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  119939. private _bindSamplerUniformToChannel;
  119940. private _getTextureWrapMode;
  119941. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  119942. /**
  119943. * Sets an array of texture to the webGL context
  119944. * @param channel defines the channel where the texture array must be set
  119945. * @param uniform defines the associated uniform location
  119946. * @param textures defines the array of textures to bind
  119947. */
  119948. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  119949. /** @hidden */
  119950. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  119951. private _setTextureParameterFloat;
  119952. private _setTextureParameterInteger;
  119953. /**
  119954. * Unbind all vertex attributes from the webGL context
  119955. */
  119956. unbindAllAttributes(): void;
  119957. /**
  119958. * 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
  119959. */
  119960. releaseEffects(): void;
  119961. /**
  119962. * Dispose and release all associated resources
  119963. */
  119964. dispose(): void;
  119965. /**
  119966. * Attach a new callback raised when context lost event is fired
  119967. * @param callback defines the callback to call
  119968. */
  119969. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  119970. /**
  119971. * Attach a new callback raised when context restored event is fired
  119972. * @param callback defines the callback to call
  119973. */
  119974. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  119975. /**
  119976. * Get the current error code of the webGL context
  119977. * @returns the error code
  119978. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  119979. */
  119980. getError(): number;
  119981. private _canRenderToFloatFramebuffer;
  119982. private _canRenderToHalfFloatFramebuffer;
  119983. private _canRenderToFramebuffer;
  119984. /** @hidden */
  119985. _getWebGLTextureType(type: number): number;
  119986. /** @hidden */
  119987. _getInternalFormat(format: number): number;
  119988. /** @hidden */
  119989. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  119990. /** @hidden */
  119991. _getRGBAMultiSampleBufferFormat(type: number): number;
  119992. /** @hidden */
  119993. _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;
  119994. /**
  119995. * Loads a file from a url
  119996. * @param url url to load
  119997. * @param onSuccess callback called when the file successfully loads
  119998. * @param onProgress callback called while file is loading (if the server supports this mode)
  119999. * @param offlineProvider defines the offline provider for caching
  120000. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  120001. * @param onError callback called when the file fails to load
  120002. * @returns a file request object
  120003. * @hidden
  120004. */
  120005. 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;
  120006. /**
  120007. * Reads pixels from the current frame buffer. Please note that this function can be slow
  120008. * @param x defines the x coordinate of the rectangle where pixels must be read
  120009. * @param y defines the y coordinate of the rectangle where pixels must be read
  120010. * @param width defines the width of the rectangle where pixels must be read
  120011. * @param height defines the height of the rectangle where pixels must be read
  120012. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  120013. * @returns a Uint8Array containing RGBA colors
  120014. */
  120015. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  120016. private static _IsSupported;
  120017. private static _HasMajorPerformanceCaveat;
  120018. /**
  120019. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120020. */
  120021. static get IsSupported(): boolean;
  120022. /**
  120023. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120024. * @returns true if the engine can be created
  120025. * @ignorenaming
  120026. */
  120027. static isSupported(): boolean;
  120028. /**
  120029. * 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)
  120030. */
  120031. static get HasMajorPerformanceCaveat(): boolean;
  120032. /**
  120033. * Find the next highest power of two.
  120034. * @param x Number to start search from.
  120035. * @return Next highest power of two.
  120036. */
  120037. static CeilingPOT(x: number): number;
  120038. /**
  120039. * Find the next lowest power of two.
  120040. * @param x Number to start search from.
  120041. * @return Next lowest power of two.
  120042. */
  120043. static FloorPOT(x: number): number;
  120044. /**
  120045. * Find the nearest power of two.
  120046. * @param x Number to start search from.
  120047. * @return Next nearest power of two.
  120048. */
  120049. static NearestPOT(x: number): number;
  120050. /**
  120051. * Get the closest exponent of two
  120052. * @param value defines the value to approximate
  120053. * @param max defines the maximum value to return
  120054. * @param mode defines how to define the closest value
  120055. * @returns closest exponent of two of the given value
  120056. */
  120057. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  120058. /**
  120059. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  120060. * @param func - the function to be called
  120061. * @param requester - the object that will request the next frame. Falls back to window.
  120062. * @returns frame number
  120063. */
  120064. static QueueNewFrame(func: () => void, requester?: any): number;
  120065. /**
  120066. * Gets host document
  120067. * @returns the host document object
  120068. */
  120069. getHostDocument(): Nullable<Document>;
  120070. }
  120071. }
  120072. declare module BABYLON {
  120073. /**
  120074. * Defines the source of the internal texture
  120075. */
  120076. export enum InternalTextureSource {
  120077. /**
  120078. * The source of the texture data is unknown
  120079. */
  120080. Unknown = 0,
  120081. /**
  120082. * Texture data comes from an URL
  120083. */
  120084. Url = 1,
  120085. /**
  120086. * Texture data is only used for temporary storage
  120087. */
  120088. Temp = 2,
  120089. /**
  120090. * Texture data comes from raw data (ArrayBuffer)
  120091. */
  120092. Raw = 3,
  120093. /**
  120094. * Texture content is dynamic (video or dynamic texture)
  120095. */
  120096. Dynamic = 4,
  120097. /**
  120098. * Texture content is generated by rendering to it
  120099. */
  120100. RenderTarget = 5,
  120101. /**
  120102. * Texture content is part of a multi render target process
  120103. */
  120104. MultiRenderTarget = 6,
  120105. /**
  120106. * Texture data comes from a cube data file
  120107. */
  120108. Cube = 7,
  120109. /**
  120110. * Texture data comes from a raw cube data
  120111. */
  120112. CubeRaw = 8,
  120113. /**
  120114. * Texture data come from a prefiltered cube data file
  120115. */
  120116. CubePrefiltered = 9,
  120117. /**
  120118. * Texture content is raw 3D data
  120119. */
  120120. Raw3D = 10,
  120121. /**
  120122. * Texture content is raw 2D array data
  120123. */
  120124. Raw2DArray = 11,
  120125. /**
  120126. * Texture content is a depth texture
  120127. */
  120128. Depth = 12,
  120129. /**
  120130. * Texture data comes from a raw cube data encoded with RGBD
  120131. */
  120132. CubeRawRGBD = 13
  120133. }
  120134. /**
  120135. * Class used to store data associated with WebGL texture data for the engine
  120136. * This class should not be used directly
  120137. */
  120138. export class InternalTexture {
  120139. /** @hidden */
  120140. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  120141. /**
  120142. * Defines if the texture is ready
  120143. */
  120144. isReady: boolean;
  120145. /**
  120146. * Defines if the texture is a cube texture
  120147. */
  120148. isCube: boolean;
  120149. /**
  120150. * Defines if the texture contains 3D data
  120151. */
  120152. is3D: boolean;
  120153. /**
  120154. * Defines if the texture contains 2D array data
  120155. */
  120156. is2DArray: boolean;
  120157. /**
  120158. * Defines if the texture contains multiview data
  120159. */
  120160. isMultiview: boolean;
  120161. /**
  120162. * Gets the URL used to load this texture
  120163. */
  120164. url: string;
  120165. /**
  120166. * Gets the sampling mode of the texture
  120167. */
  120168. samplingMode: number;
  120169. /**
  120170. * Gets a boolean indicating if the texture needs mipmaps generation
  120171. */
  120172. generateMipMaps: boolean;
  120173. /**
  120174. * Gets the number of samples used by the texture (WebGL2+ only)
  120175. */
  120176. samples: number;
  120177. /**
  120178. * Gets the type of the texture (int, float...)
  120179. */
  120180. type: number;
  120181. /**
  120182. * Gets the format of the texture (RGB, RGBA...)
  120183. */
  120184. format: number;
  120185. /**
  120186. * Observable called when the texture is loaded
  120187. */
  120188. onLoadedObservable: Observable<InternalTexture>;
  120189. /**
  120190. * Gets the width of the texture
  120191. */
  120192. width: number;
  120193. /**
  120194. * Gets the height of the texture
  120195. */
  120196. height: number;
  120197. /**
  120198. * Gets the depth of the texture
  120199. */
  120200. depth: number;
  120201. /**
  120202. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  120203. */
  120204. baseWidth: number;
  120205. /**
  120206. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  120207. */
  120208. baseHeight: number;
  120209. /**
  120210. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  120211. */
  120212. baseDepth: number;
  120213. /**
  120214. * Gets a boolean indicating if the texture is inverted on Y axis
  120215. */
  120216. invertY: boolean;
  120217. /** @hidden */
  120218. _invertVScale: boolean;
  120219. /** @hidden */
  120220. _associatedChannel: number;
  120221. /** @hidden */
  120222. _source: InternalTextureSource;
  120223. /** @hidden */
  120224. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  120225. /** @hidden */
  120226. _bufferView: Nullable<ArrayBufferView>;
  120227. /** @hidden */
  120228. _bufferViewArray: Nullable<ArrayBufferView[]>;
  120229. /** @hidden */
  120230. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  120231. /** @hidden */
  120232. _size: number;
  120233. /** @hidden */
  120234. _extension: string;
  120235. /** @hidden */
  120236. _files: Nullable<string[]>;
  120237. /** @hidden */
  120238. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120239. /** @hidden */
  120240. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120241. /** @hidden */
  120242. _framebuffer: Nullable<WebGLFramebuffer>;
  120243. /** @hidden */
  120244. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  120245. /** @hidden */
  120246. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  120247. /** @hidden */
  120248. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  120249. /** @hidden */
  120250. _attachments: Nullable<number[]>;
  120251. /** @hidden */
  120252. _textureArray: Nullable<InternalTexture[]>;
  120253. /** @hidden */
  120254. _cachedCoordinatesMode: Nullable<number>;
  120255. /** @hidden */
  120256. _cachedWrapU: Nullable<number>;
  120257. /** @hidden */
  120258. _cachedWrapV: Nullable<number>;
  120259. /** @hidden */
  120260. _cachedWrapR: Nullable<number>;
  120261. /** @hidden */
  120262. _cachedAnisotropicFilteringLevel: Nullable<number>;
  120263. /** @hidden */
  120264. _isDisabled: boolean;
  120265. /** @hidden */
  120266. _compression: Nullable<string>;
  120267. /** @hidden */
  120268. _generateStencilBuffer: boolean;
  120269. /** @hidden */
  120270. _generateDepthBuffer: boolean;
  120271. /** @hidden */
  120272. _comparisonFunction: number;
  120273. /** @hidden */
  120274. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  120275. /** @hidden */
  120276. _lodGenerationScale: number;
  120277. /** @hidden */
  120278. _lodGenerationOffset: number;
  120279. /** @hidden */
  120280. _depthStencilTexture: Nullable<InternalTexture>;
  120281. /** @hidden */
  120282. _colorTextureArray: Nullable<WebGLTexture>;
  120283. /** @hidden */
  120284. _depthStencilTextureArray: Nullable<WebGLTexture>;
  120285. /** @hidden */
  120286. _lodTextureHigh: Nullable<BaseTexture>;
  120287. /** @hidden */
  120288. _lodTextureMid: Nullable<BaseTexture>;
  120289. /** @hidden */
  120290. _lodTextureLow: Nullable<BaseTexture>;
  120291. /** @hidden */
  120292. _isRGBD: boolean;
  120293. /** @hidden */
  120294. _linearSpecularLOD: boolean;
  120295. /** @hidden */
  120296. _irradianceTexture: Nullable<BaseTexture>;
  120297. /** @hidden */
  120298. _webGLTexture: Nullable<WebGLTexture>;
  120299. /** @hidden */
  120300. _references: number;
  120301. /** @hidden */
  120302. _gammaSpace: Nullable<boolean>;
  120303. private _engine;
  120304. /**
  120305. * Gets the Engine the texture belongs to.
  120306. * @returns The babylon engine
  120307. */
  120308. getEngine(): ThinEngine;
  120309. /**
  120310. * Gets the data source type of the texture
  120311. */
  120312. get source(): InternalTextureSource;
  120313. /**
  120314. * Creates a new InternalTexture
  120315. * @param engine defines the engine to use
  120316. * @param source defines the type of data that will be used
  120317. * @param delayAllocation if the texture allocation should be delayed (default: false)
  120318. */
  120319. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  120320. /**
  120321. * Increments the number of references (ie. the number of Texture that point to it)
  120322. */
  120323. incrementReferences(): void;
  120324. /**
  120325. * Change the size of the texture (not the size of the content)
  120326. * @param width defines the new width
  120327. * @param height defines the new height
  120328. * @param depth defines the new depth (1 by default)
  120329. */
  120330. updateSize(width: int, height: int, depth?: int): void;
  120331. /** @hidden */
  120332. _rebuild(): void;
  120333. /** @hidden */
  120334. _swapAndDie(target: InternalTexture): void;
  120335. /**
  120336. * Dispose the current allocated resources
  120337. */
  120338. dispose(): void;
  120339. }
  120340. }
  120341. declare module BABYLON {
  120342. /**
  120343. * Class used to work with sound analyzer using fast fourier transform (FFT)
  120344. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120345. */
  120346. export class Analyser {
  120347. /**
  120348. * Gets or sets the smoothing
  120349. * @ignorenaming
  120350. */
  120351. SMOOTHING: number;
  120352. /**
  120353. * Gets or sets the FFT table size
  120354. * @ignorenaming
  120355. */
  120356. FFT_SIZE: number;
  120357. /**
  120358. * Gets or sets the bar graph amplitude
  120359. * @ignorenaming
  120360. */
  120361. BARGRAPHAMPLITUDE: number;
  120362. /**
  120363. * Gets or sets the position of the debug canvas
  120364. * @ignorenaming
  120365. */
  120366. DEBUGCANVASPOS: {
  120367. x: number;
  120368. y: number;
  120369. };
  120370. /**
  120371. * Gets or sets the debug canvas size
  120372. * @ignorenaming
  120373. */
  120374. DEBUGCANVASSIZE: {
  120375. width: number;
  120376. height: number;
  120377. };
  120378. private _byteFreqs;
  120379. private _byteTime;
  120380. private _floatFreqs;
  120381. private _webAudioAnalyser;
  120382. private _debugCanvas;
  120383. private _debugCanvasContext;
  120384. private _scene;
  120385. private _registerFunc;
  120386. private _audioEngine;
  120387. /**
  120388. * Creates a new analyser
  120389. * @param scene defines hosting scene
  120390. */
  120391. constructor(scene: Scene);
  120392. /**
  120393. * Get the number of data values you will have to play with for the visualization
  120394. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  120395. * @returns a number
  120396. */
  120397. getFrequencyBinCount(): number;
  120398. /**
  120399. * Gets the current frequency data as a byte array
  120400. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120401. * @returns a Uint8Array
  120402. */
  120403. getByteFrequencyData(): Uint8Array;
  120404. /**
  120405. * Gets the current waveform as a byte array
  120406. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  120407. * @returns a Uint8Array
  120408. */
  120409. getByteTimeDomainData(): Uint8Array;
  120410. /**
  120411. * Gets the current frequency data as a float array
  120412. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120413. * @returns a Float32Array
  120414. */
  120415. getFloatFrequencyData(): Float32Array;
  120416. /**
  120417. * Renders the debug canvas
  120418. */
  120419. drawDebugCanvas(): void;
  120420. /**
  120421. * Stops rendering the debug canvas and removes it
  120422. */
  120423. stopDebugCanvas(): void;
  120424. /**
  120425. * Connects two audio nodes
  120426. * @param inputAudioNode defines first node to connect
  120427. * @param outputAudioNode defines second node to connect
  120428. */
  120429. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  120430. /**
  120431. * Releases all associated resources
  120432. */
  120433. dispose(): void;
  120434. }
  120435. }
  120436. declare module BABYLON {
  120437. /**
  120438. * This represents an audio engine and it is responsible
  120439. * to play, synchronize and analyse sounds throughout the application.
  120440. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120441. */
  120442. export interface IAudioEngine extends IDisposable {
  120443. /**
  120444. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120445. */
  120446. readonly canUseWebAudio: boolean;
  120447. /**
  120448. * Gets the current AudioContext if available.
  120449. */
  120450. readonly audioContext: Nullable<AudioContext>;
  120451. /**
  120452. * The master gain node defines the global audio volume of your audio engine.
  120453. */
  120454. readonly masterGain: GainNode;
  120455. /**
  120456. * Gets whether or not mp3 are supported by your browser.
  120457. */
  120458. readonly isMP3supported: boolean;
  120459. /**
  120460. * Gets whether or not ogg are supported by your browser.
  120461. */
  120462. readonly isOGGsupported: boolean;
  120463. /**
  120464. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120465. * @ignoreNaming
  120466. */
  120467. WarnedWebAudioUnsupported: boolean;
  120468. /**
  120469. * Defines if the audio engine relies on a custom unlocked button.
  120470. * In this case, the embedded button will not be displayed.
  120471. */
  120472. useCustomUnlockedButton: boolean;
  120473. /**
  120474. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  120475. */
  120476. readonly unlocked: boolean;
  120477. /**
  120478. * Event raised when audio has been unlocked on the browser.
  120479. */
  120480. onAudioUnlockedObservable: Observable<AudioEngine>;
  120481. /**
  120482. * Event raised when audio has been locked on the browser.
  120483. */
  120484. onAudioLockedObservable: Observable<AudioEngine>;
  120485. /**
  120486. * Flags the audio engine in Locked state.
  120487. * This happens due to new browser policies preventing audio to autoplay.
  120488. */
  120489. lock(): void;
  120490. /**
  120491. * Unlocks the audio engine once a user action has been done on the dom.
  120492. * This is helpful to resume play once browser policies have been satisfied.
  120493. */
  120494. unlock(): void;
  120495. /**
  120496. * Gets the global volume sets on the master gain.
  120497. * @returns the global volume if set or -1 otherwise
  120498. */
  120499. getGlobalVolume(): number;
  120500. /**
  120501. * Sets the global volume of your experience (sets on the master gain).
  120502. * @param newVolume Defines the new global volume of the application
  120503. */
  120504. setGlobalVolume(newVolume: number): void;
  120505. /**
  120506. * Connect the audio engine to an audio analyser allowing some amazing
  120507. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120508. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120509. * @param analyser The analyser to connect to the engine
  120510. */
  120511. connectToAnalyser(analyser: Analyser): void;
  120512. }
  120513. /**
  120514. * This represents the default audio engine used in babylon.
  120515. * It is responsible to play, synchronize and analyse sounds throughout the application.
  120516. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120517. */
  120518. export class AudioEngine implements IAudioEngine {
  120519. private _audioContext;
  120520. private _audioContextInitialized;
  120521. private _muteButton;
  120522. private _hostElement;
  120523. /**
  120524. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120525. */
  120526. canUseWebAudio: boolean;
  120527. /**
  120528. * The master gain node defines the global audio volume of your audio engine.
  120529. */
  120530. masterGain: GainNode;
  120531. /**
  120532. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120533. * @ignoreNaming
  120534. */
  120535. WarnedWebAudioUnsupported: boolean;
  120536. /**
  120537. * Gets whether or not mp3 are supported by your browser.
  120538. */
  120539. isMP3supported: boolean;
  120540. /**
  120541. * Gets whether or not ogg are supported by your browser.
  120542. */
  120543. isOGGsupported: boolean;
  120544. /**
  120545. * Gets whether audio has been unlocked on the device.
  120546. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  120547. * a user interaction has happened.
  120548. */
  120549. unlocked: boolean;
  120550. /**
  120551. * Defines if the audio engine relies on a custom unlocked button.
  120552. * In this case, the embedded button will not be displayed.
  120553. */
  120554. useCustomUnlockedButton: boolean;
  120555. /**
  120556. * Event raised when audio has been unlocked on the browser.
  120557. */
  120558. onAudioUnlockedObservable: Observable<AudioEngine>;
  120559. /**
  120560. * Event raised when audio has been locked on the browser.
  120561. */
  120562. onAudioLockedObservable: Observable<AudioEngine>;
  120563. /**
  120564. * Gets the current AudioContext if available.
  120565. */
  120566. get audioContext(): Nullable<AudioContext>;
  120567. private _connectedAnalyser;
  120568. /**
  120569. * Instantiates a new audio engine.
  120570. *
  120571. * There should be only one per page as some browsers restrict the number
  120572. * of audio contexts you can create.
  120573. * @param hostElement defines the host element where to display the mute icon if necessary
  120574. */
  120575. constructor(hostElement?: Nullable<HTMLElement>);
  120576. /**
  120577. * Flags the audio engine in Locked state.
  120578. * This happens due to new browser policies preventing audio to autoplay.
  120579. */
  120580. lock(): void;
  120581. /**
  120582. * Unlocks the audio engine once a user action has been done on the dom.
  120583. * This is helpful to resume play once browser policies have been satisfied.
  120584. */
  120585. unlock(): void;
  120586. private _resumeAudioContext;
  120587. private _initializeAudioContext;
  120588. private _tryToRun;
  120589. private _triggerRunningState;
  120590. private _triggerSuspendedState;
  120591. private _displayMuteButton;
  120592. private _moveButtonToTopLeft;
  120593. private _onResize;
  120594. private _hideMuteButton;
  120595. /**
  120596. * Destroy and release the resources associated with the audio ccontext.
  120597. */
  120598. dispose(): void;
  120599. /**
  120600. * Gets the global volume sets on the master gain.
  120601. * @returns the global volume if set or -1 otherwise
  120602. */
  120603. getGlobalVolume(): number;
  120604. /**
  120605. * Sets the global volume of your experience (sets on the master gain).
  120606. * @param newVolume Defines the new global volume of the application
  120607. */
  120608. setGlobalVolume(newVolume: number): void;
  120609. /**
  120610. * Connect the audio engine to an audio analyser allowing some amazing
  120611. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120612. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120613. * @param analyser The analyser to connect to the engine
  120614. */
  120615. connectToAnalyser(analyser: Analyser): void;
  120616. }
  120617. }
  120618. declare module BABYLON {
  120619. /**
  120620. * Interface used to present a loading screen while loading a scene
  120621. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120622. */
  120623. export interface ILoadingScreen {
  120624. /**
  120625. * Function called to display the loading screen
  120626. */
  120627. displayLoadingUI: () => void;
  120628. /**
  120629. * Function called to hide the loading screen
  120630. */
  120631. hideLoadingUI: () => void;
  120632. /**
  120633. * Gets or sets the color to use for the background
  120634. */
  120635. loadingUIBackgroundColor: string;
  120636. /**
  120637. * Gets or sets the text to display while loading
  120638. */
  120639. loadingUIText: string;
  120640. }
  120641. /**
  120642. * Class used for the default loading screen
  120643. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120644. */
  120645. export class DefaultLoadingScreen implements ILoadingScreen {
  120646. private _renderingCanvas;
  120647. private _loadingText;
  120648. private _loadingDivBackgroundColor;
  120649. private _loadingDiv;
  120650. private _loadingTextDiv;
  120651. /** Gets or sets the logo url to use for the default loading screen */
  120652. static DefaultLogoUrl: string;
  120653. /** Gets or sets the spinner url to use for the default loading screen */
  120654. static DefaultSpinnerUrl: string;
  120655. /**
  120656. * Creates a new default loading screen
  120657. * @param _renderingCanvas defines the canvas used to render the scene
  120658. * @param _loadingText defines the default text to display
  120659. * @param _loadingDivBackgroundColor defines the default background color
  120660. */
  120661. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  120662. /**
  120663. * Function called to display the loading screen
  120664. */
  120665. displayLoadingUI(): void;
  120666. /**
  120667. * Function called to hide the loading screen
  120668. */
  120669. hideLoadingUI(): void;
  120670. /**
  120671. * Gets or sets the text to display while loading
  120672. */
  120673. set loadingUIText(text: string);
  120674. get loadingUIText(): string;
  120675. /**
  120676. * Gets or sets the color to use for the background
  120677. */
  120678. get loadingUIBackgroundColor(): string;
  120679. set loadingUIBackgroundColor(color: string);
  120680. private _resizeLoadingUI;
  120681. }
  120682. }
  120683. declare module BABYLON {
  120684. /**
  120685. * Interface for any object that can request an animation frame
  120686. */
  120687. export interface ICustomAnimationFrameRequester {
  120688. /**
  120689. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  120690. */
  120691. renderFunction?: Function;
  120692. /**
  120693. * Called to request the next frame to render to
  120694. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  120695. */
  120696. requestAnimationFrame: Function;
  120697. /**
  120698. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  120699. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  120700. */
  120701. requestID?: number;
  120702. }
  120703. }
  120704. declare module BABYLON {
  120705. /**
  120706. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  120707. */
  120708. export class PerformanceMonitor {
  120709. private _enabled;
  120710. private _rollingFrameTime;
  120711. private _lastFrameTimeMs;
  120712. /**
  120713. * constructor
  120714. * @param frameSampleSize The number of samples required to saturate the sliding window
  120715. */
  120716. constructor(frameSampleSize?: number);
  120717. /**
  120718. * Samples current frame
  120719. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  120720. */
  120721. sampleFrame(timeMs?: number): void;
  120722. /**
  120723. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  120724. */
  120725. get averageFrameTime(): number;
  120726. /**
  120727. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  120728. */
  120729. get averageFrameTimeVariance(): number;
  120730. /**
  120731. * Returns the frame time of the most recent frame
  120732. */
  120733. get instantaneousFrameTime(): number;
  120734. /**
  120735. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  120736. */
  120737. get averageFPS(): number;
  120738. /**
  120739. * Returns the average framerate in frames per second using the most recent frame time
  120740. */
  120741. get instantaneousFPS(): number;
  120742. /**
  120743. * Returns true if enough samples have been taken to completely fill the sliding window
  120744. */
  120745. get isSaturated(): boolean;
  120746. /**
  120747. * Enables contributions to the sliding window sample set
  120748. */
  120749. enable(): void;
  120750. /**
  120751. * Disables contributions to the sliding window sample set
  120752. * Samples will not be interpolated over the disabled period
  120753. */
  120754. disable(): void;
  120755. /**
  120756. * Returns true if sampling is enabled
  120757. */
  120758. get isEnabled(): boolean;
  120759. /**
  120760. * Resets performance monitor
  120761. */
  120762. reset(): void;
  120763. }
  120764. /**
  120765. * RollingAverage
  120766. *
  120767. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  120768. */
  120769. export class RollingAverage {
  120770. /**
  120771. * Current average
  120772. */
  120773. average: number;
  120774. /**
  120775. * Current variance
  120776. */
  120777. variance: number;
  120778. protected _samples: Array<number>;
  120779. protected _sampleCount: number;
  120780. protected _pos: number;
  120781. protected _m2: number;
  120782. /**
  120783. * constructor
  120784. * @param length The number of samples required to saturate the sliding window
  120785. */
  120786. constructor(length: number);
  120787. /**
  120788. * Adds a sample to the sample set
  120789. * @param v The sample value
  120790. */
  120791. add(v: number): void;
  120792. /**
  120793. * Returns previously added values or null if outside of history or outside the sliding window domain
  120794. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  120795. * @return Value previously recorded with add() or null if outside of range
  120796. */
  120797. history(i: number): number;
  120798. /**
  120799. * Returns true if enough samples have been taken to completely fill the sliding window
  120800. * @return true if sample-set saturated
  120801. */
  120802. isSaturated(): boolean;
  120803. /**
  120804. * Resets the rolling average (equivalent to 0 samples taken so far)
  120805. */
  120806. reset(): void;
  120807. /**
  120808. * Wraps a value around the sample range boundaries
  120809. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  120810. * @return Wrapped position in sample range
  120811. */
  120812. protected _wrapPosition(i: number): number;
  120813. }
  120814. }
  120815. declare module BABYLON {
  120816. /**
  120817. * This class is used to track a performance counter which is number based.
  120818. * The user has access to many properties which give statistics of different nature.
  120819. *
  120820. * The implementer can track two kinds of Performance Counter: time and count.
  120821. * 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.
  120822. * 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.
  120823. */
  120824. export class PerfCounter {
  120825. /**
  120826. * Gets or sets a global boolean to turn on and off all the counters
  120827. */
  120828. static Enabled: boolean;
  120829. /**
  120830. * Returns the smallest value ever
  120831. */
  120832. get min(): number;
  120833. /**
  120834. * Returns the biggest value ever
  120835. */
  120836. get max(): number;
  120837. /**
  120838. * Returns the average value since the performance counter is running
  120839. */
  120840. get average(): number;
  120841. /**
  120842. * Returns the average value of the last second the counter was monitored
  120843. */
  120844. get lastSecAverage(): number;
  120845. /**
  120846. * Returns the current value
  120847. */
  120848. get current(): number;
  120849. /**
  120850. * Gets the accumulated total
  120851. */
  120852. get total(): number;
  120853. /**
  120854. * Gets the total value count
  120855. */
  120856. get count(): number;
  120857. /**
  120858. * Creates a new counter
  120859. */
  120860. constructor();
  120861. /**
  120862. * Call this method to start monitoring a new frame.
  120863. * 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.
  120864. */
  120865. fetchNewFrame(): void;
  120866. /**
  120867. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  120868. * @param newCount the count value to add to the monitored count
  120869. * @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.
  120870. */
  120871. addCount(newCount: number, fetchResult: boolean): void;
  120872. /**
  120873. * Start monitoring this performance counter
  120874. */
  120875. beginMonitoring(): void;
  120876. /**
  120877. * Compute the time lapsed since the previous beginMonitoring() call.
  120878. * @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
  120879. */
  120880. endMonitoring(newFrame?: boolean): void;
  120881. private _fetchResult;
  120882. private _startMonitoringTime;
  120883. private _min;
  120884. private _max;
  120885. private _average;
  120886. private _current;
  120887. private _totalValueCount;
  120888. private _totalAccumulated;
  120889. private _lastSecAverage;
  120890. private _lastSecAccumulated;
  120891. private _lastSecTime;
  120892. private _lastSecValueCount;
  120893. }
  120894. }
  120895. declare module BABYLON {
  120896. interface ThinEngine {
  120897. /** @hidden */
  120898. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  120899. }
  120900. }
  120901. declare module BABYLON {
  120902. /**
  120903. * Defines the interface used by display changed events
  120904. */
  120905. export interface IDisplayChangedEventArgs {
  120906. /** Gets the vrDisplay object (if any) */
  120907. vrDisplay: Nullable<any>;
  120908. /** Gets a boolean indicating if webVR is supported */
  120909. vrSupported: boolean;
  120910. }
  120911. /**
  120912. * Defines the interface used by objects containing a viewport (like a camera)
  120913. */
  120914. interface IViewportOwnerLike {
  120915. /**
  120916. * Gets or sets the viewport
  120917. */
  120918. viewport: IViewportLike;
  120919. }
  120920. /**
  120921. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  120922. */
  120923. export class Engine extends ThinEngine {
  120924. /** Defines that alpha blending is disabled */
  120925. static readonly ALPHA_DISABLE: number;
  120926. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  120927. static readonly ALPHA_ADD: number;
  120928. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  120929. static readonly ALPHA_COMBINE: number;
  120930. /** Defines that alpha blending to DEST - SRC * DEST */
  120931. static readonly ALPHA_SUBTRACT: number;
  120932. /** Defines that alpha blending to SRC * DEST */
  120933. static readonly ALPHA_MULTIPLY: number;
  120934. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  120935. static readonly ALPHA_MAXIMIZED: number;
  120936. /** Defines that alpha blending to SRC + DEST */
  120937. static readonly ALPHA_ONEONE: number;
  120938. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  120939. static readonly ALPHA_PREMULTIPLIED: number;
  120940. /**
  120941. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  120942. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  120943. */
  120944. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  120945. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  120946. static readonly ALPHA_INTERPOLATE: number;
  120947. /**
  120948. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  120949. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  120950. */
  120951. static readonly ALPHA_SCREENMODE: number;
  120952. /** Defines that the ressource is not delayed*/
  120953. static readonly DELAYLOADSTATE_NONE: number;
  120954. /** Defines that the ressource was successfully delay loaded */
  120955. static readonly DELAYLOADSTATE_LOADED: number;
  120956. /** Defines that the ressource is currently delay loading */
  120957. static readonly DELAYLOADSTATE_LOADING: number;
  120958. /** Defines that the ressource is delayed and has not started loading */
  120959. static readonly DELAYLOADSTATE_NOTLOADED: number;
  120960. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  120961. static readonly NEVER: number;
  120962. /** 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 */
  120963. static readonly ALWAYS: number;
  120964. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  120965. static readonly LESS: number;
  120966. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  120967. static readonly EQUAL: number;
  120968. /** 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 */
  120969. static readonly LEQUAL: number;
  120970. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  120971. static readonly GREATER: number;
  120972. /** 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 */
  120973. static readonly GEQUAL: number;
  120974. /** 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 */
  120975. static readonly NOTEQUAL: number;
  120976. /** Passed to stencilOperation to specify that stencil value must be kept */
  120977. static readonly KEEP: number;
  120978. /** Passed to stencilOperation to specify that stencil value must be replaced */
  120979. static readonly REPLACE: number;
  120980. /** Passed to stencilOperation to specify that stencil value must be incremented */
  120981. static readonly INCR: number;
  120982. /** Passed to stencilOperation to specify that stencil value must be decremented */
  120983. static readonly DECR: number;
  120984. /** Passed to stencilOperation to specify that stencil value must be inverted */
  120985. static readonly INVERT: number;
  120986. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  120987. static readonly INCR_WRAP: number;
  120988. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  120989. static readonly DECR_WRAP: number;
  120990. /** Texture is not repeating outside of 0..1 UVs */
  120991. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  120992. /** Texture is repeating outside of 0..1 UVs */
  120993. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  120994. /** Texture is repeating and mirrored */
  120995. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  120996. /** ALPHA */
  120997. static readonly TEXTUREFORMAT_ALPHA: number;
  120998. /** LUMINANCE */
  120999. static readonly TEXTUREFORMAT_LUMINANCE: number;
  121000. /** LUMINANCE_ALPHA */
  121001. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  121002. /** RGB */
  121003. static readonly TEXTUREFORMAT_RGB: number;
  121004. /** RGBA */
  121005. static readonly TEXTUREFORMAT_RGBA: number;
  121006. /** RED */
  121007. static readonly TEXTUREFORMAT_RED: number;
  121008. /** RED (2nd reference) */
  121009. static readonly TEXTUREFORMAT_R: number;
  121010. /** RG */
  121011. static readonly TEXTUREFORMAT_RG: number;
  121012. /** RED_INTEGER */
  121013. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  121014. /** RED_INTEGER (2nd reference) */
  121015. static readonly TEXTUREFORMAT_R_INTEGER: number;
  121016. /** RG_INTEGER */
  121017. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  121018. /** RGB_INTEGER */
  121019. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  121020. /** RGBA_INTEGER */
  121021. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  121022. /** UNSIGNED_BYTE */
  121023. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  121024. /** UNSIGNED_BYTE (2nd reference) */
  121025. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  121026. /** FLOAT */
  121027. static readonly TEXTURETYPE_FLOAT: number;
  121028. /** HALF_FLOAT */
  121029. static readonly TEXTURETYPE_HALF_FLOAT: number;
  121030. /** BYTE */
  121031. static readonly TEXTURETYPE_BYTE: number;
  121032. /** SHORT */
  121033. static readonly TEXTURETYPE_SHORT: number;
  121034. /** UNSIGNED_SHORT */
  121035. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  121036. /** INT */
  121037. static readonly TEXTURETYPE_INT: number;
  121038. /** UNSIGNED_INT */
  121039. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  121040. /** UNSIGNED_SHORT_4_4_4_4 */
  121041. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  121042. /** UNSIGNED_SHORT_5_5_5_1 */
  121043. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  121044. /** UNSIGNED_SHORT_5_6_5 */
  121045. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  121046. /** UNSIGNED_INT_2_10_10_10_REV */
  121047. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  121048. /** UNSIGNED_INT_24_8 */
  121049. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  121050. /** UNSIGNED_INT_10F_11F_11F_REV */
  121051. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  121052. /** UNSIGNED_INT_5_9_9_9_REV */
  121053. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  121054. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  121055. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121056. /** nearest is mag = nearest and min = nearest and mip = linear */
  121057. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  121058. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121059. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  121060. /** Trilinear is mag = linear and min = linear and mip = linear */
  121061. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  121062. /** nearest is mag = nearest and min = nearest and mip = linear */
  121063. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  121064. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121065. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  121066. /** Trilinear is mag = linear and min = linear and mip = linear */
  121067. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  121068. /** mag = nearest and min = nearest and mip = nearest */
  121069. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  121070. /** mag = nearest and min = linear and mip = nearest */
  121071. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  121072. /** mag = nearest and min = linear and mip = linear */
  121073. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  121074. /** mag = nearest and min = linear and mip = none */
  121075. static readonly TEXTURE_NEAREST_LINEAR: number;
  121076. /** mag = nearest and min = nearest and mip = none */
  121077. static readonly TEXTURE_NEAREST_NEAREST: number;
  121078. /** mag = linear and min = nearest and mip = nearest */
  121079. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  121080. /** mag = linear and min = nearest and mip = linear */
  121081. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  121082. /** mag = linear and min = linear and mip = none */
  121083. static readonly TEXTURE_LINEAR_LINEAR: number;
  121084. /** mag = linear and min = nearest and mip = none */
  121085. static readonly TEXTURE_LINEAR_NEAREST: number;
  121086. /** Explicit coordinates mode */
  121087. static readonly TEXTURE_EXPLICIT_MODE: number;
  121088. /** Spherical coordinates mode */
  121089. static readonly TEXTURE_SPHERICAL_MODE: number;
  121090. /** Planar coordinates mode */
  121091. static readonly TEXTURE_PLANAR_MODE: number;
  121092. /** Cubic coordinates mode */
  121093. static readonly TEXTURE_CUBIC_MODE: number;
  121094. /** Projection coordinates mode */
  121095. static readonly TEXTURE_PROJECTION_MODE: number;
  121096. /** Skybox coordinates mode */
  121097. static readonly TEXTURE_SKYBOX_MODE: number;
  121098. /** Inverse Cubic coordinates mode */
  121099. static readonly TEXTURE_INVCUBIC_MODE: number;
  121100. /** Equirectangular coordinates mode */
  121101. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  121102. /** Equirectangular Fixed coordinates mode */
  121103. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  121104. /** Equirectangular Fixed Mirrored coordinates mode */
  121105. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  121106. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  121107. static readonly SCALEMODE_FLOOR: number;
  121108. /** Defines that texture rescaling will look for the nearest power of 2 size */
  121109. static readonly SCALEMODE_NEAREST: number;
  121110. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  121111. static readonly SCALEMODE_CEILING: number;
  121112. /**
  121113. * Returns the current npm package of the sdk
  121114. */
  121115. static get NpmPackage(): string;
  121116. /**
  121117. * Returns the current version of the framework
  121118. */
  121119. static get Version(): string;
  121120. /** Gets the list of created engines */
  121121. static get Instances(): Engine[];
  121122. /**
  121123. * Gets the latest created engine
  121124. */
  121125. static get LastCreatedEngine(): Nullable<Engine>;
  121126. /**
  121127. * Gets the latest created scene
  121128. */
  121129. static get LastCreatedScene(): Nullable<Scene>;
  121130. /**
  121131. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  121132. * @param flag defines which part of the materials must be marked as dirty
  121133. * @param predicate defines a predicate used to filter which materials should be affected
  121134. */
  121135. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121136. /**
  121137. * Method called to create the default loading screen.
  121138. * This can be overriden in your own app.
  121139. * @param canvas The rendering canvas element
  121140. * @returns The loading screen
  121141. */
  121142. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  121143. /**
  121144. * Method called to create the default rescale post process on each engine.
  121145. */
  121146. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  121147. /**
  121148. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  121149. **/
  121150. enableOfflineSupport: boolean;
  121151. /**
  121152. * 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)
  121153. **/
  121154. disableManifestCheck: boolean;
  121155. /**
  121156. * Gets the list of created scenes
  121157. */
  121158. scenes: Scene[];
  121159. /**
  121160. * Event raised when a new scene is created
  121161. */
  121162. onNewSceneAddedObservable: Observable<Scene>;
  121163. /**
  121164. * Gets the list of created postprocesses
  121165. */
  121166. postProcesses: PostProcess[];
  121167. /**
  121168. * Gets a boolean indicating if the pointer is currently locked
  121169. */
  121170. isPointerLock: boolean;
  121171. /**
  121172. * Observable event triggered each time the rendering canvas is resized
  121173. */
  121174. onResizeObservable: Observable<Engine>;
  121175. /**
  121176. * Observable event triggered each time the canvas loses focus
  121177. */
  121178. onCanvasBlurObservable: Observable<Engine>;
  121179. /**
  121180. * Observable event triggered each time the canvas gains focus
  121181. */
  121182. onCanvasFocusObservable: Observable<Engine>;
  121183. /**
  121184. * Observable event triggered each time the canvas receives pointerout event
  121185. */
  121186. onCanvasPointerOutObservable: Observable<PointerEvent>;
  121187. /**
  121188. * Observable raised when the engine begins a new frame
  121189. */
  121190. onBeginFrameObservable: Observable<Engine>;
  121191. /**
  121192. * If set, will be used to request the next animation frame for the render loop
  121193. */
  121194. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  121195. /**
  121196. * Observable raised when the engine ends the current frame
  121197. */
  121198. onEndFrameObservable: Observable<Engine>;
  121199. /**
  121200. * Observable raised when the engine is about to compile a shader
  121201. */
  121202. onBeforeShaderCompilationObservable: Observable<Engine>;
  121203. /**
  121204. * Observable raised when the engine has jsut compiled a shader
  121205. */
  121206. onAfterShaderCompilationObservable: Observable<Engine>;
  121207. /**
  121208. * Gets the audio engine
  121209. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121210. * @ignorenaming
  121211. */
  121212. static audioEngine: IAudioEngine;
  121213. /**
  121214. * Default AudioEngine factory responsible of creating the Audio Engine.
  121215. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  121216. */
  121217. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  121218. /**
  121219. * Default offline support factory responsible of creating a tool used to store data locally.
  121220. * By default, this will create a Database object if the workload has been embedded.
  121221. */
  121222. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  121223. private _loadingScreen;
  121224. private _pointerLockRequested;
  121225. private _rescalePostProcess;
  121226. private _deterministicLockstep;
  121227. private _lockstepMaxSteps;
  121228. private _timeStep;
  121229. protected get _supportsHardwareTextureRescaling(): boolean;
  121230. private _fps;
  121231. private _deltaTime;
  121232. /** @hidden */
  121233. _drawCalls: PerfCounter;
  121234. /** 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 */
  121235. canvasTabIndex: number;
  121236. /**
  121237. * Turn this value on if you want to pause FPS computation when in background
  121238. */
  121239. disablePerformanceMonitorInBackground: boolean;
  121240. private _performanceMonitor;
  121241. /**
  121242. * Gets the performance monitor attached to this engine
  121243. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  121244. */
  121245. get performanceMonitor(): PerformanceMonitor;
  121246. private _onFocus;
  121247. private _onBlur;
  121248. private _onCanvasPointerOut;
  121249. private _onCanvasBlur;
  121250. private _onCanvasFocus;
  121251. private _onFullscreenChange;
  121252. private _onPointerLockChange;
  121253. /**
  121254. * Gets the HTML element used to attach event listeners
  121255. * @returns a HTML element
  121256. */
  121257. getInputElement(): Nullable<HTMLElement>;
  121258. /**
  121259. * Creates a new engine
  121260. * @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
  121261. * @param antialias defines enable antialiasing (default: false)
  121262. * @param options defines further options to be sent to the getContext() function
  121263. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  121264. */
  121265. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  121266. /**
  121267. * Gets current aspect ratio
  121268. * @param viewportOwner defines the camera to use to get the aspect ratio
  121269. * @param useScreen defines if screen size must be used (or the current render target if any)
  121270. * @returns a number defining the aspect ratio
  121271. */
  121272. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  121273. /**
  121274. * Gets current screen aspect ratio
  121275. * @returns a number defining the aspect ratio
  121276. */
  121277. getScreenAspectRatio(): number;
  121278. /**
  121279. * Gets the client rect of the HTML canvas attached with the current webGL context
  121280. * @returns a client rectanglee
  121281. */
  121282. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  121283. /**
  121284. * Gets the client rect of the HTML element used for events
  121285. * @returns a client rectanglee
  121286. */
  121287. getInputElementClientRect(): Nullable<ClientRect>;
  121288. /**
  121289. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  121290. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121291. * @returns true if engine is in deterministic lock step mode
  121292. */
  121293. isDeterministicLockStep(): boolean;
  121294. /**
  121295. * Gets the max steps when engine is running in deterministic lock step
  121296. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121297. * @returns the max steps
  121298. */
  121299. getLockstepMaxSteps(): number;
  121300. /**
  121301. * Returns the time in ms between steps when using deterministic lock step.
  121302. * @returns time step in (ms)
  121303. */
  121304. getTimeStep(): number;
  121305. /**
  121306. * Force the mipmap generation for the given render target texture
  121307. * @param texture defines the render target texture to use
  121308. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  121309. */
  121310. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  121311. /** States */
  121312. /**
  121313. * Set various states to the webGL context
  121314. * @param culling defines backface culling state
  121315. * @param zOffset defines the value to apply to zOffset (0 by default)
  121316. * @param force defines if states must be applied even if cache is up to date
  121317. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  121318. */
  121319. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121320. /**
  121321. * Set the z offset to apply to current rendering
  121322. * @param value defines the offset to apply
  121323. */
  121324. setZOffset(value: number): void;
  121325. /**
  121326. * Gets the current value of the zOffset
  121327. * @returns the current zOffset state
  121328. */
  121329. getZOffset(): number;
  121330. /**
  121331. * Enable or disable depth buffering
  121332. * @param enable defines the state to set
  121333. */
  121334. setDepthBuffer(enable: boolean): void;
  121335. /**
  121336. * Gets a boolean indicating if depth writing is enabled
  121337. * @returns the current depth writing state
  121338. */
  121339. getDepthWrite(): boolean;
  121340. /**
  121341. * Enable or disable depth writing
  121342. * @param enable defines the state to set
  121343. */
  121344. setDepthWrite(enable: boolean): void;
  121345. /**
  121346. * Gets a boolean indicating if stencil buffer is enabled
  121347. * @returns the current stencil buffer state
  121348. */
  121349. getStencilBuffer(): boolean;
  121350. /**
  121351. * Enable or disable the stencil buffer
  121352. * @param enable defines if the stencil buffer must be enabled or disabled
  121353. */
  121354. setStencilBuffer(enable: boolean): void;
  121355. /**
  121356. * Gets the current stencil mask
  121357. * @returns a number defining the new stencil mask to use
  121358. */
  121359. getStencilMask(): number;
  121360. /**
  121361. * Sets the current stencil mask
  121362. * @param mask defines the new stencil mask to use
  121363. */
  121364. setStencilMask(mask: number): void;
  121365. /**
  121366. * Gets the current stencil function
  121367. * @returns a number defining the stencil function to use
  121368. */
  121369. getStencilFunction(): number;
  121370. /**
  121371. * Gets the current stencil reference value
  121372. * @returns a number defining the stencil reference value to use
  121373. */
  121374. getStencilFunctionReference(): number;
  121375. /**
  121376. * Gets the current stencil mask
  121377. * @returns a number defining the stencil mask to use
  121378. */
  121379. getStencilFunctionMask(): number;
  121380. /**
  121381. * Sets the current stencil function
  121382. * @param stencilFunc defines the new stencil function to use
  121383. */
  121384. setStencilFunction(stencilFunc: number): void;
  121385. /**
  121386. * Sets the current stencil reference
  121387. * @param reference defines the new stencil reference to use
  121388. */
  121389. setStencilFunctionReference(reference: number): void;
  121390. /**
  121391. * Sets the current stencil mask
  121392. * @param mask defines the new stencil mask to use
  121393. */
  121394. setStencilFunctionMask(mask: number): void;
  121395. /**
  121396. * Gets the current stencil operation when stencil fails
  121397. * @returns a number defining stencil operation to use when stencil fails
  121398. */
  121399. getStencilOperationFail(): number;
  121400. /**
  121401. * Gets the current stencil operation when depth fails
  121402. * @returns a number defining stencil operation to use when depth fails
  121403. */
  121404. getStencilOperationDepthFail(): number;
  121405. /**
  121406. * Gets the current stencil operation when stencil passes
  121407. * @returns a number defining stencil operation to use when stencil passes
  121408. */
  121409. getStencilOperationPass(): number;
  121410. /**
  121411. * Sets the stencil operation to use when stencil fails
  121412. * @param operation defines the stencil operation to use when stencil fails
  121413. */
  121414. setStencilOperationFail(operation: number): void;
  121415. /**
  121416. * Sets the stencil operation to use when depth fails
  121417. * @param operation defines the stencil operation to use when depth fails
  121418. */
  121419. setStencilOperationDepthFail(operation: number): void;
  121420. /**
  121421. * Sets the stencil operation to use when stencil passes
  121422. * @param operation defines the stencil operation to use when stencil passes
  121423. */
  121424. setStencilOperationPass(operation: number): void;
  121425. /**
  121426. * Sets a boolean indicating if the dithering state is enabled or disabled
  121427. * @param value defines the dithering state
  121428. */
  121429. setDitheringState(value: boolean): void;
  121430. /**
  121431. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  121432. * @param value defines the rasterizer state
  121433. */
  121434. setRasterizerState(value: boolean): void;
  121435. /**
  121436. * Gets the current depth function
  121437. * @returns a number defining the depth function
  121438. */
  121439. getDepthFunction(): Nullable<number>;
  121440. /**
  121441. * Sets the current depth function
  121442. * @param depthFunc defines the function to use
  121443. */
  121444. setDepthFunction(depthFunc: number): void;
  121445. /**
  121446. * Sets the current depth function to GREATER
  121447. */
  121448. setDepthFunctionToGreater(): void;
  121449. /**
  121450. * Sets the current depth function to GEQUAL
  121451. */
  121452. setDepthFunctionToGreaterOrEqual(): void;
  121453. /**
  121454. * Sets the current depth function to LESS
  121455. */
  121456. setDepthFunctionToLess(): void;
  121457. /**
  121458. * Sets the current depth function to LEQUAL
  121459. */
  121460. setDepthFunctionToLessOrEqual(): void;
  121461. private _cachedStencilBuffer;
  121462. private _cachedStencilFunction;
  121463. private _cachedStencilMask;
  121464. private _cachedStencilOperationPass;
  121465. private _cachedStencilOperationFail;
  121466. private _cachedStencilOperationDepthFail;
  121467. private _cachedStencilReference;
  121468. /**
  121469. * Caches the the state of the stencil buffer
  121470. */
  121471. cacheStencilState(): void;
  121472. /**
  121473. * Restores the state of the stencil buffer
  121474. */
  121475. restoreStencilState(): void;
  121476. /**
  121477. * Directly set the WebGL Viewport
  121478. * @param x defines the x coordinate of the viewport (in screen space)
  121479. * @param y defines the y coordinate of the viewport (in screen space)
  121480. * @param width defines the width of the viewport (in screen space)
  121481. * @param height defines the height of the viewport (in screen space)
  121482. * @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
  121483. */
  121484. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  121485. /**
  121486. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  121487. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121488. * @param y defines the y-coordinate of the corner of the clear rectangle
  121489. * @param width defines the width of the clear rectangle
  121490. * @param height defines the height of the clear rectangle
  121491. * @param clearColor defines the clear color
  121492. */
  121493. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  121494. /**
  121495. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  121496. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121497. * @param y defines the y-coordinate of the corner of the clear rectangle
  121498. * @param width defines the width of the clear rectangle
  121499. * @param height defines the height of the clear rectangle
  121500. */
  121501. enableScissor(x: number, y: number, width: number, height: number): void;
  121502. /**
  121503. * Disable previously set scissor test rectangle
  121504. */
  121505. disableScissor(): void;
  121506. protected _reportDrawCall(): void;
  121507. /**
  121508. * Initializes a webVR display and starts listening to display change events
  121509. * The onVRDisplayChangedObservable will be notified upon these changes
  121510. * @returns The onVRDisplayChangedObservable
  121511. */
  121512. initWebVR(): Observable<IDisplayChangedEventArgs>;
  121513. /** @hidden */
  121514. _prepareVRComponent(): void;
  121515. /** @hidden */
  121516. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  121517. /** @hidden */
  121518. _submitVRFrame(): void;
  121519. /**
  121520. * Call this function to leave webVR mode
  121521. * Will do nothing if webVR is not supported or if there is no webVR device
  121522. * @see https://doc.babylonjs.com/how_to/webvr_camera
  121523. */
  121524. disableVR(): void;
  121525. /**
  121526. * Gets a boolean indicating that the system is in VR mode and is presenting
  121527. * @returns true if VR mode is engaged
  121528. */
  121529. isVRPresenting(): boolean;
  121530. /** @hidden */
  121531. _requestVRFrame(): void;
  121532. /** @hidden */
  121533. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121534. /**
  121535. * Gets the source code of the vertex shader associated with a specific webGL program
  121536. * @param program defines the program to use
  121537. * @returns a string containing the source code of the vertex shader associated with the program
  121538. */
  121539. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  121540. /**
  121541. * Gets the source code of the fragment shader associated with a specific webGL program
  121542. * @param program defines the program to use
  121543. * @returns a string containing the source code of the fragment shader associated with the program
  121544. */
  121545. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  121546. /**
  121547. * Sets a depth stencil texture from a render target to the according uniform.
  121548. * @param channel The texture channel
  121549. * @param uniform The uniform to set
  121550. * @param texture The render target texture containing the depth stencil texture to apply
  121551. */
  121552. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  121553. /**
  121554. * Sets a texture to the webGL context from a postprocess
  121555. * @param channel defines the channel to use
  121556. * @param postProcess defines the source postprocess
  121557. */
  121558. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  121559. /**
  121560. * Binds the output of the passed in post process to the texture channel specified
  121561. * @param channel The channel the texture should be bound to
  121562. * @param postProcess The post process which's output should be bound
  121563. */
  121564. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  121565. protected _rebuildBuffers(): void;
  121566. /** @hidden */
  121567. _renderFrame(): void;
  121568. _renderLoop(): void;
  121569. /** @hidden */
  121570. _renderViews(): boolean;
  121571. /**
  121572. * Toggle full screen mode
  121573. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121574. */
  121575. switchFullscreen(requestPointerLock: boolean): void;
  121576. /**
  121577. * Enters full screen mode
  121578. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121579. */
  121580. enterFullscreen(requestPointerLock: boolean): void;
  121581. /**
  121582. * Exits full screen mode
  121583. */
  121584. exitFullscreen(): void;
  121585. /**
  121586. * Enters Pointerlock mode
  121587. */
  121588. enterPointerlock(): void;
  121589. /**
  121590. * Exits Pointerlock mode
  121591. */
  121592. exitPointerlock(): void;
  121593. /**
  121594. * Begin a new frame
  121595. */
  121596. beginFrame(): void;
  121597. /**
  121598. * Enf the current frame
  121599. */
  121600. endFrame(): void;
  121601. resize(): void;
  121602. /**
  121603. * Force a specific size of the canvas
  121604. * @param width defines the new canvas' width
  121605. * @param height defines the new canvas' height
  121606. * @returns true if the size was changed
  121607. */
  121608. setSize(width: number, height: number): boolean;
  121609. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121610. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121611. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121612. _releaseTexture(texture: InternalTexture): void;
  121613. /**
  121614. * @hidden
  121615. * Rescales a texture
  121616. * @param source input texutre
  121617. * @param destination destination texture
  121618. * @param scene scene to use to render the resize
  121619. * @param internalFormat format to use when resizing
  121620. * @param onComplete callback to be called when resize has completed
  121621. */
  121622. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  121623. /**
  121624. * Gets the current framerate
  121625. * @returns a number representing the framerate
  121626. */
  121627. getFps(): number;
  121628. /**
  121629. * Gets the time spent between current and previous frame
  121630. * @returns a number representing the delta time in ms
  121631. */
  121632. getDeltaTime(): number;
  121633. private _measureFps;
  121634. /** @hidden */
  121635. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  121636. /**
  121637. * Updates the sample count of a render target texture
  121638. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  121639. * @param texture defines the texture to update
  121640. * @param samples defines the sample count to set
  121641. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  121642. */
  121643. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  121644. /**
  121645. * Updates a depth texture Comparison Mode and Function.
  121646. * If the comparison Function is equal to 0, the mode will be set to none.
  121647. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  121648. * @param texture The texture to set the comparison function for
  121649. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  121650. */
  121651. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  121652. /**
  121653. * Creates a webGL buffer to use with instanciation
  121654. * @param capacity defines the size of the buffer
  121655. * @returns the webGL buffer
  121656. */
  121657. createInstancesBuffer(capacity: number): DataBuffer;
  121658. /**
  121659. * Delete a webGL buffer used with instanciation
  121660. * @param buffer defines the webGL buffer to delete
  121661. */
  121662. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  121663. private _clientWaitAsync;
  121664. /** @hidden */
  121665. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  121666. dispose(): void;
  121667. private _disableTouchAction;
  121668. /**
  121669. * Display the loading screen
  121670. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121671. */
  121672. displayLoadingUI(): void;
  121673. /**
  121674. * Hide the loading screen
  121675. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121676. */
  121677. hideLoadingUI(): void;
  121678. /**
  121679. * Gets the current loading screen object
  121680. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121681. */
  121682. get loadingScreen(): ILoadingScreen;
  121683. /**
  121684. * Sets the current loading screen object
  121685. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121686. */
  121687. set loadingScreen(loadingScreen: ILoadingScreen);
  121688. /**
  121689. * Sets the current loading screen text
  121690. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121691. */
  121692. set loadingUIText(text: string);
  121693. /**
  121694. * Sets the current loading screen background color
  121695. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121696. */
  121697. set loadingUIBackgroundColor(color: string);
  121698. /** Pointerlock and fullscreen */
  121699. /**
  121700. * Ask the browser to promote the current element to pointerlock mode
  121701. * @param element defines the DOM element to promote
  121702. */
  121703. static _RequestPointerlock(element: HTMLElement): void;
  121704. /**
  121705. * Asks the browser to exit pointerlock mode
  121706. */
  121707. static _ExitPointerlock(): void;
  121708. /**
  121709. * Ask the browser to promote the current element to fullscreen rendering mode
  121710. * @param element defines the DOM element to promote
  121711. */
  121712. static _RequestFullscreen(element: HTMLElement): void;
  121713. /**
  121714. * Asks the browser to exit fullscreen mode
  121715. */
  121716. static _ExitFullscreen(): void;
  121717. }
  121718. }
  121719. declare module BABYLON {
  121720. /**
  121721. * The engine store class is responsible to hold all the instances of Engine and Scene created
  121722. * during the life time of the application.
  121723. */
  121724. export class EngineStore {
  121725. /** Gets the list of created engines */
  121726. static Instances: Engine[];
  121727. /** @hidden */
  121728. static _LastCreatedScene: Nullable<Scene>;
  121729. /**
  121730. * Gets the latest created engine
  121731. */
  121732. static get LastCreatedEngine(): Nullable<Engine>;
  121733. /**
  121734. * Gets the latest created scene
  121735. */
  121736. static get LastCreatedScene(): Nullable<Scene>;
  121737. /**
  121738. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  121739. * @ignorenaming
  121740. */
  121741. static UseFallbackTexture: boolean;
  121742. /**
  121743. * Texture content used if a texture cannot loaded
  121744. * @ignorenaming
  121745. */
  121746. static FallbackTexture: string;
  121747. }
  121748. }
  121749. declare module BABYLON {
  121750. /**
  121751. * Helper class that provides a small promise polyfill
  121752. */
  121753. export class PromisePolyfill {
  121754. /**
  121755. * Static function used to check if the polyfill is required
  121756. * If this is the case then the function will inject the polyfill to window.Promise
  121757. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  121758. */
  121759. static Apply(force?: boolean): void;
  121760. }
  121761. }
  121762. declare module BABYLON {
  121763. /**
  121764. * Interface for screenshot methods with describe argument called `size` as object with options
  121765. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  121766. */
  121767. export interface IScreenshotSize {
  121768. /**
  121769. * number in pixels for canvas height
  121770. */
  121771. height?: number;
  121772. /**
  121773. * multiplier allowing render at a higher or lower resolution
  121774. * If value is defined then height and width will be ignored and taken from camera
  121775. */
  121776. precision?: number;
  121777. /**
  121778. * number in pixels for canvas width
  121779. */
  121780. width?: number;
  121781. }
  121782. }
  121783. declare module BABYLON {
  121784. interface IColor4Like {
  121785. r: float;
  121786. g: float;
  121787. b: float;
  121788. a: float;
  121789. }
  121790. /**
  121791. * Class containing a set of static utilities functions
  121792. */
  121793. export class Tools {
  121794. /**
  121795. * Gets or sets the base URL to use to load assets
  121796. */
  121797. static get BaseUrl(): string;
  121798. static set BaseUrl(value: string);
  121799. /**
  121800. * Enable/Disable Custom HTTP Request Headers globally.
  121801. * default = false
  121802. * @see CustomRequestHeaders
  121803. */
  121804. static UseCustomRequestHeaders: boolean;
  121805. /**
  121806. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  121807. * i.e. when loading files, where the server/service expects an Authorization header
  121808. */
  121809. static CustomRequestHeaders: {
  121810. [key: string]: string;
  121811. };
  121812. /**
  121813. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  121814. */
  121815. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  121816. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  121817. /**
  121818. * Default behaviour for cors in the application.
  121819. * It can be a string if the expected behavior is identical in the entire app.
  121820. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  121821. */
  121822. static get CorsBehavior(): string | ((url: string | string[]) => string);
  121823. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  121824. /**
  121825. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  121826. * @ignorenaming
  121827. */
  121828. static get UseFallbackTexture(): boolean;
  121829. static set UseFallbackTexture(value: boolean);
  121830. /**
  121831. * Use this object to register external classes like custom textures or material
  121832. * to allow the laoders to instantiate them
  121833. */
  121834. static get RegisteredExternalClasses(): {
  121835. [key: string]: Object;
  121836. };
  121837. static set RegisteredExternalClasses(classes: {
  121838. [key: string]: Object;
  121839. });
  121840. /**
  121841. * Texture content used if a texture cannot loaded
  121842. * @ignorenaming
  121843. */
  121844. static get fallbackTexture(): string;
  121845. static set fallbackTexture(value: string);
  121846. /**
  121847. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  121848. * @param u defines the coordinate on X axis
  121849. * @param v defines the coordinate on Y axis
  121850. * @param width defines the width of the source data
  121851. * @param height defines the height of the source data
  121852. * @param pixels defines the source byte array
  121853. * @param color defines the output color
  121854. */
  121855. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  121856. /**
  121857. * Interpolates between a and b via alpha
  121858. * @param a The lower value (returned when alpha = 0)
  121859. * @param b The upper value (returned when alpha = 1)
  121860. * @param alpha The interpolation-factor
  121861. * @return The mixed value
  121862. */
  121863. static Mix(a: number, b: number, alpha: number): number;
  121864. /**
  121865. * Tries to instantiate a new object from a given class name
  121866. * @param className defines the class name to instantiate
  121867. * @returns the new object or null if the system was not able to do the instantiation
  121868. */
  121869. static Instantiate(className: string): any;
  121870. /**
  121871. * Provides a slice function that will work even on IE
  121872. * @param data defines the array to slice
  121873. * @param start defines the start of the data (optional)
  121874. * @param end defines the end of the data (optional)
  121875. * @returns the new sliced array
  121876. */
  121877. static Slice<T>(data: T, start?: number, end?: number): T;
  121878. /**
  121879. * Polyfill for setImmediate
  121880. * @param action defines the action to execute after the current execution block
  121881. */
  121882. static SetImmediate(action: () => void): void;
  121883. /**
  121884. * Function indicating if a number is an exponent of 2
  121885. * @param value defines the value to test
  121886. * @returns true if the value is an exponent of 2
  121887. */
  121888. static IsExponentOfTwo(value: number): boolean;
  121889. private static _tmpFloatArray;
  121890. /**
  121891. * Returns the nearest 32-bit single precision float representation of a Number
  121892. * @param value A Number. If the parameter is of a different type, it will get converted
  121893. * to a number or to NaN if it cannot be converted
  121894. * @returns number
  121895. */
  121896. static FloatRound(value: number): number;
  121897. /**
  121898. * Extracts the filename from a path
  121899. * @param path defines the path to use
  121900. * @returns the filename
  121901. */
  121902. static GetFilename(path: string): string;
  121903. /**
  121904. * Extracts the "folder" part of a path (everything before the filename).
  121905. * @param uri The URI to extract the info from
  121906. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  121907. * @returns The "folder" part of the path
  121908. */
  121909. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  121910. /**
  121911. * Extracts text content from a DOM element hierarchy
  121912. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  121913. */
  121914. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  121915. /**
  121916. * Convert an angle in radians to degrees
  121917. * @param angle defines the angle to convert
  121918. * @returns the angle in degrees
  121919. */
  121920. static ToDegrees(angle: number): number;
  121921. /**
  121922. * Convert an angle in degrees to radians
  121923. * @param angle defines the angle to convert
  121924. * @returns the angle in radians
  121925. */
  121926. static ToRadians(angle: number): number;
  121927. /**
  121928. * Returns an array if obj is not an array
  121929. * @param obj defines the object to evaluate as an array
  121930. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  121931. * @returns either obj directly if obj is an array or a new array containing obj
  121932. */
  121933. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  121934. /**
  121935. * Gets the pointer prefix to use
  121936. * @param engine defines the engine we are finding the prefix for
  121937. * @returns "pointer" if touch is enabled. Else returns "mouse"
  121938. */
  121939. static GetPointerPrefix(engine: Engine): string;
  121940. /**
  121941. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  121942. * @param url define the url we are trying
  121943. * @param element define the dom element where to configure the cors policy
  121944. */
  121945. static SetCorsBehavior(url: string | string[], element: {
  121946. crossOrigin: string | null;
  121947. }): void;
  121948. /**
  121949. * Removes unwanted characters from an url
  121950. * @param url defines the url to clean
  121951. * @returns the cleaned url
  121952. */
  121953. static CleanUrl(url: string): string;
  121954. /**
  121955. * Gets or sets a function used to pre-process url before using them to load assets
  121956. */
  121957. static get PreprocessUrl(): (url: string) => string;
  121958. static set PreprocessUrl(processor: (url: string) => string);
  121959. /**
  121960. * Loads an image as an HTMLImageElement.
  121961. * @param input url string, ArrayBuffer, or Blob to load
  121962. * @param onLoad callback called when the image successfully loads
  121963. * @param onError callback called when the image fails to load
  121964. * @param offlineProvider offline provider for caching
  121965. * @param mimeType optional mime type
  121966. * @returns the HTMLImageElement of the loaded image
  121967. */
  121968. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  121969. /**
  121970. * Loads a file from a url
  121971. * @param url url string, ArrayBuffer, or Blob to load
  121972. * @param onSuccess callback called when the file successfully loads
  121973. * @param onProgress callback called while file is loading (if the server supports this mode)
  121974. * @param offlineProvider defines the offline provider for caching
  121975. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  121976. * @param onError callback called when the file fails to load
  121977. * @returns a file request object
  121978. */
  121979. 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;
  121980. /**
  121981. * Loads a file from a url
  121982. * @param url the file url to load
  121983. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  121984. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  121985. */
  121986. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  121987. /**
  121988. * Load a script (identified by an url). When the url returns, the
  121989. * content of this file is added into a new script element, attached to the DOM (body element)
  121990. * @param scriptUrl defines the url of the script to laod
  121991. * @param onSuccess defines the callback called when the script is loaded
  121992. * @param onError defines the callback to call if an error occurs
  121993. * @param scriptId defines the id of the script element
  121994. */
  121995. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  121996. /**
  121997. * Load an asynchronous script (identified by an url). When the url returns, the
  121998. * content of this file is added into a new script element, attached to the DOM (body element)
  121999. * @param scriptUrl defines the url of the script to laod
  122000. * @param scriptId defines the id of the script element
  122001. * @returns a promise request object
  122002. */
  122003. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  122004. /**
  122005. * Loads a file from a blob
  122006. * @param fileToLoad defines the blob to use
  122007. * @param callback defines the callback to call when data is loaded
  122008. * @param progressCallback defines the callback to call during loading process
  122009. * @returns a file request object
  122010. */
  122011. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  122012. /**
  122013. * Reads a file from a File object
  122014. * @param file defines the file to load
  122015. * @param onSuccess defines the callback to call when data is loaded
  122016. * @param onProgress defines the callback to call during loading process
  122017. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  122018. * @param onError defines the callback to call when an error occurs
  122019. * @returns a file request object
  122020. */
  122021. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  122022. /**
  122023. * Creates a data url from a given string content
  122024. * @param content defines the content to convert
  122025. * @returns the new data url link
  122026. */
  122027. static FileAsURL(content: string): string;
  122028. /**
  122029. * Format the given number to a specific decimal format
  122030. * @param value defines the number to format
  122031. * @param decimals defines the number of decimals to use
  122032. * @returns the formatted string
  122033. */
  122034. static Format(value: number, decimals?: number): string;
  122035. /**
  122036. * Tries to copy an object by duplicating every property
  122037. * @param source defines the source object
  122038. * @param destination defines the target object
  122039. * @param doNotCopyList defines a list of properties to avoid
  122040. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  122041. */
  122042. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  122043. /**
  122044. * Gets a boolean indicating if the given object has no own property
  122045. * @param obj defines the object to test
  122046. * @returns true if object has no own property
  122047. */
  122048. static IsEmpty(obj: any): boolean;
  122049. /**
  122050. * Function used to register events at window level
  122051. * @param windowElement defines the Window object to use
  122052. * @param events defines the events to register
  122053. */
  122054. static RegisterTopRootEvents(windowElement: Window, events: {
  122055. name: string;
  122056. handler: Nullable<(e: FocusEvent) => any>;
  122057. }[]): void;
  122058. /**
  122059. * Function used to unregister events from window level
  122060. * @param windowElement defines the Window object to use
  122061. * @param events defines the events to unregister
  122062. */
  122063. static UnregisterTopRootEvents(windowElement: Window, events: {
  122064. name: string;
  122065. handler: Nullable<(e: FocusEvent) => any>;
  122066. }[]): void;
  122067. /**
  122068. * @ignore
  122069. */
  122070. static _ScreenshotCanvas: HTMLCanvasElement;
  122071. /**
  122072. * Dumps the current bound framebuffer
  122073. * @param width defines the rendering width
  122074. * @param height defines the rendering height
  122075. * @param engine defines the hosting engine
  122076. * @param successCallback defines the callback triggered once the data are available
  122077. * @param mimeType defines the mime type of the result
  122078. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  122079. */
  122080. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122081. /**
  122082. * Converts the canvas data to blob.
  122083. * This acts as a polyfill for browsers not supporting the to blob function.
  122084. * @param canvas Defines the canvas to extract the data from
  122085. * @param successCallback Defines the callback triggered once the data are available
  122086. * @param mimeType Defines the mime type of the result
  122087. */
  122088. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  122089. /**
  122090. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  122091. * @param successCallback defines the callback triggered once the data are available
  122092. * @param mimeType defines the mime type of the result
  122093. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  122094. */
  122095. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122096. /**
  122097. * Downloads a blob in the browser
  122098. * @param blob defines the blob to download
  122099. * @param fileName defines the name of the downloaded file
  122100. */
  122101. static Download(blob: Blob, fileName: string): void;
  122102. /**
  122103. * Captures a screenshot of the current rendering
  122104. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122105. * @param engine defines the rendering engine
  122106. * @param camera defines the source camera
  122107. * @param size This parameter can be set to a single number or to an object with the
  122108. * following (optional) properties: precision, width, height. If a single number is passed,
  122109. * it will be used for both width and height. If an object is passed, the screenshot size
  122110. * will be derived from the parameters. The precision property is a multiplier allowing
  122111. * rendering at a higher or lower resolution
  122112. * @param successCallback defines the callback receives a single parameter which contains the
  122113. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122114. * src parameter of an <img> to display it
  122115. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122116. * Check your browser for supported MIME types
  122117. */
  122118. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  122119. /**
  122120. * Captures a screenshot of the current rendering
  122121. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122122. * @param engine defines the rendering engine
  122123. * @param camera defines the source camera
  122124. * @param size This parameter can be set to a single number or to an object with the
  122125. * following (optional) properties: precision, width, height. If a single number is passed,
  122126. * it will be used for both width and height. If an object is passed, the screenshot size
  122127. * will be derived from the parameters. The precision property is a multiplier allowing
  122128. * rendering at a higher or lower resolution
  122129. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122130. * Check your browser for supported MIME types
  122131. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122132. * to the src parameter of an <img> to display it
  122133. */
  122134. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  122135. /**
  122136. * Generates an image screenshot from the specified camera.
  122137. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122138. * @param engine The engine to use for rendering
  122139. * @param camera The camera to use for rendering
  122140. * @param size This parameter can be set to a single number or to an object with the
  122141. * following (optional) properties: precision, width, height. If a single number is passed,
  122142. * it will be used for both width and height. If an object is passed, the screenshot size
  122143. * will be derived from the parameters. The precision property is a multiplier allowing
  122144. * rendering at a higher or lower resolution
  122145. * @param successCallback The callback receives a single parameter which contains the
  122146. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122147. * src parameter of an <img> to display it
  122148. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122149. * Check your browser for supported MIME types
  122150. * @param samples Texture samples (default: 1)
  122151. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122152. * @param fileName A name for for the downloaded file.
  122153. */
  122154. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122155. /**
  122156. * Generates an image screenshot from the specified camera.
  122157. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122158. * @param engine The engine to use for rendering
  122159. * @param camera The camera to use for rendering
  122160. * @param size This parameter can be set to a single number or to an object with the
  122161. * following (optional) properties: precision, width, height. If a single number is passed,
  122162. * it will be used for both width and height. If an object is passed, the screenshot size
  122163. * will be derived from the parameters. The precision property is a multiplier allowing
  122164. * rendering at a higher or lower resolution
  122165. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122166. * Check your browser for supported MIME types
  122167. * @param samples Texture samples (default: 1)
  122168. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122169. * @param fileName A name for for the downloaded file.
  122170. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122171. * to the src parameter of an <img> to display it
  122172. */
  122173. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  122174. /**
  122175. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  122176. * Be aware Math.random() could cause collisions, but:
  122177. * "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"
  122178. * @returns a pseudo random id
  122179. */
  122180. static RandomId(): string;
  122181. /**
  122182. * Test if the given uri is a base64 string
  122183. * @param uri The uri to test
  122184. * @return True if the uri is a base64 string or false otherwise
  122185. */
  122186. static IsBase64(uri: string): boolean;
  122187. /**
  122188. * Decode the given base64 uri.
  122189. * @param uri The uri to decode
  122190. * @return The decoded base64 data.
  122191. */
  122192. static DecodeBase64(uri: string): ArrayBuffer;
  122193. /**
  122194. * Gets the absolute url.
  122195. * @param url the input url
  122196. * @return the absolute url
  122197. */
  122198. static GetAbsoluteUrl(url: string): string;
  122199. /**
  122200. * No log
  122201. */
  122202. static readonly NoneLogLevel: number;
  122203. /**
  122204. * Only message logs
  122205. */
  122206. static readonly MessageLogLevel: number;
  122207. /**
  122208. * Only warning logs
  122209. */
  122210. static readonly WarningLogLevel: number;
  122211. /**
  122212. * Only error logs
  122213. */
  122214. static readonly ErrorLogLevel: number;
  122215. /**
  122216. * All logs
  122217. */
  122218. static readonly AllLogLevel: number;
  122219. /**
  122220. * Gets a value indicating the number of loading errors
  122221. * @ignorenaming
  122222. */
  122223. static get errorsCount(): number;
  122224. /**
  122225. * Callback called when a new log is added
  122226. */
  122227. static OnNewCacheEntry: (entry: string) => void;
  122228. /**
  122229. * Log a message to the console
  122230. * @param message defines the message to log
  122231. */
  122232. static Log(message: string): void;
  122233. /**
  122234. * Write a warning message to the console
  122235. * @param message defines the message to log
  122236. */
  122237. static Warn(message: string): void;
  122238. /**
  122239. * Write an error message to the console
  122240. * @param message defines the message to log
  122241. */
  122242. static Error(message: string): void;
  122243. /**
  122244. * Gets current log cache (list of logs)
  122245. */
  122246. static get LogCache(): string;
  122247. /**
  122248. * Clears the log cache
  122249. */
  122250. static ClearLogCache(): void;
  122251. /**
  122252. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  122253. */
  122254. static set LogLevels(level: number);
  122255. /**
  122256. * Checks if the window object exists
  122257. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  122258. */
  122259. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  122260. /**
  122261. * No performance log
  122262. */
  122263. static readonly PerformanceNoneLogLevel: number;
  122264. /**
  122265. * Use user marks to log performance
  122266. */
  122267. static readonly PerformanceUserMarkLogLevel: number;
  122268. /**
  122269. * Log performance to the console
  122270. */
  122271. static readonly PerformanceConsoleLogLevel: number;
  122272. private static _performance;
  122273. /**
  122274. * Sets the current performance log level
  122275. */
  122276. static set PerformanceLogLevel(level: number);
  122277. private static _StartPerformanceCounterDisabled;
  122278. private static _EndPerformanceCounterDisabled;
  122279. private static _StartUserMark;
  122280. private static _EndUserMark;
  122281. private static _StartPerformanceConsole;
  122282. private static _EndPerformanceConsole;
  122283. /**
  122284. * Starts a performance counter
  122285. */
  122286. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122287. /**
  122288. * Ends a specific performance coutner
  122289. */
  122290. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122291. /**
  122292. * Gets either window.performance.now() if supported or Date.now() else
  122293. */
  122294. static get Now(): number;
  122295. /**
  122296. * This method will return the name of the class used to create the instance of the given object.
  122297. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  122298. * @param object the object to get the class name from
  122299. * @param isType defines if the object is actually a type
  122300. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  122301. */
  122302. static GetClassName(object: any, isType?: boolean): string;
  122303. /**
  122304. * Gets the first element of an array satisfying a given predicate
  122305. * @param array defines the array to browse
  122306. * @param predicate defines the predicate to use
  122307. * @returns null if not found or the element
  122308. */
  122309. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  122310. /**
  122311. * This method will return the name of the full name of the class, including its owning module (if any).
  122312. * 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).
  122313. * @param object the object to get the class name from
  122314. * @param isType defines if the object is actually a type
  122315. * @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.
  122316. * @ignorenaming
  122317. */
  122318. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  122319. /**
  122320. * Returns a promise that resolves after the given amount of time.
  122321. * @param delay Number of milliseconds to delay
  122322. * @returns Promise that resolves after the given amount of time
  122323. */
  122324. static DelayAsync(delay: number): Promise<void>;
  122325. /**
  122326. * Utility function to detect if the current user agent is Safari
  122327. * @returns whether or not the current user agent is safari
  122328. */
  122329. static IsSafari(): boolean;
  122330. }
  122331. /**
  122332. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  122333. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  122334. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  122335. * @param name The name of the class, case should be preserved
  122336. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  122337. */
  122338. export function className(name: string, module?: string): (target: Object) => void;
  122339. /**
  122340. * An implementation of a loop for asynchronous functions.
  122341. */
  122342. export class AsyncLoop {
  122343. /**
  122344. * Defines the number of iterations for the loop
  122345. */
  122346. iterations: number;
  122347. /**
  122348. * Defines the current index of the loop.
  122349. */
  122350. index: number;
  122351. private _done;
  122352. private _fn;
  122353. private _successCallback;
  122354. /**
  122355. * Constructor.
  122356. * @param iterations the number of iterations.
  122357. * @param func the function to run each iteration
  122358. * @param successCallback the callback that will be called upon succesful execution
  122359. * @param offset starting offset.
  122360. */
  122361. constructor(
  122362. /**
  122363. * Defines the number of iterations for the loop
  122364. */
  122365. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  122366. /**
  122367. * Execute the next iteration. Must be called after the last iteration was finished.
  122368. */
  122369. executeNext(): void;
  122370. /**
  122371. * Break the loop and run the success callback.
  122372. */
  122373. breakLoop(): void;
  122374. /**
  122375. * Create and run an async loop.
  122376. * @param iterations the number of iterations.
  122377. * @param fn the function to run each iteration
  122378. * @param successCallback the callback that will be called upon succesful execution
  122379. * @param offset starting offset.
  122380. * @returns the created async loop object
  122381. */
  122382. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  122383. /**
  122384. * A for-loop that will run a given number of iterations synchronous and the rest async.
  122385. * @param iterations total number of iterations
  122386. * @param syncedIterations number of synchronous iterations in each async iteration.
  122387. * @param fn the function to call each iteration.
  122388. * @param callback a success call back that will be called when iterating stops.
  122389. * @param breakFunction a break condition (optional)
  122390. * @param timeout timeout settings for the setTimeout function. default - 0.
  122391. * @returns the created async loop object
  122392. */
  122393. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  122394. }
  122395. }
  122396. declare module BABYLON {
  122397. /**
  122398. * This class implement a typical dictionary using a string as key and the generic type T as value.
  122399. * The underlying implementation relies on an associative array to ensure the best performances.
  122400. * The value can be anything including 'null' but except 'undefined'
  122401. */
  122402. export class StringDictionary<T> {
  122403. /**
  122404. * This will clear this dictionary and copy the content from the 'source' one.
  122405. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  122406. * @param source the dictionary to take the content from and copy to this dictionary
  122407. */
  122408. copyFrom(source: StringDictionary<T>): void;
  122409. /**
  122410. * Get a value based from its key
  122411. * @param key the given key to get the matching value from
  122412. * @return the value if found, otherwise undefined is returned
  122413. */
  122414. get(key: string): T | undefined;
  122415. /**
  122416. * Get a value from its key or add it if it doesn't exist.
  122417. * This method will ensure you that a given key/data will be present in the dictionary.
  122418. * @param key the given key to get the matching value from
  122419. * @param factory the factory that will create the value if the key is not present in the dictionary.
  122420. * The factory will only be invoked if there's no data for the given key.
  122421. * @return the value corresponding to the key.
  122422. */
  122423. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  122424. /**
  122425. * Get a value from its key if present in the dictionary otherwise add it
  122426. * @param key the key to get the value from
  122427. * @param val if there's no such key/value pair in the dictionary add it with this value
  122428. * @return the value corresponding to the key
  122429. */
  122430. getOrAdd(key: string, val: T): T;
  122431. /**
  122432. * Check if there's a given key in the dictionary
  122433. * @param key the key to check for
  122434. * @return true if the key is present, false otherwise
  122435. */
  122436. contains(key: string): boolean;
  122437. /**
  122438. * Add a new key and its corresponding value
  122439. * @param key the key to add
  122440. * @param value the value corresponding to the key
  122441. * @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
  122442. */
  122443. add(key: string, value: T): boolean;
  122444. /**
  122445. * Update a specific value associated to a key
  122446. * @param key defines the key to use
  122447. * @param value defines the value to store
  122448. * @returns true if the value was updated (or false if the key was not found)
  122449. */
  122450. set(key: string, value: T): boolean;
  122451. /**
  122452. * Get the element of the given key and remove it from the dictionary
  122453. * @param key defines the key to search
  122454. * @returns the value associated with the key or null if not found
  122455. */
  122456. getAndRemove(key: string): Nullable<T>;
  122457. /**
  122458. * Remove a key/value from the dictionary.
  122459. * @param key the key to remove
  122460. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  122461. */
  122462. remove(key: string): boolean;
  122463. /**
  122464. * Clear the whole content of the dictionary
  122465. */
  122466. clear(): void;
  122467. /**
  122468. * Gets the current count
  122469. */
  122470. get count(): number;
  122471. /**
  122472. * Execute a callback on each key/val of the dictionary.
  122473. * Note that you can remove any element in this dictionary in the callback implementation
  122474. * @param callback the callback to execute on a given key/value pair
  122475. */
  122476. forEach(callback: (key: string, val: T) => void): void;
  122477. /**
  122478. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  122479. * If the callback returns null or undefined the method will iterate to the next key/value pair
  122480. * Note that you can remove any element in this dictionary in the callback implementation
  122481. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  122482. * @returns the first item
  122483. */
  122484. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  122485. private _count;
  122486. private _data;
  122487. }
  122488. }
  122489. declare module BABYLON {
  122490. /** @hidden */
  122491. export interface ICollisionCoordinator {
  122492. createCollider(): Collider;
  122493. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122494. init(scene: Scene): void;
  122495. }
  122496. /** @hidden */
  122497. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  122498. private _scene;
  122499. private _scaledPosition;
  122500. private _scaledVelocity;
  122501. private _finalPosition;
  122502. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122503. createCollider(): Collider;
  122504. init(scene: Scene): void;
  122505. private _collideWithWorld;
  122506. }
  122507. }
  122508. declare module BABYLON {
  122509. /**
  122510. * Class used to manage all inputs for the scene.
  122511. */
  122512. export class InputManager {
  122513. /** The distance in pixel that you have to move to prevent some events */
  122514. static DragMovementThreshold: number;
  122515. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  122516. static LongPressDelay: number;
  122517. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  122518. static DoubleClickDelay: number;
  122519. /** If you need to check double click without raising a single click at first click, enable this flag */
  122520. static ExclusiveDoubleClickMode: boolean;
  122521. /** 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. */
  122522. private _alreadyAttached;
  122523. private _wheelEventName;
  122524. private _onPointerMove;
  122525. private _onPointerDown;
  122526. private _onPointerUp;
  122527. private _initClickEvent;
  122528. private _initActionManager;
  122529. private _delayedSimpleClick;
  122530. private _delayedSimpleClickTimeout;
  122531. private _previousDelayedSimpleClickTimeout;
  122532. private _meshPickProceed;
  122533. private _previousButtonPressed;
  122534. private _currentPickResult;
  122535. private _previousPickResult;
  122536. private _totalPointersPressed;
  122537. private _doubleClickOccured;
  122538. private _pointerOverMesh;
  122539. private _pickedDownMesh;
  122540. private _pickedUpMesh;
  122541. private _pointerX;
  122542. private _pointerY;
  122543. private _unTranslatedPointerX;
  122544. private _unTranslatedPointerY;
  122545. private _startingPointerPosition;
  122546. private _previousStartingPointerPosition;
  122547. private _startingPointerTime;
  122548. private _previousStartingPointerTime;
  122549. private _pointerCaptures;
  122550. private _meshUnderPointerId;
  122551. private _onKeyDown;
  122552. private _onKeyUp;
  122553. private _onCanvasFocusObserver;
  122554. private _onCanvasBlurObserver;
  122555. private _scene;
  122556. /**
  122557. * Creates a new InputManager
  122558. * @param scene defines the hosting scene
  122559. */
  122560. constructor(scene: Scene);
  122561. /**
  122562. * Gets the mesh that is currently under the pointer
  122563. */
  122564. get meshUnderPointer(): Nullable<AbstractMesh>;
  122565. /**
  122566. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  122567. * @param pointerId the pointer id to use
  122568. * @returns The mesh under this pointer id or null if not found
  122569. */
  122570. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  122571. /**
  122572. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  122573. */
  122574. get unTranslatedPointer(): Vector2;
  122575. /**
  122576. * Gets or sets the current on-screen X position of the pointer
  122577. */
  122578. get pointerX(): number;
  122579. set pointerX(value: number);
  122580. /**
  122581. * Gets or sets the current on-screen Y position of the pointer
  122582. */
  122583. get pointerY(): number;
  122584. set pointerY(value: number);
  122585. private _updatePointerPosition;
  122586. private _processPointerMove;
  122587. private _setRayOnPointerInfo;
  122588. private _checkPrePointerObservable;
  122589. /**
  122590. * Use this method to simulate a pointer move on a mesh
  122591. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122592. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122593. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122594. */
  122595. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122596. /**
  122597. * Use this method to simulate a pointer down 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. */
  122602. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122603. private _processPointerDown;
  122604. /** @hidden */
  122605. _isPointerSwiping(): boolean;
  122606. /**
  122607. * Use this method to simulate a pointer up on a mesh
  122608. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122609. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122610. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122611. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  122612. */
  122613. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  122614. private _processPointerUp;
  122615. /**
  122616. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  122617. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  122618. * @returns true if the pointer was captured
  122619. */
  122620. isPointerCaptured(pointerId?: number): boolean;
  122621. /**
  122622. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  122623. * @param attachUp defines if you want to attach events to pointerup
  122624. * @param attachDown defines if you want to attach events to pointerdown
  122625. * @param attachMove defines if you want to attach events to pointermove
  122626. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  122627. */
  122628. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  122629. /**
  122630. * Detaches all event handlers
  122631. */
  122632. detachControl(): void;
  122633. /**
  122634. * Force the value of meshUnderPointer
  122635. * @param mesh defines the mesh to use
  122636. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  122637. */
  122638. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  122639. /**
  122640. * Gets the mesh under the pointer
  122641. * @returns a Mesh or null if no mesh is under the pointer
  122642. */
  122643. getPointerOverMesh(): Nullable<AbstractMesh>;
  122644. }
  122645. }
  122646. declare module BABYLON {
  122647. /**
  122648. * This class defines the direct association between an animation and a target
  122649. */
  122650. export class TargetedAnimation {
  122651. /**
  122652. * Animation to perform
  122653. */
  122654. animation: Animation;
  122655. /**
  122656. * Target to animate
  122657. */
  122658. target: any;
  122659. /**
  122660. * Returns the string "TargetedAnimation"
  122661. * @returns "TargetedAnimation"
  122662. */
  122663. getClassName(): string;
  122664. /**
  122665. * Serialize the object
  122666. * @returns the JSON object representing the current entity
  122667. */
  122668. serialize(): any;
  122669. }
  122670. /**
  122671. * Use this class to create coordinated animations on multiple targets
  122672. */
  122673. export class AnimationGroup implements IDisposable {
  122674. /** The name of the animation group */
  122675. name: string;
  122676. private _scene;
  122677. private _targetedAnimations;
  122678. private _animatables;
  122679. private _from;
  122680. private _to;
  122681. private _isStarted;
  122682. private _isPaused;
  122683. private _speedRatio;
  122684. private _loopAnimation;
  122685. private _isAdditive;
  122686. /**
  122687. * Gets or sets the unique id of the node
  122688. */
  122689. uniqueId: number;
  122690. /**
  122691. * This observable will notify when one animation have ended
  122692. */
  122693. onAnimationEndObservable: Observable<TargetedAnimation>;
  122694. /**
  122695. * Observer raised when one animation loops
  122696. */
  122697. onAnimationLoopObservable: Observable<TargetedAnimation>;
  122698. /**
  122699. * Observer raised when all animations have looped
  122700. */
  122701. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  122702. /**
  122703. * This observable will notify when all animations have ended.
  122704. */
  122705. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  122706. /**
  122707. * This observable will notify when all animations have paused.
  122708. */
  122709. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  122710. /**
  122711. * This observable will notify when all animations are playing.
  122712. */
  122713. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  122714. /**
  122715. * Gets the first frame
  122716. */
  122717. get from(): number;
  122718. /**
  122719. * Gets the last frame
  122720. */
  122721. get to(): number;
  122722. /**
  122723. * Define if the animations are started
  122724. */
  122725. get isStarted(): boolean;
  122726. /**
  122727. * Gets a value indicating that the current group is playing
  122728. */
  122729. get isPlaying(): boolean;
  122730. /**
  122731. * Gets or sets the speed ratio to use for all animations
  122732. */
  122733. get speedRatio(): number;
  122734. /**
  122735. * Gets or sets the speed ratio to use for all animations
  122736. */
  122737. set speedRatio(value: number);
  122738. /**
  122739. * Gets or sets if all animations should loop or not
  122740. */
  122741. get loopAnimation(): boolean;
  122742. set loopAnimation(value: boolean);
  122743. /**
  122744. * Gets or sets if all animations should be evaluated additively
  122745. */
  122746. get isAdditive(): boolean;
  122747. set isAdditive(value: boolean);
  122748. /**
  122749. * Gets the targeted animations for this animation group
  122750. */
  122751. get targetedAnimations(): Array<TargetedAnimation>;
  122752. /**
  122753. * returning the list of animatables controlled by this animation group.
  122754. */
  122755. get animatables(): Array<Animatable>;
  122756. /**
  122757. * Gets the list of target animations
  122758. */
  122759. get children(): TargetedAnimation[];
  122760. /**
  122761. * Instantiates a new Animation Group.
  122762. * This helps managing several animations at once.
  122763. * @see https://doc.babylonjs.com/how_to/group
  122764. * @param name Defines the name of the group
  122765. * @param scene Defines the scene the group belongs to
  122766. */
  122767. constructor(
  122768. /** The name of the animation group */
  122769. name: string, scene?: Nullable<Scene>);
  122770. /**
  122771. * Add an animation (with its target) in the group
  122772. * @param animation defines the animation we want to add
  122773. * @param target defines the target of the animation
  122774. * @returns the TargetedAnimation object
  122775. */
  122776. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  122777. /**
  122778. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  122779. * It can add constant keys at begin or end
  122780. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  122781. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  122782. * @returns the animation group
  122783. */
  122784. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  122785. private _animationLoopCount;
  122786. private _animationLoopFlags;
  122787. private _processLoop;
  122788. /**
  122789. * Start all animations on given targets
  122790. * @param loop defines if animations must loop
  122791. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  122792. * @param from defines the from key (optional)
  122793. * @param to defines the to key (optional)
  122794. * @param isAdditive defines the additive state for the resulting animatables (optional)
  122795. * @returns the current animation group
  122796. */
  122797. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  122798. /**
  122799. * Pause all animations
  122800. * @returns the animation group
  122801. */
  122802. pause(): AnimationGroup;
  122803. /**
  122804. * Play all animations to initial state
  122805. * This function will start() the animations if they were not started or will restart() them if they were paused
  122806. * @param loop defines if animations must loop
  122807. * @returns the animation group
  122808. */
  122809. play(loop?: boolean): AnimationGroup;
  122810. /**
  122811. * Reset all animations to initial state
  122812. * @returns the animation group
  122813. */
  122814. reset(): AnimationGroup;
  122815. /**
  122816. * Restart animations from key 0
  122817. * @returns the animation group
  122818. */
  122819. restart(): AnimationGroup;
  122820. /**
  122821. * Stop all animations
  122822. * @returns the animation group
  122823. */
  122824. stop(): AnimationGroup;
  122825. /**
  122826. * Set animation weight for all animatables
  122827. * @param weight defines the weight to use
  122828. * @return the animationGroup
  122829. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  122830. */
  122831. setWeightForAllAnimatables(weight: number): AnimationGroup;
  122832. /**
  122833. * Synchronize and normalize all animatables with a source animatable
  122834. * @param root defines the root animatable to synchronize with
  122835. * @return the animationGroup
  122836. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  122837. */
  122838. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  122839. /**
  122840. * Goes to a specific frame in this animation group
  122841. * @param frame the frame number to go to
  122842. * @return the animationGroup
  122843. */
  122844. goToFrame(frame: number): AnimationGroup;
  122845. /**
  122846. * Dispose all associated resources
  122847. */
  122848. dispose(): void;
  122849. private _checkAnimationGroupEnded;
  122850. /**
  122851. * Clone the current animation group and returns a copy
  122852. * @param newName defines the name of the new group
  122853. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  122854. * @returns the new aniamtion group
  122855. */
  122856. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  122857. /**
  122858. * Serializes the animationGroup to an object
  122859. * @returns Serialized object
  122860. */
  122861. serialize(): any;
  122862. /**
  122863. * Returns a new AnimationGroup object parsed from the source provided.
  122864. * @param parsedAnimationGroup defines the source
  122865. * @param scene defines the scene that will receive the animationGroup
  122866. * @returns a new AnimationGroup
  122867. */
  122868. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  122869. /**
  122870. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  122871. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  122872. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  122873. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  122874. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  122875. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  122876. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  122877. */
  122878. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  122879. /**
  122880. * Returns the string "AnimationGroup"
  122881. * @returns "AnimationGroup"
  122882. */
  122883. getClassName(): string;
  122884. /**
  122885. * Creates a detailled string about the object
  122886. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  122887. * @returns a string representing the object
  122888. */
  122889. toString(fullDetails?: boolean): string;
  122890. }
  122891. }
  122892. declare module BABYLON {
  122893. /**
  122894. * Define an interface for all classes that will hold resources
  122895. */
  122896. export interface IDisposable {
  122897. /**
  122898. * Releases all held resources
  122899. */
  122900. dispose(): void;
  122901. }
  122902. /** Interface defining initialization parameters for Scene class */
  122903. export interface SceneOptions {
  122904. /**
  122905. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  122906. * It will improve performance when the number of geometries becomes important.
  122907. */
  122908. useGeometryUniqueIdsMap?: boolean;
  122909. /**
  122910. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  122911. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  122912. */
  122913. useMaterialMeshMap?: boolean;
  122914. /**
  122915. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  122916. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  122917. */
  122918. useClonedMeshMap?: boolean;
  122919. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  122920. virtual?: boolean;
  122921. }
  122922. /**
  122923. * Represents a scene to be rendered by the engine.
  122924. * @see https://doc.babylonjs.com/features/scene
  122925. */
  122926. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  122927. /** The fog is deactivated */
  122928. static readonly FOGMODE_NONE: number;
  122929. /** The fog density is following an exponential function */
  122930. static readonly FOGMODE_EXP: number;
  122931. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  122932. static readonly FOGMODE_EXP2: number;
  122933. /** The fog density is following a linear function. */
  122934. static readonly FOGMODE_LINEAR: number;
  122935. /**
  122936. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  122937. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122938. */
  122939. static MinDeltaTime: number;
  122940. /**
  122941. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  122942. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122943. */
  122944. static MaxDeltaTime: number;
  122945. /**
  122946. * Factory used to create the default material.
  122947. * @param name The name of the material to create
  122948. * @param scene The scene to create the material for
  122949. * @returns The default material
  122950. */
  122951. static DefaultMaterialFactory(scene: Scene): Material;
  122952. /**
  122953. * Factory used to create the a collision coordinator.
  122954. * @returns The collision coordinator
  122955. */
  122956. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  122957. /** @hidden */
  122958. _inputManager: InputManager;
  122959. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  122960. cameraToUseForPointers: Nullable<Camera>;
  122961. /** @hidden */
  122962. readonly _isScene: boolean;
  122963. /** @hidden */
  122964. _blockEntityCollection: boolean;
  122965. /**
  122966. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  122967. */
  122968. autoClear: boolean;
  122969. /**
  122970. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  122971. */
  122972. autoClearDepthAndStencil: boolean;
  122973. /**
  122974. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  122975. */
  122976. clearColor: Color4;
  122977. /**
  122978. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  122979. */
  122980. ambientColor: Color3;
  122981. /**
  122982. * This is use to store the default BRDF lookup for PBR materials in your scene.
  122983. * It should only be one of the following (if not the default embedded one):
  122984. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  122985. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  122986. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  122987. * The material properties need to be setup according to the type of texture in use.
  122988. */
  122989. environmentBRDFTexture: BaseTexture;
  122990. /**
  122991. * Texture used in all pbr material as the reflection texture.
  122992. * As in the majority of the scene they are the same (exception for multi room and so on),
  122993. * this is easier to reference from here than from all the materials.
  122994. */
  122995. get environmentTexture(): Nullable<BaseTexture>;
  122996. /**
  122997. * Texture used in all pbr material as the reflection texture.
  122998. * As in the majority of the scene they are the same (exception for multi room and so on),
  122999. * this is easier to set here than in all the materials.
  123000. */
  123001. set environmentTexture(value: Nullable<BaseTexture>);
  123002. /** @hidden */
  123003. protected _environmentIntensity: number;
  123004. /**
  123005. * Intensity of the environment in all pbr material.
  123006. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123007. * As in the majority of the scene they are the same (exception for multi room and so on),
  123008. * this is easier to reference from here than from all the materials.
  123009. */
  123010. get environmentIntensity(): number;
  123011. /**
  123012. * Intensity of the environment in all pbr material.
  123013. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123014. * As in the majority of the scene they are the same (exception for multi room and so on),
  123015. * this is easier to set here than in all the materials.
  123016. */
  123017. set environmentIntensity(value: number);
  123018. /** @hidden */
  123019. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123020. /**
  123021. * Default image processing configuration used either in the rendering
  123022. * Forward main pass or through the imageProcessingPostProcess if present.
  123023. * As in the majority of the scene they are the same (exception for multi camera),
  123024. * this is easier to reference from here than from all the materials and post process.
  123025. *
  123026. * No setter as we it is a shared configuration, you can set the values instead.
  123027. */
  123028. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123029. private _forceWireframe;
  123030. /**
  123031. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  123032. */
  123033. set forceWireframe(value: boolean);
  123034. get forceWireframe(): boolean;
  123035. private _skipFrustumClipping;
  123036. /**
  123037. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  123038. */
  123039. set skipFrustumClipping(value: boolean);
  123040. get skipFrustumClipping(): boolean;
  123041. private _forcePointsCloud;
  123042. /**
  123043. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  123044. */
  123045. set forcePointsCloud(value: boolean);
  123046. get forcePointsCloud(): boolean;
  123047. /**
  123048. * Gets or sets the active clipplane 1
  123049. */
  123050. clipPlane: Nullable<Plane>;
  123051. /**
  123052. * Gets or sets the active clipplane 2
  123053. */
  123054. clipPlane2: Nullable<Plane>;
  123055. /**
  123056. * Gets or sets the active clipplane 3
  123057. */
  123058. clipPlane3: Nullable<Plane>;
  123059. /**
  123060. * Gets or sets the active clipplane 4
  123061. */
  123062. clipPlane4: Nullable<Plane>;
  123063. /**
  123064. * Gets or sets the active clipplane 5
  123065. */
  123066. clipPlane5: Nullable<Plane>;
  123067. /**
  123068. * Gets or sets the active clipplane 6
  123069. */
  123070. clipPlane6: Nullable<Plane>;
  123071. /**
  123072. * Gets or sets a boolean indicating if animations are enabled
  123073. */
  123074. animationsEnabled: boolean;
  123075. private _animationPropertiesOverride;
  123076. /**
  123077. * Gets or sets the animation properties override
  123078. */
  123079. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  123080. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  123081. /**
  123082. * Gets or sets a boolean indicating if a constant deltatime has to be used
  123083. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  123084. */
  123085. useConstantAnimationDeltaTime: boolean;
  123086. /**
  123087. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  123088. * Please note that it requires to run a ray cast through the scene on every frame
  123089. */
  123090. constantlyUpdateMeshUnderPointer: boolean;
  123091. /**
  123092. * Defines the HTML cursor to use when hovering over interactive elements
  123093. */
  123094. hoverCursor: string;
  123095. /**
  123096. * Defines the HTML default cursor to use (empty by default)
  123097. */
  123098. defaultCursor: string;
  123099. /**
  123100. * Defines whether cursors are handled by the scene.
  123101. */
  123102. doNotHandleCursors: boolean;
  123103. /**
  123104. * This is used to call preventDefault() on pointer down
  123105. * in order to block unwanted artifacts like system double clicks
  123106. */
  123107. preventDefaultOnPointerDown: boolean;
  123108. /**
  123109. * This is used to call preventDefault() on pointer up
  123110. * in order to block unwanted artifacts like system double clicks
  123111. */
  123112. preventDefaultOnPointerUp: boolean;
  123113. /**
  123114. * Gets or sets user defined metadata
  123115. */
  123116. metadata: any;
  123117. /**
  123118. * For internal use only. Please do not use.
  123119. */
  123120. reservedDataStore: any;
  123121. /**
  123122. * Gets the name of the plugin used to load this scene (null by default)
  123123. */
  123124. loadingPluginName: string;
  123125. /**
  123126. * Use this array to add regular expressions used to disable offline support for specific urls
  123127. */
  123128. disableOfflineSupportExceptionRules: RegExp[];
  123129. /**
  123130. * An event triggered when the scene is disposed.
  123131. */
  123132. onDisposeObservable: Observable<Scene>;
  123133. private _onDisposeObserver;
  123134. /** Sets a function to be executed when this scene is disposed. */
  123135. set onDispose(callback: () => void);
  123136. /**
  123137. * An event triggered before rendering the scene (right after animations and physics)
  123138. */
  123139. onBeforeRenderObservable: Observable<Scene>;
  123140. private _onBeforeRenderObserver;
  123141. /** Sets a function to be executed before rendering this scene */
  123142. set beforeRender(callback: Nullable<() => void>);
  123143. /**
  123144. * An event triggered after rendering the scene
  123145. */
  123146. onAfterRenderObservable: Observable<Scene>;
  123147. /**
  123148. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  123149. */
  123150. onAfterRenderCameraObservable: Observable<Camera>;
  123151. private _onAfterRenderObserver;
  123152. /** Sets a function to be executed after rendering this scene */
  123153. set afterRender(callback: Nullable<() => void>);
  123154. /**
  123155. * An event triggered before animating the scene
  123156. */
  123157. onBeforeAnimationsObservable: Observable<Scene>;
  123158. /**
  123159. * An event triggered after animations processing
  123160. */
  123161. onAfterAnimationsObservable: Observable<Scene>;
  123162. /**
  123163. * An event triggered before draw calls are ready to be sent
  123164. */
  123165. onBeforeDrawPhaseObservable: Observable<Scene>;
  123166. /**
  123167. * An event triggered after draw calls have been sent
  123168. */
  123169. onAfterDrawPhaseObservable: Observable<Scene>;
  123170. /**
  123171. * An event triggered when the scene is ready
  123172. */
  123173. onReadyObservable: Observable<Scene>;
  123174. /**
  123175. * An event triggered before rendering a camera
  123176. */
  123177. onBeforeCameraRenderObservable: Observable<Camera>;
  123178. private _onBeforeCameraRenderObserver;
  123179. /** Sets a function to be executed before rendering a camera*/
  123180. set beforeCameraRender(callback: () => void);
  123181. /**
  123182. * An event triggered after rendering a camera
  123183. */
  123184. onAfterCameraRenderObservable: Observable<Camera>;
  123185. private _onAfterCameraRenderObserver;
  123186. /** Sets a function to be executed after rendering a camera*/
  123187. set afterCameraRender(callback: () => void);
  123188. /**
  123189. * An event triggered when active meshes evaluation is about to start
  123190. */
  123191. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  123192. /**
  123193. * An event triggered when active meshes evaluation is done
  123194. */
  123195. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  123196. /**
  123197. * An event triggered when particles rendering is about to start
  123198. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123199. */
  123200. onBeforeParticlesRenderingObservable: Observable<Scene>;
  123201. /**
  123202. * An event triggered when particles rendering is done
  123203. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123204. */
  123205. onAfterParticlesRenderingObservable: Observable<Scene>;
  123206. /**
  123207. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  123208. */
  123209. onDataLoadedObservable: Observable<Scene>;
  123210. /**
  123211. * An event triggered when a camera is created
  123212. */
  123213. onNewCameraAddedObservable: Observable<Camera>;
  123214. /**
  123215. * An event triggered when a camera is removed
  123216. */
  123217. onCameraRemovedObservable: Observable<Camera>;
  123218. /**
  123219. * An event triggered when a light is created
  123220. */
  123221. onNewLightAddedObservable: Observable<Light>;
  123222. /**
  123223. * An event triggered when a light is removed
  123224. */
  123225. onLightRemovedObservable: Observable<Light>;
  123226. /**
  123227. * An event triggered when a geometry is created
  123228. */
  123229. onNewGeometryAddedObservable: Observable<Geometry>;
  123230. /**
  123231. * An event triggered when a geometry is removed
  123232. */
  123233. onGeometryRemovedObservable: Observable<Geometry>;
  123234. /**
  123235. * An event triggered when a transform node is created
  123236. */
  123237. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  123238. /**
  123239. * An event triggered when a transform node is removed
  123240. */
  123241. onTransformNodeRemovedObservable: Observable<TransformNode>;
  123242. /**
  123243. * An event triggered when a mesh is created
  123244. */
  123245. onNewMeshAddedObservable: Observable<AbstractMesh>;
  123246. /**
  123247. * An event triggered when a mesh is removed
  123248. */
  123249. onMeshRemovedObservable: Observable<AbstractMesh>;
  123250. /**
  123251. * An event triggered when a skeleton is created
  123252. */
  123253. onNewSkeletonAddedObservable: Observable<Skeleton>;
  123254. /**
  123255. * An event triggered when a skeleton is removed
  123256. */
  123257. onSkeletonRemovedObservable: Observable<Skeleton>;
  123258. /**
  123259. * An event triggered when a material is created
  123260. */
  123261. onNewMaterialAddedObservable: Observable<Material>;
  123262. /**
  123263. * An event triggered when a material is removed
  123264. */
  123265. onMaterialRemovedObservable: Observable<Material>;
  123266. /**
  123267. * An event triggered when a texture is created
  123268. */
  123269. onNewTextureAddedObservable: Observable<BaseTexture>;
  123270. /**
  123271. * An event triggered when a texture is removed
  123272. */
  123273. onTextureRemovedObservable: Observable<BaseTexture>;
  123274. /**
  123275. * An event triggered when render targets are about to be rendered
  123276. * Can happen multiple times per frame.
  123277. */
  123278. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  123279. /**
  123280. * An event triggered when render targets were rendered.
  123281. * Can happen multiple times per frame.
  123282. */
  123283. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  123284. /**
  123285. * An event triggered before calculating deterministic simulation step
  123286. */
  123287. onBeforeStepObservable: Observable<Scene>;
  123288. /**
  123289. * An event triggered after calculating deterministic simulation step
  123290. */
  123291. onAfterStepObservable: Observable<Scene>;
  123292. /**
  123293. * An event triggered when the activeCamera property is updated
  123294. */
  123295. onActiveCameraChanged: Observable<Scene>;
  123296. /**
  123297. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  123298. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123299. * 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)
  123300. */
  123301. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123302. /**
  123303. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  123304. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123305. * 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)
  123306. */
  123307. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123308. /**
  123309. * This Observable will when a mesh has been imported into the scene.
  123310. */
  123311. onMeshImportedObservable: Observable<AbstractMesh>;
  123312. /**
  123313. * This Observable will when an animation file has been imported into the scene.
  123314. */
  123315. onAnimationFileImportedObservable: Observable<Scene>;
  123316. /**
  123317. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  123318. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  123319. */
  123320. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  123321. /** @hidden */
  123322. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  123323. /**
  123324. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  123325. */
  123326. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  123327. /**
  123328. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  123329. */
  123330. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  123331. /**
  123332. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  123333. */
  123334. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  123335. /** Callback called when a pointer move is detected */
  123336. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123337. /** Callback called when a pointer down is detected */
  123338. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123339. /** Callback called when a pointer up is detected */
  123340. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  123341. /** Callback called when a pointer pick is detected */
  123342. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  123343. /**
  123344. * 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).
  123345. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  123346. */
  123347. onPrePointerObservable: Observable<PointerInfoPre>;
  123348. /**
  123349. * Observable event triggered each time an input event is received from the rendering canvas
  123350. */
  123351. onPointerObservable: Observable<PointerInfo>;
  123352. /**
  123353. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  123354. */
  123355. get unTranslatedPointer(): Vector2;
  123356. /**
  123357. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  123358. */
  123359. static get DragMovementThreshold(): number;
  123360. static set DragMovementThreshold(value: number);
  123361. /**
  123362. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  123363. */
  123364. static get LongPressDelay(): number;
  123365. static set LongPressDelay(value: number);
  123366. /**
  123367. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  123368. */
  123369. static get DoubleClickDelay(): number;
  123370. static set DoubleClickDelay(value: number);
  123371. /** If you need to check double click without raising a single click at first click, enable this flag */
  123372. static get ExclusiveDoubleClickMode(): boolean;
  123373. static set ExclusiveDoubleClickMode(value: boolean);
  123374. /** @hidden */
  123375. _mirroredCameraPosition: Nullable<Vector3>;
  123376. /**
  123377. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  123378. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  123379. */
  123380. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  123381. /**
  123382. * Observable event triggered each time an keyboard event is received from the hosting window
  123383. */
  123384. onKeyboardObservable: Observable<KeyboardInfo>;
  123385. private _useRightHandedSystem;
  123386. /**
  123387. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  123388. */
  123389. set useRightHandedSystem(value: boolean);
  123390. get useRightHandedSystem(): boolean;
  123391. private _timeAccumulator;
  123392. private _currentStepId;
  123393. private _currentInternalStep;
  123394. /**
  123395. * Sets the step Id used by deterministic lock step
  123396. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123397. * @param newStepId defines the step Id
  123398. */
  123399. setStepId(newStepId: number): void;
  123400. /**
  123401. * Gets the step Id used by deterministic lock step
  123402. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123403. * @returns the step Id
  123404. */
  123405. getStepId(): number;
  123406. /**
  123407. * Gets the internal step used by deterministic lock step
  123408. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123409. * @returns the internal step
  123410. */
  123411. getInternalStep(): number;
  123412. private _fogEnabled;
  123413. /**
  123414. * Gets or sets a boolean indicating if fog is enabled on this scene
  123415. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123416. * (Default is true)
  123417. */
  123418. set fogEnabled(value: boolean);
  123419. get fogEnabled(): boolean;
  123420. private _fogMode;
  123421. /**
  123422. * Gets or sets the fog mode to use
  123423. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123424. * | mode | value |
  123425. * | --- | --- |
  123426. * | FOGMODE_NONE | 0 |
  123427. * | FOGMODE_EXP | 1 |
  123428. * | FOGMODE_EXP2 | 2 |
  123429. * | FOGMODE_LINEAR | 3 |
  123430. */
  123431. set fogMode(value: number);
  123432. get fogMode(): number;
  123433. /**
  123434. * Gets or sets the fog color to use
  123435. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123436. * (Default is Color3(0.2, 0.2, 0.3))
  123437. */
  123438. fogColor: Color3;
  123439. /**
  123440. * Gets or sets the fog density to use
  123441. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123442. * (Default is 0.1)
  123443. */
  123444. fogDensity: number;
  123445. /**
  123446. * Gets or sets the fog start distance to use
  123447. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123448. * (Default is 0)
  123449. */
  123450. fogStart: number;
  123451. /**
  123452. * Gets or sets the fog end distance to use
  123453. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123454. * (Default is 1000)
  123455. */
  123456. fogEnd: number;
  123457. /**
  123458. * Flag indicating that the frame buffer binding is handled by another component
  123459. */
  123460. prePass: boolean;
  123461. private _shadowsEnabled;
  123462. /**
  123463. * Gets or sets a boolean indicating if shadows are enabled on this scene
  123464. */
  123465. set shadowsEnabled(value: boolean);
  123466. get shadowsEnabled(): boolean;
  123467. private _lightsEnabled;
  123468. /**
  123469. * Gets or sets a boolean indicating if lights are enabled on this scene
  123470. */
  123471. set lightsEnabled(value: boolean);
  123472. get lightsEnabled(): boolean;
  123473. /** All of the active cameras added to this scene. */
  123474. activeCameras: Camera[];
  123475. /** @hidden */
  123476. _activeCamera: Nullable<Camera>;
  123477. /** Gets or sets the current active camera */
  123478. get activeCamera(): Nullable<Camera>;
  123479. set activeCamera(value: Nullable<Camera>);
  123480. private _defaultMaterial;
  123481. /** The default material used on meshes when no material is affected */
  123482. get defaultMaterial(): Material;
  123483. /** The default material used on meshes when no material is affected */
  123484. set defaultMaterial(value: Material);
  123485. private _texturesEnabled;
  123486. /**
  123487. * Gets or sets a boolean indicating if textures are enabled on this scene
  123488. */
  123489. set texturesEnabled(value: boolean);
  123490. get texturesEnabled(): boolean;
  123491. /**
  123492. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  123493. */
  123494. physicsEnabled: boolean;
  123495. /**
  123496. * Gets or sets a boolean indicating if particles are enabled on this scene
  123497. */
  123498. particlesEnabled: boolean;
  123499. /**
  123500. * Gets or sets a boolean indicating if sprites are enabled on this scene
  123501. */
  123502. spritesEnabled: boolean;
  123503. private _skeletonsEnabled;
  123504. /**
  123505. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  123506. */
  123507. set skeletonsEnabled(value: boolean);
  123508. get skeletonsEnabled(): boolean;
  123509. /**
  123510. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  123511. */
  123512. lensFlaresEnabled: boolean;
  123513. /**
  123514. * Gets or sets a boolean indicating if collisions are enabled on this scene
  123515. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123516. */
  123517. collisionsEnabled: boolean;
  123518. private _collisionCoordinator;
  123519. /** @hidden */
  123520. get collisionCoordinator(): ICollisionCoordinator;
  123521. /**
  123522. * Defines the gravity applied to this scene (used only for collisions)
  123523. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123524. */
  123525. gravity: Vector3;
  123526. /**
  123527. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  123528. */
  123529. postProcessesEnabled: boolean;
  123530. /**
  123531. * Gets the current postprocess manager
  123532. */
  123533. postProcessManager: PostProcessManager;
  123534. /**
  123535. * Gets or sets a boolean indicating if render targets are enabled on this scene
  123536. */
  123537. renderTargetsEnabled: boolean;
  123538. /**
  123539. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  123540. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  123541. */
  123542. dumpNextRenderTargets: boolean;
  123543. /**
  123544. * The list of user defined render targets added to the scene
  123545. */
  123546. customRenderTargets: RenderTargetTexture[];
  123547. /**
  123548. * Defines if texture loading must be delayed
  123549. * If true, textures will only be loaded when they need to be rendered
  123550. */
  123551. useDelayedTextureLoading: boolean;
  123552. /**
  123553. * Gets the list of meshes imported to the scene through SceneLoader
  123554. */
  123555. importedMeshesFiles: String[];
  123556. /**
  123557. * Gets or sets a boolean indicating if probes are enabled on this scene
  123558. */
  123559. probesEnabled: boolean;
  123560. /**
  123561. * Gets or sets the current offline provider to use to store scene data
  123562. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  123563. */
  123564. offlineProvider: IOfflineProvider;
  123565. /**
  123566. * Gets or sets the action manager associated with the scene
  123567. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  123568. */
  123569. actionManager: AbstractActionManager;
  123570. private _meshesForIntersections;
  123571. /**
  123572. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  123573. */
  123574. proceduralTexturesEnabled: boolean;
  123575. private _engine;
  123576. private _totalVertices;
  123577. /** @hidden */
  123578. _activeIndices: PerfCounter;
  123579. /** @hidden */
  123580. _activeParticles: PerfCounter;
  123581. /** @hidden */
  123582. _activeBones: PerfCounter;
  123583. private _animationRatio;
  123584. /** @hidden */
  123585. _animationTimeLast: number;
  123586. /** @hidden */
  123587. _animationTime: number;
  123588. /**
  123589. * Gets or sets a general scale for animation speed
  123590. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  123591. */
  123592. animationTimeScale: number;
  123593. /** @hidden */
  123594. _cachedMaterial: Nullable<Material>;
  123595. /** @hidden */
  123596. _cachedEffect: Nullable<Effect>;
  123597. /** @hidden */
  123598. _cachedVisibility: Nullable<number>;
  123599. private _renderId;
  123600. private _frameId;
  123601. private _executeWhenReadyTimeoutId;
  123602. private _intermediateRendering;
  123603. private _viewUpdateFlag;
  123604. private _projectionUpdateFlag;
  123605. /** @hidden */
  123606. _toBeDisposed: Nullable<IDisposable>[];
  123607. private _activeRequests;
  123608. /** @hidden */
  123609. _pendingData: any[];
  123610. private _isDisposed;
  123611. /**
  123612. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  123613. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  123614. */
  123615. dispatchAllSubMeshesOfActiveMeshes: boolean;
  123616. private _activeMeshes;
  123617. private _processedMaterials;
  123618. private _renderTargets;
  123619. /** @hidden */
  123620. _activeParticleSystems: SmartArray<IParticleSystem>;
  123621. private _activeSkeletons;
  123622. private _softwareSkinnedMeshes;
  123623. private _renderingManager;
  123624. /** @hidden */
  123625. _activeAnimatables: Animatable[];
  123626. private _transformMatrix;
  123627. private _sceneUbo;
  123628. /** @hidden */
  123629. _viewMatrix: Matrix;
  123630. private _projectionMatrix;
  123631. /** @hidden */
  123632. _forcedViewPosition: Nullable<Vector3>;
  123633. /** @hidden */
  123634. _frustumPlanes: Plane[];
  123635. /**
  123636. * Gets the list of frustum planes (built from the active camera)
  123637. */
  123638. get frustumPlanes(): Plane[];
  123639. /**
  123640. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  123641. * This is useful if there are more lights that the maximum simulteanous authorized
  123642. */
  123643. requireLightSorting: boolean;
  123644. /** @hidden */
  123645. readonly useMaterialMeshMap: boolean;
  123646. /** @hidden */
  123647. readonly useClonedMeshMap: boolean;
  123648. private _externalData;
  123649. private _uid;
  123650. /**
  123651. * @hidden
  123652. * Backing store of defined scene components.
  123653. */
  123654. _components: ISceneComponent[];
  123655. /**
  123656. * @hidden
  123657. * Backing store of defined scene components.
  123658. */
  123659. _serializableComponents: ISceneSerializableComponent[];
  123660. /**
  123661. * List of components to register on the next registration step.
  123662. */
  123663. private _transientComponents;
  123664. /**
  123665. * Registers the transient components if needed.
  123666. */
  123667. private _registerTransientComponents;
  123668. /**
  123669. * @hidden
  123670. * Add a component to the scene.
  123671. * Note that the ccomponent could be registered on th next frame if this is called after
  123672. * the register component stage.
  123673. * @param component Defines the component to add to the scene
  123674. */
  123675. _addComponent(component: ISceneComponent): void;
  123676. /**
  123677. * @hidden
  123678. * Gets a component from the scene.
  123679. * @param name defines the name of the component to retrieve
  123680. * @returns the component or null if not present
  123681. */
  123682. _getComponent(name: string): Nullable<ISceneComponent>;
  123683. /**
  123684. * @hidden
  123685. * Defines the actions happening before camera updates.
  123686. */
  123687. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  123688. /**
  123689. * @hidden
  123690. * Defines the actions happening before clear the canvas.
  123691. */
  123692. _beforeClearStage: Stage<SimpleStageAction>;
  123693. /**
  123694. * @hidden
  123695. * Defines the actions when collecting render targets for the frame.
  123696. */
  123697. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  123698. /**
  123699. * @hidden
  123700. * Defines the actions happening for one camera in the frame.
  123701. */
  123702. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  123703. /**
  123704. * @hidden
  123705. * Defines the actions happening during the per mesh ready checks.
  123706. */
  123707. _isReadyForMeshStage: Stage<MeshStageAction>;
  123708. /**
  123709. * @hidden
  123710. * Defines the actions happening before evaluate active mesh checks.
  123711. */
  123712. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  123713. /**
  123714. * @hidden
  123715. * Defines the actions happening during the evaluate sub mesh checks.
  123716. */
  123717. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  123718. /**
  123719. * @hidden
  123720. * Defines the actions happening during the active mesh stage.
  123721. */
  123722. _activeMeshStage: Stage<ActiveMeshStageAction>;
  123723. /**
  123724. * @hidden
  123725. * Defines the actions happening during the per camera render target step.
  123726. */
  123727. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  123728. /**
  123729. * @hidden
  123730. * Defines the actions happening just before the active camera is drawing.
  123731. */
  123732. _beforeCameraDrawStage: Stage<CameraStageAction>;
  123733. /**
  123734. * @hidden
  123735. * Defines the actions happening just before a render target is drawing.
  123736. */
  123737. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  123738. /**
  123739. * @hidden
  123740. * Defines the actions happening just before a rendering group is drawing.
  123741. */
  123742. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  123743. /**
  123744. * @hidden
  123745. * Defines the actions happening just before a mesh is drawing.
  123746. */
  123747. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  123748. /**
  123749. * @hidden
  123750. * Defines the actions happening just after a mesh has been drawn.
  123751. */
  123752. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  123753. /**
  123754. * @hidden
  123755. * Defines the actions happening just after a rendering group has been drawn.
  123756. */
  123757. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  123758. /**
  123759. * @hidden
  123760. * Defines the actions happening just after the active camera has been drawn.
  123761. */
  123762. _afterCameraDrawStage: Stage<CameraStageAction>;
  123763. /**
  123764. * @hidden
  123765. * Defines the actions happening just after a render target has been drawn.
  123766. */
  123767. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  123768. /**
  123769. * @hidden
  123770. * Defines the actions happening just after rendering all cameras and computing intersections.
  123771. */
  123772. _afterRenderStage: Stage<SimpleStageAction>;
  123773. /**
  123774. * @hidden
  123775. * Defines the actions happening when a pointer move event happens.
  123776. */
  123777. _pointerMoveStage: Stage<PointerMoveStageAction>;
  123778. /**
  123779. * @hidden
  123780. * Defines the actions happening when a pointer down event happens.
  123781. */
  123782. _pointerDownStage: Stage<PointerUpDownStageAction>;
  123783. /**
  123784. * @hidden
  123785. * Defines the actions happening when a pointer up event happens.
  123786. */
  123787. _pointerUpStage: Stage<PointerUpDownStageAction>;
  123788. /**
  123789. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  123790. */
  123791. private geometriesByUniqueId;
  123792. /**
  123793. * Creates a new Scene
  123794. * @param engine defines the engine to use to render this scene
  123795. * @param options defines the scene options
  123796. */
  123797. constructor(engine: Engine, options?: SceneOptions);
  123798. /**
  123799. * Gets a string identifying the name of the class
  123800. * @returns "Scene" string
  123801. */
  123802. getClassName(): string;
  123803. private _defaultMeshCandidates;
  123804. /**
  123805. * @hidden
  123806. */
  123807. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  123808. private _defaultSubMeshCandidates;
  123809. /**
  123810. * @hidden
  123811. */
  123812. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  123813. /**
  123814. * Sets the default candidate providers for the scene.
  123815. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  123816. * and getCollidingSubMeshCandidates to their default function
  123817. */
  123818. setDefaultCandidateProviders(): void;
  123819. /**
  123820. * Gets the mesh that is currently under the pointer
  123821. */
  123822. get meshUnderPointer(): Nullable<AbstractMesh>;
  123823. /**
  123824. * Gets or sets the current on-screen X position of the pointer
  123825. */
  123826. get pointerX(): number;
  123827. set pointerX(value: number);
  123828. /**
  123829. * Gets or sets the current on-screen Y position of the pointer
  123830. */
  123831. get pointerY(): number;
  123832. set pointerY(value: number);
  123833. /**
  123834. * Gets the cached material (ie. the latest rendered one)
  123835. * @returns the cached material
  123836. */
  123837. getCachedMaterial(): Nullable<Material>;
  123838. /**
  123839. * Gets the cached effect (ie. the latest rendered one)
  123840. * @returns the cached effect
  123841. */
  123842. getCachedEffect(): Nullable<Effect>;
  123843. /**
  123844. * Gets the cached visibility state (ie. the latest rendered one)
  123845. * @returns the cached visibility state
  123846. */
  123847. getCachedVisibility(): Nullable<number>;
  123848. /**
  123849. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  123850. * @param material defines the current material
  123851. * @param effect defines the current effect
  123852. * @param visibility defines the current visibility state
  123853. * @returns true if one parameter is not cached
  123854. */
  123855. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  123856. /**
  123857. * Gets the engine associated with the scene
  123858. * @returns an Engine
  123859. */
  123860. getEngine(): Engine;
  123861. /**
  123862. * Gets the total number of vertices rendered per frame
  123863. * @returns the total number of vertices rendered per frame
  123864. */
  123865. getTotalVertices(): number;
  123866. /**
  123867. * Gets the performance counter for total vertices
  123868. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  123869. */
  123870. get totalVerticesPerfCounter(): PerfCounter;
  123871. /**
  123872. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  123873. * @returns the total number of active indices rendered per frame
  123874. */
  123875. getActiveIndices(): number;
  123876. /**
  123877. * Gets the performance counter for active indices
  123878. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  123879. */
  123880. get totalActiveIndicesPerfCounter(): PerfCounter;
  123881. /**
  123882. * Gets the total number of active particles rendered per frame
  123883. * @returns the total number of active particles rendered per frame
  123884. */
  123885. getActiveParticles(): number;
  123886. /**
  123887. * Gets the performance counter for active particles
  123888. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  123889. */
  123890. get activeParticlesPerfCounter(): PerfCounter;
  123891. /**
  123892. * Gets the total number of active bones rendered per frame
  123893. * @returns the total number of active bones rendered per frame
  123894. */
  123895. getActiveBones(): number;
  123896. /**
  123897. * Gets the performance counter for active bones
  123898. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  123899. */
  123900. get activeBonesPerfCounter(): PerfCounter;
  123901. /**
  123902. * Gets the array of active meshes
  123903. * @returns an array of AbstractMesh
  123904. */
  123905. getActiveMeshes(): SmartArray<AbstractMesh>;
  123906. /**
  123907. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  123908. * @returns a number
  123909. */
  123910. getAnimationRatio(): number;
  123911. /**
  123912. * Gets an unique Id for the current render phase
  123913. * @returns a number
  123914. */
  123915. getRenderId(): number;
  123916. /**
  123917. * Gets an unique Id for the current frame
  123918. * @returns a number
  123919. */
  123920. getFrameId(): number;
  123921. /** Call this function if you want to manually increment the render Id*/
  123922. incrementRenderId(): void;
  123923. private _createUbo;
  123924. /**
  123925. * Use this method to simulate a pointer move on a mesh
  123926. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123927. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123928. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123929. * @returns the current scene
  123930. */
  123931. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  123932. /**
  123933. * Use this method to simulate a pointer down on a mesh
  123934. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123935. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123936. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123937. * @returns the current scene
  123938. */
  123939. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  123940. /**
  123941. * Use this method to simulate a pointer up on a mesh
  123942. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123943. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123944. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123945. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  123946. * @returns the current scene
  123947. */
  123948. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  123949. /**
  123950. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  123951. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  123952. * @returns true if the pointer was captured
  123953. */
  123954. isPointerCaptured(pointerId?: number): boolean;
  123955. /**
  123956. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  123957. * @param attachUp defines if you want to attach events to pointerup
  123958. * @param attachDown defines if you want to attach events to pointerdown
  123959. * @param attachMove defines if you want to attach events to pointermove
  123960. */
  123961. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  123962. /** Detaches all event handlers*/
  123963. detachControl(): void;
  123964. /**
  123965. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  123966. * Delay loaded resources are not taking in account
  123967. * @return true if all required resources are ready
  123968. */
  123969. isReady(): boolean;
  123970. /** Resets all cached information relative to material (including effect and visibility) */
  123971. resetCachedMaterial(): void;
  123972. /**
  123973. * Registers a function to be called before every frame render
  123974. * @param func defines the function to register
  123975. */
  123976. registerBeforeRender(func: () => void): void;
  123977. /**
  123978. * Unregisters a function called before every frame render
  123979. * @param func defines the function to unregister
  123980. */
  123981. unregisterBeforeRender(func: () => void): void;
  123982. /**
  123983. * Registers a function to be called after every frame render
  123984. * @param func defines the function to register
  123985. */
  123986. registerAfterRender(func: () => void): void;
  123987. /**
  123988. * Unregisters a function called after every frame render
  123989. * @param func defines the function to unregister
  123990. */
  123991. unregisterAfterRender(func: () => void): void;
  123992. private _executeOnceBeforeRender;
  123993. /**
  123994. * The provided function will run before render once and will be disposed afterwards.
  123995. * A timeout delay can be provided so that the function will be executed in N ms.
  123996. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  123997. * @param func The function to be executed.
  123998. * @param timeout optional delay in ms
  123999. */
  124000. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  124001. /** @hidden */
  124002. _addPendingData(data: any): void;
  124003. /** @hidden */
  124004. _removePendingData(data: any): void;
  124005. /**
  124006. * Returns the number of items waiting to be loaded
  124007. * @returns the number of items waiting to be loaded
  124008. */
  124009. getWaitingItemsCount(): number;
  124010. /**
  124011. * Returns a boolean indicating if the scene is still loading data
  124012. */
  124013. get isLoading(): boolean;
  124014. /**
  124015. * Registers a function to be executed when the scene is ready
  124016. * @param {Function} func - the function to be executed
  124017. */
  124018. executeWhenReady(func: () => void): void;
  124019. /**
  124020. * Returns a promise that resolves when the scene is ready
  124021. * @returns A promise that resolves when the scene is ready
  124022. */
  124023. whenReadyAsync(): Promise<void>;
  124024. /** @hidden */
  124025. _checkIsReady(): void;
  124026. /**
  124027. * Gets all animatable attached to the scene
  124028. */
  124029. get animatables(): Animatable[];
  124030. /**
  124031. * Resets the last animation time frame.
  124032. * Useful to override when animations start running when loading a scene for the first time.
  124033. */
  124034. resetLastAnimationTimeFrame(): void;
  124035. /**
  124036. * Gets the current view matrix
  124037. * @returns a Matrix
  124038. */
  124039. getViewMatrix(): Matrix;
  124040. /**
  124041. * Gets the current projection matrix
  124042. * @returns a Matrix
  124043. */
  124044. getProjectionMatrix(): Matrix;
  124045. /**
  124046. * Gets the current transform matrix
  124047. * @returns a Matrix made of View * Projection
  124048. */
  124049. getTransformMatrix(): Matrix;
  124050. /**
  124051. * Sets the current transform matrix
  124052. * @param viewL defines the View matrix to use
  124053. * @param projectionL defines the Projection matrix to use
  124054. * @param viewR defines the right View matrix to use (if provided)
  124055. * @param projectionR defines the right Projection matrix to use (if provided)
  124056. */
  124057. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  124058. /**
  124059. * Gets the uniform buffer used to store scene data
  124060. * @returns a UniformBuffer
  124061. */
  124062. getSceneUniformBuffer(): UniformBuffer;
  124063. /**
  124064. * Gets an unique (relatively to the current scene) Id
  124065. * @returns an unique number for the scene
  124066. */
  124067. getUniqueId(): number;
  124068. /**
  124069. * Add a mesh to the list of scene's meshes
  124070. * @param newMesh defines the mesh to add
  124071. * @param recursive if all child meshes should also be added to the scene
  124072. */
  124073. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  124074. /**
  124075. * Remove a mesh for the list of scene's meshes
  124076. * @param toRemove defines the mesh to remove
  124077. * @param recursive if all child meshes should also be removed from the scene
  124078. * @returns the index where the mesh was in the mesh list
  124079. */
  124080. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  124081. /**
  124082. * Add a transform node to the list of scene's transform nodes
  124083. * @param newTransformNode defines the transform node to add
  124084. */
  124085. addTransformNode(newTransformNode: TransformNode): void;
  124086. /**
  124087. * Remove a transform node for the list of scene's transform nodes
  124088. * @param toRemove defines the transform node to remove
  124089. * @returns the index where the transform node was in the transform node list
  124090. */
  124091. removeTransformNode(toRemove: TransformNode): number;
  124092. /**
  124093. * Remove a skeleton for the list of scene's skeletons
  124094. * @param toRemove defines the skeleton to remove
  124095. * @returns the index where the skeleton was in the skeleton list
  124096. */
  124097. removeSkeleton(toRemove: Skeleton): number;
  124098. /**
  124099. * Remove a morph target for the list of scene's morph targets
  124100. * @param toRemove defines the morph target to remove
  124101. * @returns the index where the morph target was in the morph target list
  124102. */
  124103. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  124104. /**
  124105. * Remove a light for the list of scene's lights
  124106. * @param toRemove defines the light to remove
  124107. * @returns the index where the light was in the light list
  124108. */
  124109. removeLight(toRemove: Light): number;
  124110. /**
  124111. * Remove a camera for the list of scene's cameras
  124112. * @param toRemove defines the camera to remove
  124113. * @returns the index where the camera was in the camera list
  124114. */
  124115. removeCamera(toRemove: Camera): number;
  124116. /**
  124117. * Remove a particle system for the list of scene's particle systems
  124118. * @param toRemove defines the particle system to remove
  124119. * @returns the index where the particle system was in the particle system list
  124120. */
  124121. removeParticleSystem(toRemove: IParticleSystem): number;
  124122. /**
  124123. * Remove a animation for the list of scene's animations
  124124. * @param toRemove defines the animation to remove
  124125. * @returns the index where the animation was in the animation list
  124126. */
  124127. removeAnimation(toRemove: Animation): number;
  124128. /**
  124129. * Will stop the animation of the given target
  124130. * @param target - the target
  124131. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  124132. * @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)
  124133. */
  124134. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  124135. /**
  124136. * Removes the given animation group from this scene.
  124137. * @param toRemove The animation group to remove
  124138. * @returns The index of the removed animation group
  124139. */
  124140. removeAnimationGroup(toRemove: AnimationGroup): number;
  124141. /**
  124142. * Removes the given multi-material from this scene.
  124143. * @param toRemove The multi-material to remove
  124144. * @returns The index of the removed multi-material
  124145. */
  124146. removeMultiMaterial(toRemove: MultiMaterial): number;
  124147. /**
  124148. * Removes the given material from this scene.
  124149. * @param toRemove The material to remove
  124150. * @returns The index of the removed material
  124151. */
  124152. removeMaterial(toRemove: Material): number;
  124153. /**
  124154. * Removes the given action manager from this scene.
  124155. * @param toRemove The action manager to remove
  124156. * @returns The index of the removed action manager
  124157. */
  124158. removeActionManager(toRemove: AbstractActionManager): number;
  124159. /**
  124160. * Removes the given texture from this scene.
  124161. * @param toRemove The texture to remove
  124162. * @returns The index of the removed texture
  124163. */
  124164. removeTexture(toRemove: BaseTexture): number;
  124165. /**
  124166. * Adds the given light to this scene
  124167. * @param newLight The light to add
  124168. */
  124169. addLight(newLight: Light): void;
  124170. /**
  124171. * Sorts the list list based on light priorities
  124172. */
  124173. sortLightsByPriority(): void;
  124174. /**
  124175. * Adds the given camera to this scene
  124176. * @param newCamera The camera to add
  124177. */
  124178. addCamera(newCamera: Camera): void;
  124179. /**
  124180. * Adds the given skeleton to this scene
  124181. * @param newSkeleton The skeleton to add
  124182. */
  124183. addSkeleton(newSkeleton: Skeleton): void;
  124184. /**
  124185. * Adds the given particle system to this scene
  124186. * @param newParticleSystem The particle system to add
  124187. */
  124188. addParticleSystem(newParticleSystem: IParticleSystem): void;
  124189. /**
  124190. * Adds the given animation to this scene
  124191. * @param newAnimation The animation to add
  124192. */
  124193. addAnimation(newAnimation: Animation): void;
  124194. /**
  124195. * Adds the given animation group to this scene.
  124196. * @param newAnimationGroup The animation group to add
  124197. */
  124198. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  124199. /**
  124200. * Adds the given multi-material to this scene
  124201. * @param newMultiMaterial The multi-material to add
  124202. */
  124203. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  124204. /**
  124205. * Adds the given material to this scene
  124206. * @param newMaterial The material to add
  124207. */
  124208. addMaterial(newMaterial: Material): void;
  124209. /**
  124210. * Adds the given morph target to this scene
  124211. * @param newMorphTargetManager The morph target to add
  124212. */
  124213. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  124214. /**
  124215. * Adds the given geometry to this scene
  124216. * @param newGeometry The geometry to add
  124217. */
  124218. addGeometry(newGeometry: Geometry): void;
  124219. /**
  124220. * Adds the given action manager to this scene
  124221. * @param newActionManager The action manager to add
  124222. */
  124223. addActionManager(newActionManager: AbstractActionManager): void;
  124224. /**
  124225. * Adds the given texture to this scene.
  124226. * @param newTexture The texture to add
  124227. */
  124228. addTexture(newTexture: BaseTexture): void;
  124229. /**
  124230. * Switch active camera
  124231. * @param newCamera defines the new active camera
  124232. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  124233. */
  124234. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  124235. /**
  124236. * sets the active camera of the scene using its ID
  124237. * @param id defines the camera's ID
  124238. * @return the new active camera or null if none found.
  124239. */
  124240. setActiveCameraByID(id: string): Nullable<Camera>;
  124241. /**
  124242. * sets the active camera of the scene using its name
  124243. * @param name defines the camera's name
  124244. * @returns the new active camera or null if none found.
  124245. */
  124246. setActiveCameraByName(name: string): Nullable<Camera>;
  124247. /**
  124248. * get an animation group using its name
  124249. * @param name defines the material's name
  124250. * @return the animation group or null if none found.
  124251. */
  124252. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  124253. /**
  124254. * Get a material using its unique id
  124255. * @param uniqueId defines the material's unique id
  124256. * @return the material or null if none found.
  124257. */
  124258. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  124259. /**
  124260. * get a material using its id
  124261. * @param id defines the material's ID
  124262. * @return the material or null if none found.
  124263. */
  124264. getMaterialByID(id: string): Nullable<Material>;
  124265. /**
  124266. * Gets a the last added material using a given id
  124267. * @param id defines the material's ID
  124268. * @return the last material with the given id or null if none found.
  124269. */
  124270. getLastMaterialByID(id: string): Nullable<Material>;
  124271. /**
  124272. * Gets a material using its name
  124273. * @param name defines the material's name
  124274. * @return the material or null if none found.
  124275. */
  124276. getMaterialByName(name: string): Nullable<Material>;
  124277. /**
  124278. * Get a texture using its unique id
  124279. * @param uniqueId defines the texture's unique id
  124280. * @return the texture or null if none found.
  124281. */
  124282. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  124283. /**
  124284. * Gets a camera using its id
  124285. * @param id defines the id to look for
  124286. * @returns the camera or null if not found
  124287. */
  124288. getCameraByID(id: string): Nullable<Camera>;
  124289. /**
  124290. * Gets a camera using its unique id
  124291. * @param uniqueId defines the unique id to look for
  124292. * @returns the camera or null if not found
  124293. */
  124294. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  124295. /**
  124296. * Gets a camera using its name
  124297. * @param name defines the camera's name
  124298. * @return the camera or null if none found.
  124299. */
  124300. getCameraByName(name: string): Nullable<Camera>;
  124301. /**
  124302. * Gets a bone using its id
  124303. * @param id defines the bone's id
  124304. * @return the bone or null if not found
  124305. */
  124306. getBoneByID(id: string): Nullable<Bone>;
  124307. /**
  124308. * Gets a bone using its id
  124309. * @param name defines the bone's name
  124310. * @return the bone or null if not found
  124311. */
  124312. getBoneByName(name: string): Nullable<Bone>;
  124313. /**
  124314. * Gets a light node using its name
  124315. * @param name defines the the light's name
  124316. * @return the light or null if none found.
  124317. */
  124318. getLightByName(name: string): Nullable<Light>;
  124319. /**
  124320. * Gets a light node using its id
  124321. * @param id defines the light's id
  124322. * @return the light or null if none found.
  124323. */
  124324. getLightByID(id: string): Nullable<Light>;
  124325. /**
  124326. * Gets a light node using its scene-generated unique ID
  124327. * @param uniqueId defines the light's unique id
  124328. * @return the light or null if none found.
  124329. */
  124330. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  124331. /**
  124332. * Gets a particle system by id
  124333. * @param id defines the particle system id
  124334. * @return the corresponding system or null if none found
  124335. */
  124336. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  124337. /**
  124338. * Gets a geometry using its ID
  124339. * @param id defines the geometry's id
  124340. * @return the geometry or null if none found.
  124341. */
  124342. getGeometryByID(id: string): Nullable<Geometry>;
  124343. private _getGeometryByUniqueID;
  124344. /**
  124345. * Add a new geometry to this scene
  124346. * @param geometry defines the geometry to be added to the scene.
  124347. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  124348. * @return a boolean defining if the geometry was added or not
  124349. */
  124350. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  124351. /**
  124352. * Removes an existing geometry
  124353. * @param geometry defines the geometry to be removed from the scene
  124354. * @return a boolean defining if the geometry was removed or not
  124355. */
  124356. removeGeometry(geometry: Geometry): boolean;
  124357. /**
  124358. * Gets the list of geometries attached to the scene
  124359. * @returns an array of Geometry
  124360. */
  124361. getGeometries(): Geometry[];
  124362. /**
  124363. * Gets the first added mesh found of a given ID
  124364. * @param id defines the id to search for
  124365. * @return the mesh found or null if not found at all
  124366. */
  124367. getMeshByID(id: string): Nullable<AbstractMesh>;
  124368. /**
  124369. * Gets a list of meshes using their id
  124370. * @param id defines the id to search for
  124371. * @returns a list of meshes
  124372. */
  124373. getMeshesByID(id: string): Array<AbstractMesh>;
  124374. /**
  124375. * Gets the first added transform node found of a given ID
  124376. * @param id defines the id to search for
  124377. * @return the found transform node or null if not found at all.
  124378. */
  124379. getTransformNodeByID(id: string): Nullable<TransformNode>;
  124380. /**
  124381. * Gets a transform node with its auto-generated unique id
  124382. * @param uniqueId efines the unique id to search for
  124383. * @return the found transform node or null if not found at all.
  124384. */
  124385. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  124386. /**
  124387. * Gets a list of transform nodes using their id
  124388. * @param id defines the id to search for
  124389. * @returns a list of transform nodes
  124390. */
  124391. getTransformNodesByID(id: string): Array<TransformNode>;
  124392. /**
  124393. * Gets a mesh with its auto-generated unique id
  124394. * @param uniqueId defines the unique id to search for
  124395. * @return the found mesh or null if not found at all.
  124396. */
  124397. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  124398. /**
  124399. * Gets a the last added mesh using a given id
  124400. * @param id defines the id to search for
  124401. * @return the found mesh or null if not found at all.
  124402. */
  124403. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  124404. /**
  124405. * Gets a the last added node (Mesh, Camera, Light) using a given id
  124406. * @param id defines the id to search for
  124407. * @return the found node or null if not found at all
  124408. */
  124409. getLastEntryByID(id: string): Nullable<Node>;
  124410. /**
  124411. * Gets a node (Mesh, Camera, Light) using a given id
  124412. * @param id defines the id to search for
  124413. * @return the found node or null if not found at all
  124414. */
  124415. getNodeByID(id: string): Nullable<Node>;
  124416. /**
  124417. * Gets a node (Mesh, Camera, Light) using a given name
  124418. * @param name defines the name to search for
  124419. * @return the found node or null if not found at all.
  124420. */
  124421. getNodeByName(name: string): Nullable<Node>;
  124422. /**
  124423. * Gets a mesh using a given name
  124424. * @param name defines the name to search for
  124425. * @return the found mesh or null if not found at all.
  124426. */
  124427. getMeshByName(name: string): Nullable<AbstractMesh>;
  124428. /**
  124429. * Gets a transform node using a given name
  124430. * @param name defines the name to search for
  124431. * @return the found transform node or null if not found at all.
  124432. */
  124433. getTransformNodeByName(name: string): Nullable<TransformNode>;
  124434. /**
  124435. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  124436. * @param id defines the id to search for
  124437. * @return the found skeleton or null if not found at all.
  124438. */
  124439. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  124440. /**
  124441. * Gets a skeleton using a given auto generated unique id
  124442. * @param uniqueId defines the unique id to search for
  124443. * @return the found skeleton or null if not found at all.
  124444. */
  124445. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  124446. /**
  124447. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  124448. * @param id defines the id to search for
  124449. * @return the found skeleton or null if not found at all.
  124450. */
  124451. getSkeletonById(id: string): Nullable<Skeleton>;
  124452. /**
  124453. * Gets a skeleton using a given name
  124454. * @param name defines the name to search for
  124455. * @return the found skeleton or null if not found at all.
  124456. */
  124457. getSkeletonByName(name: string): Nullable<Skeleton>;
  124458. /**
  124459. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  124460. * @param id defines the id to search for
  124461. * @return the found morph target manager or null if not found at all.
  124462. */
  124463. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  124464. /**
  124465. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  124466. * @param id defines the id to search for
  124467. * @return the found morph target or null if not found at all.
  124468. */
  124469. getMorphTargetById(id: string): Nullable<MorphTarget>;
  124470. /**
  124471. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  124472. * @param name defines the name to search for
  124473. * @return the found morph target or null if not found at all.
  124474. */
  124475. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  124476. /**
  124477. * Gets a post process using a given name (if many are found, this function will pick the first one)
  124478. * @param name defines the name to search for
  124479. * @return the found post process or null if not found at all.
  124480. */
  124481. getPostProcessByName(name: string): Nullable<PostProcess>;
  124482. /**
  124483. * Gets a boolean indicating if the given mesh is active
  124484. * @param mesh defines the mesh to look for
  124485. * @returns true if the mesh is in the active list
  124486. */
  124487. isActiveMesh(mesh: AbstractMesh): boolean;
  124488. /**
  124489. * Return a unique id as a string which can serve as an identifier for the scene
  124490. */
  124491. get uid(): string;
  124492. /**
  124493. * Add an externaly attached data from its key.
  124494. * This method call will fail and return false, if such key already exists.
  124495. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  124496. * @param key the unique key that identifies the data
  124497. * @param data the data object to associate to the key for this Engine instance
  124498. * @return true if no such key were already present and the data was added successfully, false otherwise
  124499. */
  124500. addExternalData<T>(key: string, data: T): boolean;
  124501. /**
  124502. * Get an externaly attached data from its key
  124503. * @param key the unique key that identifies the data
  124504. * @return the associated data, if present (can be null), or undefined if not present
  124505. */
  124506. getExternalData<T>(key: string): Nullable<T>;
  124507. /**
  124508. * Get an externaly attached data from its key, create it using a factory if it's not already present
  124509. * @param key the unique key that identifies the data
  124510. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  124511. * @return the associated data, can be null if the factory returned null.
  124512. */
  124513. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  124514. /**
  124515. * Remove an externaly attached data from the Engine instance
  124516. * @param key the unique key that identifies the data
  124517. * @return true if the data was successfully removed, false if it doesn't exist
  124518. */
  124519. removeExternalData(key: string): boolean;
  124520. private _evaluateSubMesh;
  124521. /**
  124522. * Clear the processed materials smart array preventing retention point in material dispose.
  124523. */
  124524. freeProcessedMaterials(): void;
  124525. private _preventFreeActiveMeshesAndRenderingGroups;
  124526. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  124527. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  124528. * when disposing several meshes in a row or a hierarchy of meshes.
  124529. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  124530. */
  124531. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  124532. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  124533. /**
  124534. * Clear the active meshes smart array preventing retention point in mesh dispose.
  124535. */
  124536. freeActiveMeshes(): void;
  124537. /**
  124538. * Clear the info related to rendering groups preventing retention points during dispose.
  124539. */
  124540. freeRenderingGroups(): void;
  124541. /** @hidden */
  124542. _isInIntermediateRendering(): boolean;
  124543. /**
  124544. * Lambda returning the list of potentially active meshes.
  124545. */
  124546. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  124547. /**
  124548. * Lambda returning the list of potentially active sub meshes.
  124549. */
  124550. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  124551. /**
  124552. * Lambda returning the list of potentially intersecting sub meshes.
  124553. */
  124554. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  124555. /**
  124556. * Lambda returning the list of potentially colliding sub meshes.
  124557. */
  124558. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  124559. private _activeMeshesFrozen;
  124560. private _skipEvaluateActiveMeshesCompletely;
  124561. /**
  124562. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  124563. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  124564. * @param onSuccess optional success callback
  124565. * @param onError optional error callback
  124566. * @returns the current scene
  124567. */
  124568. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  124569. /**
  124570. * Use this function to restart evaluating active meshes on every frame
  124571. * @returns the current scene
  124572. */
  124573. unfreezeActiveMeshes(): Scene;
  124574. private _evaluateActiveMeshes;
  124575. private _activeMesh;
  124576. /**
  124577. * Update the transform matrix to update from the current active camera
  124578. * @param force defines a boolean used to force the update even if cache is up to date
  124579. */
  124580. updateTransformMatrix(force?: boolean): void;
  124581. private _bindFrameBuffer;
  124582. /** @hidden */
  124583. _allowPostProcessClearColor: boolean;
  124584. /** @hidden */
  124585. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  124586. private _processSubCameras;
  124587. private _checkIntersections;
  124588. /** @hidden */
  124589. _advancePhysicsEngineStep(step: number): void;
  124590. /**
  124591. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  124592. */
  124593. getDeterministicFrameTime: () => number;
  124594. /** @hidden */
  124595. _animate(): void;
  124596. /** Execute all animations (for a frame) */
  124597. animate(): void;
  124598. /**
  124599. * Render the scene
  124600. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  124601. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  124602. */
  124603. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  124604. /**
  124605. * Freeze all materials
  124606. * A frozen material will not be updatable but should be faster to render
  124607. */
  124608. freezeMaterials(): void;
  124609. /**
  124610. * Unfreeze all materials
  124611. * A frozen material will not be updatable but should be faster to render
  124612. */
  124613. unfreezeMaterials(): void;
  124614. /**
  124615. * Releases all held ressources
  124616. */
  124617. dispose(): void;
  124618. /**
  124619. * Gets if the scene is already disposed
  124620. */
  124621. get isDisposed(): boolean;
  124622. /**
  124623. * Call this function to reduce memory footprint of the scene.
  124624. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  124625. */
  124626. clearCachedVertexData(): void;
  124627. /**
  124628. * This function will remove the local cached buffer data from texture.
  124629. * It will save memory but will prevent the texture from being rebuilt
  124630. */
  124631. cleanCachedTextureBuffer(): void;
  124632. /**
  124633. * Get the world extend vectors with an optional filter
  124634. *
  124635. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  124636. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  124637. */
  124638. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  124639. min: Vector3;
  124640. max: Vector3;
  124641. };
  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 camera defines the camera to use for the picking
  124648. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124649. * @returns a Ray
  124650. */
  124651. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  124652. /**
  124653. * Creates a ray that can be used to pick in the scene
  124654. * @param x defines the x coordinate of the origin (on-screen)
  124655. * @param y defines the y coordinate of the origin (on-screen)
  124656. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  124657. * @param result defines the ray where to store the picking ray
  124658. * @param camera defines the camera to use for the picking
  124659. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124660. * @returns the current scene
  124661. */
  124662. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  124663. /**
  124664. * Creates a ray that can be used to pick in the scene
  124665. * @param x defines the x coordinate of the origin (on-screen)
  124666. * @param y defines the y coordinate of the origin (on-screen)
  124667. * @param camera defines the camera to use for the picking
  124668. * @returns a Ray
  124669. */
  124670. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  124671. /**
  124672. * Creates a ray that can be used to pick in the scene
  124673. * @param x defines the x coordinate of the origin (on-screen)
  124674. * @param y defines the y coordinate of the origin (on-screen)
  124675. * @param result defines the ray where to store the picking ray
  124676. * @param camera defines the camera to use for the picking
  124677. * @returns the current scene
  124678. */
  124679. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  124680. /** Launch a ray to try to pick a mesh in the scene
  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. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124687. * @returns a PickingInfo
  124688. */
  124689. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  124690. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  124691. * @param x position on screen
  124692. * @param y position on screen
  124693. * @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
  124694. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124695. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124696. * @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)
  124697. */
  124698. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  124699. /** Use the given ray to pick a mesh in the scene
  124700. * @param ray The ray to use to pick meshes
  124701. * @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
  124702. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124703. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124704. * @returns a PickingInfo
  124705. */
  124706. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  124707. /**
  124708. * Launch a ray to try to pick a mesh in the scene
  124709. * @param x X position on screen
  124710. * @param y Y position on screen
  124711. * @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
  124712. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124713. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124714. * @returns an array of PickingInfo
  124715. */
  124716. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  124717. /**
  124718. * Launch a ray to try to pick a mesh in the scene
  124719. * @param ray Ray to use
  124720. * @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
  124721. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124722. * @returns an array of PickingInfo
  124723. */
  124724. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  124725. /**
  124726. * Force the value of meshUnderPointer
  124727. * @param mesh defines the mesh to use
  124728. * @param pointerId optional pointer id when using more than one pointer
  124729. */
  124730. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  124731. /**
  124732. * Gets the mesh under the pointer
  124733. * @returns a Mesh or null if no mesh is under the pointer
  124734. */
  124735. getPointerOverMesh(): Nullable<AbstractMesh>;
  124736. /** @hidden */
  124737. _rebuildGeometries(): void;
  124738. /** @hidden */
  124739. _rebuildTextures(): void;
  124740. private _getByTags;
  124741. /**
  124742. * Get a list of meshes by tags
  124743. * @param tagsQuery defines the tags query to use
  124744. * @param forEach defines a predicate used to filter results
  124745. * @returns an array of Mesh
  124746. */
  124747. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  124748. /**
  124749. * Get a list of cameras by tags
  124750. * @param tagsQuery defines the tags query to use
  124751. * @param forEach defines a predicate used to filter results
  124752. * @returns an array of Camera
  124753. */
  124754. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  124755. /**
  124756. * Get a list of lights by tags
  124757. * @param tagsQuery defines the tags query to use
  124758. * @param forEach defines a predicate used to filter results
  124759. * @returns an array of Light
  124760. */
  124761. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  124762. /**
  124763. * Get a list of materials by tags
  124764. * @param tagsQuery defines the tags query to use
  124765. * @param forEach defines a predicate used to filter results
  124766. * @returns an array of Material
  124767. */
  124768. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  124769. /**
  124770. * Get a list of transform nodes by tags
  124771. * @param tagsQuery defines the tags query to use
  124772. * @param forEach defines a predicate used to filter results
  124773. * @returns an array of TransformNode
  124774. */
  124775. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  124776. /**
  124777. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  124778. * This allowed control for front to back rendering or reversly depending of the special needs.
  124779. *
  124780. * @param renderingGroupId The rendering group id corresponding to its index
  124781. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  124782. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  124783. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  124784. */
  124785. 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;
  124786. /**
  124787. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  124788. *
  124789. * @param renderingGroupId The rendering group id corresponding to its index
  124790. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  124791. * @param depth Automatically clears depth between groups if true and autoClear is true.
  124792. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  124793. */
  124794. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  124795. /**
  124796. * Gets the current auto clear configuration for one rendering group of the rendering
  124797. * manager.
  124798. * @param index the rendering group index to get the information for
  124799. * @returns The auto clear setup for the requested rendering group
  124800. */
  124801. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  124802. private _blockMaterialDirtyMechanism;
  124803. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  124804. get blockMaterialDirtyMechanism(): boolean;
  124805. set blockMaterialDirtyMechanism(value: boolean);
  124806. /**
  124807. * Will flag all materials as dirty to trigger new shader compilation
  124808. * @param flag defines the flag used to specify which material part must be marked as dirty
  124809. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  124810. */
  124811. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  124812. /** @hidden */
  124813. _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;
  124814. /** @hidden */
  124815. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  124816. /** @hidden */
  124817. _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;
  124818. /** @hidden */
  124819. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  124820. /** @hidden */
  124821. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  124822. /** @hidden */
  124823. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  124824. }
  124825. }
  124826. declare module BABYLON {
  124827. /**
  124828. * Set of assets to keep when moving a scene into an asset container.
  124829. */
  124830. export class KeepAssets extends AbstractScene {
  124831. }
  124832. /**
  124833. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  124834. */
  124835. export class InstantiatedEntries {
  124836. /**
  124837. * List of new root nodes (eg. nodes with no parent)
  124838. */
  124839. rootNodes: TransformNode[];
  124840. /**
  124841. * List of new skeletons
  124842. */
  124843. skeletons: Skeleton[];
  124844. /**
  124845. * List of new animation groups
  124846. */
  124847. animationGroups: AnimationGroup[];
  124848. }
  124849. /**
  124850. * Container with a set of assets that can be added or removed from a scene.
  124851. */
  124852. export class AssetContainer extends AbstractScene {
  124853. private _wasAddedToScene;
  124854. /**
  124855. * The scene the AssetContainer belongs to.
  124856. */
  124857. scene: Scene;
  124858. /**
  124859. * Instantiates an AssetContainer.
  124860. * @param scene The scene the AssetContainer belongs to.
  124861. */
  124862. constructor(scene: Scene);
  124863. /**
  124864. * Instantiate or clone all meshes and add the new ones to the scene.
  124865. * Skeletons and animation groups will all be cloned
  124866. * @param nameFunction defines an optional function used to get new names for clones
  124867. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  124868. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  124869. */
  124870. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  124871. /**
  124872. * Adds all the assets from the container to the scene.
  124873. */
  124874. addAllToScene(): void;
  124875. /**
  124876. * Removes all the assets in the container from the scene
  124877. */
  124878. removeAllFromScene(): void;
  124879. /**
  124880. * Disposes all the assets in the container
  124881. */
  124882. dispose(): void;
  124883. private _moveAssets;
  124884. /**
  124885. * Removes all the assets contained in the scene and adds them to the container.
  124886. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  124887. */
  124888. moveAllFromScene(keepAssets?: KeepAssets): void;
  124889. /**
  124890. * 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.
  124891. * @returns the root mesh
  124892. */
  124893. createRootMesh(): Mesh;
  124894. /**
  124895. * Merge animations (direct and animation groups) from this asset container into a scene
  124896. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124897. * @param animatables set of animatables to retarget to a node from the scene
  124898. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  124899. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  124900. */
  124901. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  124902. }
  124903. }
  124904. declare module BABYLON {
  124905. /**
  124906. * Defines how the parser contract is defined.
  124907. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  124908. */
  124909. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  124910. /**
  124911. * Defines how the individual parser contract is defined.
  124912. * These parser can parse an individual asset
  124913. */
  124914. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  124915. /**
  124916. * Base class of the scene acting as a container for the different elements composing a scene.
  124917. * This class is dynamically extended by the different components of the scene increasing
  124918. * flexibility and reducing coupling
  124919. */
  124920. export abstract class AbstractScene {
  124921. /**
  124922. * Stores the list of available parsers in the application.
  124923. */
  124924. private static _BabylonFileParsers;
  124925. /**
  124926. * Stores the list of available individual parsers in the application.
  124927. */
  124928. private static _IndividualBabylonFileParsers;
  124929. /**
  124930. * Adds a parser in the list of available ones
  124931. * @param name Defines the name of the parser
  124932. * @param parser Defines the parser to add
  124933. */
  124934. static AddParser(name: string, parser: BabylonFileParser): void;
  124935. /**
  124936. * Gets a general parser from the list of avaialble ones
  124937. * @param name Defines the name of the parser
  124938. * @returns the requested parser or null
  124939. */
  124940. static GetParser(name: string): Nullable<BabylonFileParser>;
  124941. /**
  124942. * Adds n individual parser in the list of available ones
  124943. * @param name Defines the name of the parser
  124944. * @param parser Defines the parser to add
  124945. */
  124946. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  124947. /**
  124948. * Gets an individual parser from the list of avaialble ones
  124949. * @param name Defines the name of the parser
  124950. * @returns the requested parser or null
  124951. */
  124952. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  124953. /**
  124954. * Parser json data and populate both a scene and its associated container object
  124955. * @param jsonData Defines the data to parse
  124956. * @param scene Defines the scene to parse the data for
  124957. * @param container Defines the container attached to the parsing sequence
  124958. * @param rootUrl Defines the root url of the data
  124959. */
  124960. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  124961. /**
  124962. * Gets the list of root nodes (ie. nodes with no parent)
  124963. */
  124964. rootNodes: Node[];
  124965. /** All of the cameras added to this scene
  124966. * @see https://doc.babylonjs.com/babylon101/cameras
  124967. */
  124968. cameras: Camera[];
  124969. /**
  124970. * All of the lights added to this scene
  124971. * @see https://doc.babylonjs.com/babylon101/lights
  124972. */
  124973. lights: Light[];
  124974. /**
  124975. * All of the (abstract) meshes added to this scene
  124976. */
  124977. meshes: AbstractMesh[];
  124978. /**
  124979. * The list of skeletons added to the scene
  124980. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  124981. */
  124982. skeletons: Skeleton[];
  124983. /**
  124984. * All of the particle systems added to this scene
  124985. * @see https://doc.babylonjs.com/babylon101/particles
  124986. */
  124987. particleSystems: IParticleSystem[];
  124988. /**
  124989. * Gets a list of Animations associated with the scene
  124990. */
  124991. animations: Animation[];
  124992. /**
  124993. * All of the animation groups added to this scene
  124994. * @see https://doc.babylonjs.com/how_to/group
  124995. */
  124996. animationGroups: AnimationGroup[];
  124997. /**
  124998. * All of the multi-materials added to this scene
  124999. * @see https://doc.babylonjs.com/how_to/multi_materials
  125000. */
  125001. multiMaterials: MultiMaterial[];
  125002. /**
  125003. * All of the materials added to this scene
  125004. * In the context of a Scene, it is not supposed to be modified manually.
  125005. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  125006. * Note also that the order of the Material within the array is not significant and might change.
  125007. * @see https://doc.babylonjs.com/babylon101/materials
  125008. */
  125009. materials: Material[];
  125010. /**
  125011. * The list of morph target managers added to the scene
  125012. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  125013. */
  125014. morphTargetManagers: MorphTargetManager[];
  125015. /**
  125016. * The list of geometries used in the scene.
  125017. */
  125018. geometries: Geometry[];
  125019. /**
  125020. * All of the tranform nodes added to this scene
  125021. * In the context of a Scene, it is not supposed to be modified manually.
  125022. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  125023. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  125024. * @see https://doc.babylonjs.com/how_to/transformnode
  125025. */
  125026. transformNodes: TransformNode[];
  125027. /**
  125028. * ActionManagers available on the scene.
  125029. */
  125030. actionManagers: AbstractActionManager[];
  125031. /**
  125032. * Textures to keep.
  125033. */
  125034. textures: BaseTexture[];
  125035. /** @hidden */
  125036. protected _environmentTexture: Nullable<BaseTexture>;
  125037. /**
  125038. * Texture used in all pbr material as the reflection texture.
  125039. * As in the majority of the scene they are the same (exception for multi room and so on),
  125040. * this is easier to reference from here than from all the materials.
  125041. */
  125042. get environmentTexture(): Nullable<BaseTexture>;
  125043. set environmentTexture(value: Nullable<BaseTexture>);
  125044. /**
  125045. * The list of postprocesses added to the scene
  125046. */
  125047. postProcesses: PostProcess[];
  125048. /**
  125049. * @returns all meshes, lights, cameras, transformNodes and bones
  125050. */
  125051. getNodes(): Array<Node>;
  125052. }
  125053. }
  125054. declare module BABYLON {
  125055. /**
  125056. * Interface used to define options for Sound class
  125057. */
  125058. export interface ISoundOptions {
  125059. /**
  125060. * Does the sound autoplay once loaded.
  125061. */
  125062. autoplay?: boolean;
  125063. /**
  125064. * Does the sound loop after it finishes playing once.
  125065. */
  125066. loop?: boolean;
  125067. /**
  125068. * Sound's volume
  125069. */
  125070. volume?: number;
  125071. /**
  125072. * Is it a spatial sound?
  125073. */
  125074. spatialSound?: boolean;
  125075. /**
  125076. * Maximum distance to hear that sound
  125077. */
  125078. maxDistance?: number;
  125079. /**
  125080. * Uses user defined attenuation function
  125081. */
  125082. useCustomAttenuation?: boolean;
  125083. /**
  125084. * Define the roll off factor of spatial sounds.
  125085. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125086. */
  125087. rolloffFactor?: number;
  125088. /**
  125089. * Define the reference distance the sound should be heard perfectly.
  125090. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125091. */
  125092. refDistance?: number;
  125093. /**
  125094. * Define the distance attenuation model the sound will follow.
  125095. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125096. */
  125097. distanceModel?: string;
  125098. /**
  125099. * Defines the playback speed (1 by default)
  125100. */
  125101. playbackRate?: number;
  125102. /**
  125103. * Defines if the sound is from a streaming source
  125104. */
  125105. streaming?: boolean;
  125106. /**
  125107. * Defines an optional length (in seconds) inside the sound file
  125108. */
  125109. length?: number;
  125110. /**
  125111. * Defines an optional offset (in seconds) inside the sound file
  125112. */
  125113. offset?: number;
  125114. /**
  125115. * If true, URLs will not be required to state the audio file codec to use.
  125116. */
  125117. skipCodecCheck?: boolean;
  125118. }
  125119. /**
  125120. * Defines a sound that can be played in the application.
  125121. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  125122. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125123. */
  125124. export class Sound {
  125125. /**
  125126. * The name of the sound in the scene.
  125127. */
  125128. name: string;
  125129. /**
  125130. * Does the sound autoplay once loaded.
  125131. */
  125132. autoplay: boolean;
  125133. /**
  125134. * Does the sound loop after it finishes playing once.
  125135. */
  125136. loop: boolean;
  125137. /**
  125138. * Does the sound use a custom attenuation curve to simulate the falloff
  125139. * happening when the source gets further away from the camera.
  125140. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125141. */
  125142. useCustomAttenuation: boolean;
  125143. /**
  125144. * The sound track id this sound belongs to.
  125145. */
  125146. soundTrackId: number;
  125147. /**
  125148. * Is this sound currently played.
  125149. */
  125150. isPlaying: boolean;
  125151. /**
  125152. * Is this sound currently paused.
  125153. */
  125154. isPaused: boolean;
  125155. /**
  125156. * Does this sound enables spatial sound.
  125157. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125158. */
  125159. spatialSound: boolean;
  125160. /**
  125161. * Define the reference distance the sound should be heard perfectly.
  125162. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125163. */
  125164. refDistance: number;
  125165. /**
  125166. * Define the roll off factor of spatial sounds.
  125167. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125168. */
  125169. rolloffFactor: number;
  125170. /**
  125171. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  125172. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125173. */
  125174. maxDistance: number;
  125175. /**
  125176. * Define the distance attenuation model the sound will follow.
  125177. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125178. */
  125179. distanceModel: string;
  125180. /**
  125181. * @hidden
  125182. * Back Compat
  125183. **/
  125184. onended: () => any;
  125185. /**
  125186. * Gets or sets an object used to store user defined information for the sound.
  125187. */
  125188. metadata: any;
  125189. /**
  125190. * Observable event when the current playing sound finishes.
  125191. */
  125192. onEndedObservable: Observable<Sound>;
  125193. private _panningModel;
  125194. private _playbackRate;
  125195. private _streaming;
  125196. private _startTime;
  125197. private _startOffset;
  125198. private _position;
  125199. /** @hidden */
  125200. _positionInEmitterSpace: boolean;
  125201. private _localDirection;
  125202. private _volume;
  125203. private _isReadyToPlay;
  125204. private _isDirectional;
  125205. private _readyToPlayCallback;
  125206. private _audioBuffer;
  125207. private _soundSource;
  125208. private _streamingSource;
  125209. private _soundPanner;
  125210. private _soundGain;
  125211. private _inputAudioNode;
  125212. private _outputAudioNode;
  125213. private _coneInnerAngle;
  125214. private _coneOuterAngle;
  125215. private _coneOuterGain;
  125216. private _scene;
  125217. private _connectedTransformNode;
  125218. private _customAttenuationFunction;
  125219. private _registerFunc;
  125220. private _isOutputConnected;
  125221. private _htmlAudioElement;
  125222. private _urlType;
  125223. private _length?;
  125224. private _offset?;
  125225. /** @hidden */
  125226. static _SceneComponentInitialization: (scene: Scene) => void;
  125227. /**
  125228. * Create a sound and attach it to a scene
  125229. * @param name Name of your sound
  125230. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  125231. * @param scene defines the scene the sound belongs to
  125232. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  125233. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  125234. */
  125235. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  125236. /**
  125237. * Release the sound and its associated resources
  125238. */
  125239. dispose(): void;
  125240. /**
  125241. * Gets if the sounds is ready to be played or not.
  125242. * @returns true if ready, otherwise false
  125243. */
  125244. isReady(): boolean;
  125245. private _soundLoaded;
  125246. /**
  125247. * Sets the data of the sound from an audiobuffer
  125248. * @param audioBuffer The audioBuffer containing the data
  125249. */
  125250. setAudioBuffer(audioBuffer: AudioBuffer): void;
  125251. /**
  125252. * Updates the current sounds options such as maxdistance, loop...
  125253. * @param options A JSON object containing values named as the object properties
  125254. */
  125255. updateOptions(options: ISoundOptions): void;
  125256. private _createSpatialParameters;
  125257. private _updateSpatialParameters;
  125258. /**
  125259. * Switch the panning model to HRTF:
  125260. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125261. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125262. */
  125263. switchPanningModelToHRTF(): void;
  125264. /**
  125265. * Switch the panning model to Equal Power:
  125266. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125267. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125268. */
  125269. switchPanningModelToEqualPower(): void;
  125270. private _switchPanningModel;
  125271. /**
  125272. * Connect this sound to a sound track audio node like gain...
  125273. * @param soundTrackAudioNode the sound track audio node to connect to
  125274. */
  125275. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  125276. /**
  125277. * Transform this sound into a directional source
  125278. * @param coneInnerAngle Size of the inner cone in degree
  125279. * @param coneOuterAngle Size of the outer cone in degree
  125280. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  125281. */
  125282. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  125283. /**
  125284. * Gets or sets the inner angle for the directional cone.
  125285. */
  125286. get directionalConeInnerAngle(): number;
  125287. /**
  125288. * Gets or sets the inner angle for the directional cone.
  125289. */
  125290. set directionalConeInnerAngle(value: number);
  125291. /**
  125292. * Gets or sets the outer angle for the directional cone.
  125293. */
  125294. get directionalConeOuterAngle(): number;
  125295. /**
  125296. * Gets or sets the outer angle for the directional cone.
  125297. */
  125298. set directionalConeOuterAngle(value: number);
  125299. /**
  125300. * Sets the position of the emitter if spatial sound is enabled
  125301. * @param newPosition Defines the new posisiton
  125302. */
  125303. setPosition(newPosition: Vector3): void;
  125304. /**
  125305. * Sets the local direction of the emitter if spatial sound is enabled
  125306. * @param newLocalDirection Defines the new local direction
  125307. */
  125308. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  125309. private _updateDirection;
  125310. /** @hidden */
  125311. updateDistanceFromListener(): void;
  125312. /**
  125313. * Sets a new custom attenuation function for the sound.
  125314. * @param callback Defines the function used for the attenuation
  125315. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125316. */
  125317. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  125318. /**
  125319. * Play the sound
  125320. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  125321. * @param offset (optional) Start the sound at a specific time in seconds
  125322. * @param length (optional) Sound duration (in seconds)
  125323. */
  125324. play(time?: number, offset?: number, length?: number): void;
  125325. private _onended;
  125326. /**
  125327. * Stop the sound
  125328. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  125329. */
  125330. stop(time?: number): void;
  125331. /**
  125332. * Put the sound in pause
  125333. */
  125334. pause(): void;
  125335. /**
  125336. * Sets a dedicated volume for this sounds
  125337. * @param newVolume Define the new volume of the sound
  125338. * @param time Define time for gradual change to new volume
  125339. */
  125340. setVolume(newVolume: number, time?: number): void;
  125341. /**
  125342. * Set the sound play back rate
  125343. * @param newPlaybackRate Define the playback rate the sound should be played at
  125344. */
  125345. setPlaybackRate(newPlaybackRate: number): void;
  125346. /**
  125347. * Gets the volume of the sound.
  125348. * @returns the volume of the sound
  125349. */
  125350. getVolume(): number;
  125351. /**
  125352. * Attach the sound to a dedicated mesh
  125353. * @param transformNode The transform node to connect the sound with
  125354. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125355. */
  125356. attachToMesh(transformNode: TransformNode): void;
  125357. /**
  125358. * Detach the sound from the previously attached mesh
  125359. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125360. */
  125361. detachFromMesh(): void;
  125362. private _onRegisterAfterWorldMatrixUpdate;
  125363. /**
  125364. * Clone the current sound in the scene.
  125365. * @returns the new sound clone
  125366. */
  125367. clone(): Nullable<Sound>;
  125368. /**
  125369. * Gets the current underlying audio buffer containing the data
  125370. * @returns the audio buffer
  125371. */
  125372. getAudioBuffer(): Nullable<AudioBuffer>;
  125373. /**
  125374. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  125375. * @returns the source node
  125376. */
  125377. getSoundSource(): Nullable<AudioBufferSourceNode>;
  125378. /**
  125379. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  125380. * @returns the gain node
  125381. */
  125382. getSoundGain(): Nullable<GainNode>;
  125383. /**
  125384. * Serializes the Sound in a JSON representation
  125385. * @returns the JSON representation of the sound
  125386. */
  125387. serialize(): any;
  125388. /**
  125389. * Parse a JSON representation of a sound to innstantiate in a given scene
  125390. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  125391. * @param scene Define the scene the new parsed sound should be created in
  125392. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  125393. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  125394. * @returns the newly parsed sound
  125395. */
  125396. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  125397. }
  125398. }
  125399. declare module BABYLON {
  125400. /**
  125401. * This defines an action helpful to play a defined sound on a triggered action.
  125402. */
  125403. export class PlaySoundAction extends Action {
  125404. private _sound;
  125405. /**
  125406. * Instantiate the action
  125407. * @param triggerOptions defines the trigger options
  125408. * @param sound defines the sound to play
  125409. * @param condition defines the trigger related conditions
  125410. */
  125411. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125412. /** @hidden */
  125413. _prepare(): void;
  125414. /**
  125415. * Execute the action and play the sound.
  125416. */
  125417. execute(): void;
  125418. /**
  125419. * Serializes the actions and its related information.
  125420. * @param parent defines the object to serialize in
  125421. * @returns the serialized object
  125422. */
  125423. serialize(parent: any): any;
  125424. }
  125425. /**
  125426. * This defines an action helpful to stop a defined sound on a triggered action.
  125427. */
  125428. export class StopSoundAction extends Action {
  125429. private _sound;
  125430. /**
  125431. * Instantiate the action
  125432. * @param triggerOptions defines the trigger options
  125433. * @param sound defines the sound to stop
  125434. * @param condition defines the trigger related conditions
  125435. */
  125436. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125437. /** @hidden */
  125438. _prepare(): void;
  125439. /**
  125440. * Execute the action and stop the sound.
  125441. */
  125442. execute(): void;
  125443. /**
  125444. * Serializes the actions and its related information.
  125445. * @param parent defines the object to serialize in
  125446. * @returns the serialized object
  125447. */
  125448. serialize(parent: any): any;
  125449. }
  125450. }
  125451. declare module BABYLON {
  125452. /**
  125453. * This defines an action responsible to change the value of a property
  125454. * by interpolating between its current value and the newly set one once triggered.
  125455. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  125456. */
  125457. export class InterpolateValueAction extends Action {
  125458. /**
  125459. * Defines the path of the property where the value should be interpolated
  125460. */
  125461. propertyPath: string;
  125462. /**
  125463. * Defines the target value at the end of the interpolation.
  125464. */
  125465. value: any;
  125466. /**
  125467. * Defines the time it will take for the property to interpolate to the value.
  125468. */
  125469. duration: number;
  125470. /**
  125471. * Defines if the other scene animations should be stopped when the action has been triggered
  125472. */
  125473. stopOtherAnimations?: boolean;
  125474. /**
  125475. * Defines a callback raised once the interpolation animation has been done.
  125476. */
  125477. onInterpolationDone?: () => void;
  125478. /**
  125479. * Observable triggered once the interpolation animation has been done.
  125480. */
  125481. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  125482. private _target;
  125483. private _effectiveTarget;
  125484. private _property;
  125485. /**
  125486. * Instantiate the action
  125487. * @param triggerOptions defines the trigger options
  125488. * @param target defines the object containing the value to interpolate
  125489. * @param propertyPath defines the path to the property in the target object
  125490. * @param value defines the target value at the end of the interpolation
  125491. * @param duration deines the time it will take for the property to interpolate to the value.
  125492. * @param condition defines the trigger related conditions
  125493. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  125494. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  125495. */
  125496. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  125497. /** @hidden */
  125498. _prepare(): void;
  125499. /**
  125500. * Execute the action starts the value interpolation.
  125501. */
  125502. execute(): void;
  125503. /**
  125504. * Serializes the actions and its related information.
  125505. * @param parent defines the object to serialize in
  125506. * @returns the serialized object
  125507. */
  125508. serialize(parent: any): any;
  125509. }
  125510. }
  125511. declare module BABYLON {
  125512. /**
  125513. * Options allowed during the creation of a sound track.
  125514. */
  125515. export interface ISoundTrackOptions {
  125516. /**
  125517. * The volume the sound track should take during creation
  125518. */
  125519. volume?: number;
  125520. /**
  125521. * Define if the sound track is the main sound track of the scene
  125522. */
  125523. mainTrack?: boolean;
  125524. }
  125525. /**
  125526. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  125527. * It will be also used in a future release to apply effects on a specific track.
  125528. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125529. */
  125530. export class SoundTrack {
  125531. /**
  125532. * The unique identifier of the sound track in the scene.
  125533. */
  125534. id: number;
  125535. /**
  125536. * The list of sounds included in the sound track.
  125537. */
  125538. soundCollection: Array<Sound>;
  125539. private _outputAudioNode;
  125540. private _scene;
  125541. private _connectedAnalyser;
  125542. private _options;
  125543. private _isInitialized;
  125544. /**
  125545. * Creates a new sound track.
  125546. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125547. * @param scene Define the scene the sound track belongs to
  125548. * @param options
  125549. */
  125550. constructor(scene: Scene, options?: ISoundTrackOptions);
  125551. private _initializeSoundTrackAudioGraph;
  125552. /**
  125553. * Release the sound track and its associated resources
  125554. */
  125555. dispose(): void;
  125556. /**
  125557. * Adds a sound to this sound track
  125558. * @param sound define the cound to add
  125559. * @ignoreNaming
  125560. */
  125561. AddSound(sound: Sound): void;
  125562. /**
  125563. * Removes a sound to this sound track
  125564. * @param sound define the cound to remove
  125565. * @ignoreNaming
  125566. */
  125567. RemoveSound(sound: Sound): void;
  125568. /**
  125569. * Set a global volume for the full sound track.
  125570. * @param newVolume Define the new volume of the sound track
  125571. */
  125572. setVolume(newVolume: number): void;
  125573. /**
  125574. * Switch the panning model to HRTF:
  125575. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125576. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125577. */
  125578. switchPanningModelToHRTF(): void;
  125579. /**
  125580. * Switch the panning model to Equal Power:
  125581. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125582. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125583. */
  125584. switchPanningModelToEqualPower(): void;
  125585. /**
  125586. * Connect the sound track to an audio analyser allowing some amazing
  125587. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  125588. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  125589. * @param analyser The analyser to connect to the engine
  125590. */
  125591. connectToAnalyser(analyser: Analyser): void;
  125592. }
  125593. }
  125594. declare module BABYLON {
  125595. interface AbstractScene {
  125596. /**
  125597. * The list of sounds used in the scene.
  125598. */
  125599. sounds: Nullable<Array<Sound>>;
  125600. }
  125601. interface Scene {
  125602. /**
  125603. * @hidden
  125604. * Backing field
  125605. */
  125606. _mainSoundTrack: SoundTrack;
  125607. /**
  125608. * The main sound track played by the scene.
  125609. * It cotains your primary collection of sounds.
  125610. */
  125611. mainSoundTrack: SoundTrack;
  125612. /**
  125613. * The list of sound tracks added to the scene
  125614. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125615. */
  125616. soundTracks: Nullable<Array<SoundTrack>>;
  125617. /**
  125618. * Gets a sound using a given name
  125619. * @param name defines the name to search for
  125620. * @return the found sound or null if not found at all.
  125621. */
  125622. getSoundByName(name: string): Nullable<Sound>;
  125623. /**
  125624. * Gets or sets if audio support is enabled
  125625. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125626. */
  125627. audioEnabled: boolean;
  125628. /**
  125629. * Gets or sets if audio will be output to headphones
  125630. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125631. */
  125632. headphone: boolean;
  125633. /**
  125634. * Gets or sets custom audio listener position provider
  125635. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125636. */
  125637. audioListenerPositionProvider: Nullable<() => Vector3>;
  125638. /**
  125639. * Gets or sets a refresh rate when using 3D audio positioning
  125640. */
  125641. audioPositioningRefreshRate: number;
  125642. }
  125643. /**
  125644. * Defines the sound scene component responsible to manage any sounds
  125645. * in a given scene.
  125646. */
  125647. export class AudioSceneComponent implements ISceneSerializableComponent {
  125648. private static _CameraDirectionLH;
  125649. private static _CameraDirectionRH;
  125650. /**
  125651. * The component name helpfull to identify the component in the list of scene components.
  125652. */
  125653. readonly name: string;
  125654. /**
  125655. * The scene the component belongs to.
  125656. */
  125657. scene: Scene;
  125658. private _audioEnabled;
  125659. /**
  125660. * Gets whether audio is enabled or not.
  125661. * Please use related enable/disable method to switch state.
  125662. */
  125663. get audioEnabled(): boolean;
  125664. private _headphone;
  125665. /**
  125666. * Gets whether audio is outputing to headphone or not.
  125667. * Please use the according Switch methods to change output.
  125668. */
  125669. get headphone(): boolean;
  125670. /**
  125671. * Gets or sets a refresh rate when using 3D audio positioning
  125672. */
  125673. audioPositioningRefreshRate: number;
  125674. private _audioListenerPositionProvider;
  125675. /**
  125676. * Gets the current audio listener position provider
  125677. */
  125678. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  125679. /**
  125680. * Sets a custom listener position for all sounds in the scene
  125681. * By default, this is the position of the first active camera
  125682. */
  125683. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  125684. /**
  125685. * Creates a new instance of the component for the given scene
  125686. * @param scene Defines the scene to register the component in
  125687. */
  125688. constructor(scene: Scene);
  125689. /**
  125690. * Registers the component in a given scene
  125691. */
  125692. register(): void;
  125693. /**
  125694. * Rebuilds the elements related to this component in case of
  125695. * context lost for instance.
  125696. */
  125697. rebuild(): void;
  125698. /**
  125699. * Serializes the component data to the specified json object
  125700. * @param serializationObject The object to serialize to
  125701. */
  125702. serialize(serializationObject: any): void;
  125703. /**
  125704. * Adds all the elements from the container to the scene
  125705. * @param container the container holding the elements
  125706. */
  125707. addFromContainer(container: AbstractScene): void;
  125708. /**
  125709. * Removes all the elements in the container from the scene
  125710. * @param container contains the elements to remove
  125711. * @param dispose if the removed element should be disposed (default: false)
  125712. */
  125713. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125714. /**
  125715. * Disposes the component and the associated ressources.
  125716. */
  125717. dispose(): void;
  125718. /**
  125719. * Disables audio in the associated scene.
  125720. */
  125721. disableAudio(): void;
  125722. /**
  125723. * Enables audio in the associated scene.
  125724. */
  125725. enableAudio(): void;
  125726. /**
  125727. * Switch audio to headphone output.
  125728. */
  125729. switchAudioModeForHeadphones(): void;
  125730. /**
  125731. * Switch audio to normal speakers.
  125732. */
  125733. switchAudioModeForNormalSpeakers(): void;
  125734. private _cachedCameraDirection;
  125735. private _cachedCameraPosition;
  125736. private _lastCheck;
  125737. private _afterRender;
  125738. }
  125739. }
  125740. declare module BABYLON {
  125741. /**
  125742. * Wraps one or more Sound objects and selects one with random weight for playback.
  125743. */
  125744. export class WeightedSound {
  125745. /** When true a Sound will be selected and played when the current playing Sound completes. */
  125746. loop: boolean;
  125747. private _coneInnerAngle;
  125748. private _coneOuterAngle;
  125749. private _volume;
  125750. /** A Sound is currently playing. */
  125751. isPlaying: boolean;
  125752. /** A Sound is currently paused. */
  125753. isPaused: boolean;
  125754. private _sounds;
  125755. private _weights;
  125756. private _currentIndex?;
  125757. /**
  125758. * Creates a new WeightedSound from the list of sounds given.
  125759. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  125760. * @param sounds Array of Sounds that will be selected from.
  125761. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  125762. */
  125763. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  125764. /**
  125765. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  125766. */
  125767. get directionalConeInnerAngle(): number;
  125768. /**
  125769. * The size of cone in degress for a directional sound in which there will be no attenuation.
  125770. */
  125771. set directionalConeInnerAngle(value: number);
  125772. /**
  125773. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  125774. * Listener angles between innerAngle and outerAngle will falloff linearly.
  125775. */
  125776. get directionalConeOuterAngle(): number;
  125777. /**
  125778. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  125779. * Listener angles between innerAngle and outerAngle will falloff linearly.
  125780. */
  125781. set directionalConeOuterAngle(value: number);
  125782. /**
  125783. * Playback volume.
  125784. */
  125785. get volume(): number;
  125786. /**
  125787. * Playback volume.
  125788. */
  125789. set volume(value: number);
  125790. private _onended;
  125791. /**
  125792. * Suspend playback
  125793. */
  125794. pause(): void;
  125795. /**
  125796. * Stop playback
  125797. */
  125798. stop(): void;
  125799. /**
  125800. * Start playback.
  125801. * @param startOffset Position the clip head at a specific time in seconds.
  125802. */
  125803. play(startOffset?: number): void;
  125804. }
  125805. }
  125806. declare module BABYLON {
  125807. /**
  125808. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  125809. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  125810. */
  125811. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  125812. /**
  125813. * Gets the name of the behavior.
  125814. */
  125815. get name(): string;
  125816. /**
  125817. * The easing function used by animations
  125818. */
  125819. static EasingFunction: BackEase;
  125820. /**
  125821. * The easing mode used by animations
  125822. */
  125823. static EasingMode: number;
  125824. /**
  125825. * The duration of the animation, in milliseconds
  125826. */
  125827. transitionDuration: number;
  125828. /**
  125829. * Length of the distance animated by the transition when lower radius is reached
  125830. */
  125831. lowerRadiusTransitionRange: number;
  125832. /**
  125833. * Length of the distance animated by the transition when upper radius is reached
  125834. */
  125835. upperRadiusTransitionRange: number;
  125836. private _autoTransitionRange;
  125837. /**
  125838. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  125839. */
  125840. get autoTransitionRange(): boolean;
  125841. /**
  125842. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  125843. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  125844. */
  125845. set autoTransitionRange(value: boolean);
  125846. private _attachedCamera;
  125847. private _onAfterCheckInputsObserver;
  125848. private _onMeshTargetChangedObserver;
  125849. /**
  125850. * Initializes the behavior.
  125851. */
  125852. init(): void;
  125853. /**
  125854. * Attaches the behavior to its arc rotate camera.
  125855. * @param camera Defines the camera to attach the behavior to
  125856. */
  125857. attach(camera: ArcRotateCamera): void;
  125858. /**
  125859. * Detaches the behavior from its current arc rotate camera.
  125860. */
  125861. detach(): void;
  125862. private _radiusIsAnimating;
  125863. private _radiusBounceTransition;
  125864. private _animatables;
  125865. private _cachedWheelPrecision;
  125866. /**
  125867. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  125868. * @param radiusLimit The limit to check against.
  125869. * @return Bool to indicate if at limit.
  125870. */
  125871. private _isRadiusAtLimit;
  125872. /**
  125873. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  125874. * @param radiusDelta The delta by which to animate to. Can be negative.
  125875. */
  125876. private _applyBoundRadiusAnimation;
  125877. /**
  125878. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  125879. */
  125880. protected _clearAnimationLocks(): void;
  125881. /**
  125882. * Stops and removes all animations that have been applied to the camera
  125883. */
  125884. stopAllAnimations(): void;
  125885. }
  125886. }
  125887. declare module BABYLON {
  125888. /**
  125889. * 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.
  125890. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  125891. */
  125892. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  125893. /**
  125894. * Gets the name of the behavior.
  125895. */
  125896. get name(): string;
  125897. private _mode;
  125898. private _radiusScale;
  125899. private _positionScale;
  125900. private _defaultElevation;
  125901. private _elevationReturnTime;
  125902. private _elevationReturnWaitTime;
  125903. private _zoomStopsAnimation;
  125904. private _framingTime;
  125905. /**
  125906. * The easing function used by animations
  125907. */
  125908. static EasingFunction: ExponentialEase;
  125909. /**
  125910. * The easing mode used by animations
  125911. */
  125912. static EasingMode: number;
  125913. /**
  125914. * Sets the current mode used by the behavior
  125915. */
  125916. set mode(mode: number);
  125917. /**
  125918. * Gets current mode used by the behavior.
  125919. */
  125920. get mode(): number;
  125921. /**
  125922. * Sets the scale applied to the radius (1 by default)
  125923. */
  125924. set radiusScale(radius: number);
  125925. /**
  125926. * Gets the scale applied to the radius
  125927. */
  125928. get radiusScale(): number;
  125929. /**
  125930. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  125931. */
  125932. set positionScale(scale: number);
  125933. /**
  125934. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  125935. */
  125936. get positionScale(): number;
  125937. /**
  125938. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  125939. * behaviour is triggered, in radians.
  125940. */
  125941. set defaultElevation(elevation: number);
  125942. /**
  125943. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  125944. * behaviour is triggered, in radians.
  125945. */
  125946. get defaultElevation(): number;
  125947. /**
  125948. * Sets the time (in milliseconds) taken to return to the default beta position.
  125949. * Negative value indicates camera should not return to default.
  125950. */
  125951. set elevationReturnTime(speed: number);
  125952. /**
  125953. * Gets the time (in milliseconds) taken to return to the default beta position.
  125954. * Negative value indicates camera should not return to default.
  125955. */
  125956. get elevationReturnTime(): number;
  125957. /**
  125958. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  125959. */
  125960. set elevationReturnWaitTime(time: number);
  125961. /**
  125962. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  125963. */
  125964. get elevationReturnWaitTime(): number;
  125965. /**
  125966. * Sets the flag that indicates if user zooming should stop animation.
  125967. */
  125968. set zoomStopsAnimation(flag: boolean);
  125969. /**
  125970. * Gets the flag that indicates if user zooming should stop animation.
  125971. */
  125972. get zoomStopsAnimation(): boolean;
  125973. /**
  125974. * Sets the transition time when framing the mesh, in milliseconds
  125975. */
  125976. set framingTime(time: number);
  125977. /**
  125978. * Gets the transition time when framing the mesh, in milliseconds
  125979. */
  125980. get framingTime(): number;
  125981. /**
  125982. * Define if the behavior should automatically change the configured
  125983. * camera limits and sensibilities.
  125984. */
  125985. autoCorrectCameraLimitsAndSensibility: boolean;
  125986. private _onPrePointerObservableObserver;
  125987. private _onAfterCheckInputsObserver;
  125988. private _onMeshTargetChangedObserver;
  125989. private _attachedCamera;
  125990. private _isPointerDown;
  125991. private _lastInteractionTime;
  125992. /**
  125993. * Initializes the behavior.
  125994. */
  125995. init(): void;
  125996. /**
  125997. * Attaches the behavior to its arc rotate camera.
  125998. * @param camera Defines the camera to attach the behavior to
  125999. */
  126000. attach(camera: ArcRotateCamera): void;
  126001. /**
  126002. * Detaches the behavior from its current arc rotate camera.
  126003. */
  126004. detach(): void;
  126005. private _animatables;
  126006. private _betaIsAnimating;
  126007. private _betaTransition;
  126008. private _radiusTransition;
  126009. private _vectorTransition;
  126010. /**
  126011. * Targets the given mesh and updates zoom level accordingly.
  126012. * @param mesh The mesh to target.
  126013. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126014. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126015. */
  126016. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126017. /**
  126018. * Targets the given mesh with its children and updates zoom level accordingly.
  126019. * @param mesh The mesh to target.
  126020. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126021. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126022. */
  126023. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126024. /**
  126025. * Targets the given meshes with their children and updates zoom level accordingly.
  126026. * @param meshes The mesh to target.
  126027. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126028. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126029. */
  126030. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126031. /**
  126032. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  126033. * @param minimumWorld Determines the smaller position of the bounding box extend
  126034. * @param maximumWorld Determines the bigger position of the bounding box extend
  126035. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126036. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126037. */
  126038. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126039. /**
  126040. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  126041. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  126042. * frustum width.
  126043. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  126044. * to fully enclose the mesh in the viewing frustum.
  126045. */
  126046. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  126047. /**
  126048. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  126049. * is automatically returned to its default position (expected to be above ground plane).
  126050. */
  126051. private _maintainCameraAboveGround;
  126052. /**
  126053. * Returns the frustum slope based on the canvas ratio and camera FOV
  126054. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  126055. */
  126056. private _getFrustumSlope;
  126057. /**
  126058. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  126059. */
  126060. private _clearAnimationLocks;
  126061. /**
  126062. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  126063. */
  126064. private _applyUserInteraction;
  126065. /**
  126066. * Stops and removes all animations that have been applied to the camera
  126067. */
  126068. stopAllAnimations(): void;
  126069. /**
  126070. * Gets a value indicating if the user is moving the camera
  126071. */
  126072. get isUserIsMoving(): boolean;
  126073. /**
  126074. * The camera can move all the way towards the mesh.
  126075. */
  126076. static IgnoreBoundsSizeMode: number;
  126077. /**
  126078. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  126079. */
  126080. static FitFrustumSidesMode: number;
  126081. }
  126082. }
  126083. declare module BABYLON {
  126084. /**
  126085. * Base class for Camera Pointer Inputs.
  126086. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  126087. * for example usage.
  126088. */
  126089. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  126090. /**
  126091. * Defines the camera the input is attached to.
  126092. */
  126093. abstract camera: Camera;
  126094. /**
  126095. * Whether keyboard modifier keys are pressed at time of last mouse event.
  126096. */
  126097. protected _altKey: boolean;
  126098. protected _ctrlKey: boolean;
  126099. protected _metaKey: boolean;
  126100. protected _shiftKey: boolean;
  126101. /**
  126102. * Which mouse buttons were pressed at time of last mouse event.
  126103. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  126104. */
  126105. protected _buttonsPressed: number;
  126106. /**
  126107. * Defines the buttons associated with the input to handle camera move.
  126108. */
  126109. buttons: number[];
  126110. /**
  126111. * Attach the input controls to a specific dom element to get the input from.
  126112. * @param element Defines the element the controls should be listened from
  126113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126114. */
  126115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126116. /**
  126117. * Detach the current controls from the specified dom element.
  126118. * @param element Defines the element to stop listening the inputs from
  126119. */
  126120. detachControl(element: Nullable<HTMLElement>): void;
  126121. /**
  126122. * Gets the class name of the current input.
  126123. * @returns the class name
  126124. */
  126125. getClassName(): string;
  126126. /**
  126127. * Get the friendly name associated with the input class.
  126128. * @returns the input friendly name
  126129. */
  126130. getSimpleName(): string;
  126131. /**
  126132. * Called on pointer POINTERDOUBLETAP event.
  126133. * Override this method to provide functionality on POINTERDOUBLETAP event.
  126134. */
  126135. protected onDoubleTap(type: string): void;
  126136. /**
  126137. * Called on pointer POINTERMOVE event if only a single touch is active.
  126138. * Override this method to provide functionality.
  126139. */
  126140. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126141. /**
  126142. * Called on pointer POINTERMOVE event if multiple touches are active.
  126143. * Override this method to provide functionality.
  126144. */
  126145. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126146. /**
  126147. * Called on JS contextmenu event.
  126148. * Override this method to provide functionality.
  126149. */
  126150. protected onContextMenu(evt: PointerEvent): void;
  126151. /**
  126152. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126153. * press.
  126154. * Override this method to provide functionality.
  126155. */
  126156. protected onButtonDown(evt: PointerEvent): void;
  126157. /**
  126158. * Called each time a new POINTERUP event occurs. Ie, for each button
  126159. * release.
  126160. * Override this method to provide functionality.
  126161. */
  126162. protected onButtonUp(evt: PointerEvent): void;
  126163. /**
  126164. * Called when window becomes inactive.
  126165. * Override this method to provide functionality.
  126166. */
  126167. protected onLostFocus(): void;
  126168. private _pointerInput;
  126169. private _observer;
  126170. private _onLostFocus;
  126171. private pointA;
  126172. private pointB;
  126173. }
  126174. }
  126175. declare module BABYLON {
  126176. /**
  126177. * Manage the pointers inputs to control an arc rotate camera.
  126178. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126179. */
  126180. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  126181. /**
  126182. * Defines the camera the input is attached to.
  126183. */
  126184. camera: ArcRotateCamera;
  126185. /**
  126186. * Gets the class name of the current input.
  126187. * @returns the class name
  126188. */
  126189. getClassName(): string;
  126190. /**
  126191. * Defines the buttons associated with the input to handle camera move.
  126192. */
  126193. buttons: number[];
  126194. /**
  126195. * Defines the pointer angular sensibility along the X axis or how fast is
  126196. * the camera rotating.
  126197. */
  126198. angularSensibilityX: number;
  126199. /**
  126200. * Defines the pointer angular sensibility along the Y axis or how fast is
  126201. * the camera rotating.
  126202. */
  126203. angularSensibilityY: number;
  126204. /**
  126205. * Defines the pointer pinch precision or how fast is the camera zooming.
  126206. */
  126207. pinchPrecision: number;
  126208. /**
  126209. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  126210. * from 0.
  126211. * It defines the percentage of current camera.radius to use as delta when
  126212. * pinch zoom is used.
  126213. */
  126214. pinchDeltaPercentage: number;
  126215. /**
  126216. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126217. * that any object in the plane at the camera's target point will scale
  126218. * perfectly with finger motion.
  126219. * Overrides pinchDeltaPercentage and pinchPrecision.
  126220. */
  126221. useNaturalPinchZoom: boolean;
  126222. /**
  126223. * Defines the pointer panning sensibility or how fast is the camera moving.
  126224. */
  126225. panningSensibility: number;
  126226. /**
  126227. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  126228. */
  126229. multiTouchPanning: boolean;
  126230. /**
  126231. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  126232. * zoom (pinch) through multitouch.
  126233. */
  126234. multiTouchPanAndZoom: boolean;
  126235. /**
  126236. * Revers pinch action direction.
  126237. */
  126238. pinchInwards: boolean;
  126239. private _isPanClick;
  126240. private _twoFingerActivityCount;
  126241. private _isPinching;
  126242. /**
  126243. * Called on pointer POINTERMOVE event if only a single touch is active.
  126244. */
  126245. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126246. /**
  126247. * Called on pointer POINTERDOUBLETAP event.
  126248. */
  126249. protected onDoubleTap(type: string): void;
  126250. /**
  126251. * Called on pointer POINTERMOVE event if multiple touches are active.
  126252. */
  126253. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126254. /**
  126255. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126256. * press.
  126257. */
  126258. protected onButtonDown(evt: PointerEvent): void;
  126259. /**
  126260. * Called each time a new POINTERUP event occurs. Ie, for each button
  126261. * release.
  126262. */
  126263. protected onButtonUp(evt: PointerEvent): void;
  126264. /**
  126265. * Called when window becomes inactive.
  126266. */
  126267. protected onLostFocus(): void;
  126268. }
  126269. }
  126270. declare module BABYLON {
  126271. /**
  126272. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  126273. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126274. */
  126275. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  126276. /**
  126277. * Defines the camera the input is attached to.
  126278. */
  126279. camera: ArcRotateCamera;
  126280. /**
  126281. * Defines the list of key codes associated with the up action (increase alpha)
  126282. */
  126283. keysUp: number[];
  126284. /**
  126285. * Defines the list of key codes associated with the down action (decrease alpha)
  126286. */
  126287. keysDown: number[];
  126288. /**
  126289. * Defines the list of key codes associated with the left action (increase beta)
  126290. */
  126291. keysLeft: number[];
  126292. /**
  126293. * Defines the list of key codes associated with the right action (decrease beta)
  126294. */
  126295. keysRight: number[];
  126296. /**
  126297. * Defines the list of key codes associated with the reset action.
  126298. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  126299. */
  126300. keysReset: number[];
  126301. /**
  126302. * Defines the panning sensibility of the inputs.
  126303. * (How fast is the camera panning)
  126304. */
  126305. panningSensibility: number;
  126306. /**
  126307. * Defines the zooming sensibility of the inputs.
  126308. * (How fast is the camera zooming)
  126309. */
  126310. zoomingSensibility: number;
  126311. /**
  126312. * Defines whether maintaining the alt key down switch the movement mode from
  126313. * orientation to zoom.
  126314. */
  126315. useAltToZoom: boolean;
  126316. /**
  126317. * Rotation speed of the camera
  126318. */
  126319. angularSpeed: number;
  126320. private _keys;
  126321. private _ctrlPressed;
  126322. private _altPressed;
  126323. private _onCanvasBlurObserver;
  126324. private _onKeyboardObserver;
  126325. private _engine;
  126326. private _scene;
  126327. /**
  126328. * Attach the input controls to a specific dom element to get the input from.
  126329. * @param element Defines the element the controls should be listened from
  126330. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126331. */
  126332. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126333. /**
  126334. * Detach the current controls from the specified dom element.
  126335. * @param element Defines the element to stop listening the inputs from
  126336. */
  126337. detachControl(element: Nullable<HTMLElement>): void;
  126338. /**
  126339. * Update the current camera state depending on the inputs that have been used this frame.
  126340. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  126341. */
  126342. checkInputs(): void;
  126343. /**
  126344. * Gets the class name of the current intput.
  126345. * @returns the class name
  126346. */
  126347. getClassName(): string;
  126348. /**
  126349. * Get the friendly name associated with the input class.
  126350. * @returns the input friendly name
  126351. */
  126352. getSimpleName(): string;
  126353. }
  126354. }
  126355. declare module BABYLON {
  126356. /**
  126357. * Manage the mouse wheel inputs to control an arc rotate camera.
  126358. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126359. */
  126360. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  126361. /**
  126362. * Defines the camera the input is attached to.
  126363. */
  126364. camera: ArcRotateCamera;
  126365. /**
  126366. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126367. */
  126368. wheelPrecision: number;
  126369. /**
  126370. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  126371. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  126372. */
  126373. wheelDeltaPercentage: number;
  126374. private _wheel;
  126375. private _observer;
  126376. private computeDeltaFromMouseWheelLegacyEvent;
  126377. /**
  126378. * Attach the input controls to a specific dom element to get the input from.
  126379. * @param element Defines the element the controls should be listened from
  126380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126381. */
  126382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126383. /**
  126384. * Detach the current controls from the specified dom element.
  126385. * @param element Defines the element to stop listening the inputs from
  126386. */
  126387. detachControl(element: Nullable<HTMLElement>): void;
  126388. /**
  126389. * Gets the class name of the current intput.
  126390. * @returns the class name
  126391. */
  126392. getClassName(): string;
  126393. /**
  126394. * Get the friendly name associated with the input class.
  126395. * @returns the input friendly name
  126396. */
  126397. getSimpleName(): string;
  126398. }
  126399. }
  126400. declare module BABYLON {
  126401. /**
  126402. * Default Inputs manager for the ArcRotateCamera.
  126403. * It groups all the default supported inputs for ease of use.
  126404. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126405. */
  126406. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  126407. /**
  126408. * Instantiates a new ArcRotateCameraInputsManager.
  126409. * @param camera Defines the camera the inputs belong to
  126410. */
  126411. constructor(camera: ArcRotateCamera);
  126412. /**
  126413. * Add mouse wheel input support to the input manager.
  126414. * @returns the current input manager
  126415. */
  126416. addMouseWheel(): ArcRotateCameraInputsManager;
  126417. /**
  126418. * Add pointers input support to the input manager.
  126419. * @returns the current input manager
  126420. */
  126421. addPointers(): ArcRotateCameraInputsManager;
  126422. /**
  126423. * Add keyboard input support to the input manager.
  126424. * @returns the current input manager
  126425. */
  126426. addKeyboard(): ArcRotateCameraInputsManager;
  126427. }
  126428. }
  126429. declare module BABYLON {
  126430. /**
  126431. * This represents an orbital type of camera.
  126432. *
  126433. * 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.
  126434. * 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.
  126435. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  126436. */
  126437. export class ArcRotateCamera extends TargetCamera {
  126438. /**
  126439. * Defines the rotation angle of the camera along the longitudinal axis.
  126440. */
  126441. alpha: number;
  126442. /**
  126443. * Defines the rotation angle of the camera along the latitudinal axis.
  126444. */
  126445. beta: number;
  126446. /**
  126447. * Defines the radius of the camera from it s target point.
  126448. */
  126449. radius: number;
  126450. protected _target: Vector3;
  126451. protected _targetHost: Nullable<AbstractMesh>;
  126452. /**
  126453. * Defines the target point of the camera.
  126454. * The camera looks towards it form the radius distance.
  126455. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  126456. */
  126457. get target(): Vector3;
  126458. set target(value: Vector3);
  126459. /**
  126460. * Define the current local position of the camera in the scene
  126461. */
  126462. get position(): Vector3;
  126463. set position(newPosition: Vector3);
  126464. protected _upToYMatrix: Matrix;
  126465. protected _YToUpMatrix: Matrix;
  126466. /**
  126467. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  126468. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  126469. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  126470. */
  126471. set upVector(vec: Vector3);
  126472. get upVector(): Vector3;
  126473. /**
  126474. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  126475. */
  126476. setMatUp(): void;
  126477. /**
  126478. * Current inertia value on the longitudinal axis.
  126479. * The bigger this number the longer it will take for the camera to stop.
  126480. */
  126481. inertialAlphaOffset: number;
  126482. /**
  126483. * Current inertia value on the latitudinal axis.
  126484. * The bigger this number the longer it will take for the camera to stop.
  126485. */
  126486. inertialBetaOffset: number;
  126487. /**
  126488. * Current inertia value on the radius axis.
  126489. * The bigger this number the longer it will take for the camera to stop.
  126490. */
  126491. inertialRadiusOffset: number;
  126492. /**
  126493. * Minimum allowed angle on the longitudinal axis.
  126494. * This can help limiting how the Camera is able to move in the scene.
  126495. */
  126496. lowerAlphaLimit: Nullable<number>;
  126497. /**
  126498. * Maximum allowed angle on the longitudinal axis.
  126499. * This can help limiting how the Camera is able to move in the scene.
  126500. */
  126501. upperAlphaLimit: Nullable<number>;
  126502. /**
  126503. * Minimum allowed angle on the latitudinal axis.
  126504. * This can help limiting how the Camera is able to move in the scene.
  126505. */
  126506. lowerBetaLimit: number;
  126507. /**
  126508. * Maximum allowed angle on the latitudinal axis.
  126509. * This can help limiting how the Camera is able to move in the scene.
  126510. */
  126511. upperBetaLimit: number;
  126512. /**
  126513. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  126514. * This can help limiting how the Camera is able to move in the scene.
  126515. */
  126516. lowerRadiusLimit: Nullable<number>;
  126517. /**
  126518. * Maximum allowed distance of the camera to the target (The camera can not get further).
  126519. * This can help limiting how the Camera is able to move in the scene.
  126520. */
  126521. upperRadiusLimit: Nullable<number>;
  126522. /**
  126523. * Defines the current inertia value used during panning of the camera along the X axis.
  126524. */
  126525. inertialPanningX: number;
  126526. /**
  126527. * Defines the current inertia value used during panning of the camera along the Y axis.
  126528. */
  126529. inertialPanningY: number;
  126530. /**
  126531. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  126532. * Basically if your fingers moves away from more than this distance you will be considered
  126533. * in pinch mode.
  126534. */
  126535. pinchToPanMaxDistance: number;
  126536. /**
  126537. * Defines the maximum distance the camera can pan.
  126538. * This could help keeping the cammera always in your scene.
  126539. */
  126540. panningDistanceLimit: Nullable<number>;
  126541. /**
  126542. * Defines the target of the camera before paning.
  126543. */
  126544. panningOriginTarget: Vector3;
  126545. /**
  126546. * Defines the value of the inertia used during panning.
  126547. * 0 would mean stop inertia and one would mean no decelleration at all.
  126548. */
  126549. panningInertia: number;
  126550. /**
  126551. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  126552. */
  126553. get angularSensibilityX(): number;
  126554. set angularSensibilityX(value: number);
  126555. /**
  126556. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  126557. */
  126558. get angularSensibilityY(): number;
  126559. set angularSensibilityY(value: number);
  126560. /**
  126561. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  126562. */
  126563. get pinchPrecision(): number;
  126564. set pinchPrecision(value: number);
  126565. /**
  126566. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  126567. * It will be used instead of pinchDeltaPrecision if different from 0.
  126568. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126569. */
  126570. get pinchDeltaPercentage(): number;
  126571. set pinchDeltaPercentage(value: number);
  126572. /**
  126573. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  126574. * and pinch delta percentage.
  126575. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126576. * that any object in the plane at the camera's target point will scale
  126577. * perfectly with finger motion.
  126578. */
  126579. get useNaturalPinchZoom(): boolean;
  126580. set useNaturalPinchZoom(value: boolean);
  126581. /**
  126582. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  126583. */
  126584. get panningSensibility(): number;
  126585. set panningSensibility(value: number);
  126586. /**
  126587. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  126588. */
  126589. get keysUp(): number[];
  126590. set keysUp(value: number[]);
  126591. /**
  126592. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  126593. */
  126594. get keysDown(): number[];
  126595. set keysDown(value: number[]);
  126596. /**
  126597. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  126598. */
  126599. get keysLeft(): number[];
  126600. set keysLeft(value: number[]);
  126601. /**
  126602. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  126603. */
  126604. get keysRight(): number[];
  126605. set keysRight(value: number[]);
  126606. /**
  126607. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126608. */
  126609. get wheelPrecision(): number;
  126610. set wheelPrecision(value: number);
  126611. /**
  126612. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  126613. * It will be used instead of pinchDeltaPrecision if different from 0.
  126614. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126615. */
  126616. get wheelDeltaPercentage(): number;
  126617. set wheelDeltaPercentage(value: number);
  126618. /**
  126619. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  126620. */
  126621. zoomOnFactor: number;
  126622. /**
  126623. * Defines a screen offset for the camera position.
  126624. */
  126625. targetScreenOffset: Vector2;
  126626. /**
  126627. * Allows the camera to be completely reversed.
  126628. * If false the camera can not arrive upside down.
  126629. */
  126630. allowUpsideDown: boolean;
  126631. /**
  126632. * Define if double tap/click is used to restore the previously saved state of the camera.
  126633. */
  126634. useInputToRestoreState: boolean;
  126635. /** @hidden */
  126636. _viewMatrix: Matrix;
  126637. /** @hidden */
  126638. _useCtrlForPanning: boolean;
  126639. /** @hidden */
  126640. _panningMouseButton: number;
  126641. /**
  126642. * Defines the input associated to the camera.
  126643. */
  126644. inputs: ArcRotateCameraInputsManager;
  126645. /** @hidden */
  126646. _reset: () => void;
  126647. /**
  126648. * Defines the allowed panning axis.
  126649. */
  126650. panningAxis: Vector3;
  126651. protected _localDirection: Vector3;
  126652. protected _transformedDirection: Vector3;
  126653. private _bouncingBehavior;
  126654. /**
  126655. * Gets the bouncing behavior of the camera if it has been enabled.
  126656. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126657. */
  126658. get bouncingBehavior(): Nullable<BouncingBehavior>;
  126659. /**
  126660. * Defines if the bouncing behavior of the camera is enabled on the camera.
  126661. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126662. */
  126663. get useBouncingBehavior(): boolean;
  126664. set useBouncingBehavior(value: boolean);
  126665. private _framingBehavior;
  126666. /**
  126667. * Gets the framing behavior of the camera if it has been enabled.
  126668. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126669. */
  126670. get framingBehavior(): Nullable<FramingBehavior>;
  126671. /**
  126672. * Defines if the framing behavior of the camera is enabled on the camera.
  126673. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126674. */
  126675. get useFramingBehavior(): boolean;
  126676. set useFramingBehavior(value: boolean);
  126677. private _autoRotationBehavior;
  126678. /**
  126679. * Gets the auto rotation behavior of the camera if it has been enabled.
  126680. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126681. */
  126682. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  126683. /**
  126684. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  126685. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126686. */
  126687. get useAutoRotationBehavior(): boolean;
  126688. set useAutoRotationBehavior(value: boolean);
  126689. /**
  126690. * Observable triggered when the mesh target has been changed on the camera.
  126691. */
  126692. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  126693. /**
  126694. * Event raised when the camera is colliding with a mesh.
  126695. */
  126696. onCollide: (collidedMesh: AbstractMesh) => void;
  126697. /**
  126698. * Defines whether the camera should check collision with the objects oh the scene.
  126699. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  126700. */
  126701. checkCollisions: boolean;
  126702. /**
  126703. * Defines the collision radius of the camera.
  126704. * This simulates a sphere around the camera.
  126705. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  126706. */
  126707. collisionRadius: Vector3;
  126708. protected _collider: Collider;
  126709. protected _previousPosition: Vector3;
  126710. protected _collisionVelocity: Vector3;
  126711. protected _newPosition: Vector3;
  126712. protected _previousAlpha: number;
  126713. protected _previousBeta: number;
  126714. protected _previousRadius: number;
  126715. protected _collisionTriggered: boolean;
  126716. protected _targetBoundingCenter: Nullable<Vector3>;
  126717. private _computationVector;
  126718. /**
  126719. * Instantiates a new ArcRotateCamera in a given scene
  126720. * @param name Defines the name of the camera
  126721. * @param alpha Defines the camera rotation along the logitudinal axis
  126722. * @param beta Defines the camera rotation along the latitudinal axis
  126723. * @param radius Defines the camera distance from its target
  126724. * @param target Defines the camera target
  126725. * @param scene Defines the scene the camera belongs to
  126726. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  126727. */
  126728. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  126729. /** @hidden */
  126730. _initCache(): void;
  126731. /** @hidden */
  126732. _updateCache(ignoreParentClass?: boolean): void;
  126733. protected _getTargetPosition(): Vector3;
  126734. private _storedAlpha;
  126735. private _storedBeta;
  126736. private _storedRadius;
  126737. private _storedTarget;
  126738. private _storedTargetScreenOffset;
  126739. /**
  126740. * Stores the current state of the camera (alpha, beta, radius and target)
  126741. * @returns the camera itself
  126742. */
  126743. storeState(): Camera;
  126744. /**
  126745. * @hidden
  126746. * Restored camera state. You must call storeState() first
  126747. */
  126748. _restoreStateValues(): boolean;
  126749. /** @hidden */
  126750. _isSynchronizedViewMatrix(): boolean;
  126751. /**
  126752. * Attached controls to the current camera.
  126753. * @param element Defines the element the controls should be listened from
  126754. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126755. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  126756. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  126757. */
  126758. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  126759. /**
  126760. * Detach the current controls from the camera.
  126761. * The camera will stop reacting to inputs.
  126762. * @param element Defines the element to stop listening the inputs from
  126763. */
  126764. detachControl(element: HTMLElement): void;
  126765. /** @hidden */
  126766. _checkInputs(): void;
  126767. protected _checkLimits(): void;
  126768. /**
  126769. * Rebuilds angles (alpha, beta) and radius from the give position and target
  126770. */
  126771. rebuildAnglesAndRadius(): void;
  126772. /**
  126773. * Use a position to define the current camera related information like alpha, beta and radius
  126774. * @param position Defines the position to set the camera at
  126775. */
  126776. setPosition(position: Vector3): void;
  126777. /**
  126778. * Defines the target the camera should look at.
  126779. * This will automatically adapt alpha beta and radius to fit within the new target.
  126780. * @param target Defines the new target as a Vector or a mesh
  126781. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  126782. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  126783. */
  126784. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  126785. /** @hidden */
  126786. _getViewMatrix(): Matrix;
  126787. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  126788. /**
  126789. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  126790. * @param meshes Defines the mesh to zoom on
  126791. * @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)
  126792. */
  126793. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  126794. /**
  126795. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  126796. * The target will be changed but the radius
  126797. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  126798. * @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)
  126799. */
  126800. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  126801. min: Vector3;
  126802. max: Vector3;
  126803. distance: number;
  126804. }, doNotUpdateMaxZ?: boolean): void;
  126805. /**
  126806. * @override
  126807. * Override Camera.createRigCamera
  126808. */
  126809. createRigCamera(name: string, cameraIndex: number): Camera;
  126810. /**
  126811. * @hidden
  126812. * @override
  126813. * Override Camera._updateRigCameras
  126814. */
  126815. _updateRigCameras(): void;
  126816. /**
  126817. * Destroy the camera and release the current resources hold by it.
  126818. */
  126819. dispose(): void;
  126820. /**
  126821. * Gets the current object class name.
  126822. * @return the class name
  126823. */
  126824. getClassName(): string;
  126825. }
  126826. }
  126827. declare module BABYLON {
  126828. /**
  126829. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  126830. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126831. */
  126832. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  126833. /**
  126834. * Gets the name of the behavior.
  126835. */
  126836. get name(): string;
  126837. private _zoomStopsAnimation;
  126838. private _idleRotationSpeed;
  126839. private _idleRotationWaitTime;
  126840. private _idleRotationSpinupTime;
  126841. /**
  126842. * Sets the flag that indicates if user zooming should stop animation.
  126843. */
  126844. set zoomStopsAnimation(flag: boolean);
  126845. /**
  126846. * Gets the flag that indicates if user zooming should stop animation.
  126847. */
  126848. get zoomStopsAnimation(): boolean;
  126849. /**
  126850. * Sets the default speed at which the camera rotates around the model.
  126851. */
  126852. set idleRotationSpeed(speed: number);
  126853. /**
  126854. * Gets the default speed at which the camera rotates around the model.
  126855. */
  126856. get idleRotationSpeed(): number;
  126857. /**
  126858. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  126859. */
  126860. set idleRotationWaitTime(time: number);
  126861. /**
  126862. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  126863. */
  126864. get idleRotationWaitTime(): number;
  126865. /**
  126866. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  126867. */
  126868. set idleRotationSpinupTime(time: number);
  126869. /**
  126870. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  126871. */
  126872. get idleRotationSpinupTime(): number;
  126873. /**
  126874. * Gets a value indicating if the camera is currently rotating because of this behavior
  126875. */
  126876. get rotationInProgress(): boolean;
  126877. private _onPrePointerObservableObserver;
  126878. private _onAfterCheckInputsObserver;
  126879. private _attachedCamera;
  126880. private _isPointerDown;
  126881. private _lastFrameTime;
  126882. private _lastInteractionTime;
  126883. private _cameraRotationSpeed;
  126884. /**
  126885. * Initializes the behavior.
  126886. */
  126887. init(): void;
  126888. /**
  126889. * Attaches the behavior to its arc rotate camera.
  126890. * @param camera Defines the camera to attach the behavior to
  126891. */
  126892. attach(camera: ArcRotateCamera): void;
  126893. /**
  126894. * Detaches the behavior from its current arc rotate camera.
  126895. */
  126896. detach(): void;
  126897. /**
  126898. * Returns true if user is scrolling.
  126899. * @return true if user is scrolling.
  126900. */
  126901. private _userIsZooming;
  126902. private _lastFrameRadius;
  126903. private _shouldAnimationStopForInteraction;
  126904. /**
  126905. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  126906. */
  126907. private _applyUserInteraction;
  126908. private _userIsMoving;
  126909. }
  126910. }
  126911. declare module BABYLON {
  126912. /**
  126913. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  126914. */
  126915. export class AttachToBoxBehavior implements Behavior<Mesh> {
  126916. private ui;
  126917. /**
  126918. * The name of the behavior
  126919. */
  126920. name: string;
  126921. /**
  126922. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  126923. */
  126924. distanceAwayFromFace: number;
  126925. /**
  126926. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  126927. */
  126928. distanceAwayFromBottomOfFace: number;
  126929. private _faceVectors;
  126930. private _target;
  126931. private _scene;
  126932. private _onRenderObserver;
  126933. private _tmpMatrix;
  126934. private _tmpVector;
  126935. /**
  126936. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  126937. * @param ui The transform node that should be attched to the mesh
  126938. */
  126939. constructor(ui: TransformNode);
  126940. /**
  126941. * Initializes the behavior
  126942. */
  126943. init(): void;
  126944. private _closestFace;
  126945. private _zeroVector;
  126946. private _lookAtTmpMatrix;
  126947. private _lookAtToRef;
  126948. /**
  126949. * Attaches the AttachToBoxBehavior to the passed in mesh
  126950. * @param target The mesh that the specified node will be attached to
  126951. */
  126952. attach(target: Mesh): void;
  126953. /**
  126954. * Detaches the behavior from the mesh
  126955. */
  126956. detach(): void;
  126957. }
  126958. }
  126959. declare module BABYLON {
  126960. /**
  126961. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  126962. */
  126963. export class FadeInOutBehavior implements Behavior<Mesh> {
  126964. /**
  126965. * Time in milliseconds to delay before fading in (Default: 0)
  126966. */
  126967. delay: number;
  126968. /**
  126969. * Time in milliseconds for the mesh to fade in (Default: 300)
  126970. */
  126971. fadeInTime: number;
  126972. private _millisecondsPerFrame;
  126973. private _hovered;
  126974. private _hoverValue;
  126975. private _ownerNode;
  126976. /**
  126977. * Instatiates the FadeInOutBehavior
  126978. */
  126979. constructor();
  126980. /**
  126981. * The name of the behavior
  126982. */
  126983. get name(): string;
  126984. /**
  126985. * Initializes the behavior
  126986. */
  126987. init(): void;
  126988. /**
  126989. * Attaches the fade behavior on the passed in mesh
  126990. * @param ownerNode The mesh that will be faded in/out once attached
  126991. */
  126992. attach(ownerNode: Mesh): void;
  126993. /**
  126994. * Detaches the behavior from the mesh
  126995. */
  126996. detach(): void;
  126997. /**
  126998. * Triggers the mesh to begin fading in or out
  126999. * @param value if the object should fade in or out (true to fade in)
  127000. */
  127001. fadeIn(value: boolean): void;
  127002. private _update;
  127003. private _setAllVisibility;
  127004. }
  127005. }
  127006. declare module BABYLON {
  127007. /**
  127008. * Class containing a set of static utilities functions for managing Pivots
  127009. * @hidden
  127010. */
  127011. export class PivotTools {
  127012. private static _PivotCached;
  127013. private static _OldPivotPoint;
  127014. private static _PivotTranslation;
  127015. private static _PivotTmpVector;
  127016. private static _PivotPostMultiplyPivotMatrix;
  127017. /** @hidden */
  127018. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  127019. /** @hidden */
  127020. static _RestorePivotPoint(mesh: AbstractMesh): void;
  127021. }
  127022. }
  127023. declare module BABYLON {
  127024. /**
  127025. * Class containing static functions to help procedurally build meshes
  127026. */
  127027. export class PlaneBuilder {
  127028. /**
  127029. * Creates a plane mesh
  127030. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127031. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127032. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127036. * @param name defines the name of the mesh
  127037. * @param options defines the options used to create the mesh
  127038. * @param scene defines the hosting scene
  127039. * @returns the plane mesh
  127040. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127041. */
  127042. static CreatePlane(name: string, options: {
  127043. size?: number;
  127044. width?: number;
  127045. height?: number;
  127046. sideOrientation?: number;
  127047. frontUVs?: Vector4;
  127048. backUVs?: Vector4;
  127049. updatable?: boolean;
  127050. sourcePlane?: Plane;
  127051. }, scene?: Nullable<Scene>): Mesh;
  127052. }
  127053. }
  127054. declare module BABYLON {
  127055. /**
  127056. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  127057. */
  127058. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  127059. private static _AnyMouseID;
  127060. /**
  127061. * Abstract mesh the behavior is set on
  127062. */
  127063. attachedNode: AbstractMesh;
  127064. private _dragPlane;
  127065. private _scene;
  127066. private _pointerObserver;
  127067. private _beforeRenderObserver;
  127068. private static _planeScene;
  127069. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  127070. /**
  127071. * 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)
  127072. */
  127073. maxDragAngle: number;
  127074. /**
  127075. * @hidden
  127076. */
  127077. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  127078. /**
  127079. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127080. */
  127081. currentDraggingPointerID: number;
  127082. /**
  127083. * The last position where the pointer hit the drag plane in world space
  127084. */
  127085. lastDragPosition: Vector3;
  127086. /**
  127087. * If the behavior is currently in a dragging state
  127088. */
  127089. dragging: boolean;
  127090. /**
  127091. * 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)
  127092. */
  127093. dragDeltaRatio: number;
  127094. /**
  127095. * If the drag plane orientation should be updated during the dragging (Default: true)
  127096. */
  127097. updateDragPlane: boolean;
  127098. private _debugMode;
  127099. private _moving;
  127100. /**
  127101. * Fires each time the attached mesh is dragged with the pointer
  127102. * * delta between last drag position and current drag position in world space
  127103. * * dragDistance along the drag axis
  127104. * * dragPlaneNormal normal of the current drag plane used during the drag
  127105. * * dragPlanePoint in world space where the drag intersects the drag plane
  127106. */
  127107. onDragObservable: Observable<{
  127108. delta: Vector3;
  127109. dragPlanePoint: Vector3;
  127110. dragPlaneNormal: Vector3;
  127111. dragDistance: number;
  127112. pointerId: number;
  127113. }>;
  127114. /**
  127115. * Fires each time a drag begins (eg. mouse down on mesh)
  127116. */
  127117. onDragStartObservable: Observable<{
  127118. dragPlanePoint: Vector3;
  127119. pointerId: number;
  127120. }>;
  127121. /**
  127122. * Fires each time a drag ends (eg. mouse release after drag)
  127123. */
  127124. onDragEndObservable: Observable<{
  127125. dragPlanePoint: Vector3;
  127126. pointerId: number;
  127127. }>;
  127128. /**
  127129. * If the attached mesh should be moved when dragged
  127130. */
  127131. moveAttached: boolean;
  127132. /**
  127133. * If the drag behavior will react to drag events (Default: true)
  127134. */
  127135. enabled: boolean;
  127136. /**
  127137. * If pointer events should start and release the drag (Default: true)
  127138. */
  127139. startAndReleaseDragOnPointerEvents: boolean;
  127140. /**
  127141. * If camera controls should be detached during the drag
  127142. */
  127143. detachCameraControls: boolean;
  127144. /**
  127145. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  127146. */
  127147. useObjectOrientationForDragging: boolean;
  127148. private _options;
  127149. /**
  127150. * Gets the options used by the behavior
  127151. */
  127152. get options(): {
  127153. dragAxis?: Vector3;
  127154. dragPlaneNormal?: Vector3;
  127155. };
  127156. /**
  127157. * Sets the options used by the behavior
  127158. */
  127159. set options(options: {
  127160. dragAxis?: Vector3;
  127161. dragPlaneNormal?: Vector3;
  127162. });
  127163. /**
  127164. * Creates a pointer drag behavior that can be attached to a mesh
  127165. * @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)
  127166. */
  127167. constructor(options?: {
  127168. dragAxis?: Vector3;
  127169. dragPlaneNormal?: Vector3;
  127170. });
  127171. /**
  127172. * Predicate to determine if it is valid to move the object to a new position when it is moved
  127173. */
  127174. validateDrag: (targetPosition: Vector3) => boolean;
  127175. /**
  127176. * The name of the behavior
  127177. */
  127178. get name(): string;
  127179. /**
  127180. * Initializes the behavior
  127181. */
  127182. init(): void;
  127183. private _tmpVector;
  127184. private _alternatePickedPoint;
  127185. private _worldDragAxis;
  127186. private _targetPosition;
  127187. private _attachedElement;
  127188. /**
  127189. * Attaches the drag behavior the passed in mesh
  127190. * @param ownerNode The mesh that will be dragged around once attached
  127191. * @param predicate Predicate to use for pick filtering
  127192. */
  127193. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  127194. /**
  127195. * Force relase the drag action by code.
  127196. */
  127197. releaseDrag(): void;
  127198. private _startDragRay;
  127199. private _lastPointerRay;
  127200. /**
  127201. * Simulates the start of a pointer drag event on the behavior
  127202. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  127203. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  127204. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  127205. */
  127206. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127207. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127208. private _dragDelta;
  127209. protected _moveDrag(ray: Ray): void;
  127210. private _pickWithRayOnDragPlane;
  127211. private _pointA;
  127212. private _pointC;
  127213. private _localAxis;
  127214. private _lookAt;
  127215. private _updateDragPlanePosition;
  127216. /**
  127217. * Detaches the behavior from the mesh
  127218. */
  127219. detach(): void;
  127220. }
  127221. }
  127222. declare module BABYLON {
  127223. /**
  127224. * A behavior that when attached to a mesh will allow the mesh to be scaled
  127225. */
  127226. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  127227. private _dragBehaviorA;
  127228. private _dragBehaviorB;
  127229. private _startDistance;
  127230. private _initialScale;
  127231. private _targetScale;
  127232. private _ownerNode;
  127233. private _sceneRenderObserver;
  127234. /**
  127235. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  127236. */
  127237. constructor();
  127238. /**
  127239. * The name of the behavior
  127240. */
  127241. get name(): string;
  127242. /**
  127243. * Initializes the behavior
  127244. */
  127245. init(): void;
  127246. private _getCurrentDistance;
  127247. /**
  127248. * Attaches the scale behavior the passed in mesh
  127249. * @param ownerNode The mesh that will be scaled around once attached
  127250. */
  127251. attach(ownerNode: Mesh): void;
  127252. /**
  127253. * Detaches the behavior from the mesh
  127254. */
  127255. detach(): void;
  127256. }
  127257. }
  127258. declare module BABYLON {
  127259. /**
  127260. * 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
  127261. */
  127262. export class SixDofDragBehavior implements Behavior<Mesh> {
  127263. private static _virtualScene;
  127264. private _ownerNode;
  127265. private _sceneRenderObserver;
  127266. private _scene;
  127267. private _targetPosition;
  127268. private _virtualOriginMesh;
  127269. private _virtualDragMesh;
  127270. private _pointerObserver;
  127271. private _moving;
  127272. private _startingOrientation;
  127273. private _attachedElement;
  127274. /**
  127275. * 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)
  127276. */
  127277. private zDragFactor;
  127278. /**
  127279. * If the object should rotate to face the drag origin
  127280. */
  127281. rotateDraggedObject: boolean;
  127282. /**
  127283. * If the behavior is currently in a dragging state
  127284. */
  127285. dragging: boolean;
  127286. /**
  127287. * 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)
  127288. */
  127289. dragDeltaRatio: number;
  127290. /**
  127291. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127292. */
  127293. currentDraggingPointerID: number;
  127294. /**
  127295. * If camera controls should be detached during the drag
  127296. */
  127297. detachCameraControls: boolean;
  127298. /**
  127299. * Fires each time a drag starts
  127300. */
  127301. onDragStartObservable: Observable<{}>;
  127302. /**
  127303. * Fires each time a drag ends (eg. mouse release after drag)
  127304. */
  127305. onDragEndObservable: Observable<{}>;
  127306. /**
  127307. * 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
  127308. */
  127309. constructor();
  127310. /**
  127311. * The name of the behavior
  127312. */
  127313. get name(): string;
  127314. /**
  127315. * Initializes the behavior
  127316. */
  127317. init(): void;
  127318. /**
  127319. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  127320. */
  127321. private get _pointerCamera();
  127322. /**
  127323. * Attaches the scale behavior the passed in mesh
  127324. * @param ownerNode The mesh that will be scaled around once attached
  127325. */
  127326. attach(ownerNode: Mesh): void;
  127327. /**
  127328. * Detaches the behavior from the mesh
  127329. */
  127330. detach(): void;
  127331. }
  127332. }
  127333. declare module BABYLON {
  127334. /**
  127335. * Class used to apply inverse kinematics to bones
  127336. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  127337. */
  127338. export class BoneIKController {
  127339. private static _tmpVecs;
  127340. private static _tmpQuat;
  127341. private static _tmpMats;
  127342. /**
  127343. * Gets or sets the target mesh
  127344. */
  127345. targetMesh: AbstractMesh;
  127346. /** Gets or sets the mesh used as pole */
  127347. poleTargetMesh: AbstractMesh;
  127348. /**
  127349. * Gets or sets the bone used as pole
  127350. */
  127351. poleTargetBone: Nullable<Bone>;
  127352. /**
  127353. * Gets or sets the target position
  127354. */
  127355. targetPosition: Vector3;
  127356. /**
  127357. * Gets or sets the pole target position
  127358. */
  127359. poleTargetPosition: Vector3;
  127360. /**
  127361. * Gets or sets the pole target local offset
  127362. */
  127363. poleTargetLocalOffset: Vector3;
  127364. /**
  127365. * Gets or sets the pole angle
  127366. */
  127367. poleAngle: number;
  127368. /**
  127369. * Gets or sets the mesh associated with the controller
  127370. */
  127371. mesh: AbstractMesh;
  127372. /**
  127373. * 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)
  127374. */
  127375. slerpAmount: number;
  127376. private _bone1Quat;
  127377. private _bone1Mat;
  127378. private _bone2Ang;
  127379. private _bone1;
  127380. private _bone2;
  127381. private _bone1Length;
  127382. private _bone2Length;
  127383. private _maxAngle;
  127384. private _maxReach;
  127385. private _rightHandedSystem;
  127386. private _bendAxis;
  127387. private _slerping;
  127388. private _adjustRoll;
  127389. /**
  127390. * Gets or sets maximum allowed angle
  127391. */
  127392. get maxAngle(): number;
  127393. set maxAngle(value: number);
  127394. /**
  127395. * Creates a new BoneIKController
  127396. * @param mesh defines the mesh to control
  127397. * @param bone defines the bone to control
  127398. * @param options defines options to set up the controller
  127399. */
  127400. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  127401. targetMesh?: AbstractMesh;
  127402. poleTargetMesh?: AbstractMesh;
  127403. poleTargetBone?: Bone;
  127404. poleTargetLocalOffset?: Vector3;
  127405. poleAngle?: number;
  127406. bendAxis?: Vector3;
  127407. maxAngle?: number;
  127408. slerpAmount?: number;
  127409. });
  127410. private _setMaxAngle;
  127411. /**
  127412. * Force the controller to update the bones
  127413. */
  127414. update(): void;
  127415. }
  127416. }
  127417. declare module BABYLON {
  127418. /**
  127419. * Class used to make a bone look toward a point in space
  127420. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  127421. */
  127422. export class BoneLookController {
  127423. private static _tmpVecs;
  127424. private static _tmpQuat;
  127425. private static _tmpMats;
  127426. /**
  127427. * The target Vector3 that the bone will look at
  127428. */
  127429. target: Vector3;
  127430. /**
  127431. * The mesh that the bone is attached to
  127432. */
  127433. mesh: AbstractMesh;
  127434. /**
  127435. * The bone that will be looking to the target
  127436. */
  127437. bone: Bone;
  127438. /**
  127439. * The up axis of the coordinate system that is used when the bone is rotated
  127440. */
  127441. upAxis: Vector3;
  127442. /**
  127443. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  127444. */
  127445. upAxisSpace: Space;
  127446. /**
  127447. * Used to make an adjustment to the yaw of the bone
  127448. */
  127449. adjustYaw: number;
  127450. /**
  127451. * Used to make an adjustment to the pitch of the bone
  127452. */
  127453. adjustPitch: number;
  127454. /**
  127455. * Used to make an adjustment to the roll of the bone
  127456. */
  127457. adjustRoll: number;
  127458. /**
  127459. * 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)
  127460. */
  127461. slerpAmount: number;
  127462. private _minYaw;
  127463. private _maxYaw;
  127464. private _minPitch;
  127465. private _maxPitch;
  127466. private _minYawSin;
  127467. private _minYawCos;
  127468. private _maxYawSin;
  127469. private _maxYawCos;
  127470. private _midYawConstraint;
  127471. private _minPitchTan;
  127472. private _maxPitchTan;
  127473. private _boneQuat;
  127474. private _slerping;
  127475. private _transformYawPitch;
  127476. private _transformYawPitchInv;
  127477. private _firstFrameSkipped;
  127478. private _yawRange;
  127479. private _fowardAxis;
  127480. /**
  127481. * Gets or sets the minimum yaw angle that the bone can look to
  127482. */
  127483. get minYaw(): number;
  127484. set minYaw(value: number);
  127485. /**
  127486. * Gets or sets the maximum yaw angle that the bone can look to
  127487. */
  127488. get maxYaw(): number;
  127489. set maxYaw(value: number);
  127490. /**
  127491. * Gets or sets the minimum pitch angle that the bone can look to
  127492. */
  127493. get minPitch(): number;
  127494. set minPitch(value: number);
  127495. /**
  127496. * Gets or sets the maximum pitch angle that the bone can look to
  127497. */
  127498. get maxPitch(): number;
  127499. set maxPitch(value: number);
  127500. /**
  127501. * Create a BoneLookController
  127502. * @param mesh the mesh that the bone belongs to
  127503. * @param bone the bone that will be looking to the target
  127504. * @param target the target Vector3 to look at
  127505. * @param options optional settings:
  127506. * * maxYaw: the maximum angle the bone will yaw to
  127507. * * minYaw: the minimum angle the bone will yaw to
  127508. * * maxPitch: the maximum angle the bone will pitch to
  127509. * * minPitch: the minimum angle the bone will yaw to
  127510. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  127511. * * upAxis: the up axis of the coordinate system
  127512. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  127513. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  127514. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  127515. * * adjustYaw: used to make an adjustment to the yaw of the bone
  127516. * * adjustPitch: used to make an adjustment to the pitch of the bone
  127517. * * adjustRoll: used to make an adjustment to the roll of the bone
  127518. **/
  127519. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  127520. maxYaw?: number;
  127521. minYaw?: number;
  127522. maxPitch?: number;
  127523. minPitch?: number;
  127524. slerpAmount?: number;
  127525. upAxis?: Vector3;
  127526. upAxisSpace?: Space;
  127527. yawAxis?: Vector3;
  127528. pitchAxis?: Vector3;
  127529. adjustYaw?: number;
  127530. adjustPitch?: number;
  127531. adjustRoll?: number;
  127532. });
  127533. /**
  127534. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  127535. */
  127536. update(): void;
  127537. private _getAngleDiff;
  127538. private _getAngleBetween;
  127539. private _isAngleBetween;
  127540. }
  127541. }
  127542. declare module BABYLON {
  127543. /**
  127544. * Manage the gamepad inputs to control an arc rotate camera.
  127545. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127546. */
  127547. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  127548. /**
  127549. * Defines the camera the input is attached to.
  127550. */
  127551. camera: ArcRotateCamera;
  127552. /**
  127553. * Defines the gamepad the input is gathering event from.
  127554. */
  127555. gamepad: Nullable<Gamepad>;
  127556. /**
  127557. * Defines the gamepad rotation sensiblity.
  127558. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  127559. */
  127560. gamepadRotationSensibility: number;
  127561. /**
  127562. * Defines the gamepad move sensiblity.
  127563. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  127564. */
  127565. gamepadMoveSensibility: number;
  127566. private _yAxisScale;
  127567. /**
  127568. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  127569. */
  127570. get invertYAxis(): boolean;
  127571. set invertYAxis(value: boolean);
  127572. private _onGamepadConnectedObserver;
  127573. private _onGamepadDisconnectedObserver;
  127574. /**
  127575. * Attach the input controls to a specific dom element to get the input from.
  127576. * @param element Defines the element the controls should be listened from
  127577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127578. */
  127579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127580. /**
  127581. * Detach the current controls from the specified dom element.
  127582. * @param element Defines the element to stop listening the inputs from
  127583. */
  127584. detachControl(element: Nullable<HTMLElement>): void;
  127585. /**
  127586. * Update the current camera state depending on the inputs that have been used this frame.
  127587. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127588. */
  127589. checkInputs(): void;
  127590. /**
  127591. * Gets the class name of the current intput.
  127592. * @returns the class name
  127593. */
  127594. getClassName(): string;
  127595. /**
  127596. * Get the friendly name associated with the input class.
  127597. * @returns the input friendly name
  127598. */
  127599. getSimpleName(): string;
  127600. }
  127601. }
  127602. declare module BABYLON {
  127603. interface ArcRotateCameraInputsManager {
  127604. /**
  127605. * Add orientation input support to the input manager.
  127606. * @returns the current input manager
  127607. */
  127608. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  127609. }
  127610. /**
  127611. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  127612. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127613. */
  127614. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  127615. /**
  127616. * Defines the camera the input is attached to.
  127617. */
  127618. camera: ArcRotateCamera;
  127619. /**
  127620. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  127621. */
  127622. alphaCorrection: number;
  127623. /**
  127624. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  127625. */
  127626. gammaCorrection: number;
  127627. private _alpha;
  127628. private _gamma;
  127629. private _dirty;
  127630. private _deviceOrientationHandler;
  127631. /**
  127632. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  127633. */
  127634. constructor();
  127635. /**
  127636. * Attach the input controls to a specific dom element to get the input from.
  127637. * @param element Defines the element the controls should be listened from
  127638. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127639. */
  127640. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127641. /** @hidden */
  127642. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  127643. /**
  127644. * Update the current camera state depending on the inputs that have been used this frame.
  127645. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127646. */
  127647. checkInputs(): void;
  127648. /**
  127649. * Detach the current controls from the specified dom element.
  127650. * @param element Defines the element to stop listening the inputs from
  127651. */
  127652. detachControl(element: Nullable<HTMLElement>): void;
  127653. /**
  127654. * Gets the class name of the current intput.
  127655. * @returns the class name
  127656. */
  127657. getClassName(): string;
  127658. /**
  127659. * Get the friendly name associated with the input class.
  127660. * @returns the input friendly name
  127661. */
  127662. getSimpleName(): string;
  127663. }
  127664. }
  127665. declare module BABYLON {
  127666. /**
  127667. * Listen to mouse events to control the camera.
  127668. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127669. */
  127670. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  127671. /**
  127672. * Defines the camera the input is attached to.
  127673. */
  127674. camera: FlyCamera;
  127675. /**
  127676. * Defines if touch is enabled. (Default is true.)
  127677. */
  127678. touchEnabled: boolean;
  127679. /**
  127680. * Defines the buttons associated with the input to handle camera rotation.
  127681. */
  127682. buttons: number[];
  127683. /**
  127684. * Assign buttons for Yaw control.
  127685. */
  127686. buttonsYaw: number[];
  127687. /**
  127688. * Assign buttons for Pitch control.
  127689. */
  127690. buttonsPitch: number[];
  127691. /**
  127692. * Assign buttons for Roll control.
  127693. */
  127694. buttonsRoll: number[];
  127695. /**
  127696. * Detect if any button is being pressed while mouse is moved.
  127697. * -1 = Mouse locked.
  127698. * 0 = Left button.
  127699. * 1 = Middle Button.
  127700. * 2 = Right Button.
  127701. */
  127702. activeButton: number;
  127703. /**
  127704. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  127705. * Higher values reduce its sensitivity.
  127706. */
  127707. angularSensibility: number;
  127708. private _observer;
  127709. private _rollObserver;
  127710. private previousPosition;
  127711. private noPreventDefault;
  127712. private element;
  127713. /**
  127714. * Listen to mouse events to control the camera.
  127715. * @param touchEnabled Define if touch is enabled. (Default is true.)
  127716. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127717. */
  127718. constructor(touchEnabled?: boolean);
  127719. /**
  127720. * Attach the mouse control to the HTML DOM element.
  127721. * @param element Defines the element that listens to the input events.
  127722. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  127723. */
  127724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127725. /**
  127726. * Detach the current controls from the specified dom element.
  127727. * @param element Defines the element to stop listening the inputs from
  127728. */
  127729. detachControl(element: Nullable<HTMLElement>): void;
  127730. /**
  127731. * Gets the class name of the current input.
  127732. * @returns the class name.
  127733. */
  127734. getClassName(): string;
  127735. /**
  127736. * Get the friendly name associated with the input class.
  127737. * @returns the input's friendly name.
  127738. */
  127739. getSimpleName(): string;
  127740. private _pointerInput;
  127741. private _onMouseMove;
  127742. /**
  127743. * Rotate camera by mouse offset.
  127744. */
  127745. private rotateCamera;
  127746. }
  127747. }
  127748. declare module BABYLON {
  127749. /**
  127750. * Default Inputs manager for the FlyCamera.
  127751. * It groups all the default supported inputs for ease of use.
  127752. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127753. */
  127754. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  127755. /**
  127756. * Instantiates a new FlyCameraInputsManager.
  127757. * @param camera Defines the camera the inputs belong to.
  127758. */
  127759. constructor(camera: FlyCamera);
  127760. /**
  127761. * Add keyboard input support to the input manager.
  127762. * @returns the new FlyCameraKeyboardMoveInput().
  127763. */
  127764. addKeyboard(): FlyCameraInputsManager;
  127765. /**
  127766. * Add mouse input support to the input manager.
  127767. * @param touchEnabled Enable touch screen support.
  127768. * @returns the new FlyCameraMouseInput().
  127769. */
  127770. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  127771. }
  127772. }
  127773. declare module BABYLON {
  127774. /**
  127775. * This is a flying camera, designed for 3D movement and rotation in all directions,
  127776. * such as in a 3D Space Shooter or a Flight Simulator.
  127777. */
  127778. export class FlyCamera extends TargetCamera {
  127779. /**
  127780. * Define the collision ellipsoid of the camera.
  127781. * This is helpful for simulating a camera body, like a player's body.
  127782. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  127783. */
  127784. ellipsoid: Vector3;
  127785. /**
  127786. * Define an offset for the position of the ellipsoid around the camera.
  127787. * This can be helpful if the camera is attached away from the player's body center,
  127788. * such as at its head.
  127789. */
  127790. ellipsoidOffset: Vector3;
  127791. /**
  127792. * Enable or disable collisions of the camera with the rest of the scene objects.
  127793. */
  127794. checkCollisions: boolean;
  127795. /**
  127796. * Enable or disable gravity on the camera.
  127797. */
  127798. applyGravity: boolean;
  127799. /**
  127800. * Define the current direction the camera is moving to.
  127801. */
  127802. cameraDirection: Vector3;
  127803. /**
  127804. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  127805. * This overrides and empties cameraRotation.
  127806. */
  127807. rotationQuaternion: Quaternion;
  127808. /**
  127809. * Track Roll to maintain the wanted Rolling when looking around.
  127810. */
  127811. _trackRoll: number;
  127812. /**
  127813. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  127814. */
  127815. rollCorrect: number;
  127816. /**
  127817. * Mimic a banked turn, Rolling the camera when Yawing.
  127818. * It's recommended to use rollCorrect = 10 for faster banking correction.
  127819. */
  127820. bankedTurn: boolean;
  127821. /**
  127822. * Limit in radians for how much Roll banking will add. (Default: 90°)
  127823. */
  127824. bankedTurnLimit: number;
  127825. /**
  127826. * Value of 0 disables the banked Roll.
  127827. * Value of 1 is equal to the Yaw angle in radians.
  127828. */
  127829. bankedTurnMultiplier: number;
  127830. /**
  127831. * The inputs manager loads all the input sources, such as keyboard and mouse.
  127832. */
  127833. inputs: FlyCameraInputsManager;
  127834. /**
  127835. * Gets the input sensibility for mouse input.
  127836. * Higher values reduce sensitivity.
  127837. */
  127838. get angularSensibility(): number;
  127839. /**
  127840. * Sets the input sensibility for a mouse input.
  127841. * Higher values reduce sensitivity.
  127842. */
  127843. set angularSensibility(value: number);
  127844. /**
  127845. * Get the keys for camera movement forward.
  127846. */
  127847. get keysForward(): number[];
  127848. /**
  127849. * Set the keys for camera movement forward.
  127850. */
  127851. set keysForward(value: number[]);
  127852. /**
  127853. * Get the keys for camera movement backward.
  127854. */
  127855. get keysBackward(): number[];
  127856. set keysBackward(value: number[]);
  127857. /**
  127858. * Get the keys for camera movement up.
  127859. */
  127860. get keysUp(): number[];
  127861. /**
  127862. * Set the keys for camera movement up.
  127863. */
  127864. set keysUp(value: number[]);
  127865. /**
  127866. * Get the keys for camera movement down.
  127867. */
  127868. get keysDown(): number[];
  127869. /**
  127870. * Set the keys for camera movement down.
  127871. */
  127872. set keysDown(value: number[]);
  127873. /**
  127874. * Get the keys for camera movement left.
  127875. */
  127876. get keysLeft(): number[];
  127877. /**
  127878. * Set the keys for camera movement left.
  127879. */
  127880. set keysLeft(value: number[]);
  127881. /**
  127882. * Set the keys for camera movement right.
  127883. */
  127884. get keysRight(): number[];
  127885. /**
  127886. * Set the keys for camera movement right.
  127887. */
  127888. set keysRight(value: number[]);
  127889. /**
  127890. * Event raised when the camera collides with a mesh in the scene.
  127891. */
  127892. onCollide: (collidedMesh: AbstractMesh) => void;
  127893. private _collider;
  127894. private _needMoveForGravity;
  127895. private _oldPosition;
  127896. private _diffPosition;
  127897. private _newPosition;
  127898. /** @hidden */
  127899. _localDirection: Vector3;
  127900. /** @hidden */
  127901. _transformedDirection: Vector3;
  127902. /**
  127903. * Instantiates a FlyCamera.
  127904. * This is a flying camera, designed for 3D movement and rotation in all directions,
  127905. * such as in a 3D Space Shooter or a Flight Simulator.
  127906. * @param name Define the name of the camera in the scene.
  127907. * @param position Define the starting position of the camera in the scene.
  127908. * @param scene Define the scene the camera belongs to.
  127909. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  127910. */
  127911. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  127912. /**
  127913. * Attach a control to the HTML DOM element.
  127914. * @param element Defines the element that listens to the input events.
  127915. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  127916. */
  127917. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127918. /**
  127919. * Detach a control from the HTML DOM element.
  127920. * The camera will stop reacting to that input.
  127921. * @param element Defines the element that listens to the input events.
  127922. */
  127923. detachControl(element: HTMLElement): void;
  127924. private _collisionMask;
  127925. /**
  127926. * Get the mask that the camera ignores in collision events.
  127927. */
  127928. get collisionMask(): number;
  127929. /**
  127930. * Set the mask that the camera ignores in collision events.
  127931. */
  127932. set collisionMask(mask: number);
  127933. /** @hidden */
  127934. _collideWithWorld(displacement: Vector3): void;
  127935. /** @hidden */
  127936. private _onCollisionPositionChange;
  127937. /** @hidden */
  127938. _checkInputs(): void;
  127939. /** @hidden */
  127940. _decideIfNeedsToMove(): boolean;
  127941. /** @hidden */
  127942. _updatePosition(): void;
  127943. /**
  127944. * Restore the Roll to its target value at the rate specified.
  127945. * @param rate - Higher means slower restoring.
  127946. * @hidden
  127947. */
  127948. restoreRoll(rate: number): void;
  127949. /**
  127950. * Destroy the camera and release the current resources held by it.
  127951. */
  127952. dispose(): void;
  127953. /**
  127954. * Get the current object class name.
  127955. * @returns the class name.
  127956. */
  127957. getClassName(): string;
  127958. }
  127959. }
  127960. declare module BABYLON {
  127961. /**
  127962. * Listen to keyboard events to control the camera.
  127963. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127964. */
  127965. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  127966. /**
  127967. * Defines the camera the input is attached to.
  127968. */
  127969. camera: FlyCamera;
  127970. /**
  127971. * The list of keyboard keys used to control the forward move of the camera.
  127972. */
  127973. keysForward: number[];
  127974. /**
  127975. * The list of keyboard keys used to control the backward move of the camera.
  127976. */
  127977. keysBackward: number[];
  127978. /**
  127979. * The list of keyboard keys used to control the forward move of the camera.
  127980. */
  127981. keysUp: number[];
  127982. /**
  127983. * The list of keyboard keys used to control the backward move of the camera.
  127984. */
  127985. keysDown: number[];
  127986. /**
  127987. * The list of keyboard keys used to control the right strafe move of the camera.
  127988. */
  127989. keysRight: number[];
  127990. /**
  127991. * The list of keyboard keys used to control the left strafe move of the camera.
  127992. */
  127993. keysLeft: number[];
  127994. private _keys;
  127995. private _onCanvasBlurObserver;
  127996. private _onKeyboardObserver;
  127997. private _engine;
  127998. private _scene;
  127999. /**
  128000. * Attach the input controls to a specific dom element to get the input from.
  128001. * @param element Defines the element the controls should be listened from
  128002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128003. */
  128004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128005. /**
  128006. * Detach the current controls from the specified dom element.
  128007. * @param element Defines the element to stop listening the inputs from
  128008. */
  128009. detachControl(element: Nullable<HTMLElement>): void;
  128010. /**
  128011. * Gets the class name of the current intput.
  128012. * @returns the class name
  128013. */
  128014. getClassName(): string;
  128015. /** @hidden */
  128016. _onLostFocus(e: FocusEvent): void;
  128017. /**
  128018. * Get the friendly name associated with the input class.
  128019. * @returns the input friendly name
  128020. */
  128021. getSimpleName(): string;
  128022. /**
  128023. * Update the current camera state depending on the inputs that have been used this frame.
  128024. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128025. */
  128026. checkInputs(): void;
  128027. }
  128028. }
  128029. declare module BABYLON {
  128030. /**
  128031. * Manage the mouse wheel inputs to control a follow camera.
  128032. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128033. */
  128034. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  128035. /**
  128036. * Defines the camera the input is attached to.
  128037. */
  128038. camera: FollowCamera;
  128039. /**
  128040. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  128041. */
  128042. axisControlRadius: boolean;
  128043. /**
  128044. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  128045. */
  128046. axisControlHeight: boolean;
  128047. /**
  128048. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  128049. */
  128050. axisControlRotation: boolean;
  128051. /**
  128052. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  128053. * relation to mouseWheel events.
  128054. */
  128055. wheelPrecision: number;
  128056. /**
  128057. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  128058. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  128059. */
  128060. wheelDeltaPercentage: number;
  128061. private _wheel;
  128062. private _observer;
  128063. /**
  128064. * Attach the input controls to a specific dom element to get the input from.
  128065. * @param element Defines the element the controls should be listened from
  128066. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128067. */
  128068. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128069. /**
  128070. * Detach the current controls from the specified dom element.
  128071. * @param element Defines the element to stop listening the inputs from
  128072. */
  128073. detachControl(element: Nullable<HTMLElement>): void;
  128074. /**
  128075. * Gets the class name of the current intput.
  128076. * @returns the class name
  128077. */
  128078. getClassName(): string;
  128079. /**
  128080. * Get the friendly name associated with the input class.
  128081. * @returns the input friendly name
  128082. */
  128083. getSimpleName(): string;
  128084. }
  128085. }
  128086. declare module BABYLON {
  128087. /**
  128088. * Manage the pointers inputs to control an follow camera.
  128089. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128090. */
  128091. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  128092. /**
  128093. * Defines the camera the input is attached to.
  128094. */
  128095. camera: FollowCamera;
  128096. /**
  128097. * Gets the class name of the current input.
  128098. * @returns the class name
  128099. */
  128100. getClassName(): string;
  128101. /**
  128102. * Defines the pointer angular sensibility along the X axis or how fast is
  128103. * the camera rotating.
  128104. * A negative number will reverse the axis direction.
  128105. */
  128106. angularSensibilityX: number;
  128107. /**
  128108. * Defines the pointer angular sensibility along the Y axis or how fast is
  128109. * the camera rotating.
  128110. * A negative number will reverse the axis direction.
  128111. */
  128112. angularSensibilityY: number;
  128113. /**
  128114. * Defines the pointer pinch precision or how fast is the camera zooming.
  128115. * A negative number will reverse the axis direction.
  128116. */
  128117. pinchPrecision: number;
  128118. /**
  128119. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  128120. * from 0.
  128121. * It defines the percentage of current camera.radius to use as delta when
  128122. * pinch zoom is used.
  128123. */
  128124. pinchDeltaPercentage: number;
  128125. /**
  128126. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  128127. */
  128128. axisXControlRadius: boolean;
  128129. /**
  128130. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  128131. */
  128132. axisXControlHeight: boolean;
  128133. /**
  128134. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  128135. */
  128136. axisXControlRotation: boolean;
  128137. /**
  128138. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  128139. */
  128140. axisYControlRadius: boolean;
  128141. /**
  128142. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  128143. */
  128144. axisYControlHeight: boolean;
  128145. /**
  128146. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  128147. */
  128148. axisYControlRotation: boolean;
  128149. /**
  128150. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  128151. */
  128152. axisPinchControlRadius: boolean;
  128153. /**
  128154. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  128155. */
  128156. axisPinchControlHeight: boolean;
  128157. /**
  128158. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  128159. */
  128160. axisPinchControlRotation: boolean;
  128161. /**
  128162. * Log error messages if basic misconfiguration has occurred.
  128163. */
  128164. warningEnable: boolean;
  128165. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  128166. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  128167. private _warningCounter;
  128168. private _warning;
  128169. }
  128170. }
  128171. declare module BABYLON {
  128172. /**
  128173. * Default Inputs manager for the FollowCamera.
  128174. * It groups all the default supported inputs for ease of use.
  128175. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128176. */
  128177. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  128178. /**
  128179. * Instantiates a new FollowCameraInputsManager.
  128180. * @param camera Defines the camera the inputs belong to
  128181. */
  128182. constructor(camera: FollowCamera);
  128183. /**
  128184. * Add keyboard input support to the input manager.
  128185. * @returns the current input manager
  128186. */
  128187. addKeyboard(): FollowCameraInputsManager;
  128188. /**
  128189. * Add mouse wheel input support to the input manager.
  128190. * @returns the current input manager
  128191. */
  128192. addMouseWheel(): FollowCameraInputsManager;
  128193. /**
  128194. * Add pointers input support to the input manager.
  128195. * @returns the current input manager
  128196. */
  128197. addPointers(): FollowCameraInputsManager;
  128198. /**
  128199. * Add orientation input support to the input manager.
  128200. * @returns the current input manager
  128201. */
  128202. addVRDeviceOrientation(): FollowCameraInputsManager;
  128203. }
  128204. }
  128205. declare module BABYLON {
  128206. /**
  128207. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  128208. * an arc rotate version arcFollowCamera are available.
  128209. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128210. */
  128211. export class FollowCamera extends TargetCamera {
  128212. /**
  128213. * Distance the follow camera should follow an object at
  128214. */
  128215. radius: number;
  128216. /**
  128217. * Minimum allowed distance of the camera to the axis of rotation
  128218. * (The camera can not get closer).
  128219. * This can help limiting how the Camera is able to move in the scene.
  128220. */
  128221. lowerRadiusLimit: Nullable<number>;
  128222. /**
  128223. * Maximum allowed distance of the camera to the axis of rotation
  128224. * (The camera can not get further).
  128225. * This can help limiting how the Camera is able to move in the scene.
  128226. */
  128227. upperRadiusLimit: Nullable<number>;
  128228. /**
  128229. * Define a rotation offset between the camera and the object it follows
  128230. */
  128231. rotationOffset: number;
  128232. /**
  128233. * Minimum allowed angle to camera position relative to target object.
  128234. * This can help limiting how the Camera is able to move in the scene.
  128235. */
  128236. lowerRotationOffsetLimit: Nullable<number>;
  128237. /**
  128238. * Maximum allowed angle to camera position relative to target object.
  128239. * This can help limiting how the Camera is able to move in the scene.
  128240. */
  128241. upperRotationOffsetLimit: Nullable<number>;
  128242. /**
  128243. * Define a height offset between the camera and the object it follows.
  128244. * It can help following an object from the top (like a car chaing a plane)
  128245. */
  128246. heightOffset: number;
  128247. /**
  128248. * Minimum allowed height of camera position relative to target object.
  128249. * This can help limiting how the Camera is able to move in the scene.
  128250. */
  128251. lowerHeightOffsetLimit: Nullable<number>;
  128252. /**
  128253. * Maximum allowed height of camera position relative to target object.
  128254. * This can help limiting how the Camera is able to move in the scene.
  128255. */
  128256. upperHeightOffsetLimit: Nullable<number>;
  128257. /**
  128258. * Define how fast the camera can accelerate to follow it s target.
  128259. */
  128260. cameraAcceleration: number;
  128261. /**
  128262. * Define the speed limit of the camera following an object.
  128263. */
  128264. maxCameraSpeed: number;
  128265. /**
  128266. * Define the target of the camera.
  128267. */
  128268. lockedTarget: Nullable<AbstractMesh>;
  128269. /**
  128270. * Defines the input associated with the camera.
  128271. */
  128272. inputs: FollowCameraInputsManager;
  128273. /**
  128274. * Instantiates the follow camera.
  128275. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128276. * @param name Define the name of the camera in the scene
  128277. * @param position Define the position of the camera
  128278. * @param scene Define the scene the camera belong to
  128279. * @param lockedTarget Define the target of the camera
  128280. */
  128281. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  128282. private _follow;
  128283. /**
  128284. * Attached controls to the current camera.
  128285. * @param element Defines the element the controls should be listened from
  128286. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128287. */
  128288. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128289. /**
  128290. * Detach the current controls from the camera.
  128291. * The camera will stop reacting to inputs.
  128292. * @param element Defines the element to stop listening the inputs from
  128293. */
  128294. detachControl(element: HTMLElement): void;
  128295. /** @hidden */
  128296. _checkInputs(): void;
  128297. private _checkLimits;
  128298. /**
  128299. * Gets the camera class name.
  128300. * @returns the class name
  128301. */
  128302. getClassName(): string;
  128303. }
  128304. /**
  128305. * Arc Rotate version of the follow camera.
  128306. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  128307. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128308. */
  128309. export class ArcFollowCamera extends TargetCamera {
  128310. /** The longitudinal angle of the camera */
  128311. alpha: number;
  128312. /** The latitudinal angle of the camera */
  128313. beta: number;
  128314. /** The radius of the camera from its target */
  128315. radius: number;
  128316. private _cartesianCoordinates;
  128317. /** Define the camera target (the mesh it should follow) */
  128318. private _meshTarget;
  128319. /**
  128320. * Instantiates a new ArcFollowCamera
  128321. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128322. * @param name Define the name of the camera
  128323. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  128324. * @param beta Define the rotation angle of the camera around the elevation axis
  128325. * @param radius Define the radius of the camera from its target point
  128326. * @param target Define the target of the camera
  128327. * @param scene Define the scene the camera belongs to
  128328. */
  128329. constructor(name: string,
  128330. /** The longitudinal angle of the camera */
  128331. alpha: number,
  128332. /** The latitudinal angle of the camera */
  128333. beta: number,
  128334. /** The radius of the camera from its target */
  128335. radius: number,
  128336. /** Define the camera target (the mesh it should follow) */
  128337. target: Nullable<AbstractMesh>, scene: Scene);
  128338. private _follow;
  128339. /** @hidden */
  128340. _checkInputs(): void;
  128341. /**
  128342. * Returns the class name of the object.
  128343. * It is mostly used internally for serialization purposes.
  128344. */
  128345. getClassName(): string;
  128346. }
  128347. }
  128348. declare module BABYLON {
  128349. /**
  128350. * Manage the keyboard inputs to control the movement of a follow camera.
  128351. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128352. */
  128353. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  128354. /**
  128355. * Defines the camera the input is attached to.
  128356. */
  128357. camera: FollowCamera;
  128358. /**
  128359. * Defines the list of key codes associated with the up action (increase heightOffset)
  128360. */
  128361. keysHeightOffsetIncr: number[];
  128362. /**
  128363. * Defines the list of key codes associated with the down action (decrease heightOffset)
  128364. */
  128365. keysHeightOffsetDecr: number[];
  128366. /**
  128367. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  128368. */
  128369. keysHeightOffsetModifierAlt: boolean;
  128370. /**
  128371. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  128372. */
  128373. keysHeightOffsetModifierCtrl: boolean;
  128374. /**
  128375. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  128376. */
  128377. keysHeightOffsetModifierShift: boolean;
  128378. /**
  128379. * Defines the list of key codes associated with the left action (increase rotationOffset)
  128380. */
  128381. keysRotationOffsetIncr: number[];
  128382. /**
  128383. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  128384. */
  128385. keysRotationOffsetDecr: number[];
  128386. /**
  128387. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  128388. */
  128389. keysRotationOffsetModifierAlt: boolean;
  128390. /**
  128391. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  128392. */
  128393. keysRotationOffsetModifierCtrl: boolean;
  128394. /**
  128395. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  128396. */
  128397. keysRotationOffsetModifierShift: boolean;
  128398. /**
  128399. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  128400. */
  128401. keysRadiusIncr: number[];
  128402. /**
  128403. * Defines the list of key codes associated with the zoom-out action (increase radius)
  128404. */
  128405. keysRadiusDecr: number[];
  128406. /**
  128407. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  128408. */
  128409. keysRadiusModifierAlt: boolean;
  128410. /**
  128411. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  128412. */
  128413. keysRadiusModifierCtrl: boolean;
  128414. /**
  128415. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  128416. */
  128417. keysRadiusModifierShift: boolean;
  128418. /**
  128419. * Defines the rate of change of heightOffset.
  128420. */
  128421. heightSensibility: number;
  128422. /**
  128423. * Defines the rate of change of rotationOffset.
  128424. */
  128425. rotationSensibility: number;
  128426. /**
  128427. * Defines the rate of change of radius.
  128428. */
  128429. radiusSensibility: number;
  128430. private _keys;
  128431. private _ctrlPressed;
  128432. private _altPressed;
  128433. private _shiftPressed;
  128434. private _onCanvasBlurObserver;
  128435. private _onKeyboardObserver;
  128436. private _engine;
  128437. private _scene;
  128438. /**
  128439. * Attach the input controls to a specific dom element to get the input from.
  128440. * @param element Defines the element the controls should be listened from
  128441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128442. */
  128443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128444. /**
  128445. * Detach the current controls from the specified dom element.
  128446. * @param element Defines the element to stop listening the inputs from
  128447. */
  128448. detachControl(element: Nullable<HTMLElement>): void;
  128449. /**
  128450. * Update the current camera state depending on the inputs that have been used this frame.
  128451. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128452. */
  128453. checkInputs(): void;
  128454. /**
  128455. * Gets the class name of the current input.
  128456. * @returns the class name
  128457. */
  128458. getClassName(): string;
  128459. /**
  128460. * Get the friendly name associated with the input class.
  128461. * @returns the input friendly name
  128462. */
  128463. getSimpleName(): string;
  128464. /**
  128465. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128466. * allow modification of the heightOffset value.
  128467. */
  128468. private _modifierHeightOffset;
  128469. /**
  128470. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128471. * allow modification of the rotationOffset value.
  128472. */
  128473. private _modifierRotationOffset;
  128474. /**
  128475. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128476. * allow modification of the radius value.
  128477. */
  128478. private _modifierRadius;
  128479. }
  128480. }
  128481. declare module BABYLON {
  128482. interface FreeCameraInputsManager {
  128483. /**
  128484. * @hidden
  128485. */
  128486. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  128487. /**
  128488. * Add orientation input support to the input manager.
  128489. * @returns the current input manager
  128490. */
  128491. addDeviceOrientation(): FreeCameraInputsManager;
  128492. }
  128493. /**
  128494. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  128495. * Screen rotation is taken into account.
  128496. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128497. */
  128498. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  128499. private _camera;
  128500. private _screenOrientationAngle;
  128501. private _constantTranform;
  128502. private _screenQuaternion;
  128503. private _alpha;
  128504. private _beta;
  128505. private _gamma;
  128506. /**
  128507. * Can be used to detect if a device orientation sensor is available on a device
  128508. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  128509. * @returns a promise that will resolve on orientation change
  128510. */
  128511. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  128512. /**
  128513. * @hidden
  128514. */
  128515. _onDeviceOrientationChangedObservable: Observable<void>;
  128516. /**
  128517. * Instantiates a new input
  128518. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128519. */
  128520. constructor();
  128521. /**
  128522. * Define the camera controlled by the input.
  128523. */
  128524. get camera(): FreeCamera;
  128525. set camera(camera: FreeCamera);
  128526. /**
  128527. * Attach the input controls to a specific dom element to get the input from.
  128528. * @param element Defines the element the controls should be listened from
  128529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128530. */
  128531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128532. private _orientationChanged;
  128533. private _deviceOrientation;
  128534. /**
  128535. * Detach the current controls from the specified dom element.
  128536. * @param element Defines the element to stop listening the inputs from
  128537. */
  128538. detachControl(element: Nullable<HTMLElement>): void;
  128539. /**
  128540. * Update the current camera state depending on the inputs that have been used this frame.
  128541. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128542. */
  128543. checkInputs(): void;
  128544. /**
  128545. * Gets the class name of the current intput.
  128546. * @returns the class name
  128547. */
  128548. getClassName(): string;
  128549. /**
  128550. * Get the friendly name associated with the input class.
  128551. * @returns the input friendly name
  128552. */
  128553. getSimpleName(): string;
  128554. }
  128555. }
  128556. declare module BABYLON {
  128557. /**
  128558. * Manage the gamepad inputs to control a free camera.
  128559. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128560. */
  128561. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  128562. /**
  128563. * Define the camera the input is attached to.
  128564. */
  128565. camera: FreeCamera;
  128566. /**
  128567. * Define the Gamepad controlling the input
  128568. */
  128569. gamepad: Nullable<Gamepad>;
  128570. /**
  128571. * Defines the gamepad rotation sensiblity.
  128572. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  128573. */
  128574. gamepadAngularSensibility: number;
  128575. /**
  128576. * Defines the gamepad move sensiblity.
  128577. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  128578. */
  128579. gamepadMoveSensibility: number;
  128580. private _yAxisScale;
  128581. /**
  128582. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  128583. */
  128584. get invertYAxis(): boolean;
  128585. set invertYAxis(value: boolean);
  128586. private _onGamepadConnectedObserver;
  128587. private _onGamepadDisconnectedObserver;
  128588. private _cameraTransform;
  128589. private _deltaTransform;
  128590. private _vector3;
  128591. private _vector2;
  128592. /**
  128593. * Attach the input controls to a specific dom element to get the input from.
  128594. * @param element Defines the element the controls should be listened from
  128595. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128596. */
  128597. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128598. /**
  128599. * Detach the current controls from the specified dom element.
  128600. * @param element Defines the element to stop listening the inputs from
  128601. */
  128602. detachControl(element: Nullable<HTMLElement>): void;
  128603. /**
  128604. * Update the current camera state depending on the inputs that have been used this frame.
  128605. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128606. */
  128607. checkInputs(): void;
  128608. /**
  128609. * Gets the class name of the current intput.
  128610. * @returns the class name
  128611. */
  128612. getClassName(): string;
  128613. /**
  128614. * Get the friendly name associated with the input class.
  128615. * @returns the input friendly name
  128616. */
  128617. getSimpleName(): string;
  128618. }
  128619. }
  128620. declare module BABYLON {
  128621. /**
  128622. * Defines the potential axis of a Joystick
  128623. */
  128624. export enum JoystickAxis {
  128625. /** X axis */
  128626. X = 0,
  128627. /** Y axis */
  128628. Y = 1,
  128629. /** Z axis */
  128630. Z = 2
  128631. }
  128632. /**
  128633. * Represents the different customization options available
  128634. * for VirtualJoystick
  128635. */
  128636. interface VirtualJoystickCustomizations {
  128637. /**
  128638. * Size of the joystick's puck
  128639. */
  128640. puckSize: number;
  128641. /**
  128642. * Size of the joystick's container
  128643. */
  128644. containerSize: number;
  128645. /**
  128646. * Color of the joystick && puck
  128647. */
  128648. color: string;
  128649. /**
  128650. * Image URL for the joystick's puck
  128651. */
  128652. puckImage?: string;
  128653. /**
  128654. * Image URL for the joystick's container
  128655. */
  128656. containerImage?: string;
  128657. /**
  128658. * Defines the unmoving position of the joystick container
  128659. */
  128660. position?: {
  128661. x: number;
  128662. y: number;
  128663. };
  128664. /**
  128665. * Defines whether or not the joystick container is always visible
  128666. */
  128667. alwaysVisible: boolean;
  128668. /**
  128669. * Defines whether or not to limit the movement of the puck to the joystick's container
  128670. */
  128671. limitToContainer: boolean;
  128672. }
  128673. /**
  128674. * Class used to define virtual joystick (used in touch mode)
  128675. */
  128676. export class VirtualJoystick {
  128677. /**
  128678. * Gets or sets a boolean indicating that left and right values must be inverted
  128679. */
  128680. reverseLeftRight: boolean;
  128681. /**
  128682. * Gets or sets a boolean indicating that up and down values must be inverted
  128683. */
  128684. reverseUpDown: boolean;
  128685. /**
  128686. * Gets the offset value for the position (ie. the change of the position value)
  128687. */
  128688. deltaPosition: Vector3;
  128689. /**
  128690. * Gets a boolean indicating if the virtual joystick was pressed
  128691. */
  128692. pressed: boolean;
  128693. /**
  128694. * Canvas the virtual joystick will render onto, default z-index of this is 5
  128695. */
  128696. static Canvas: Nullable<HTMLCanvasElement>;
  128697. /**
  128698. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  128699. */
  128700. limitToContainer: boolean;
  128701. private static _globalJoystickIndex;
  128702. private static _alwaysVisibleSticks;
  128703. private static vjCanvasContext;
  128704. private static vjCanvasWidth;
  128705. private static vjCanvasHeight;
  128706. private static halfWidth;
  128707. private static _GetDefaultOptions;
  128708. private _action;
  128709. private _axisTargetedByLeftAndRight;
  128710. private _axisTargetedByUpAndDown;
  128711. private _joystickSensibility;
  128712. private _inversedSensibility;
  128713. private _joystickPointerID;
  128714. private _joystickColor;
  128715. private _joystickPointerPos;
  128716. private _joystickPreviousPointerPos;
  128717. private _joystickPointerStartPos;
  128718. private _deltaJoystickVector;
  128719. private _leftJoystick;
  128720. private _touches;
  128721. private _joystickPosition;
  128722. private _alwaysVisible;
  128723. private _puckImage;
  128724. private _containerImage;
  128725. private _joystickPuckSize;
  128726. private _joystickContainerSize;
  128727. private _clearPuckSize;
  128728. private _clearContainerSize;
  128729. private _clearPuckSizeOffset;
  128730. private _clearContainerSizeOffset;
  128731. private _onPointerDownHandlerRef;
  128732. private _onPointerMoveHandlerRef;
  128733. private _onPointerUpHandlerRef;
  128734. private _onResize;
  128735. /**
  128736. * Creates a new virtual joystick
  128737. * @param leftJoystick defines that the joystick is for left hand (false by default)
  128738. * @param customizations Defines the options we want to customize the VirtualJoystick
  128739. */
  128740. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  128741. /**
  128742. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  128743. * @param newJoystickSensibility defines the new sensibility
  128744. */
  128745. setJoystickSensibility(newJoystickSensibility: number): void;
  128746. private _onPointerDown;
  128747. private _onPointerMove;
  128748. private _onPointerUp;
  128749. /**
  128750. * Change the color of the virtual joystick
  128751. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  128752. */
  128753. setJoystickColor(newColor: string): void;
  128754. /**
  128755. * Size of the joystick's container
  128756. */
  128757. set containerSize(newSize: number);
  128758. get containerSize(): number;
  128759. /**
  128760. * Size of the joystick's puck
  128761. */
  128762. set puckSize(newSize: number);
  128763. get puckSize(): number;
  128764. /**
  128765. * Clears the set position of the joystick
  128766. */
  128767. clearPosition(): void;
  128768. /**
  128769. * Defines whether or not the joystick container is always visible
  128770. */
  128771. set alwaysVisible(value: boolean);
  128772. get alwaysVisible(): boolean;
  128773. /**
  128774. * Sets the constant position of the Joystick container
  128775. * @param x X axis coordinate
  128776. * @param y Y axis coordinate
  128777. */
  128778. setPosition(x: number, y: number): void;
  128779. /**
  128780. * Defines a callback to call when the joystick is touched
  128781. * @param action defines the callback
  128782. */
  128783. setActionOnTouch(action: () => any): void;
  128784. /**
  128785. * Defines which axis you'd like to control for left & right
  128786. * @param axis defines the axis to use
  128787. */
  128788. setAxisForLeftRight(axis: JoystickAxis): void;
  128789. /**
  128790. * Defines which axis you'd like to control for up & down
  128791. * @param axis defines the axis to use
  128792. */
  128793. setAxisForUpDown(axis: JoystickAxis): void;
  128794. /**
  128795. * Clears the canvas from the previous puck / container draw
  128796. */
  128797. private _clearPreviousDraw;
  128798. /**
  128799. * Loads `urlPath` to be used for the container's image
  128800. * @param urlPath defines the urlPath of an image to use
  128801. */
  128802. setContainerImage(urlPath: string): void;
  128803. /**
  128804. * Loads `urlPath` to be used for the puck's image
  128805. * @param urlPath defines the urlPath of an image to use
  128806. */
  128807. setPuckImage(urlPath: string): void;
  128808. /**
  128809. * Draws the Virtual Joystick's container
  128810. */
  128811. private _drawContainer;
  128812. /**
  128813. * Draws the Virtual Joystick's puck
  128814. */
  128815. private _drawPuck;
  128816. private _drawVirtualJoystick;
  128817. /**
  128818. * Release internal HTML canvas
  128819. */
  128820. releaseCanvas(): void;
  128821. }
  128822. }
  128823. declare module BABYLON {
  128824. interface FreeCameraInputsManager {
  128825. /**
  128826. * Add virtual joystick input support to the input manager.
  128827. * @returns the current input manager
  128828. */
  128829. addVirtualJoystick(): FreeCameraInputsManager;
  128830. }
  128831. /**
  128832. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  128833. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128834. */
  128835. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  128836. /**
  128837. * Defines the camera the input is attached to.
  128838. */
  128839. camera: FreeCamera;
  128840. private _leftjoystick;
  128841. private _rightjoystick;
  128842. /**
  128843. * Gets the left stick of the virtual joystick.
  128844. * @returns The virtual Joystick
  128845. */
  128846. getLeftJoystick(): VirtualJoystick;
  128847. /**
  128848. * Gets the right stick of the virtual joystick.
  128849. * @returns The virtual Joystick
  128850. */
  128851. getRightJoystick(): VirtualJoystick;
  128852. /**
  128853. * Update the current camera state depending on the inputs that have been used this frame.
  128854. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128855. */
  128856. checkInputs(): void;
  128857. /**
  128858. * Attach the input controls to a specific dom element to get the input from.
  128859. * @param element Defines the element the controls should be listened from
  128860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128861. */
  128862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128863. /**
  128864. * Detach the current controls from the specified dom element.
  128865. * @param element Defines the element to stop listening the inputs from
  128866. */
  128867. detachControl(element: Nullable<HTMLElement>): void;
  128868. /**
  128869. * Gets the class name of the current intput.
  128870. * @returns the class name
  128871. */
  128872. getClassName(): string;
  128873. /**
  128874. * Get the friendly name associated with the input class.
  128875. * @returns the input friendly name
  128876. */
  128877. getSimpleName(): string;
  128878. }
  128879. }
  128880. declare module BABYLON {
  128881. /**
  128882. * This represents a FPS type of camera controlled by touch.
  128883. * This is like a universal camera minus the Gamepad controls.
  128884. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  128885. */
  128886. export class TouchCamera extends FreeCamera {
  128887. /**
  128888. * Defines the touch sensibility for rotation.
  128889. * The higher the faster.
  128890. */
  128891. get touchAngularSensibility(): number;
  128892. set touchAngularSensibility(value: number);
  128893. /**
  128894. * Defines the touch sensibility for move.
  128895. * The higher the faster.
  128896. */
  128897. get touchMoveSensibility(): number;
  128898. set touchMoveSensibility(value: number);
  128899. /**
  128900. * Instantiates a new touch camera.
  128901. * This represents a FPS type of camera controlled by touch.
  128902. * This is like a universal camera minus the Gamepad controls.
  128903. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  128904. * @param name Define the name of the camera in the scene
  128905. * @param position Define the start position of the camera in the scene
  128906. * @param scene Define the scene the camera belongs to
  128907. */
  128908. constructor(name: string, position: Vector3, scene: Scene);
  128909. /**
  128910. * Gets the current object class name.
  128911. * @return the class name
  128912. */
  128913. getClassName(): string;
  128914. /** @hidden */
  128915. _setupInputs(): void;
  128916. }
  128917. }
  128918. declare module BABYLON {
  128919. /**
  128920. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  128921. * being tilted forward or back and left or right.
  128922. */
  128923. export class DeviceOrientationCamera extends FreeCamera {
  128924. private _initialQuaternion;
  128925. private _quaternionCache;
  128926. private _tmpDragQuaternion;
  128927. private _disablePointerInputWhenUsingDeviceOrientation;
  128928. /**
  128929. * Creates a new device orientation camera
  128930. * @param name The name of the camera
  128931. * @param position The start position camera
  128932. * @param scene The scene the camera belongs to
  128933. */
  128934. constructor(name: string, position: Vector3, scene: Scene);
  128935. /**
  128936. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  128937. */
  128938. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  128939. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  128940. private _dragFactor;
  128941. /**
  128942. * Enabled turning on the y axis when the orientation sensor is active
  128943. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  128944. */
  128945. enableHorizontalDragging(dragFactor?: number): void;
  128946. /**
  128947. * Gets the current instance class name ("DeviceOrientationCamera").
  128948. * This helps avoiding instanceof at run time.
  128949. * @returns the class name
  128950. */
  128951. getClassName(): string;
  128952. /**
  128953. * @hidden
  128954. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  128955. */
  128956. _checkInputs(): void;
  128957. /**
  128958. * Reset the camera to its default orientation on the specified axis only.
  128959. * @param axis The axis to reset
  128960. */
  128961. resetToCurrentRotation(axis?: Axis): void;
  128962. }
  128963. }
  128964. declare module BABYLON {
  128965. /**
  128966. * Defines supported buttons for XBox360 compatible gamepads
  128967. */
  128968. export enum Xbox360Button {
  128969. /** A */
  128970. A = 0,
  128971. /** B */
  128972. B = 1,
  128973. /** X */
  128974. X = 2,
  128975. /** Y */
  128976. Y = 3,
  128977. /** Left button */
  128978. LB = 4,
  128979. /** Right button */
  128980. RB = 5,
  128981. /** Back */
  128982. Back = 8,
  128983. /** Start */
  128984. Start = 9,
  128985. /** Left stick */
  128986. LeftStick = 10,
  128987. /** Right stick */
  128988. RightStick = 11
  128989. }
  128990. /** Defines values for XBox360 DPad */
  128991. export enum Xbox360Dpad {
  128992. /** Up */
  128993. Up = 12,
  128994. /** Down */
  128995. Down = 13,
  128996. /** Left */
  128997. Left = 14,
  128998. /** Right */
  128999. Right = 15
  129000. }
  129001. /**
  129002. * Defines a XBox360 gamepad
  129003. */
  129004. export class Xbox360Pad extends Gamepad {
  129005. private _leftTrigger;
  129006. private _rightTrigger;
  129007. private _onlefttriggerchanged;
  129008. private _onrighttriggerchanged;
  129009. private _onbuttondown;
  129010. private _onbuttonup;
  129011. private _ondpaddown;
  129012. private _ondpadup;
  129013. /** Observable raised when a button is pressed */
  129014. onButtonDownObservable: Observable<Xbox360Button>;
  129015. /** Observable raised when a button is released */
  129016. onButtonUpObservable: Observable<Xbox360Button>;
  129017. /** Observable raised when a pad is pressed */
  129018. onPadDownObservable: Observable<Xbox360Dpad>;
  129019. /** Observable raised when a pad is released */
  129020. onPadUpObservable: Observable<Xbox360Dpad>;
  129021. private _buttonA;
  129022. private _buttonB;
  129023. private _buttonX;
  129024. private _buttonY;
  129025. private _buttonBack;
  129026. private _buttonStart;
  129027. private _buttonLB;
  129028. private _buttonRB;
  129029. private _buttonLeftStick;
  129030. private _buttonRightStick;
  129031. private _dPadUp;
  129032. private _dPadDown;
  129033. private _dPadLeft;
  129034. private _dPadRight;
  129035. private _isXboxOnePad;
  129036. /**
  129037. * Creates a new XBox360 gamepad object
  129038. * @param id defines the id of this gamepad
  129039. * @param index defines its index
  129040. * @param gamepad defines the internal HTML gamepad object
  129041. * @param xboxOne defines if it is a XBox One gamepad
  129042. */
  129043. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  129044. /**
  129045. * Defines the callback to call when left trigger is pressed
  129046. * @param callback defines the callback to use
  129047. */
  129048. onlefttriggerchanged(callback: (value: number) => void): void;
  129049. /**
  129050. * Defines the callback to call when right trigger is pressed
  129051. * @param callback defines the callback to use
  129052. */
  129053. onrighttriggerchanged(callback: (value: number) => void): void;
  129054. /**
  129055. * Gets the left trigger value
  129056. */
  129057. get leftTrigger(): number;
  129058. /**
  129059. * Sets the left trigger value
  129060. */
  129061. set leftTrigger(newValue: number);
  129062. /**
  129063. * Gets the right trigger value
  129064. */
  129065. get rightTrigger(): number;
  129066. /**
  129067. * Sets the right trigger value
  129068. */
  129069. set rightTrigger(newValue: number);
  129070. /**
  129071. * Defines the callback to call when a button is pressed
  129072. * @param callback defines the callback to use
  129073. */
  129074. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  129075. /**
  129076. * Defines the callback to call when a button is released
  129077. * @param callback defines the callback to use
  129078. */
  129079. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  129080. /**
  129081. * Defines the callback to call when a pad is pressed
  129082. * @param callback defines the callback to use
  129083. */
  129084. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  129085. /**
  129086. * Defines the callback to call when a pad is released
  129087. * @param callback defines the callback to use
  129088. */
  129089. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  129090. private _setButtonValue;
  129091. private _setDPadValue;
  129092. /**
  129093. * Gets the value of the `A` button
  129094. */
  129095. get buttonA(): number;
  129096. /**
  129097. * Sets the value of the `A` button
  129098. */
  129099. set buttonA(value: number);
  129100. /**
  129101. * Gets the value of the `B` button
  129102. */
  129103. get buttonB(): number;
  129104. /**
  129105. * Sets the value of the `B` button
  129106. */
  129107. set buttonB(value: number);
  129108. /**
  129109. * Gets the value of the `X` button
  129110. */
  129111. get buttonX(): number;
  129112. /**
  129113. * Sets the value of the `X` button
  129114. */
  129115. set buttonX(value: number);
  129116. /**
  129117. * Gets the value of the `Y` button
  129118. */
  129119. get buttonY(): number;
  129120. /**
  129121. * Sets the value of the `Y` button
  129122. */
  129123. set buttonY(value: number);
  129124. /**
  129125. * Gets the value of the `Start` button
  129126. */
  129127. get buttonStart(): number;
  129128. /**
  129129. * Sets the value of the `Start` button
  129130. */
  129131. set buttonStart(value: number);
  129132. /**
  129133. * Gets the value of the `Back` button
  129134. */
  129135. get buttonBack(): number;
  129136. /**
  129137. * Sets the value of the `Back` button
  129138. */
  129139. set buttonBack(value: number);
  129140. /**
  129141. * Gets the value of the `Left` button
  129142. */
  129143. get buttonLB(): number;
  129144. /**
  129145. * Sets the value of the `Left` button
  129146. */
  129147. set buttonLB(value: number);
  129148. /**
  129149. * Gets the value of the `Right` button
  129150. */
  129151. get buttonRB(): number;
  129152. /**
  129153. * Sets the value of the `Right` button
  129154. */
  129155. set buttonRB(value: number);
  129156. /**
  129157. * Gets the value of the Left joystick
  129158. */
  129159. get buttonLeftStick(): number;
  129160. /**
  129161. * Sets the value of the Left joystick
  129162. */
  129163. set buttonLeftStick(value: number);
  129164. /**
  129165. * Gets the value of the Right joystick
  129166. */
  129167. get buttonRightStick(): number;
  129168. /**
  129169. * Sets the value of the Right joystick
  129170. */
  129171. set buttonRightStick(value: number);
  129172. /**
  129173. * Gets the value of D-pad up
  129174. */
  129175. get dPadUp(): number;
  129176. /**
  129177. * Sets the value of D-pad up
  129178. */
  129179. set dPadUp(value: number);
  129180. /**
  129181. * Gets the value of D-pad down
  129182. */
  129183. get dPadDown(): number;
  129184. /**
  129185. * Sets the value of D-pad down
  129186. */
  129187. set dPadDown(value: number);
  129188. /**
  129189. * Gets the value of D-pad left
  129190. */
  129191. get dPadLeft(): number;
  129192. /**
  129193. * Sets the value of D-pad left
  129194. */
  129195. set dPadLeft(value: number);
  129196. /**
  129197. * Gets the value of D-pad right
  129198. */
  129199. get dPadRight(): number;
  129200. /**
  129201. * Sets the value of D-pad right
  129202. */
  129203. set dPadRight(value: number);
  129204. /**
  129205. * Force the gamepad to synchronize with device values
  129206. */
  129207. update(): void;
  129208. /**
  129209. * Disposes the gamepad
  129210. */
  129211. dispose(): void;
  129212. }
  129213. }
  129214. declare module BABYLON {
  129215. /**
  129216. * Defines supported buttons for DualShock compatible gamepads
  129217. */
  129218. export enum DualShockButton {
  129219. /** Cross */
  129220. Cross = 0,
  129221. /** Circle */
  129222. Circle = 1,
  129223. /** Square */
  129224. Square = 2,
  129225. /** Triangle */
  129226. Triangle = 3,
  129227. /** L1 */
  129228. L1 = 4,
  129229. /** R1 */
  129230. R1 = 5,
  129231. /** Share */
  129232. Share = 8,
  129233. /** Options */
  129234. Options = 9,
  129235. /** Left stick */
  129236. LeftStick = 10,
  129237. /** Right stick */
  129238. RightStick = 11
  129239. }
  129240. /** Defines values for DualShock DPad */
  129241. export enum DualShockDpad {
  129242. /** Up */
  129243. Up = 12,
  129244. /** Down */
  129245. Down = 13,
  129246. /** Left */
  129247. Left = 14,
  129248. /** Right */
  129249. Right = 15
  129250. }
  129251. /**
  129252. * Defines a DualShock gamepad
  129253. */
  129254. export class DualShockPad extends Gamepad {
  129255. private _leftTrigger;
  129256. private _rightTrigger;
  129257. private _onlefttriggerchanged;
  129258. private _onrighttriggerchanged;
  129259. private _onbuttondown;
  129260. private _onbuttonup;
  129261. private _ondpaddown;
  129262. private _ondpadup;
  129263. /** Observable raised when a button is pressed */
  129264. onButtonDownObservable: Observable<DualShockButton>;
  129265. /** Observable raised when a button is released */
  129266. onButtonUpObservable: Observable<DualShockButton>;
  129267. /** Observable raised when a pad is pressed */
  129268. onPadDownObservable: Observable<DualShockDpad>;
  129269. /** Observable raised when a pad is released */
  129270. onPadUpObservable: Observable<DualShockDpad>;
  129271. private _buttonCross;
  129272. private _buttonCircle;
  129273. private _buttonSquare;
  129274. private _buttonTriangle;
  129275. private _buttonShare;
  129276. private _buttonOptions;
  129277. private _buttonL1;
  129278. private _buttonR1;
  129279. private _buttonLeftStick;
  129280. private _buttonRightStick;
  129281. private _dPadUp;
  129282. private _dPadDown;
  129283. private _dPadLeft;
  129284. private _dPadRight;
  129285. /**
  129286. * Creates a new DualShock gamepad object
  129287. * @param id defines the id of this gamepad
  129288. * @param index defines its index
  129289. * @param gamepad defines the internal HTML gamepad object
  129290. */
  129291. constructor(id: string, index: number, gamepad: any);
  129292. /**
  129293. * Defines the callback to call when left trigger is pressed
  129294. * @param callback defines the callback to use
  129295. */
  129296. onlefttriggerchanged(callback: (value: number) => void): void;
  129297. /**
  129298. * Defines the callback to call when right trigger is pressed
  129299. * @param callback defines the callback to use
  129300. */
  129301. onrighttriggerchanged(callback: (value: number) => void): void;
  129302. /**
  129303. * Gets the left trigger value
  129304. */
  129305. get leftTrigger(): number;
  129306. /**
  129307. * Sets the left trigger value
  129308. */
  129309. set leftTrigger(newValue: number);
  129310. /**
  129311. * Gets the right trigger value
  129312. */
  129313. get rightTrigger(): number;
  129314. /**
  129315. * Sets the right trigger value
  129316. */
  129317. set rightTrigger(newValue: number);
  129318. /**
  129319. * Defines the callback to call when a button is pressed
  129320. * @param callback defines the callback to use
  129321. */
  129322. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  129323. /**
  129324. * Defines the callback to call when a button is released
  129325. * @param callback defines the callback to use
  129326. */
  129327. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  129328. /**
  129329. * Defines the callback to call when a pad is pressed
  129330. * @param callback defines the callback to use
  129331. */
  129332. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  129333. /**
  129334. * Defines the callback to call when a pad is released
  129335. * @param callback defines the callback to use
  129336. */
  129337. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  129338. private _setButtonValue;
  129339. private _setDPadValue;
  129340. /**
  129341. * Gets the value of the `Cross` button
  129342. */
  129343. get buttonCross(): number;
  129344. /**
  129345. * Sets the value of the `Cross` button
  129346. */
  129347. set buttonCross(value: number);
  129348. /**
  129349. * Gets the value of the `Circle` button
  129350. */
  129351. get buttonCircle(): number;
  129352. /**
  129353. * Sets the value of the `Circle` button
  129354. */
  129355. set buttonCircle(value: number);
  129356. /**
  129357. * Gets the value of the `Square` button
  129358. */
  129359. get buttonSquare(): number;
  129360. /**
  129361. * Sets the value of the `Square` button
  129362. */
  129363. set buttonSquare(value: number);
  129364. /**
  129365. * Gets the value of the `Triangle` button
  129366. */
  129367. get buttonTriangle(): number;
  129368. /**
  129369. * Sets the value of the `Triangle` button
  129370. */
  129371. set buttonTriangle(value: number);
  129372. /**
  129373. * Gets the value of the `Options` button
  129374. */
  129375. get buttonOptions(): number;
  129376. /**
  129377. * Sets the value of the `Options` button
  129378. */
  129379. set buttonOptions(value: number);
  129380. /**
  129381. * Gets the value of the `Share` button
  129382. */
  129383. get buttonShare(): number;
  129384. /**
  129385. * Sets the value of the `Share` button
  129386. */
  129387. set buttonShare(value: number);
  129388. /**
  129389. * Gets the value of the `L1` button
  129390. */
  129391. get buttonL1(): number;
  129392. /**
  129393. * Sets the value of the `L1` button
  129394. */
  129395. set buttonL1(value: number);
  129396. /**
  129397. * Gets the value of the `R1` button
  129398. */
  129399. get buttonR1(): number;
  129400. /**
  129401. * Sets the value of the `R1` button
  129402. */
  129403. set buttonR1(value: number);
  129404. /**
  129405. * Gets the value of the Left joystick
  129406. */
  129407. get buttonLeftStick(): number;
  129408. /**
  129409. * Sets the value of the Left joystick
  129410. */
  129411. set buttonLeftStick(value: number);
  129412. /**
  129413. * Gets the value of the Right joystick
  129414. */
  129415. get buttonRightStick(): number;
  129416. /**
  129417. * Sets the value of the Right joystick
  129418. */
  129419. set buttonRightStick(value: number);
  129420. /**
  129421. * Gets the value of D-pad up
  129422. */
  129423. get dPadUp(): number;
  129424. /**
  129425. * Sets the value of D-pad up
  129426. */
  129427. set dPadUp(value: number);
  129428. /**
  129429. * Gets the value of D-pad down
  129430. */
  129431. get dPadDown(): number;
  129432. /**
  129433. * Sets the value of D-pad down
  129434. */
  129435. set dPadDown(value: number);
  129436. /**
  129437. * Gets the value of D-pad left
  129438. */
  129439. get dPadLeft(): number;
  129440. /**
  129441. * Sets the value of D-pad left
  129442. */
  129443. set dPadLeft(value: number);
  129444. /**
  129445. * Gets the value of D-pad right
  129446. */
  129447. get dPadRight(): number;
  129448. /**
  129449. * Sets the value of D-pad right
  129450. */
  129451. set dPadRight(value: number);
  129452. /**
  129453. * Force the gamepad to synchronize with device values
  129454. */
  129455. update(): void;
  129456. /**
  129457. * Disposes the gamepad
  129458. */
  129459. dispose(): void;
  129460. }
  129461. }
  129462. declare module BABYLON {
  129463. /**
  129464. * Manager for handling gamepads
  129465. */
  129466. export class GamepadManager {
  129467. private _scene?;
  129468. private _babylonGamepads;
  129469. private _oneGamepadConnected;
  129470. /** @hidden */
  129471. _isMonitoring: boolean;
  129472. private _gamepadEventSupported;
  129473. private _gamepadSupport?;
  129474. /**
  129475. * observable to be triggered when the gamepad controller has been connected
  129476. */
  129477. onGamepadConnectedObservable: Observable<Gamepad>;
  129478. /**
  129479. * observable to be triggered when the gamepad controller has been disconnected
  129480. */
  129481. onGamepadDisconnectedObservable: Observable<Gamepad>;
  129482. private _onGamepadConnectedEvent;
  129483. private _onGamepadDisconnectedEvent;
  129484. /**
  129485. * Initializes the gamepad manager
  129486. * @param _scene BabylonJS scene
  129487. */
  129488. constructor(_scene?: Scene | undefined);
  129489. /**
  129490. * The gamepads in the game pad manager
  129491. */
  129492. get gamepads(): Gamepad[];
  129493. /**
  129494. * Get the gamepad controllers based on type
  129495. * @param type The type of gamepad controller
  129496. * @returns Nullable gamepad
  129497. */
  129498. getGamepadByType(type?: number): Nullable<Gamepad>;
  129499. /**
  129500. * Disposes the gamepad manager
  129501. */
  129502. dispose(): void;
  129503. private _addNewGamepad;
  129504. private _startMonitoringGamepads;
  129505. private _stopMonitoringGamepads;
  129506. /** @hidden */
  129507. _checkGamepadsStatus(): void;
  129508. private _updateGamepadObjects;
  129509. }
  129510. }
  129511. declare module BABYLON {
  129512. interface Scene {
  129513. /** @hidden */
  129514. _gamepadManager: Nullable<GamepadManager>;
  129515. /**
  129516. * Gets the gamepad manager associated with the scene
  129517. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  129518. */
  129519. gamepadManager: GamepadManager;
  129520. }
  129521. /**
  129522. * Interface representing a free camera inputs manager
  129523. */
  129524. interface FreeCameraInputsManager {
  129525. /**
  129526. * Adds gamepad input support to the FreeCameraInputsManager.
  129527. * @returns the FreeCameraInputsManager
  129528. */
  129529. addGamepad(): FreeCameraInputsManager;
  129530. }
  129531. /**
  129532. * Interface representing an arc rotate camera inputs manager
  129533. */
  129534. interface ArcRotateCameraInputsManager {
  129535. /**
  129536. * Adds gamepad input support to the ArcRotateCamera InputManager.
  129537. * @returns the camera inputs manager
  129538. */
  129539. addGamepad(): ArcRotateCameraInputsManager;
  129540. }
  129541. /**
  129542. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  129543. */
  129544. export class GamepadSystemSceneComponent implements ISceneComponent {
  129545. /**
  129546. * The component name helpfull to identify the component in the list of scene components.
  129547. */
  129548. readonly name: string;
  129549. /**
  129550. * The scene the component belongs to.
  129551. */
  129552. scene: Scene;
  129553. /**
  129554. * Creates a new instance of the component for the given scene
  129555. * @param scene Defines the scene to register the component in
  129556. */
  129557. constructor(scene: Scene);
  129558. /**
  129559. * Registers the component in a given scene
  129560. */
  129561. register(): void;
  129562. /**
  129563. * Rebuilds the elements related to this component in case of
  129564. * context lost for instance.
  129565. */
  129566. rebuild(): void;
  129567. /**
  129568. * Disposes the component and the associated ressources
  129569. */
  129570. dispose(): void;
  129571. private _beforeCameraUpdate;
  129572. }
  129573. }
  129574. declare module BABYLON {
  129575. /**
  129576. * 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,
  129577. * which still works and will still be found in many Playgrounds.
  129578. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129579. */
  129580. export class UniversalCamera extends TouchCamera {
  129581. /**
  129582. * Defines the gamepad rotation sensiblity.
  129583. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129584. */
  129585. get gamepadAngularSensibility(): number;
  129586. set gamepadAngularSensibility(value: number);
  129587. /**
  129588. * Defines the gamepad move sensiblity.
  129589. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129590. */
  129591. get gamepadMoveSensibility(): number;
  129592. set gamepadMoveSensibility(value: number);
  129593. /**
  129594. * 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,
  129595. * which still works and will still be found in many Playgrounds.
  129596. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129597. * @param name Define the name of the camera in the scene
  129598. * @param position Define the start position of the camera in the scene
  129599. * @param scene Define the scene the camera belongs to
  129600. */
  129601. constructor(name: string, position: Vector3, scene: Scene);
  129602. /**
  129603. * Gets the current object class name.
  129604. * @return the class name
  129605. */
  129606. getClassName(): string;
  129607. }
  129608. }
  129609. declare module BABYLON {
  129610. /**
  129611. * This represents a FPS type of camera. This is only here for back compat purpose.
  129612. * Please use the UniversalCamera instead as both are identical.
  129613. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129614. */
  129615. export class GamepadCamera extends UniversalCamera {
  129616. /**
  129617. * Instantiates a new Gamepad Camera
  129618. * This represents a FPS type of camera. This is only here for back compat purpose.
  129619. * Please use the UniversalCamera instead as both are identical.
  129620. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129621. * @param name Define the name of the camera in the scene
  129622. * @param position Define the start position of the camera in the scene
  129623. * @param scene Define the scene the camera belongs to
  129624. */
  129625. constructor(name: string, position: Vector3, scene: Scene);
  129626. /**
  129627. * Gets the current object class name.
  129628. * @return the class name
  129629. */
  129630. getClassName(): string;
  129631. }
  129632. }
  129633. declare module BABYLON {
  129634. /** @hidden */
  129635. export var passPixelShader: {
  129636. name: string;
  129637. shader: string;
  129638. };
  129639. }
  129640. declare module BABYLON {
  129641. /** @hidden */
  129642. export var passCubePixelShader: {
  129643. name: string;
  129644. shader: string;
  129645. };
  129646. }
  129647. declare module BABYLON {
  129648. /**
  129649. * PassPostProcess which produces an output the same as it's input
  129650. */
  129651. export class PassPostProcess extends PostProcess {
  129652. /**
  129653. * Gets a string identifying the name of the class
  129654. * @returns "PassPostProcess" string
  129655. */
  129656. getClassName(): string;
  129657. /**
  129658. * Creates the PassPostProcess
  129659. * @param name The name of the effect.
  129660. * @param options The required width/height ratio to downsize to before computing the render pass.
  129661. * @param camera The camera to apply the render pass to.
  129662. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129663. * @param engine The engine which the post process will be applied. (default: current engine)
  129664. * @param reusable If the post process can be reused on the same frame. (default: false)
  129665. * @param textureType The type of texture to be used when performing the post processing.
  129666. * @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)
  129667. */
  129668. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129669. /** @hidden */
  129670. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  129671. }
  129672. /**
  129673. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  129674. */
  129675. export class PassCubePostProcess extends PostProcess {
  129676. private _face;
  129677. /**
  129678. * Gets or sets the cube face to display.
  129679. * * 0 is +X
  129680. * * 1 is -X
  129681. * * 2 is +Y
  129682. * * 3 is -Y
  129683. * * 4 is +Z
  129684. * * 5 is -Z
  129685. */
  129686. get face(): number;
  129687. set face(value: number);
  129688. /**
  129689. * Gets a string identifying the name of the class
  129690. * @returns "PassCubePostProcess" string
  129691. */
  129692. getClassName(): string;
  129693. /**
  129694. * Creates the PassCubePostProcess
  129695. * @param name The name of the effect.
  129696. * @param options The required width/height ratio to downsize to before computing the render pass.
  129697. * @param camera The camera to apply the render pass to.
  129698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129699. * @param engine The engine which the post process will be applied. (default: current engine)
  129700. * @param reusable If the post process can be reused on the same frame. (default: false)
  129701. * @param textureType The type of texture to be used when performing the post processing.
  129702. * @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)
  129703. */
  129704. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129705. /** @hidden */
  129706. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  129707. }
  129708. }
  129709. declare module BABYLON {
  129710. /** @hidden */
  129711. export var anaglyphPixelShader: {
  129712. name: string;
  129713. shader: string;
  129714. };
  129715. }
  129716. declare module BABYLON {
  129717. /**
  129718. * Postprocess used to generate anaglyphic rendering
  129719. */
  129720. export class AnaglyphPostProcess extends PostProcess {
  129721. private _passedProcess;
  129722. /**
  129723. * Gets a string identifying the name of the class
  129724. * @returns "AnaglyphPostProcess" string
  129725. */
  129726. getClassName(): string;
  129727. /**
  129728. * Creates a new AnaglyphPostProcess
  129729. * @param name defines postprocess name
  129730. * @param options defines creation options or target ratio scale
  129731. * @param rigCameras defines cameras using this postprocess
  129732. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  129733. * @param engine defines hosting engine
  129734. * @param reusable defines if the postprocess will be reused multiple times per frame
  129735. */
  129736. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  129737. }
  129738. }
  129739. declare module BABYLON {
  129740. /**
  129741. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  129742. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129743. */
  129744. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  129745. /**
  129746. * Creates a new AnaglyphArcRotateCamera
  129747. * @param name defines camera name
  129748. * @param alpha defines alpha angle (in radians)
  129749. * @param beta defines beta angle (in radians)
  129750. * @param radius defines radius
  129751. * @param target defines camera target
  129752. * @param interaxialDistance defines distance between each color axis
  129753. * @param scene defines the hosting scene
  129754. */
  129755. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  129756. /**
  129757. * Gets camera class name
  129758. * @returns AnaglyphArcRotateCamera
  129759. */
  129760. getClassName(): string;
  129761. }
  129762. }
  129763. declare module BABYLON {
  129764. /**
  129765. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  129766. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129767. */
  129768. export class AnaglyphFreeCamera extends FreeCamera {
  129769. /**
  129770. * Creates a new AnaglyphFreeCamera
  129771. * @param name defines camera name
  129772. * @param position defines initial position
  129773. * @param interaxialDistance defines distance between each color axis
  129774. * @param scene defines the hosting scene
  129775. */
  129776. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  129777. /**
  129778. * Gets camera class name
  129779. * @returns AnaglyphFreeCamera
  129780. */
  129781. getClassName(): string;
  129782. }
  129783. }
  129784. declare module BABYLON {
  129785. /**
  129786. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  129787. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129788. */
  129789. export class AnaglyphGamepadCamera extends GamepadCamera {
  129790. /**
  129791. * Creates a new AnaglyphGamepadCamera
  129792. * @param name defines camera name
  129793. * @param position defines initial position
  129794. * @param interaxialDistance defines distance between each color axis
  129795. * @param scene defines the hosting scene
  129796. */
  129797. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  129798. /**
  129799. * Gets camera class name
  129800. * @returns AnaglyphGamepadCamera
  129801. */
  129802. getClassName(): string;
  129803. }
  129804. }
  129805. declare module BABYLON {
  129806. /**
  129807. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  129808. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129809. */
  129810. export class AnaglyphUniversalCamera extends UniversalCamera {
  129811. /**
  129812. * Creates a new AnaglyphUniversalCamera
  129813. * @param name defines camera name
  129814. * @param position defines initial position
  129815. * @param interaxialDistance defines distance between each color axis
  129816. * @param scene defines the hosting scene
  129817. */
  129818. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  129819. /**
  129820. * Gets camera class name
  129821. * @returns AnaglyphUniversalCamera
  129822. */
  129823. getClassName(): string;
  129824. }
  129825. }
  129826. declare module BABYLON {
  129827. /**
  129828. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  129829. * @see https://doc.babylonjs.com/features/cameras
  129830. */
  129831. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  129832. /**
  129833. * Creates a new StereoscopicArcRotateCamera
  129834. * @param name defines camera name
  129835. * @param alpha defines alpha angle (in radians)
  129836. * @param beta defines beta angle (in radians)
  129837. * @param radius defines radius
  129838. * @param target defines camera target
  129839. * @param interaxialDistance defines distance between each color axis
  129840. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  129841. * @param scene defines the hosting scene
  129842. */
  129843. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  129844. /**
  129845. * Gets camera class name
  129846. * @returns StereoscopicArcRotateCamera
  129847. */
  129848. getClassName(): string;
  129849. }
  129850. }
  129851. declare module BABYLON {
  129852. /**
  129853. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  129854. * @see https://doc.babylonjs.com/features/cameras
  129855. */
  129856. export class StereoscopicFreeCamera extends FreeCamera {
  129857. /**
  129858. * Creates a new StereoscopicFreeCamera
  129859. * @param name defines camera name
  129860. * @param position defines initial position
  129861. * @param interaxialDistance defines distance between each color axis
  129862. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  129863. * @param scene defines the hosting scene
  129864. */
  129865. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  129866. /**
  129867. * Gets camera class name
  129868. * @returns StereoscopicFreeCamera
  129869. */
  129870. getClassName(): string;
  129871. }
  129872. }
  129873. declare module BABYLON {
  129874. /**
  129875. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  129876. * @see https://doc.babylonjs.com/features/cameras
  129877. */
  129878. export class StereoscopicGamepadCamera extends GamepadCamera {
  129879. /**
  129880. * Creates a new StereoscopicGamepadCamera
  129881. * @param name defines camera name
  129882. * @param position defines initial position
  129883. * @param interaxialDistance defines distance between each color axis
  129884. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  129885. * @param scene defines the hosting scene
  129886. */
  129887. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  129888. /**
  129889. * Gets camera class name
  129890. * @returns StereoscopicGamepadCamera
  129891. */
  129892. getClassName(): string;
  129893. }
  129894. }
  129895. declare module BABYLON {
  129896. /**
  129897. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  129898. * @see https://doc.babylonjs.com/features/cameras
  129899. */
  129900. export class StereoscopicUniversalCamera extends UniversalCamera {
  129901. /**
  129902. * Creates a new StereoscopicUniversalCamera
  129903. * @param name defines camera name
  129904. * @param position defines initial position
  129905. * @param interaxialDistance defines distance between each color axis
  129906. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  129907. * @param scene defines the hosting scene
  129908. */
  129909. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  129910. /**
  129911. * Gets camera class name
  129912. * @returns StereoscopicUniversalCamera
  129913. */
  129914. getClassName(): string;
  129915. }
  129916. }
  129917. declare module BABYLON {
  129918. /**
  129919. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  129920. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  129921. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  129922. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  129923. */
  129924. export class VirtualJoysticksCamera extends FreeCamera {
  129925. /**
  129926. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  129927. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  129928. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  129929. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  129930. * @param name Define the name of the camera in the scene
  129931. * @param position Define the start position of the camera in the scene
  129932. * @param scene Define the scene the camera belongs to
  129933. */
  129934. constructor(name: string, position: Vector3, scene: Scene);
  129935. /**
  129936. * Gets the current object class name.
  129937. * @return the class name
  129938. */
  129939. getClassName(): string;
  129940. }
  129941. }
  129942. declare module BABYLON {
  129943. /**
  129944. * This represents all the required metrics to create a VR camera.
  129945. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  129946. */
  129947. export class VRCameraMetrics {
  129948. /**
  129949. * Define the horizontal resolution off the screen.
  129950. */
  129951. hResolution: number;
  129952. /**
  129953. * Define the vertical resolution off the screen.
  129954. */
  129955. vResolution: number;
  129956. /**
  129957. * Define the horizontal screen size.
  129958. */
  129959. hScreenSize: number;
  129960. /**
  129961. * Define the vertical screen size.
  129962. */
  129963. vScreenSize: number;
  129964. /**
  129965. * Define the vertical screen center position.
  129966. */
  129967. vScreenCenter: number;
  129968. /**
  129969. * Define the distance of the eyes to the screen.
  129970. */
  129971. eyeToScreenDistance: number;
  129972. /**
  129973. * Define the distance between both lenses
  129974. */
  129975. lensSeparationDistance: number;
  129976. /**
  129977. * Define the distance between both viewer's eyes.
  129978. */
  129979. interpupillaryDistance: number;
  129980. /**
  129981. * Define the distortion factor of the VR postprocess.
  129982. * Please, touch with care.
  129983. */
  129984. distortionK: number[];
  129985. /**
  129986. * Define the chromatic aberration correction factors for the VR post process.
  129987. */
  129988. chromaAbCorrection: number[];
  129989. /**
  129990. * Define the scale factor of the post process.
  129991. * The smaller the better but the slower.
  129992. */
  129993. postProcessScaleFactor: number;
  129994. /**
  129995. * Define an offset for the lens center.
  129996. */
  129997. lensCenterOffset: number;
  129998. /**
  129999. * Define if the current vr camera should compensate the distortion of the lense or not.
  130000. */
  130001. compensateDistortion: boolean;
  130002. /**
  130003. * Defines if multiview should be enabled when rendering (Default: false)
  130004. */
  130005. multiviewEnabled: boolean;
  130006. /**
  130007. * Gets the rendering aspect ratio based on the provided resolutions.
  130008. */
  130009. get aspectRatio(): number;
  130010. /**
  130011. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  130012. */
  130013. get aspectRatioFov(): number;
  130014. /**
  130015. * @hidden
  130016. */
  130017. get leftHMatrix(): Matrix;
  130018. /**
  130019. * @hidden
  130020. */
  130021. get rightHMatrix(): Matrix;
  130022. /**
  130023. * @hidden
  130024. */
  130025. get leftPreViewMatrix(): Matrix;
  130026. /**
  130027. * @hidden
  130028. */
  130029. get rightPreViewMatrix(): Matrix;
  130030. /**
  130031. * Get the default VRMetrics based on the most generic setup.
  130032. * @returns the default vr metrics
  130033. */
  130034. static GetDefault(): VRCameraMetrics;
  130035. }
  130036. }
  130037. declare module BABYLON {
  130038. /** @hidden */
  130039. export var vrDistortionCorrectionPixelShader: {
  130040. name: string;
  130041. shader: string;
  130042. };
  130043. }
  130044. declare module BABYLON {
  130045. /**
  130046. * VRDistortionCorrectionPostProcess used for mobile VR
  130047. */
  130048. export class VRDistortionCorrectionPostProcess extends PostProcess {
  130049. private _isRightEye;
  130050. private _distortionFactors;
  130051. private _postProcessScaleFactor;
  130052. private _lensCenterOffset;
  130053. private _scaleIn;
  130054. private _scaleFactor;
  130055. private _lensCenter;
  130056. /**
  130057. * Gets a string identifying the name of the class
  130058. * @returns "VRDistortionCorrectionPostProcess" string
  130059. */
  130060. getClassName(): string;
  130061. /**
  130062. * Initializes the VRDistortionCorrectionPostProcess
  130063. * @param name The name of the effect.
  130064. * @param camera The camera to apply the render pass to.
  130065. * @param isRightEye If this is for the right eye distortion
  130066. * @param vrMetrics All the required metrics for the VR camera
  130067. */
  130068. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  130069. }
  130070. }
  130071. declare module BABYLON {
  130072. /**
  130073. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  130074. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130075. */
  130076. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  130077. /**
  130078. * Creates a new VRDeviceOrientationArcRotateCamera
  130079. * @param name defines camera name
  130080. * @param alpha defines the camera rotation along the logitudinal axis
  130081. * @param beta defines the camera rotation along the latitudinal axis
  130082. * @param radius defines the camera distance from its target
  130083. * @param target defines the camera target
  130084. * @param scene defines the scene the camera belongs to
  130085. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130086. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130087. */
  130088. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130089. /**
  130090. * Gets camera class name
  130091. * @returns VRDeviceOrientationArcRotateCamera
  130092. */
  130093. getClassName(): string;
  130094. }
  130095. }
  130096. declare module BABYLON {
  130097. /**
  130098. * Camera used to simulate VR rendering (based on FreeCamera)
  130099. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130100. */
  130101. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  130102. /**
  130103. * Creates a new VRDeviceOrientationFreeCamera
  130104. * @param name defines camera name
  130105. * @param position defines the start position of the camera
  130106. * @param scene defines the scene the camera belongs to
  130107. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130108. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130109. */
  130110. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130111. /**
  130112. * Gets camera class name
  130113. * @returns VRDeviceOrientationFreeCamera
  130114. */
  130115. getClassName(): string;
  130116. }
  130117. }
  130118. declare module BABYLON {
  130119. /**
  130120. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  130121. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130122. */
  130123. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  130124. /**
  130125. * Creates a new VRDeviceOrientationGamepadCamera
  130126. * @param name defines camera name
  130127. * @param position defines the start position of the camera
  130128. * @param scene defines the scene the camera belongs to
  130129. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130130. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130131. */
  130132. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130133. /**
  130134. * Gets camera class name
  130135. * @returns VRDeviceOrientationGamepadCamera
  130136. */
  130137. getClassName(): string;
  130138. }
  130139. }
  130140. declare module BABYLON {
  130141. /**
  130142. * A class extending Texture allowing drawing on a texture
  130143. * @see https://doc.babylonjs.com/how_to/dynamictexture
  130144. */
  130145. export class DynamicTexture extends Texture {
  130146. private _generateMipMaps;
  130147. private _canvas;
  130148. private _context;
  130149. /**
  130150. * Creates a DynamicTexture
  130151. * @param name defines the name of the texture
  130152. * @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
  130153. * @param scene defines the scene where you want the texture
  130154. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  130155. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130156. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  130157. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  130158. */
  130159. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  130160. /**
  130161. * Get the current class name of the texture useful for serialization or dynamic coding.
  130162. * @returns "DynamicTexture"
  130163. */
  130164. getClassName(): string;
  130165. /**
  130166. * Gets the current state of canRescale
  130167. */
  130168. get canRescale(): boolean;
  130169. private _recreate;
  130170. /**
  130171. * Scales the texture
  130172. * @param ratio the scale factor to apply to both width and height
  130173. */
  130174. scale(ratio: number): void;
  130175. /**
  130176. * Resizes the texture
  130177. * @param width the new width
  130178. * @param height the new height
  130179. */
  130180. scaleTo(width: number, height: number): void;
  130181. /**
  130182. * Gets the context of the canvas used by the texture
  130183. * @returns the canvas context of the dynamic texture
  130184. */
  130185. getContext(): CanvasRenderingContext2D;
  130186. /**
  130187. * Clears the texture
  130188. */
  130189. clear(): void;
  130190. /**
  130191. * Updates the texture
  130192. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130193. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  130194. */
  130195. update(invertY?: boolean, premulAlpha?: boolean): void;
  130196. /**
  130197. * Draws text onto the texture
  130198. * @param text defines the text to be drawn
  130199. * @param x defines the placement of the text from the left
  130200. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  130201. * @param font defines the font to be used with font-style, font-size, font-name
  130202. * @param color defines the color used for the text
  130203. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  130204. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130205. * @param update defines whether texture is immediately update (default is true)
  130206. */
  130207. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  130208. /**
  130209. * Clones the texture
  130210. * @returns the clone of the texture.
  130211. */
  130212. clone(): DynamicTexture;
  130213. /**
  130214. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  130215. * @returns a serialized dynamic texture object
  130216. */
  130217. serialize(): any;
  130218. private _IsCanvasElement;
  130219. /** @hidden */
  130220. _rebuild(): void;
  130221. }
  130222. }
  130223. declare module BABYLON {
  130224. /**
  130225. * Class containing static functions to help procedurally build meshes
  130226. */
  130227. export class GroundBuilder {
  130228. /**
  130229. * Creates a ground mesh
  130230. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  130231. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  130232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130233. * @param name defines the name of the mesh
  130234. * @param options defines the options used to create the mesh
  130235. * @param scene defines the hosting scene
  130236. * @returns the ground mesh
  130237. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  130238. */
  130239. static CreateGround(name: string, options: {
  130240. width?: number;
  130241. height?: number;
  130242. subdivisions?: number;
  130243. subdivisionsX?: number;
  130244. subdivisionsY?: number;
  130245. updatable?: boolean;
  130246. }, scene: any): Mesh;
  130247. /**
  130248. * Creates a tiled ground mesh
  130249. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  130250. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  130251. * * 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
  130252. * * 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
  130253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130254. * @param name defines the name of the mesh
  130255. * @param options defines the options used to create the mesh
  130256. * @param scene defines the hosting scene
  130257. * @returns the tiled ground mesh
  130258. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  130259. */
  130260. static CreateTiledGround(name: string, options: {
  130261. xmin: number;
  130262. zmin: number;
  130263. xmax: number;
  130264. zmax: number;
  130265. subdivisions?: {
  130266. w: number;
  130267. h: number;
  130268. };
  130269. precision?: {
  130270. w: number;
  130271. h: number;
  130272. };
  130273. updatable?: boolean;
  130274. }, scene?: Nullable<Scene>): Mesh;
  130275. /**
  130276. * Creates a ground mesh from a height map
  130277. * * The parameter `url` sets the URL of the height map image resource.
  130278. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  130279. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  130280. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  130281. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  130282. * * 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.
  130283. * * 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).
  130284. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  130285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130286. * @param name defines the name of the mesh
  130287. * @param url defines the url to the height map
  130288. * @param options defines the options used to create the mesh
  130289. * @param scene defines the hosting scene
  130290. * @returns the ground mesh
  130291. * @see https://doc.babylonjs.com/babylon101/height_map
  130292. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  130293. */
  130294. static CreateGroundFromHeightMap(name: string, url: string, options: {
  130295. width?: number;
  130296. height?: number;
  130297. subdivisions?: number;
  130298. minHeight?: number;
  130299. maxHeight?: number;
  130300. colorFilter?: Color3;
  130301. alphaFilter?: number;
  130302. updatable?: boolean;
  130303. onReady?: (mesh: GroundMesh) => void;
  130304. }, scene?: Nullable<Scene>): GroundMesh;
  130305. }
  130306. }
  130307. declare module BABYLON {
  130308. /**
  130309. * Class containing static functions to help procedurally build meshes
  130310. */
  130311. export class TorusBuilder {
  130312. /**
  130313. * Creates a torus mesh
  130314. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  130315. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  130316. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  130317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130320. * @param name defines the name of the mesh
  130321. * @param options defines the options used to create the mesh
  130322. * @param scene defines the hosting scene
  130323. * @returns the torus mesh
  130324. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  130325. */
  130326. static CreateTorus(name: string, options: {
  130327. diameter?: number;
  130328. thickness?: number;
  130329. tessellation?: number;
  130330. updatable?: boolean;
  130331. sideOrientation?: number;
  130332. frontUVs?: Vector4;
  130333. backUVs?: Vector4;
  130334. }, scene: any): Mesh;
  130335. }
  130336. }
  130337. declare module BABYLON {
  130338. /**
  130339. * Class containing static functions to help procedurally build meshes
  130340. */
  130341. export class CylinderBuilder {
  130342. /**
  130343. * Creates a cylinder or a cone mesh
  130344. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  130345. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  130346. * * 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.
  130347. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  130348. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  130349. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  130350. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  130351. * * 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).
  130352. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  130353. * * 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).
  130354. * * 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
  130355. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  130356. * * 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
  130357. * * 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.
  130358. * * If `enclose` is false, a ring surface is one element.
  130359. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  130360. * * 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
  130361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130362. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130364. * @param name defines the name of the mesh
  130365. * @param options defines the options used to create the mesh
  130366. * @param scene defines the hosting scene
  130367. * @returns the cylinder mesh
  130368. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  130369. */
  130370. static CreateCylinder(name: string, options: {
  130371. height?: number;
  130372. diameterTop?: number;
  130373. diameterBottom?: number;
  130374. diameter?: number;
  130375. tessellation?: number;
  130376. subdivisions?: number;
  130377. arc?: number;
  130378. faceColors?: Color4[];
  130379. faceUV?: Vector4[];
  130380. updatable?: boolean;
  130381. hasRings?: boolean;
  130382. enclose?: boolean;
  130383. cap?: number;
  130384. sideOrientation?: number;
  130385. frontUVs?: Vector4;
  130386. backUVs?: Vector4;
  130387. }, scene: any): Mesh;
  130388. }
  130389. }
  130390. declare module BABYLON {
  130391. /**
  130392. * States of the webXR experience
  130393. */
  130394. export enum WebXRState {
  130395. /**
  130396. * Transitioning to being in XR mode
  130397. */
  130398. ENTERING_XR = 0,
  130399. /**
  130400. * Transitioning to non XR mode
  130401. */
  130402. EXITING_XR = 1,
  130403. /**
  130404. * In XR mode and presenting
  130405. */
  130406. IN_XR = 2,
  130407. /**
  130408. * Not entered XR mode
  130409. */
  130410. NOT_IN_XR = 3
  130411. }
  130412. /**
  130413. * Abstraction of the XR render target
  130414. */
  130415. export interface WebXRRenderTarget extends IDisposable {
  130416. /**
  130417. * xrpresent context of the canvas which can be used to display/mirror xr content
  130418. */
  130419. canvasContext: WebGLRenderingContext;
  130420. /**
  130421. * xr layer for the canvas
  130422. */
  130423. xrLayer: Nullable<XRWebGLLayer>;
  130424. /**
  130425. * Initializes the xr layer for the session
  130426. * @param xrSession xr session
  130427. * @returns a promise that will resolve once the XR Layer has been created
  130428. */
  130429. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130430. }
  130431. }
  130432. declare module BABYLON {
  130433. /**
  130434. * COnfiguration object for WebXR output canvas
  130435. */
  130436. export class WebXRManagedOutputCanvasOptions {
  130437. /**
  130438. * An optional canvas in case you wish to create it yourself and provide it here.
  130439. * If not provided, a new canvas will be created
  130440. */
  130441. canvasElement?: HTMLCanvasElement;
  130442. /**
  130443. * Options for this XR Layer output
  130444. */
  130445. canvasOptions?: XRWebGLLayerOptions;
  130446. /**
  130447. * CSS styling for a newly created canvas (if not provided)
  130448. */
  130449. newCanvasCssStyle?: string;
  130450. /**
  130451. * Get the default values of the configuration object
  130452. * @param engine defines the engine to use (can be null)
  130453. * @returns default values of this configuration object
  130454. */
  130455. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  130456. }
  130457. /**
  130458. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  130459. */
  130460. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  130461. private _options;
  130462. private _canvas;
  130463. private _engine;
  130464. private _originalCanvasSize;
  130465. /**
  130466. * Rendering context of the canvas which can be used to display/mirror xr content
  130467. */
  130468. canvasContext: WebGLRenderingContext;
  130469. /**
  130470. * xr layer for the canvas
  130471. */
  130472. xrLayer: Nullable<XRWebGLLayer>;
  130473. /**
  130474. * Obseervers registered here will be triggered when the xr layer was initialized
  130475. */
  130476. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  130477. /**
  130478. * Initializes the canvas to be added/removed upon entering/exiting xr
  130479. * @param _xrSessionManager The XR Session manager
  130480. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  130481. */
  130482. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  130483. /**
  130484. * Disposes of the object
  130485. */
  130486. dispose(): void;
  130487. /**
  130488. * Initializes the xr layer for the session
  130489. * @param xrSession xr session
  130490. * @returns a promise that will resolve once the XR Layer has been created
  130491. */
  130492. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130493. private _addCanvas;
  130494. private _removeCanvas;
  130495. private _setCanvasSize;
  130496. private _setManagedOutputCanvas;
  130497. }
  130498. }
  130499. declare module BABYLON {
  130500. /**
  130501. * Manages an XRSession to work with Babylon's engine
  130502. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  130503. */
  130504. export class WebXRSessionManager implements IDisposable {
  130505. /** The scene which the session should be created for */
  130506. scene: Scene;
  130507. private _referenceSpace;
  130508. private _rttProvider;
  130509. private _sessionEnded;
  130510. private _xrNavigator;
  130511. private baseLayer;
  130512. /**
  130513. * The base reference space from which the session started. good if you want to reset your
  130514. * reference space
  130515. */
  130516. baseReferenceSpace: XRReferenceSpace;
  130517. /**
  130518. * Current XR frame
  130519. */
  130520. currentFrame: Nullable<XRFrame>;
  130521. /** WebXR timestamp updated every frame */
  130522. currentTimestamp: number;
  130523. /**
  130524. * Used just in case of a failure to initialize an immersive session.
  130525. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  130526. */
  130527. defaultHeightCompensation: number;
  130528. /**
  130529. * Fires every time a new xrFrame arrives which can be used to update the camera
  130530. */
  130531. onXRFrameObservable: Observable<XRFrame>;
  130532. /**
  130533. * Fires when the reference space changed
  130534. */
  130535. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  130536. /**
  130537. * Fires when the xr session is ended either by the device or manually done
  130538. */
  130539. onXRSessionEnded: Observable<any>;
  130540. /**
  130541. * Fires when the xr session is ended either by the device or manually done
  130542. */
  130543. onXRSessionInit: Observable<XRSession>;
  130544. /**
  130545. * Underlying xr session
  130546. */
  130547. session: XRSession;
  130548. /**
  130549. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  130550. * or get the offset the player is currently at.
  130551. */
  130552. viewerReferenceSpace: XRReferenceSpace;
  130553. /**
  130554. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  130555. * @param scene The scene which the session should be created for
  130556. */
  130557. constructor(
  130558. /** The scene which the session should be created for */
  130559. scene: Scene);
  130560. /**
  130561. * The current reference space used in this session. This reference space can constantly change!
  130562. * It is mainly used to offset the camera's position.
  130563. */
  130564. get referenceSpace(): XRReferenceSpace;
  130565. /**
  130566. * Set a new reference space and triggers the observable
  130567. */
  130568. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  130569. /**
  130570. * Disposes of the session manager
  130571. */
  130572. dispose(): void;
  130573. /**
  130574. * Stops the xrSession and restores the render loop
  130575. * @returns Promise which resolves after it exits XR
  130576. */
  130577. exitXRAsync(): Promise<void>;
  130578. /**
  130579. * Gets the correct render target texture to be rendered this frame for this eye
  130580. * @param eye the eye for which to get the render target
  130581. * @returns the render target for the specified eye
  130582. */
  130583. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  130584. /**
  130585. * Creates a WebXRRenderTarget object for the XR session
  130586. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  130587. * @param options optional options to provide when creating a new render target
  130588. * @returns a WebXR render target to which the session can render
  130589. */
  130590. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  130591. /**
  130592. * Initializes the manager
  130593. * After initialization enterXR can be called to start an XR session
  130594. * @returns Promise which resolves after it is initialized
  130595. */
  130596. initializeAsync(): Promise<void>;
  130597. /**
  130598. * Initializes an xr session
  130599. * @param xrSessionMode mode to initialize
  130600. * @param xrSessionInit defines optional and required values to pass to the session builder
  130601. * @returns a promise which will resolve once the session has been initialized
  130602. */
  130603. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  130604. /**
  130605. * Checks if a session would be supported for the creation options specified
  130606. * @param sessionMode session mode to check if supported eg. immersive-vr
  130607. * @returns A Promise that resolves to true if supported and false if not
  130608. */
  130609. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130610. /**
  130611. * Resets the reference space to the one started the session
  130612. */
  130613. resetReferenceSpace(): void;
  130614. /**
  130615. * Starts rendering to the xr layer
  130616. */
  130617. runXRRenderLoop(): void;
  130618. /**
  130619. * Sets the reference space on the xr session
  130620. * @param referenceSpaceType space to set
  130621. * @returns a promise that will resolve once the reference space has been set
  130622. */
  130623. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130624. /**
  130625. * Updates the render state of the session
  130626. * @param state state to set
  130627. * @returns a promise that resolves once the render state has been updated
  130628. */
  130629. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  130630. /**
  130631. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  130632. * @param sessionMode defines the session to test
  130633. * @returns a promise with boolean as final value
  130634. */
  130635. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130636. private _createRenderTargetTexture;
  130637. }
  130638. }
  130639. declare module BABYLON {
  130640. /**
  130641. * WebXR Camera which holds the views for the xrSession
  130642. * @see https://doc.babylonjs.com/how_to/webxr_camera
  130643. */
  130644. export class WebXRCamera extends FreeCamera {
  130645. private _xrSessionManager;
  130646. private _firstFrame;
  130647. private _referenceQuaternion;
  130648. private _referencedPosition;
  130649. private _xrInvPositionCache;
  130650. private _xrInvQuaternionCache;
  130651. /**
  130652. * Observable raised before camera teleportation
  130653. */
  130654. onBeforeCameraTeleport: Observable<Vector3>;
  130655. /**
  130656. * Observable raised after camera teleportation
  130657. */
  130658. onAfterCameraTeleport: Observable<Vector3>;
  130659. /**
  130660. * Should position compensation execute on first frame.
  130661. * This is used when copying the position from a native (non XR) camera
  130662. */
  130663. compensateOnFirstFrame: boolean;
  130664. /**
  130665. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  130666. * @param name the name of the camera
  130667. * @param scene the scene to add the camera to
  130668. * @param _xrSessionManager a constructed xr session manager
  130669. */
  130670. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  130671. /**
  130672. * Return the user's height, unrelated to the current ground.
  130673. * This will be the y position of this camera, when ground level is 0.
  130674. */
  130675. get realWorldHeight(): number;
  130676. /** @hidden */
  130677. _updateForDualEyeDebugging(): void;
  130678. /**
  130679. * Sets this camera's transformation based on a non-vr camera
  130680. * @param otherCamera the non-vr camera to copy the transformation from
  130681. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  130682. */
  130683. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  130684. /**
  130685. * Gets the current instance class name ("WebXRCamera").
  130686. * @returns the class name
  130687. */
  130688. getClassName(): string;
  130689. private _rotate180;
  130690. private _updateFromXRSession;
  130691. private _updateNumberOfRigCameras;
  130692. private _updateReferenceSpace;
  130693. private _updateReferenceSpaceOffset;
  130694. }
  130695. }
  130696. declare module BABYLON {
  130697. /**
  130698. * Defining the interface required for a (webxr) feature
  130699. */
  130700. export interface IWebXRFeature extends IDisposable {
  130701. /**
  130702. * Is this feature attached
  130703. */
  130704. attached: boolean;
  130705. /**
  130706. * Should auto-attach be disabled?
  130707. */
  130708. disableAutoAttach: boolean;
  130709. /**
  130710. * Attach the feature to the session
  130711. * Will usually be called by the features manager
  130712. *
  130713. * @param force should attachment be forced (even when already attached)
  130714. * @returns true if successful.
  130715. */
  130716. attach(force?: boolean): boolean;
  130717. /**
  130718. * Detach the feature from the session
  130719. * Will usually be called by the features manager
  130720. *
  130721. * @returns true if successful.
  130722. */
  130723. detach(): boolean;
  130724. /**
  130725. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  130726. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  130727. *
  130728. * @returns whether or not the feature is compatible in this environment
  130729. */
  130730. isCompatible(): boolean;
  130731. /**
  130732. * Was this feature disposed;
  130733. */
  130734. isDisposed: boolean;
  130735. /**
  130736. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  130737. */
  130738. xrNativeFeatureName?: string;
  130739. /**
  130740. * A list of (Babylon WebXR) features this feature depends on
  130741. */
  130742. dependsOn?: string[];
  130743. }
  130744. /**
  130745. * A list of the currently available features without referencing them
  130746. */
  130747. export class WebXRFeatureName {
  130748. /**
  130749. * The name of the anchor system feature
  130750. */
  130751. static readonly ANCHOR_SYSTEM: string;
  130752. /**
  130753. * The name of the background remover feature
  130754. */
  130755. static readonly BACKGROUND_REMOVER: string;
  130756. /**
  130757. * The name of the hit test feature
  130758. */
  130759. static readonly HIT_TEST: string;
  130760. /**
  130761. * physics impostors for xr controllers feature
  130762. */
  130763. static readonly PHYSICS_CONTROLLERS: string;
  130764. /**
  130765. * The name of the plane detection feature
  130766. */
  130767. static readonly PLANE_DETECTION: string;
  130768. /**
  130769. * The name of the pointer selection feature
  130770. */
  130771. static readonly POINTER_SELECTION: string;
  130772. /**
  130773. * The name of the teleportation feature
  130774. */
  130775. static readonly TELEPORTATION: string;
  130776. /**
  130777. * The name of the feature points feature.
  130778. */
  130779. static readonly FEATURE_POINTS: string;
  130780. /**
  130781. * The name of the hand tracking feature.
  130782. */
  130783. static readonly HAND_TRACKING: string;
  130784. }
  130785. /**
  130786. * Defining the constructor of a feature. Used to register the modules.
  130787. */
  130788. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  130789. /**
  130790. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  130791. * It is mainly used in AR sessions.
  130792. *
  130793. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  130794. */
  130795. export class WebXRFeaturesManager implements IDisposable {
  130796. private _xrSessionManager;
  130797. private static readonly _AvailableFeatures;
  130798. private _features;
  130799. /**
  130800. * constructs a new features manages.
  130801. *
  130802. * @param _xrSessionManager an instance of WebXRSessionManager
  130803. */
  130804. constructor(_xrSessionManager: WebXRSessionManager);
  130805. /**
  130806. * Used to register a module. After calling this function a developer can use this feature in the scene.
  130807. * Mainly used internally.
  130808. *
  130809. * @param featureName the name of the feature to register
  130810. * @param constructorFunction the function used to construct the module
  130811. * @param version the (babylon) version of the module
  130812. * @param stable is that a stable version of this module
  130813. */
  130814. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  130815. /**
  130816. * Returns a constructor of a specific feature.
  130817. *
  130818. * @param featureName the name of the feature to construct
  130819. * @param version the version of the feature to load
  130820. * @param xrSessionManager the xrSessionManager. Used to construct the module
  130821. * @param options optional options provided to the module.
  130822. * @returns a function that, when called, will return a new instance of this feature
  130823. */
  130824. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  130825. /**
  130826. * Can be used to return the list of features currently registered
  130827. *
  130828. * @returns an Array of available features
  130829. */
  130830. static GetAvailableFeatures(): string[];
  130831. /**
  130832. * Gets the versions available for a specific feature
  130833. * @param featureName the name of the feature
  130834. * @returns an array with the available versions
  130835. */
  130836. static GetAvailableVersions(featureName: string): string[];
  130837. /**
  130838. * Return the latest unstable version of this feature
  130839. * @param featureName the name of the feature to search
  130840. * @returns the version number. if not found will return -1
  130841. */
  130842. static GetLatestVersionOfFeature(featureName: string): number;
  130843. /**
  130844. * Return the latest stable version of this feature
  130845. * @param featureName the name of the feature to search
  130846. * @returns the version number. if not found will return -1
  130847. */
  130848. static GetStableVersionOfFeature(featureName: string): number;
  130849. /**
  130850. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  130851. * Can be used during a session to start a feature
  130852. * @param featureName the name of feature to attach
  130853. */
  130854. attachFeature(featureName: string): void;
  130855. /**
  130856. * Can be used inside a session or when the session ends to detach a specific feature
  130857. * @param featureName the name of the feature to detach
  130858. */
  130859. detachFeature(featureName: string): void;
  130860. /**
  130861. * Used to disable an already-enabled feature
  130862. * The feature will be disposed and will be recreated once enabled.
  130863. * @param featureName the feature to disable
  130864. * @returns true if disable was successful
  130865. */
  130866. disableFeature(featureName: string | {
  130867. Name: string;
  130868. }): boolean;
  130869. /**
  130870. * dispose this features manager
  130871. */
  130872. dispose(): void;
  130873. /**
  130874. * 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.
  130875. * 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.
  130876. *
  130877. * @param featureName the name of the feature to load or the class of the feature
  130878. * @param version optional version to load. if not provided the latest version will be enabled
  130879. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  130880. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  130881. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  130882. * @returns a new constructed feature or throws an error if feature not found.
  130883. */
  130884. enableFeature(featureName: string | {
  130885. Name: string;
  130886. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  130887. /**
  130888. * get the implementation of an enabled feature.
  130889. * @param featureName the name of the feature to load
  130890. * @returns the feature class, if found
  130891. */
  130892. getEnabledFeature(featureName: string): IWebXRFeature;
  130893. /**
  130894. * Get the list of enabled features
  130895. * @returns an array of enabled features
  130896. */
  130897. getEnabledFeatures(): string[];
  130898. /**
  130899. * This function will exten the session creation configuration object with enabled features.
  130900. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  130901. * according to the defined "required" variable, provided during enableFeature call
  130902. * @param xrSessionInit the xr Session init object to extend
  130903. *
  130904. * @returns an extended XRSessionInit object
  130905. */
  130906. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  130907. }
  130908. }
  130909. declare module BABYLON {
  130910. /**
  130911. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  130912. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  130913. */
  130914. export class WebXRExperienceHelper implements IDisposable {
  130915. private scene;
  130916. private _nonVRCamera;
  130917. private _originalSceneAutoClear;
  130918. private _supported;
  130919. /**
  130920. * Camera used to render xr content
  130921. */
  130922. camera: WebXRCamera;
  130923. /** A features manager for this xr session */
  130924. featuresManager: WebXRFeaturesManager;
  130925. /**
  130926. * Observers registered here will be triggered after the camera's initial transformation is set
  130927. * This can be used to set a different ground level or an extra rotation.
  130928. *
  130929. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  130930. * to the position set after this observable is done executing.
  130931. */
  130932. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  130933. /**
  130934. * Fires when the state of the experience helper has changed
  130935. */
  130936. onStateChangedObservable: Observable<WebXRState>;
  130937. /** Session manager used to keep track of xr session */
  130938. sessionManager: WebXRSessionManager;
  130939. /**
  130940. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  130941. */
  130942. state: WebXRState;
  130943. /**
  130944. * Creates a WebXRExperienceHelper
  130945. * @param scene The scene the helper should be created in
  130946. */
  130947. private constructor();
  130948. /**
  130949. * Creates the experience helper
  130950. * @param scene the scene to attach the experience helper to
  130951. * @returns a promise for the experience helper
  130952. */
  130953. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  130954. /**
  130955. * Disposes of the experience helper
  130956. */
  130957. dispose(): void;
  130958. /**
  130959. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  130960. * @param sessionMode options for the XR session
  130961. * @param referenceSpaceType frame of reference of the XR session
  130962. * @param renderTarget the output canvas that will be used to enter XR mode
  130963. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  130964. * @returns promise that resolves after xr mode has entered
  130965. */
  130966. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  130967. /**
  130968. * Exits XR mode and returns the scene to its original state
  130969. * @returns promise that resolves after xr mode has exited
  130970. */
  130971. exitXRAsync(): Promise<void>;
  130972. private _nonXRToXRCamera;
  130973. private _setState;
  130974. }
  130975. }
  130976. declare module BABYLON {
  130977. /**
  130978. * X-Y values for axes in WebXR
  130979. */
  130980. export interface IWebXRMotionControllerAxesValue {
  130981. /**
  130982. * The value of the x axis
  130983. */
  130984. x: number;
  130985. /**
  130986. * The value of the y-axis
  130987. */
  130988. y: number;
  130989. }
  130990. /**
  130991. * changed / previous values for the values of this component
  130992. */
  130993. export interface IWebXRMotionControllerComponentChangesValues<T> {
  130994. /**
  130995. * current (this frame) value
  130996. */
  130997. current: T;
  130998. /**
  130999. * previous (last change) value
  131000. */
  131001. previous: T;
  131002. }
  131003. /**
  131004. * Represents changes in the component between current frame and last values recorded
  131005. */
  131006. export interface IWebXRMotionControllerComponentChanges {
  131007. /**
  131008. * will be populated with previous and current values if axes changed
  131009. */
  131010. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  131011. /**
  131012. * will be populated with previous and current values if pressed changed
  131013. */
  131014. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131015. /**
  131016. * will be populated with previous and current values if touched changed
  131017. */
  131018. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131019. /**
  131020. * will be populated with previous and current values if value changed
  131021. */
  131022. value?: IWebXRMotionControllerComponentChangesValues<number>;
  131023. }
  131024. /**
  131025. * This class represents a single component (for example button or thumbstick) of a motion controller
  131026. */
  131027. export class WebXRControllerComponent implements IDisposable {
  131028. /**
  131029. * the id of this component
  131030. */
  131031. id: string;
  131032. /**
  131033. * the type of the component
  131034. */
  131035. type: MotionControllerComponentType;
  131036. private _buttonIndex;
  131037. private _axesIndices;
  131038. private _axes;
  131039. private _changes;
  131040. private _currentValue;
  131041. private _hasChanges;
  131042. private _pressed;
  131043. private _touched;
  131044. /**
  131045. * button component type
  131046. */
  131047. static BUTTON_TYPE: MotionControllerComponentType;
  131048. /**
  131049. * squeeze component type
  131050. */
  131051. static SQUEEZE_TYPE: MotionControllerComponentType;
  131052. /**
  131053. * Thumbstick component type
  131054. */
  131055. static THUMBSTICK_TYPE: MotionControllerComponentType;
  131056. /**
  131057. * Touchpad component type
  131058. */
  131059. static TOUCHPAD_TYPE: MotionControllerComponentType;
  131060. /**
  131061. * trigger component type
  131062. */
  131063. static TRIGGER_TYPE: MotionControllerComponentType;
  131064. /**
  131065. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  131066. * the axes data changes
  131067. */
  131068. onAxisValueChangedObservable: Observable<{
  131069. x: number;
  131070. y: number;
  131071. }>;
  131072. /**
  131073. * Observers registered here will be triggered when the state of a button changes
  131074. * State change is either pressed / touched / value
  131075. */
  131076. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  131077. /**
  131078. * Creates a new component for a motion controller.
  131079. * It is created by the motion controller itself
  131080. *
  131081. * @param id the id of this component
  131082. * @param type the type of the component
  131083. * @param _buttonIndex index in the buttons array of the gamepad
  131084. * @param _axesIndices indices of the values in the axes array of the gamepad
  131085. */
  131086. constructor(
  131087. /**
  131088. * the id of this component
  131089. */
  131090. id: string,
  131091. /**
  131092. * the type of the component
  131093. */
  131094. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  131095. /**
  131096. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  131097. */
  131098. get axes(): IWebXRMotionControllerAxesValue;
  131099. /**
  131100. * Get the changes. Elements will be populated only if they changed with their previous and current value
  131101. */
  131102. get changes(): IWebXRMotionControllerComponentChanges;
  131103. /**
  131104. * Return whether or not the component changed the last frame
  131105. */
  131106. get hasChanges(): boolean;
  131107. /**
  131108. * is the button currently pressed
  131109. */
  131110. get pressed(): boolean;
  131111. /**
  131112. * is the button currently touched
  131113. */
  131114. get touched(): boolean;
  131115. /**
  131116. * Get the current value of this component
  131117. */
  131118. get value(): number;
  131119. /**
  131120. * Dispose this component
  131121. */
  131122. dispose(): void;
  131123. /**
  131124. * Are there axes correlating to this component
  131125. * @return true is axes data is available
  131126. */
  131127. isAxes(): boolean;
  131128. /**
  131129. * Is this component a button (hence - pressable)
  131130. * @returns true if can be pressed
  131131. */
  131132. isButton(): boolean;
  131133. /**
  131134. * update this component using the gamepad object it is in. Called on every frame
  131135. * @param nativeController the native gamepad controller object
  131136. */
  131137. update(nativeController: IMinimalMotionControllerObject): void;
  131138. }
  131139. }
  131140. declare module BABYLON {
  131141. /**
  131142. * Interface used to represent data loading progression
  131143. */
  131144. export interface ISceneLoaderProgressEvent {
  131145. /**
  131146. * Defines if data length to load can be evaluated
  131147. */
  131148. readonly lengthComputable: boolean;
  131149. /**
  131150. * Defines the loaded data length
  131151. */
  131152. readonly loaded: number;
  131153. /**
  131154. * Defines the data length to load
  131155. */
  131156. readonly total: number;
  131157. }
  131158. /**
  131159. * Interface used by SceneLoader plugins to define supported file extensions
  131160. */
  131161. export interface ISceneLoaderPluginExtensions {
  131162. /**
  131163. * Defines the list of supported extensions
  131164. */
  131165. [extension: string]: {
  131166. isBinary: boolean;
  131167. };
  131168. }
  131169. /**
  131170. * Interface used by SceneLoader plugin factory
  131171. */
  131172. export interface ISceneLoaderPluginFactory {
  131173. /**
  131174. * Defines the name of the factory
  131175. */
  131176. name: string;
  131177. /**
  131178. * Function called to create a new plugin
  131179. * @return the new plugin
  131180. */
  131181. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  131182. /**
  131183. * The callback that returns true if the data can be directly loaded.
  131184. * @param data string containing the file data
  131185. * @returns if the data can be loaded directly
  131186. */
  131187. canDirectLoad?(data: string): boolean;
  131188. }
  131189. /**
  131190. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  131191. */
  131192. export interface ISceneLoaderPluginBase {
  131193. /**
  131194. * The friendly name of this plugin.
  131195. */
  131196. name: string;
  131197. /**
  131198. * The file extensions supported by this plugin.
  131199. */
  131200. extensions: string | ISceneLoaderPluginExtensions;
  131201. /**
  131202. * The callback called when loading from a url.
  131203. * @param scene scene loading this url
  131204. * @param url url to load
  131205. * @param onSuccess callback called when the file successfully loads
  131206. * @param onProgress callback called while file is loading (if the server supports this mode)
  131207. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  131208. * @param onError callback called when the file fails to load
  131209. * @returns a file request object
  131210. */
  131211. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131212. /**
  131213. * The callback called when loading from a file object.
  131214. * @param scene scene loading this file
  131215. * @param file defines the file to load
  131216. * @param onSuccess defines the callback to call when data is loaded
  131217. * @param onProgress defines the callback to call during loading process
  131218. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  131219. * @param onError defines the callback to call when an error occurs
  131220. * @returns a file request object
  131221. */
  131222. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131223. /**
  131224. * The callback that returns true if the data can be directly loaded.
  131225. * @param data string containing the file data
  131226. * @returns if the data can be loaded directly
  131227. */
  131228. canDirectLoad?(data: string): boolean;
  131229. /**
  131230. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  131231. * @param scene scene loading this data
  131232. * @param data string containing the data
  131233. * @returns data to pass to the plugin
  131234. */
  131235. directLoad?(scene: Scene, data: string): any;
  131236. /**
  131237. * The callback that allows custom handling of the root url based on the response url.
  131238. * @param rootUrl the original root url
  131239. * @param responseURL the response url if available
  131240. * @returns the new root url
  131241. */
  131242. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  131243. }
  131244. /**
  131245. * Interface used to define a SceneLoader plugin
  131246. */
  131247. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  131248. /**
  131249. * Import meshes into a scene.
  131250. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131251. * @param scene The scene to import into
  131252. * @param data The data to import
  131253. * @param rootUrl The root url for scene and resources
  131254. * @param meshes The meshes array to import into
  131255. * @param particleSystems The particle systems array to import into
  131256. * @param skeletons The skeletons array to import into
  131257. * @param onError The callback when import fails
  131258. * @returns True if successful or false otherwise
  131259. */
  131260. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  131261. /**
  131262. * Load into a scene.
  131263. * @param scene The scene to load into
  131264. * @param data The data to import
  131265. * @param rootUrl The root url for scene and resources
  131266. * @param onError The callback when import fails
  131267. * @returns True if successful or false otherwise
  131268. */
  131269. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  131270. /**
  131271. * Load into an asset container.
  131272. * @param scene The scene to load into
  131273. * @param data The data to import
  131274. * @param rootUrl The root url for scene and resources
  131275. * @param onError The callback when import fails
  131276. * @returns The loaded asset container
  131277. */
  131278. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  131279. }
  131280. /**
  131281. * Interface used to define an async SceneLoader plugin
  131282. */
  131283. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  131284. /**
  131285. * Import meshes into a scene.
  131286. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131287. * @param scene The scene to import into
  131288. * @param data The data to import
  131289. * @param rootUrl The root url for scene and resources
  131290. * @param onProgress The callback when the load progresses
  131291. * @param fileName Defines the name of the file to load
  131292. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  131293. */
  131294. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  131295. meshes: AbstractMesh[];
  131296. particleSystems: IParticleSystem[];
  131297. skeletons: Skeleton[];
  131298. animationGroups: AnimationGroup[];
  131299. }>;
  131300. /**
  131301. * Load into a scene.
  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 Nothing
  131308. */
  131309. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  131310. /**
  131311. * Load into an asset container.
  131312. * @param scene The scene to load into
  131313. * @param data The data to import
  131314. * @param rootUrl The root url for scene and resources
  131315. * @param onProgress The callback when the load progresses
  131316. * @param fileName Defines the name of the file to load
  131317. * @returns The loaded asset container
  131318. */
  131319. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  131320. }
  131321. /**
  131322. * Mode that determines how to handle old animation groups before loading new ones.
  131323. */
  131324. export enum SceneLoaderAnimationGroupLoadingMode {
  131325. /**
  131326. * Reset all old animations to initial state then dispose them.
  131327. */
  131328. Clean = 0,
  131329. /**
  131330. * Stop all old animations.
  131331. */
  131332. Stop = 1,
  131333. /**
  131334. * Restart old animations from first frame.
  131335. */
  131336. Sync = 2,
  131337. /**
  131338. * Old animations remains untouched.
  131339. */
  131340. NoSync = 3
  131341. }
  131342. /**
  131343. * Defines a plugin registered by the SceneLoader
  131344. */
  131345. interface IRegisteredPlugin {
  131346. /**
  131347. * Defines the plugin to use
  131348. */
  131349. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131350. /**
  131351. * Defines if the plugin supports binary data
  131352. */
  131353. isBinary: boolean;
  131354. }
  131355. /**
  131356. * Class used to load scene from various file formats using registered plugins
  131357. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  131358. */
  131359. export class SceneLoader {
  131360. /**
  131361. * No logging while loading
  131362. */
  131363. static readonly NO_LOGGING: number;
  131364. /**
  131365. * Minimal logging while loading
  131366. */
  131367. static readonly MINIMAL_LOGGING: number;
  131368. /**
  131369. * Summary logging while loading
  131370. */
  131371. static readonly SUMMARY_LOGGING: number;
  131372. /**
  131373. * Detailled logging while loading
  131374. */
  131375. static readonly DETAILED_LOGGING: number;
  131376. /**
  131377. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  131378. */
  131379. static get ForceFullSceneLoadingForIncremental(): boolean;
  131380. static set ForceFullSceneLoadingForIncremental(value: boolean);
  131381. /**
  131382. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  131383. */
  131384. static get ShowLoadingScreen(): boolean;
  131385. static set ShowLoadingScreen(value: boolean);
  131386. /**
  131387. * Defines the current logging level (while loading the scene)
  131388. * @ignorenaming
  131389. */
  131390. static get loggingLevel(): number;
  131391. static set loggingLevel(value: number);
  131392. /**
  131393. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  131394. */
  131395. static get CleanBoneMatrixWeights(): boolean;
  131396. static set CleanBoneMatrixWeights(value: boolean);
  131397. /**
  131398. * Event raised when a plugin is used to load a scene
  131399. */
  131400. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  131401. private static _registeredPlugins;
  131402. private static _showingLoadingScreen;
  131403. /**
  131404. * Gets the default plugin (used to load Babylon files)
  131405. * @returns the .babylon plugin
  131406. */
  131407. static GetDefaultPlugin(): IRegisteredPlugin;
  131408. private static _GetPluginForExtension;
  131409. private static _GetPluginForDirectLoad;
  131410. private static _GetPluginForFilename;
  131411. private static _GetDirectLoad;
  131412. private static _LoadData;
  131413. private static _GetFileInfo;
  131414. /**
  131415. * Gets a plugin that can load the given extension
  131416. * @param extension defines the extension to load
  131417. * @returns a plugin or null if none works
  131418. */
  131419. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131420. /**
  131421. * Gets a boolean indicating that the given extension can be loaded
  131422. * @param extension defines the extension to load
  131423. * @returns true if the extension is supported
  131424. */
  131425. static IsPluginForExtensionAvailable(extension: string): boolean;
  131426. /**
  131427. * Adds a new plugin to the list of registered plugins
  131428. * @param plugin defines the plugin to add
  131429. */
  131430. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  131431. /**
  131432. * Import meshes into a scene
  131433. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131434. * @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)
  131435. * @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)
  131436. * @param scene the instance of BABYLON.Scene to append to
  131437. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  131438. * @param onProgress a callback with a progress event for each file being loaded
  131439. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131440. * @param pluginExtension the extension used to determine the plugin
  131441. * @returns The loaded plugin
  131442. */
  131443. 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>;
  131444. /**
  131445. * Import meshes into a scene
  131446. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131447. * @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)
  131448. * @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)
  131449. * @param scene the instance of BABYLON.Scene to append to
  131450. * @param onProgress a callback with a progress event for each file being loaded
  131451. * @param pluginExtension the extension used to determine the plugin
  131452. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  131453. */
  131454. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  131455. meshes: AbstractMesh[];
  131456. particleSystems: IParticleSystem[];
  131457. skeletons: Skeleton[];
  131458. animationGroups: AnimationGroup[];
  131459. }>;
  131460. /**
  131461. * Load a scene
  131462. * @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)
  131463. * @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)
  131464. * @param engine is the instance of BABYLON.Engine to use to create the scene
  131465. * @param onSuccess a callback with the scene when import succeeds
  131466. * @param onProgress a callback with a progress event for each file being loaded
  131467. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131468. * @param pluginExtension the extension used to determine the plugin
  131469. * @returns The loaded plugin
  131470. */
  131471. 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>;
  131472. /**
  131473. * Load 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 engine is the instance of BABYLON.Engine to use to create the scene
  131477. * @param onProgress a callback with a progress event for each file being loaded
  131478. * @param pluginExtension the extension used to determine the plugin
  131479. * @returns The loaded scene
  131480. */
  131481. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131482. /**
  131483. * Append a scene
  131484. * @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)
  131485. * @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)
  131486. * @param scene is the instance of BABYLON.Scene to append to
  131487. * @param onSuccess a callback with the scene when import succeeds
  131488. * @param onProgress a callback with a progress event for each file being loaded
  131489. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131490. * @param pluginExtension the extension used to determine the plugin
  131491. * @returns The loaded plugin
  131492. */
  131493. 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>;
  131494. /**
  131495. * Append a scene
  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
  131499. * @param onProgress a callback with a progress event for each file being loaded
  131500. * @param pluginExtension the extension used to determine the plugin
  131501. * @returns The given scene
  131502. */
  131503. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131504. /**
  131505. * Load a scene into an asset container
  131506. * @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)
  131507. * @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)
  131508. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131509. * @param onSuccess a callback with the scene when import succeeds
  131510. * @param onProgress a callback with a progress event for each file being loaded
  131511. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131512. * @param pluginExtension the extension used to determine the plugin
  131513. * @returns The loaded plugin
  131514. */
  131515. 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>;
  131516. /**
  131517. * Load a scene into an asset container
  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 (default: empty string)
  131520. * @param scene is the instance of Scene to append to
  131521. * @param onProgress a callback with a progress event for each file being loaded
  131522. * @param pluginExtension the extension used to determine the plugin
  131523. * @returns The loaded asset container
  131524. */
  131525. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  131526. /**
  131527. * Import animations from a file into a scene
  131528. * @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)
  131529. * @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)
  131530. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131531. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131532. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131533. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131534. * @param onSuccess a callback with the scene when import succeeds
  131535. * @param onProgress a callback with a progress event for each file being loaded
  131536. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131537. * @param pluginExtension the extension used to determine the plugin
  131538. */
  131539. 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;
  131540. /**
  131541. * Import animations from a file into a scene
  131542. * @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)
  131543. * @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)
  131544. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131545. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131546. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131547. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131548. * @param onSuccess a callback with the scene when import succeeds
  131549. * @param onProgress a callback with a progress event for each file being loaded
  131550. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131551. * @param pluginExtension the extension used to determine the plugin
  131552. * @returns the updated scene with imported animations
  131553. */
  131554. 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>;
  131555. }
  131556. }
  131557. declare module BABYLON {
  131558. /**
  131559. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  131560. */
  131561. export type MotionControllerHandedness = "none" | "left" | "right";
  131562. /**
  131563. * The type of components available in motion controllers.
  131564. * This is not the name of the component.
  131565. */
  131566. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  131567. /**
  131568. * The state of a controller component
  131569. */
  131570. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  131571. /**
  131572. * The schema of motion controller layout.
  131573. * No object will be initialized using this interface
  131574. * This is used just to define the profile.
  131575. */
  131576. export interface IMotionControllerLayout {
  131577. /**
  131578. * Path to load the assets. Usually relative to the base path
  131579. */
  131580. assetPath: string;
  131581. /**
  131582. * Available components (unsorted)
  131583. */
  131584. components: {
  131585. /**
  131586. * A map of component Ids
  131587. */
  131588. [componentId: string]: {
  131589. /**
  131590. * The type of input the component outputs
  131591. */
  131592. type: MotionControllerComponentType;
  131593. /**
  131594. * The indices of this component in the gamepad object
  131595. */
  131596. gamepadIndices: {
  131597. /**
  131598. * Index of button
  131599. */
  131600. button?: number;
  131601. /**
  131602. * If available, index of x-axis
  131603. */
  131604. xAxis?: number;
  131605. /**
  131606. * If available, index of y-axis
  131607. */
  131608. yAxis?: number;
  131609. };
  131610. /**
  131611. * The mesh's root node name
  131612. */
  131613. rootNodeName: string;
  131614. /**
  131615. * Animation definitions for this model
  131616. */
  131617. visualResponses: {
  131618. [stateKey: string]: {
  131619. /**
  131620. * What property will be animated
  131621. */
  131622. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  131623. /**
  131624. * What states influence this visual response
  131625. */
  131626. states: MotionControllerComponentStateType[];
  131627. /**
  131628. * Type of animation - movement or visibility
  131629. */
  131630. valueNodeProperty: "transform" | "visibility";
  131631. /**
  131632. * Base node name to move. Its position will be calculated according to the min and max nodes
  131633. */
  131634. valueNodeName?: string;
  131635. /**
  131636. * Minimum movement node
  131637. */
  131638. minNodeName?: string;
  131639. /**
  131640. * Max movement node
  131641. */
  131642. maxNodeName?: string;
  131643. };
  131644. };
  131645. /**
  131646. * If touch enabled, what is the name of node to display user feedback
  131647. */
  131648. touchPointNodeName?: string;
  131649. };
  131650. };
  131651. /**
  131652. * Is it xr standard mapping or not
  131653. */
  131654. gamepadMapping: "" | "xr-standard";
  131655. /**
  131656. * Base root node of this entire model
  131657. */
  131658. rootNodeName: string;
  131659. /**
  131660. * Defines the main button component id
  131661. */
  131662. selectComponentId: string;
  131663. }
  131664. /**
  131665. * A definition for the layout map in the input profile
  131666. */
  131667. export interface IMotionControllerLayoutMap {
  131668. /**
  131669. * Layouts with handedness type as a key
  131670. */
  131671. [handedness: string]: IMotionControllerLayout;
  131672. }
  131673. /**
  131674. * The XR Input profile schema
  131675. * Profiles can be found here:
  131676. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  131677. */
  131678. export interface IMotionControllerProfile {
  131679. /**
  131680. * fallback profiles for this profileId
  131681. */
  131682. fallbackProfileIds: string[];
  131683. /**
  131684. * The layout map, with handedness as key
  131685. */
  131686. layouts: IMotionControllerLayoutMap;
  131687. /**
  131688. * The id of this profile
  131689. * correlates to the profile(s) in the xrInput.profiles array
  131690. */
  131691. profileId: string;
  131692. }
  131693. /**
  131694. * A helper-interface for the 3 meshes needed for controller button animation
  131695. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  131696. */
  131697. export interface IMotionControllerButtonMeshMap {
  131698. /**
  131699. * the mesh that defines the pressed value mesh position.
  131700. * This is used to find the max-position of this button
  131701. */
  131702. pressedMesh: AbstractMesh;
  131703. /**
  131704. * the mesh that defines the unpressed value mesh position.
  131705. * This is used to find the min (or initial) position of this button
  131706. */
  131707. unpressedMesh: AbstractMesh;
  131708. /**
  131709. * The mesh that will be changed when value changes
  131710. */
  131711. valueMesh: AbstractMesh;
  131712. }
  131713. /**
  131714. * A helper-interface for the 3 meshes needed for controller axis animation.
  131715. * This will be expanded when touchpad animations are fully supported
  131716. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  131717. */
  131718. export interface IMotionControllerMeshMap {
  131719. /**
  131720. * the mesh that defines the maximum value mesh position.
  131721. */
  131722. maxMesh?: AbstractMesh;
  131723. /**
  131724. * the mesh that defines the minimum value mesh position.
  131725. */
  131726. minMesh?: AbstractMesh;
  131727. /**
  131728. * The mesh that will be changed when axis value changes
  131729. */
  131730. valueMesh?: AbstractMesh;
  131731. }
  131732. /**
  131733. * The elements needed for change-detection of the gamepad objects in motion controllers
  131734. */
  131735. export interface IMinimalMotionControllerObject {
  131736. /**
  131737. * Available axes of this controller
  131738. */
  131739. axes: number[];
  131740. /**
  131741. * An array of available buttons
  131742. */
  131743. buttons: Array<{
  131744. /**
  131745. * Value of the button/trigger
  131746. */
  131747. value: number;
  131748. /**
  131749. * If the button/trigger is currently touched
  131750. */
  131751. touched: boolean;
  131752. /**
  131753. * If the button/trigger is currently pressed
  131754. */
  131755. pressed: boolean;
  131756. }>;
  131757. /**
  131758. * EXPERIMENTAL haptic support.
  131759. */
  131760. hapticActuators?: Array<{
  131761. pulse: (value: number, duration: number) => Promise<boolean>;
  131762. }>;
  131763. }
  131764. /**
  131765. * An Abstract Motion controller
  131766. * This class receives an xrInput and a profile layout and uses those to initialize the components
  131767. * Each component has an observable to check for changes in value and state
  131768. */
  131769. export abstract class WebXRAbstractMotionController implements IDisposable {
  131770. protected scene: Scene;
  131771. protected layout: IMotionControllerLayout;
  131772. /**
  131773. * The gamepad object correlating to this controller
  131774. */
  131775. gamepadObject: IMinimalMotionControllerObject;
  131776. /**
  131777. * handedness (left/right/none) of this controller
  131778. */
  131779. handedness: MotionControllerHandedness;
  131780. private _initComponent;
  131781. private _modelReady;
  131782. /**
  131783. * A map of components (WebXRControllerComponent) in this motion controller
  131784. * Components have a ComponentType and can also have both button and axis definitions
  131785. */
  131786. readonly components: {
  131787. [id: string]: WebXRControllerComponent;
  131788. };
  131789. /**
  131790. * Disable the model's animation. Can be set at any time.
  131791. */
  131792. disableAnimation: boolean;
  131793. /**
  131794. * Observers registered here will be triggered when the model of this controller is done loading
  131795. */
  131796. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  131797. /**
  131798. * The profile id of this motion controller
  131799. */
  131800. abstract profileId: string;
  131801. /**
  131802. * The root mesh of the model. It is null if the model was not yet initialized
  131803. */
  131804. rootMesh: Nullable<AbstractMesh>;
  131805. /**
  131806. * constructs a new abstract motion controller
  131807. * @param scene the scene to which the model of the controller will be added
  131808. * @param layout The profile layout to load
  131809. * @param gamepadObject The gamepad object correlating to this controller
  131810. * @param handedness handedness (left/right/none) of this controller
  131811. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  131812. */
  131813. constructor(scene: Scene, layout: IMotionControllerLayout,
  131814. /**
  131815. * The gamepad object correlating to this controller
  131816. */
  131817. gamepadObject: IMinimalMotionControllerObject,
  131818. /**
  131819. * handedness (left/right/none) of this controller
  131820. */
  131821. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  131822. /**
  131823. * Dispose this controller, the model mesh and all its components
  131824. */
  131825. dispose(): void;
  131826. /**
  131827. * Returns all components of specific type
  131828. * @param type the type to search for
  131829. * @return an array of components with this type
  131830. */
  131831. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  131832. /**
  131833. * get a component based an its component id as defined in layout.components
  131834. * @param id the id of the component
  131835. * @returns the component correlates to the id or undefined if not found
  131836. */
  131837. getComponent(id: string): WebXRControllerComponent;
  131838. /**
  131839. * Get the list of components available in this motion controller
  131840. * @returns an array of strings correlating to available components
  131841. */
  131842. getComponentIds(): string[];
  131843. /**
  131844. * Get the first component of specific type
  131845. * @param type type of component to find
  131846. * @return a controller component or null if not found
  131847. */
  131848. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  131849. /**
  131850. * Get the main (Select) component of this controller as defined in the layout
  131851. * @returns the main component of this controller
  131852. */
  131853. getMainComponent(): WebXRControllerComponent;
  131854. /**
  131855. * Loads the model correlating to this controller
  131856. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  131857. * @returns A promise fulfilled with the result of the model loading
  131858. */
  131859. loadModel(): Promise<boolean>;
  131860. /**
  131861. * Update this model using the current XRFrame
  131862. * @param xrFrame the current xr frame to use and update the model
  131863. */
  131864. updateFromXRFrame(xrFrame: XRFrame): void;
  131865. /**
  131866. * Backwards compatibility due to a deeply-integrated typo
  131867. */
  131868. get handness(): XREye;
  131869. /**
  131870. * Pulse (vibrate) this controller
  131871. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  131872. * Consecutive calls to this function will cancel the last pulse call
  131873. *
  131874. * @param value the strength of the pulse in 0.0...1.0 range
  131875. * @param duration Duration of the pulse in milliseconds
  131876. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  131877. * @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
  131878. */
  131879. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  131880. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  131881. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  131882. /**
  131883. * Moves the axis on the controller mesh based on its current state
  131884. * @param axis the index of the axis
  131885. * @param axisValue the value of the axis which determines the meshes new position
  131886. * @hidden
  131887. */
  131888. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  131889. /**
  131890. * Update the model itself with the current frame data
  131891. * @param xrFrame the frame to use for updating the model mesh
  131892. */
  131893. protected updateModel(xrFrame: XRFrame): void;
  131894. /**
  131895. * Get the filename and path for this controller's model
  131896. * @returns a map of filename and path
  131897. */
  131898. protected abstract _getFilenameAndPath(): {
  131899. filename: string;
  131900. path: string;
  131901. };
  131902. /**
  131903. * This function is called before the mesh is loaded. It checks for loading constraints.
  131904. * For example, this function can check if the GLB loader is available
  131905. * If this function returns false, the generic controller will be loaded instead
  131906. * @returns Is the client ready to load the mesh
  131907. */
  131908. protected abstract _getModelLoadingConstraints(): boolean;
  131909. /**
  131910. * This function will be called after the model was successfully loaded and can be used
  131911. * for mesh transformations before it is available for the user
  131912. * @param meshes the loaded meshes
  131913. */
  131914. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  131915. /**
  131916. * Set the root mesh for this controller. Important for the WebXR controller class
  131917. * @param meshes the loaded meshes
  131918. */
  131919. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  131920. /**
  131921. * A function executed each frame that updates the mesh (if needed)
  131922. * @param xrFrame the current xrFrame
  131923. */
  131924. protected abstract _updateModel(xrFrame: XRFrame): void;
  131925. private _getGenericFilenameAndPath;
  131926. private _getGenericParentMesh;
  131927. }
  131928. }
  131929. declare module BABYLON {
  131930. /**
  131931. * A generic trigger-only motion controller for WebXR
  131932. */
  131933. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  131934. /**
  131935. * Static version of the profile id of this controller
  131936. */
  131937. static ProfileId: string;
  131938. profileId: string;
  131939. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  131940. protected _getFilenameAndPath(): {
  131941. filename: string;
  131942. path: string;
  131943. };
  131944. protected _getModelLoadingConstraints(): boolean;
  131945. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  131946. protected _setRootMesh(meshes: AbstractMesh[]): void;
  131947. protected _updateModel(): void;
  131948. }
  131949. }
  131950. declare module BABYLON {
  131951. /**
  131952. * Class containing static functions to help procedurally build meshes
  131953. */
  131954. export class SphereBuilder {
  131955. /**
  131956. * Creates a sphere mesh
  131957. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  131958. * * 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`)
  131959. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  131960. * * 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
  131961. * * 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)
  131962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131965. * @param name defines the name of the mesh
  131966. * @param options defines the options used to create the mesh
  131967. * @param scene defines the hosting scene
  131968. * @returns the sphere mesh
  131969. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  131970. */
  131971. static CreateSphere(name: string, options: {
  131972. segments?: number;
  131973. diameter?: number;
  131974. diameterX?: number;
  131975. diameterY?: number;
  131976. diameterZ?: number;
  131977. arc?: number;
  131978. slice?: number;
  131979. sideOrientation?: number;
  131980. frontUVs?: Vector4;
  131981. backUVs?: Vector4;
  131982. updatable?: boolean;
  131983. }, scene?: Nullable<Scene>): Mesh;
  131984. }
  131985. }
  131986. declare module BABYLON {
  131987. /**
  131988. * A profiled motion controller has its profile loaded from an online repository.
  131989. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  131990. */
  131991. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  131992. private _repositoryUrl;
  131993. private _buttonMeshMapping;
  131994. private _touchDots;
  131995. /**
  131996. * The profile ID of this controller. Will be populated when the controller initializes.
  131997. */
  131998. profileId: string;
  131999. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  132000. dispose(): void;
  132001. protected _getFilenameAndPath(): {
  132002. filename: string;
  132003. path: string;
  132004. };
  132005. protected _getModelLoadingConstraints(): boolean;
  132006. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  132007. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132008. protected _updateModel(_xrFrame: XRFrame): void;
  132009. }
  132010. }
  132011. declare module BABYLON {
  132012. /**
  132013. * A construction function type to create a new controller based on an xrInput object
  132014. */
  132015. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  132016. /**
  132017. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  132018. *
  132019. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  132020. * it should be replaced with auto-loaded controllers.
  132021. *
  132022. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  132023. */
  132024. export class WebXRMotionControllerManager {
  132025. private static _AvailableControllers;
  132026. private static _Fallbacks;
  132027. private static _ProfileLoadingPromises;
  132028. private static _ProfilesList;
  132029. /**
  132030. * The base URL of the online controller repository. Can be changed at any time.
  132031. */
  132032. static BaseRepositoryUrl: string;
  132033. /**
  132034. * Which repository gets priority - local or online
  132035. */
  132036. static PrioritizeOnlineRepository: boolean;
  132037. /**
  132038. * Use the online repository, or use only locally-defined controllers
  132039. */
  132040. static UseOnlineRepository: boolean;
  132041. /**
  132042. * Clear the cache used for profile loading and reload when requested again
  132043. */
  132044. static ClearProfilesCache(): void;
  132045. /**
  132046. * Register the default fallbacks.
  132047. * This function is called automatically when this file is imported.
  132048. */
  132049. static DefaultFallbacks(): void;
  132050. /**
  132051. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  132052. * @param profileId the profile to which a fallback needs to be found
  132053. * @return an array with corresponding fallback profiles
  132054. */
  132055. static FindFallbackWithProfileId(profileId: string): string[];
  132056. /**
  132057. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  132058. * The order of search:
  132059. *
  132060. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  132061. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  132062. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  132063. * 4) return the generic trigger controller if none were found
  132064. *
  132065. * @param xrInput the xrInput to which a new controller is initialized
  132066. * @param scene the scene to which the model will be added
  132067. * @param forceProfile force a certain profile for this controller
  132068. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  132069. */
  132070. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  132071. /**
  132072. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  132073. *
  132074. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  132075. *
  132076. * @param type the profile type to register
  132077. * @param constructFunction the function to be called when loading this profile
  132078. */
  132079. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  132080. /**
  132081. * Register a fallback to a specific profile.
  132082. * @param profileId the profileId that will receive the fallbacks
  132083. * @param fallbacks A list of fallback profiles
  132084. */
  132085. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  132086. /**
  132087. * Will update the list of profiles available in the repository
  132088. * @return a promise that resolves to a map of profiles available online
  132089. */
  132090. static UpdateProfilesList(): Promise<{
  132091. [profile: string]: string;
  132092. }>;
  132093. private static _LoadProfileFromRepository;
  132094. private static _LoadProfilesFromAvailableControllers;
  132095. }
  132096. }
  132097. declare module BABYLON {
  132098. /**
  132099. * Configuration options for the WebXR controller creation
  132100. */
  132101. export interface IWebXRControllerOptions {
  132102. /**
  132103. * Should the controller mesh be animated when a user interacts with it
  132104. * The pressed buttons / thumbstick and touchpad animations will be disabled
  132105. */
  132106. disableMotionControllerAnimation?: boolean;
  132107. /**
  132108. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  132109. */
  132110. doNotLoadControllerMesh?: boolean;
  132111. /**
  132112. * Force a specific controller type for this controller.
  132113. * This can be used when creating your own profile or when testing different controllers
  132114. */
  132115. forceControllerProfile?: string;
  132116. /**
  132117. * Defines a rendering group ID for meshes that will be loaded.
  132118. * This is for the default controllers only.
  132119. */
  132120. renderingGroupId?: number;
  132121. }
  132122. /**
  132123. * Represents an XR controller
  132124. */
  132125. export class WebXRInputSource {
  132126. private _scene;
  132127. /** The underlying input source for the controller */
  132128. inputSource: XRInputSource;
  132129. private _options;
  132130. private _tmpVector;
  132131. private _uniqueId;
  132132. private _disposed;
  132133. /**
  132134. * 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
  132135. */
  132136. grip?: AbstractMesh;
  132137. /**
  132138. * If available, this is the gamepad object related to this controller.
  132139. * Using this object it is possible to get click events and trackpad changes of the
  132140. * webxr controller that is currently being used.
  132141. */
  132142. motionController?: WebXRAbstractMotionController;
  132143. /**
  132144. * Event that fires when the controller is removed/disposed.
  132145. * The object provided as event data is this controller, after associated assets were disposed.
  132146. * uniqueId is still available.
  132147. */
  132148. onDisposeObservable: Observable<WebXRInputSource>;
  132149. /**
  132150. * Will be triggered when the mesh associated with the motion controller is done loading.
  132151. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  132152. * A shortened version of controller -> motion controller -> on mesh loaded.
  132153. */
  132154. onMeshLoadedObservable: Observable<AbstractMesh>;
  132155. /**
  132156. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  132157. */
  132158. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  132159. /**
  132160. * Pointer which can be used to select objects or attach a visible laser to
  132161. */
  132162. pointer: AbstractMesh;
  132163. /**
  132164. * Creates the input source object
  132165. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  132166. * @param _scene the scene which the controller should be associated to
  132167. * @param inputSource the underlying input source for the controller
  132168. * @param _options options for this controller creation
  132169. */
  132170. constructor(_scene: Scene,
  132171. /** The underlying input source for the controller */
  132172. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  132173. /**
  132174. * Get this controllers unique id
  132175. */
  132176. get uniqueId(): string;
  132177. /**
  132178. * Disposes of the object
  132179. */
  132180. dispose(): void;
  132181. /**
  132182. * Gets a world space ray coming from the pointer or grip
  132183. * @param result the resulting ray
  132184. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  132185. */
  132186. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  132187. /**
  132188. * Updates the controller pose based on the given XRFrame
  132189. * @param xrFrame xr frame to update the pose with
  132190. * @param referenceSpace reference space to use
  132191. */
  132192. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  132193. }
  132194. }
  132195. declare module BABYLON {
  132196. /**
  132197. * The schema for initialization options of the XR Input class
  132198. */
  132199. export interface IWebXRInputOptions {
  132200. /**
  132201. * If set to true no model will be automatically loaded
  132202. */
  132203. doNotLoadControllerMeshes?: boolean;
  132204. /**
  132205. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  132206. * If not found, the xr input profile data will be used.
  132207. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  132208. */
  132209. forceInputProfile?: string;
  132210. /**
  132211. * Do not send a request to the controller repository to load the profile.
  132212. *
  132213. * Instead, use the controllers available in babylon itself.
  132214. */
  132215. disableOnlineControllerRepository?: boolean;
  132216. /**
  132217. * A custom URL for the controllers repository
  132218. */
  132219. customControllersRepositoryURL?: string;
  132220. /**
  132221. * Should the controller model's components not move according to the user input
  132222. */
  132223. disableControllerAnimation?: boolean;
  132224. /**
  132225. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  132226. */
  132227. controllerOptions?: IWebXRControllerOptions;
  132228. }
  132229. /**
  132230. * XR input used to track XR inputs such as controllers/rays
  132231. */
  132232. export class WebXRInput implements IDisposable {
  132233. /**
  132234. * the xr session manager for this session
  132235. */
  132236. xrSessionManager: WebXRSessionManager;
  132237. /**
  132238. * the WebXR camera for this session. Mainly used for teleportation
  132239. */
  132240. xrCamera: WebXRCamera;
  132241. private readonly options;
  132242. /**
  132243. * XR controllers being tracked
  132244. */
  132245. controllers: Array<WebXRInputSource>;
  132246. private _frameObserver;
  132247. private _sessionEndedObserver;
  132248. private _sessionInitObserver;
  132249. /**
  132250. * Event when a controller has been connected/added
  132251. */
  132252. onControllerAddedObservable: Observable<WebXRInputSource>;
  132253. /**
  132254. * Event when a controller has been removed/disconnected
  132255. */
  132256. onControllerRemovedObservable: Observable<WebXRInputSource>;
  132257. /**
  132258. * Initializes the WebXRInput
  132259. * @param xrSessionManager the xr session manager for this session
  132260. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  132261. * @param options = initialization options for this xr input
  132262. */
  132263. constructor(
  132264. /**
  132265. * the xr session manager for this session
  132266. */
  132267. xrSessionManager: WebXRSessionManager,
  132268. /**
  132269. * the WebXR camera for this session. Mainly used for teleportation
  132270. */
  132271. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  132272. private _onInputSourcesChange;
  132273. private _addAndRemoveControllers;
  132274. /**
  132275. * Disposes of the object
  132276. */
  132277. dispose(): void;
  132278. }
  132279. }
  132280. declare module BABYLON {
  132281. /**
  132282. * This is the base class for all WebXR features.
  132283. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  132284. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  132285. */
  132286. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  132287. protected _xrSessionManager: WebXRSessionManager;
  132288. private _attached;
  132289. private _removeOnDetach;
  132290. /**
  132291. * Is this feature disposed?
  132292. */
  132293. isDisposed: boolean;
  132294. /**
  132295. * Should auto-attach be disabled?
  132296. */
  132297. disableAutoAttach: boolean;
  132298. /**
  132299. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  132300. */
  132301. xrNativeFeatureName: string;
  132302. /**
  132303. * Construct a new (abstract) WebXR feature
  132304. * @param _xrSessionManager the xr session manager for this feature
  132305. */
  132306. constructor(_xrSessionManager: WebXRSessionManager);
  132307. /**
  132308. * Is this feature attached
  132309. */
  132310. get attached(): boolean;
  132311. /**
  132312. * attach this feature
  132313. *
  132314. * @param force should attachment be forced (even when already attached)
  132315. * @returns true if successful, false is failed or already attached
  132316. */
  132317. attach(force?: boolean): boolean;
  132318. /**
  132319. * detach this feature.
  132320. *
  132321. * @returns true if successful, false if failed or already detached
  132322. */
  132323. detach(): boolean;
  132324. /**
  132325. * Dispose this feature and all of the resources attached
  132326. */
  132327. dispose(): void;
  132328. /**
  132329. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  132330. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  132331. *
  132332. * @returns whether or not the feature is compatible in this environment
  132333. */
  132334. isCompatible(): boolean;
  132335. /**
  132336. * This is used to register callbacks that will automatically be removed when detach is called.
  132337. * @param observable the observable to which the observer will be attached
  132338. * @param callback the callback to register
  132339. */
  132340. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  132341. /**
  132342. * Code in this function will be executed on each xrFrame received from the browser.
  132343. * This function will not execute after the feature is detached.
  132344. * @param _xrFrame the current frame
  132345. */
  132346. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  132347. }
  132348. }
  132349. declare module BABYLON {
  132350. /**
  132351. * Renders a layer on top of an existing scene
  132352. */
  132353. export class UtilityLayerRenderer implements IDisposable {
  132354. /** the original scene that will be rendered on top of */
  132355. originalScene: Scene;
  132356. private _pointerCaptures;
  132357. private _lastPointerEvents;
  132358. private static _DefaultUtilityLayer;
  132359. private static _DefaultKeepDepthUtilityLayer;
  132360. private _sharedGizmoLight;
  132361. private _renderCamera;
  132362. /**
  132363. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  132364. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  132365. * @returns the camera that is used when rendering the utility layer
  132366. */
  132367. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  132368. /**
  132369. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  132370. * @param cam the camera that should be used when rendering the utility layer
  132371. */
  132372. setRenderCamera(cam: Nullable<Camera>): void;
  132373. /**
  132374. * @hidden
  132375. * Light which used by gizmos to get light shading
  132376. */
  132377. _getSharedGizmoLight(): HemisphericLight;
  132378. /**
  132379. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  132380. */
  132381. pickUtilitySceneFirst: boolean;
  132382. /**
  132383. * 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)
  132384. */
  132385. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  132386. /**
  132387. * 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)
  132388. */
  132389. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  132390. /**
  132391. * The scene that is rendered on top of the original scene
  132392. */
  132393. utilityLayerScene: Scene;
  132394. /**
  132395. * If the utility layer should automatically be rendered on top of existing scene
  132396. */
  132397. shouldRender: boolean;
  132398. /**
  132399. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  132400. */
  132401. onlyCheckPointerDownEvents: boolean;
  132402. /**
  132403. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  132404. */
  132405. processAllEvents: boolean;
  132406. /**
  132407. * Observable raised when the pointer move from the utility layer scene to the main scene
  132408. */
  132409. onPointerOutObservable: Observable<number>;
  132410. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  132411. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  132412. private _afterRenderObserver;
  132413. private _sceneDisposeObserver;
  132414. private _originalPointerObserver;
  132415. /**
  132416. * Instantiates a UtilityLayerRenderer
  132417. * @param originalScene the original scene that will be rendered on top of
  132418. * @param handleEvents boolean indicating if the utility layer should handle events
  132419. */
  132420. constructor(
  132421. /** the original scene that will be rendered on top of */
  132422. originalScene: Scene, handleEvents?: boolean);
  132423. private _notifyObservers;
  132424. /**
  132425. * Renders the utility layers scene on top of the original scene
  132426. */
  132427. render(): void;
  132428. /**
  132429. * Disposes of the renderer
  132430. */
  132431. dispose(): void;
  132432. private _updateCamera;
  132433. }
  132434. }
  132435. declare module BABYLON {
  132436. /**
  132437. * Options interface for the pointer selection module
  132438. */
  132439. export interface IWebXRControllerPointerSelectionOptions {
  132440. /**
  132441. * if provided, this scene will be used to render meshes.
  132442. */
  132443. customUtilityLayerScene?: Scene;
  132444. /**
  132445. * 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)
  132446. * If not disabled, the last picked point will be used to execute a pointer up event
  132447. * If disabled, pointer up event will be triggered right after the pointer down event.
  132448. * Used in screen and gaze target ray mode only
  132449. */
  132450. disablePointerUpOnTouchOut: boolean;
  132451. /**
  132452. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  132453. */
  132454. forceGazeMode: boolean;
  132455. /**
  132456. * 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
  132457. * to start a new countdown to the pointer down event.
  132458. * Defaults to 1.
  132459. */
  132460. gazeModePointerMovedFactor?: number;
  132461. /**
  132462. * Different button type to use instead of the main component
  132463. */
  132464. overrideButtonId?: string;
  132465. /**
  132466. * use this rendering group id for the meshes (optional)
  132467. */
  132468. renderingGroupId?: number;
  132469. /**
  132470. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  132471. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  132472. * 3000 means 3 seconds between pointing at something and selecting it
  132473. */
  132474. timeToSelect?: number;
  132475. /**
  132476. * Should meshes created here be added to a utility layer or the main scene
  132477. */
  132478. useUtilityLayer?: boolean;
  132479. /**
  132480. * Optional WebXR camera to be used for gaze selection
  132481. */
  132482. gazeCamera?: WebXRCamera;
  132483. /**
  132484. * the xr input to use with this pointer selection
  132485. */
  132486. xrInput: WebXRInput;
  132487. }
  132488. /**
  132489. * A module that will enable pointer selection for motion controllers of XR Input Sources
  132490. */
  132491. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  132492. private readonly _options;
  132493. private static _idCounter;
  132494. private _attachController;
  132495. private _controllers;
  132496. private _scene;
  132497. private _tmpVectorForPickCompare;
  132498. /**
  132499. * The module's name
  132500. */
  132501. static readonly Name: string;
  132502. /**
  132503. * The (Babylon) version of this module.
  132504. * This is an integer representing the implementation version.
  132505. * This number does not correspond to the WebXR specs version
  132506. */
  132507. static readonly Version: number;
  132508. /**
  132509. * Disable lighting on the laser pointer (so it will always be visible)
  132510. */
  132511. disablePointerLighting: boolean;
  132512. /**
  132513. * Disable lighting on the selection mesh (so it will always be visible)
  132514. */
  132515. disableSelectionMeshLighting: boolean;
  132516. /**
  132517. * Should the laser pointer be displayed
  132518. */
  132519. displayLaserPointer: boolean;
  132520. /**
  132521. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  132522. */
  132523. displaySelectionMesh: boolean;
  132524. /**
  132525. * This color will be set to the laser pointer when selection is triggered
  132526. */
  132527. laserPointerPickedColor: Color3;
  132528. /**
  132529. * Default color of the laser pointer
  132530. */
  132531. laserPointerDefaultColor: Color3;
  132532. /**
  132533. * default color of the selection ring
  132534. */
  132535. selectionMeshDefaultColor: Color3;
  132536. /**
  132537. * This color will be applied to the selection ring when selection is triggered
  132538. */
  132539. selectionMeshPickedColor: Color3;
  132540. /**
  132541. * Optional filter to be used for ray selection. This predicate shares behavior with
  132542. * scene.pointerMovePredicate which takes priority if it is also assigned.
  132543. */
  132544. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  132545. /**
  132546. * constructs a new background remover module
  132547. * @param _xrSessionManager the session manager for this module
  132548. * @param _options read-only options to be used in this module
  132549. */
  132550. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  132551. /**
  132552. * attach this feature
  132553. * Will usually be called by the features manager
  132554. *
  132555. * @returns true if successful.
  132556. */
  132557. attach(): boolean;
  132558. /**
  132559. * detach this feature.
  132560. * Will usually be called by the features manager
  132561. *
  132562. * @returns true if successful.
  132563. */
  132564. detach(): boolean;
  132565. /**
  132566. * Will get the mesh under a specific pointer.
  132567. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  132568. * @param controllerId the controllerId to check
  132569. * @returns The mesh under pointer or null if no mesh is under the pointer
  132570. */
  132571. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  132572. /**
  132573. * Get the xr controller that correlates to the pointer id in the pointer event
  132574. *
  132575. * @param id the pointer id to search for
  132576. * @returns the controller that correlates to this id or null if not found
  132577. */
  132578. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  132579. protected _onXRFrame(_xrFrame: XRFrame): void;
  132580. private _attachGazeMode;
  132581. private _attachScreenRayMode;
  132582. private _attachTrackedPointerRayMode;
  132583. private _convertNormalToDirectionOfRay;
  132584. private _detachController;
  132585. private _generateNewMeshPair;
  132586. private _pickingMoved;
  132587. private _updatePointerDistance;
  132588. /** @hidden */
  132589. get lasterPointerDefaultColor(): Color3;
  132590. }
  132591. }
  132592. declare module BABYLON {
  132593. /**
  132594. * Button which can be used to enter a different mode of XR
  132595. */
  132596. export class WebXREnterExitUIButton {
  132597. /** button element */
  132598. element: HTMLElement;
  132599. /** XR initialization options for the button */
  132600. sessionMode: XRSessionMode;
  132601. /** Reference space type */
  132602. referenceSpaceType: XRReferenceSpaceType;
  132603. /**
  132604. * Creates a WebXREnterExitUIButton
  132605. * @param element button element
  132606. * @param sessionMode XR initialization session mode
  132607. * @param referenceSpaceType the type of reference space to be used
  132608. */
  132609. constructor(
  132610. /** button element */
  132611. element: HTMLElement,
  132612. /** XR initialization options for the button */
  132613. sessionMode: XRSessionMode,
  132614. /** Reference space type */
  132615. referenceSpaceType: XRReferenceSpaceType);
  132616. /**
  132617. * Extendable function which can be used to update the button's visuals when the state changes
  132618. * @param activeButton the current active button in the UI
  132619. */
  132620. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  132621. }
  132622. /**
  132623. * Options to create the webXR UI
  132624. */
  132625. export class WebXREnterExitUIOptions {
  132626. /**
  132627. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  132628. */
  132629. customButtons?: Array<WebXREnterExitUIButton>;
  132630. /**
  132631. * A reference space type to use when creating the default button.
  132632. * Default is local-floor
  132633. */
  132634. referenceSpaceType?: XRReferenceSpaceType;
  132635. /**
  132636. * Context to enter xr with
  132637. */
  132638. renderTarget?: Nullable<WebXRRenderTarget>;
  132639. /**
  132640. * A session mode to use when creating the default button.
  132641. * Default is immersive-vr
  132642. */
  132643. sessionMode?: XRSessionMode;
  132644. /**
  132645. * A list of optional features to init the session with
  132646. */
  132647. optionalFeatures?: string[];
  132648. /**
  132649. * A list of optional features to init the session with
  132650. */
  132651. requiredFeatures?: string[];
  132652. }
  132653. /**
  132654. * UI to allow the user to enter/exit XR mode
  132655. */
  132656. export class WebXREnterExitUI implements IDisposable {
  132657. private scene;
  132658. /** version of the options passed to this UI */
  132659. options: WebXREnterExitUIOptions;
  132660. private _activeButton;
  132661. private _buttons;
  132662. /**
  132663. * The HTML Div Element to which buttons are added.
  132664. */
  132665. readonly overlay: HTMLDivElement;
  132666. /**
  132667. * Fired every time the active button is changed.
  132668. *
  132669. * When xr is entered via a button that launches xr that button will be the callback parameter
  132670. *
  132671. * When exiting xr the callback parameter will be null)
  132672. */
  132673. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  132674. /**
  132675. *
  132676. * @param scene babylon scene object to use
  132677. * @param options (read-only) version of the options passed to this UI
  132678. */
  132679. private constructor();
  132680. /**
  132681. * Creates UI to allow the user to enter/exit XR mode
  132682. * @param scene the scene to add the ui to
  132683. * @param helper the xr experience helper to enter/exit xr with
  132684. * @param options options to configure the UI
  132685. * @returns the created ui
  132686. */
  132687. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  132688. /**
  132689. * Disposes of the XR UI component
  132690. */
  132691. dispose(): void;
  132692. private _updateButtons;
  132693. }
  132694. }
  132695. declare module BABYLON {
  132696. /**
  132697. * Class containing static functions to help procedurally build meshes
  132698. */
  132699. export class LinesBuilder {
  132700. /**
  132701. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  132702. * * 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
  132703. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  132704. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  132705. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  132706. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  132707. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  132708. * * 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
  132709. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  132710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132711. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  132712. * @param name defines the name of the new line system
  132713. * @param options defines the options used to create the line system
  132714. * @param scene defines the hosting scene
  132715. * @returns a new line system mesh
  132716. */
  132717. static CreateLineSystem(name: string, options: {
  132718. lines: Vector3[][];
  132719. updatable?: boolean;
  132720. instance?: Nullable<LinesMesh>;
  132721. colors?: Nullable<Color4[][]>;
  132722. useVertexAlpha?: boolean;
  132723. }, scene: Nullable<Scene>): LinesMesh;
  132724. /**
  132725. * Creates a line mesh
  132726. * 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
  132727. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  132728. * * The parameter `points` is an array successive Vector3
  132729. * * 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
  132730. * * The optional parameter `colors` is an array of successive Color4, one per line point
  132731. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  132732. * * When updating an instance, remember that only point positions can change, not the number of points
  132733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132734. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  132735. * @param name defines the name of the new line system
  132736. * @param options defines the options used to create the line system
  132737. * @param scene defines the hosting scene
  132738. * @returns a new line mesh
  132739. */
  132740. static CreateLines(name: string, options: {
  132741. points: Vector3[];
  132742. updatable?: boolean;
  132743. instance?: Nullable<LinesMesh>;
  132744. colors?: Color4[];
  132745. useVertexAlpha?: boolean;
  132746. }, scene?: Nullable<Scene>): LinesMesh;
  132747. /**
  132748. * Creates a dashed line mesh
  132749. * * 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
  132750. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  132751. * * The parameter `points` is an array successive Vector3
  132752. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  132753. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  132754. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  132755. * * 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
  132756. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  132757. * * When updating an instance, remember that only point positions can change, not the number of points
  132758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132759. * @param name defines the name of the mesh
  132760. * @param options defines the options used to create the mesh
  132761. * @param scene defines the hosting scene
  132762. * @returns the dashed line mesh
  132763. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  132764. */
  132765. static CreateDashedLines(name: string, options: {
  132766. points: Vector3[];
  132767. dashSize?: number;
  132768. gapSize?: number;
  132769. dashNb?: number;
  132770. updatable?: boolean;
  132771. instance?: LinesMesh;
  132772. useVertexAlpha?: boolean;
  132773. }, scene?: Nullable<Scene>): LinesMesh;
  132774. }
  132775. }
  132776. declare module BABYLON {
  132777. /**
  132778. * Construction options for a timer
  132779. */
  132780. export interface ITimerOptions<T> {
  132781. /**
  132782. * Time-to-end
  132783. */
  132784. timeout: number;
  132785. /**
  132786. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  132787. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  132788. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  132789. */
  132790. contextObservable: Observable<T>;
  132791. /**
  132792. * Optional parameters when adding an observer to the observable
  132793. */
  132794. observableParameters?: {
  132795. mask?: number;
  132796. insertFirst?: boolean;
  132797. scope?: any;
  132798. };
  132799. /**
  132800. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  132801. */
  132802. breakCondition?: (data?: ITimerData<T>) => boolean;
  132803. /**
  132804. * Will be triggered when the time condition has met
  132805. */
  132806. onEnded?: (data: ITimerData<any>) => void;
  132807. /**
  132808. * Will be triggered when the break condition has met (prematurely ended)
  132809. */
  132810. onAborted?: (data: ITimerData<any>) => void;
  132811. /**
  132812. * Optional function to execute on each tick (or count)
  132813. */
  132814. onTick?: (data: ITimerData<any>) => void;
  132815. }
  132816. /**
  132817. * An interface defining the data sent by the timer
  132818. */
  132819. export interface ITimerData<T> {
  132820. /**
  132821. * When did it start
  132822. */
  132823. startTime: number;
  132824. /**
  132825. * Time now
  132826. */
  132827. currentTime: number;
  132828. /**
  132829. * Time passed since started
  132830. */
  132831. deltaTime: number;
  132832. /**
  132833. * How much is completed, in [0.0...1.0].
  132834. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  132835. */
  132836. completeRate: number;
  132837. /**
  132838. * What the registered observable sent in the last count
  132839. */
  132840. payload: T;
  132841. }
  132842. /**
  132843. * The current state of the timer
  132844. */
  132845. export enum TimerState {
  132846. /**
  132847. * Timer initialized, not yet started
  132848. */
  132849. INIT = 0,
  132850. /**
  132851. * Timer started and counting
  132852. */
  132853. STARTED = 1,
  132854. /**
  132855. * Timer ended (whether aborted or time reached)
  132856. */
  132857. ENDED = 2
  132858. }
  132859. /**
  132860. * A simple version of the timer. Will take options and start the timer immediately after calling it
  132861. *
  132862. * @param options options with which to initialize this timer
  132863. */
  132864. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  132865. /**
  132866. * An advanced implementation of a timer class
  132867. */
  132868. export class AdvancedTimer<T = any> implements IDisposable {
  132869. /**
  132870. * Will notify each time the timer calculates the remaining time
  132871. */
  132872. onEachCountObservable: Observable<ITimerData<T>>;
  132873. /**
  132874. * Will trigger when the timer was aborted due to the break condition
  132875. */
  132876. onTimerAbortedObservable: Observable<ITimerData<T>>;
  132877. /**
  132878. * Will trigger when the timer ended successfully
  132879. */
  132880. onTimerEndedObservable: Observable<ITimerData<T>>;
  132881. /**
  132882. * Will trigger when the timer state has changed
  132883. */
  132884. onStateChangedObservable: Observable<TimerState>;
  132885. private _observer;
  132886. private _contextObservable;
  132887. private _observableParameters;
  132888. private _startTime;
  132889. private _timer;
  132890. private _state;
  132891. private _breakCondition;
  132892. private _timeToEnd;
  132893. private _breakOnNextTick;
  132894. /**
  132895. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  132896. * @param options construction options for this advanced timer
  132897. */
  132898. constructor(options: ITimerOptions<T>);
  132899. /**
  132900. * set a breaking condition for this timer. Default is to never break during count
  132901. * @param predicate the new break condition. Returns true to break, false otherwise
  132902. */
  132903. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  132904. /**
  132905. * Reset ALL associated observables in this advanced timer
  132906. */
  132907. clearObservables(): void;
  132908. /**
  132909. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  132910. *
  132911. * @param timeToEnd how much time to measure until timer ended
  132912. */
  132913. start(timeToEnd?: number): void;
  132914. /**
  132915. * Will force a stop on the next tick.
  132916. */
  132917. stop(): void;
  132918. /**
  132919. * Dispose this timer, clearing all resources
  132920. */
  132921. dispose(): void;
  132922. private _setState;
  132923. private _tick;
  132924. private _stop;
  132925. }
  132926. }
  132927. declare module BABYLON {
  132928. /**
  132929. * The options container for the teleportation module
  132930. */
  132931. export interface IWebXRTeleportationOptions {
  132932. /**
  132933. * if provided, this scene will be used to render meshes.
  132934. */
  132935. customUtilityLayerScene?: Scene;
  132936. /**
  132937. * Values to configure the default target mesh
  132938. */
  132939. defaultTargetMeshOptions?: {
  132940. /**
  132941. * Fill color of the teleportation area
  132942. */
  132943. teleportationFillColor?: string;
  132944. /**
  132945. * Border color for the teleportation area
  132946. */
  132947. teleportationBorderColor?: string;
  132948. /**
  132949. * Disable the mesh's animation sequence
  132950. */
  132951. disableAnimation?: boolean;
  132952. /**
  132953. * Disable lighting on the material or the ring and arrow
  132954. */
  132955. disableLighting?: boolean;
  132956. /**
  132957. * Override the default material of the torus and arrow
  132958. */
  132959. torusArrowMaterial?: Material;
  132960. };
  132961. /**
  132962. * A list of meshes to use as floor meshes.
  132963. * Meshes can be added and removed after initializing the feature using the
  132964. * addFloorMesh and removeFloorMesh functions
  132965. * If empty, rotation will still work
  132966. */
  132967. floorMeshes?: AbstractMesh[];
  132968. /**
  132969. * use this rendering group id for the meshes (optional)
  132970. */
  132971. renderingGroupId?: number;
  132972. /**
  132973. * Should teleportation move only to snap points
  132974. */
  132975. snapPointsOnly?: boolean;
  132976. /**
  132977. * An array of points to which the teleportation will snap to.
  132978. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  132979. */
  132980. snapPositions?: Vector3[];
  132981. /**
  132982. * How close should the teleportation ray be in order to snap to position.
  132983. * Default to 0.8 units (meters)
  132984. */
  132985. snapToPositionRadius?: number;
  132986. /**
  132987. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  132988. * If you want to support rotation, make sure your mesh has a direction indicator.
  132989. *
  132990. * When left untouched, the default mesh will be initialized.
  132991. */
  132992. teleportationTargetMesh?: AbstractMesh;
  132993. /**
  132994. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  132995. */
  132996. timeToTeleport?: number;
  132997. /**
  132998. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  132999. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  133000. */
  133001. useMainComponentOnly?: boolean;
  133002. /**
  133003. * Should meshes created here be added to a utility layer or the main scene
  133004. */
  133005. useUtilityLayer?: boolean;
  133006. /**
  133007. * Babylon XR Input class for controller
  133008. */
  133009. xrInput: WebXRInput;
  133010. /**
  133011. * Meshes that the teleportation ray cannot go through
  133012. */
  133013. pickBlockerMeshes?: AbstractMesh[];
  133014. }
  133015. /**
  133016. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  133017. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  133018. * the input of the attached controllers.
  133019. */
  133020. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  133021. private _options;
  133022. private _controllers;
  133023. private _currentTeleportationControllerId;
  133024. private _floorMeshes;
  133025. private _quadraticBezierCurve;
  133026. private _selectionFeature;
  133027. private _snapToPositions;
  133028. private _snappedToPoint;
  133029. private _teleportationRingMaterial?;
  133030. private _tmpRay;
  133031. private _tmpVector;
  133032. private _tmpQuaternion;
  133033. /**
  133034. * The module's name
  133035. */
  133036. static readonly Name: string;
  133037. /**
  133038. * The (Babylon) version of this module.
  133039. * This is an integer representing the implementation version.
  133040. * This number does not correspond to the webxr specs version
  133041. */
  133042. static readonly Version: number;
  133043. /**
  133044. * Is movement backwards enabled
  133045. */
  133046. backwardsMovementEnabled: boolean;
  133047. /**
  133048. * Distance to travel when moving backwards
  133049. */
  133050. backwardsTeleportationDistance: number;
  133051. /**
  133052. * The distance from the user to the inspection point in the direction of the controller
  133053. * A higher number will allow the user to move further
  133054. * defaults to 5 (meters, in xr units)
  133055. */
  133056. parabolicCheckRadius: number;
  133057. /**
  133058. * Should the module support parabolic ray on top of direct ray
  133059. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  133060. * Very helpful when moving between floors / different heights
  133061. */
  133062. parabolicRayEnabled: boolean;
  133063. /**
  133064. * How much rotation should be applied when rotating right and left
  133065. */
  133066. rotationAngle: number;
  133067. /**
  133068. * Is rotation enabled when moving forward?
  133069. * Disabling this feature will prevent the user from deciding the direction when teleporting
  133070. */
  133071. rotationEnabled: boolean;
  133072. /**
  133073. * constructs a new anchor system
  133074. * @param _xrSessionManager an instance of WebXRSessionManager
  133075. * @param _options configuration object for this feature
  133076. */
  133077. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  133078. /**
  133079. * Get the snapPointsOnly flag
  133080. */
  133081. get snapPointsOnly(): boolean;
  133082. /**
  133083. * Sets the snapPointsOnly flag
  133084. * @param snapToPoints should teleportation be exclusively to snap points
  133085. */
  133086. set snapPointsOnly(snapToPoints: boolean);
  133087. /**
  133088. * Add a new mesh to the floor meshes array
  133089. * @param mesh the mesh to use as floor mesh
  133090. */
  133091. addFloorMesh(mesh: AbstractMesh): void;
  133092. /**
  133093. * Add a new snap-to point to fix teleportation to this position
  133094. * @param newSnapPoint The new Snap-To point
  133095. */
  133096. addSnapPoint(newSnapPoint: Vector3): void;
  133097. attach(): boolean;
  133098. detach(): boolean;
  133099. dispose(): void;
  133100. /**
  133101. * Remove a mesh from the floor meshes array
  133102. * @param mesh the mesh to remove
  133103. */
  133104. removeFloorMesh(mesh: AbstractMesh): void;
  133105. /**
  133106. * Remove a mesh from the floor meshes array using its name
  133107. * @param name the mesh name to remove
  133108. */
  133109. removeFloorMeshByName(name: string): void;
  133110. /**
  133111. * 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
  133112. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  133113. * @returns was the point found and removed or not
  133114. */
  133115. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  133116. /**
  133117. * This function sets a selection feature that will be disabled when
  133118. * the forward ray is shown and will be reattached when hidden.
  133119. * This is used to remove the selection rays when moving.
  133120. * @param selectionFeature the feature to disable when forward movement is enabled
  133121. */
  133122. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  133123. protected _onXRFrame(_xrFrame: XRFrame): void;
  133124. private _attachController;
  133125. private _createDefaultTargetMesh;
  133126. private _detachController;
  133127. private _findClosestSnapPointWithRadius;
  133128. private _setTargetMeshPosition;
  133129. private _setTargetMeshVisibility;
  133130. private _showParabolicPath;
  133131. private _teleportForward;
  133132. }
  133133. }
  133134. declare module BABYLON {
  133135. /**
  133136. * Options for the default xr helper
  133137. */
  133138. export class WebXRDefaultExperienceOptions {
  133139. /**
  133140. * Enable or disable default UI to enter XR
  133141. */
  133142. disableDefaultUI?: boolean;
  133143. /**
  133144. * Should teleportation not initialize. defaults to false.
  133145. */
  133146. disableTeleportation?: boolean;
  133147. /**
  133148. * Floor meshes that will be used for teleport
  133149. */
  133150. floorMeshes?: Array<AbstractMesh>;
  133151. /**
  133152. * If set to true, the first frame will not be used to reset position
  133153. * The first frame is mainly used when copying transformation from the old camera
  133154. * Mainly used in AR
  133155. */
  133156. ignoreNativeCameraTransformation?: boolean;
  133157. /**
  133158. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  133159. */
  133160. inputOptions?: IWebXRInputOptions;
  133161. /**
  133162. * optional configuration for the output canvas
  133163. */
  133164. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  133165. /**
  133166. * optional UI options. This can be used among other to change session mode and reference space type
  133167. */
  133168. uiOptions?: WebXREnterExitUIOptions;
  133169. /**
  133170. * When loading teleportation and pointer select, use stable versions instead of latest.
  133171. */
  133172. useStablePlugins?: boolean;
  133173. /**
  133174. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  133175. */
  133176. renderingGroupId?: number;
  133177. /**
  133178. * A list of optional features to init the session with
  133179. * If set to true, all features we support will be added
  133180. */
  133181. optionalFeatures?: boolean | string[];
  133182. }
  133183. /**
  133184. * Default experience which provides a similar setup to the previous webVRExperience
  133185. */
  133186. export class WebXRDefaultExperience {
  133187. /**
  133188. * Base experience
  133189. */
  133190. baseExperience: WebXRExperienceHelper;
  133191. /**
  133192. * Enables ui for entering/exiting xr
  133193. */
  133194. enterExitUI: WebXREnterExitUI;
  133195. /**
  133196. * Input experience extension
  133197. */
  133198. input: WebXRInput;
  133199. /**
  133200. * Enables laser pointer and selection
  133201. */
  133202. pointerSelection: WebXRControllerPointerSelection;
  133203. /**
  133204. * Default target xr should render to
  133205. */
  133206. renderTarget: WebXRRenderTarget;
  133207. /**
  133208. * Enables teleportation
  133209. */
  133210. teleportation: WebXRMotionControllerTeleportation;
  133211. private constructor();
  133212. /**
  133213. * Creates the default xr experience
  133214. * @param scene scene
  133215. * @param options options for basic configuration
  133216. * @returns resulting WebXRDefaultExperience
  133217. */
  133218. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  133219. /**
  133220. * DIsposes of the experience helper
  133221. */
  133222. dispose(): void;
  133223. }
  133224. }
  133225. declare module BABYLON {
  133226. /**
  133227. * Options to modify the vr teleportation behavior.
  133228. */
  133229. export interface VRTeleportationOptions {
  133230. /**
  133231. * The name of the mesh which should be used as the teleportation floor. (default: null)
  133232. */
  133233. floorMeshName?: string;
  133234. /**
  133235. * A list of meshes to be used as the teleportation floor. (default: empty)
  133236. */
  133237. floorMeshes?: Mesh[];
  133238. /**
  133239. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  133240. */
  133241. teleportationMode?: number;
  133242. /**
  133243. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  133244. */
  133245. teleportationTime?: number;
  133246. /**
  133247. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  133248. */
  133249. teleportationSpeed?: number;
  133250. /**
  133251. * The easing function used in the animation or null for Linear. (default CircleEase)
  133252. */
  133253. easingFunction?: EasingFunction;
  133254. }
  133255. /**
  133256. * Options to modify the vr experience helper's behavior.
  133257. */
  133258. export interface VRExperienceHelperOptions extends WebVROptions {
  133259. /**
  133260. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  133261. */
  133262. createDeviceOrientationCamera?: boolean;
  133263. /**
  133264. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  133265. */
  133266. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  133267. /**
  133268. * Uses the main button on the controller to toggle the laser casted. (default: true)
  133269. */
  133270. laserToggle?: boolean;
  133271. /**
  133272. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  133273. */
  133274. floorMeshes?: Mesh[];
  133275. /**
  133276. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  133277. */
  133278. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  133279. /**
  133280. * Defines if WebXR should be used instead of WebVR (if available)
  133281. */
  133282. useXR?: boolean;
  133283. }
  133284. /**
  133285. * Event containing information after VR has been entered
  133286. */
  133287. export class OnAfterEnteringVRObservableEvent {
  133288. /**
  133289. * If entering vr was successful
  133290. */
  133291. success: boolean;
  133292. }
  133293. /**
  133294. * Helps to quickly add VR support to an existing scene.
  133295. * See https://doc.babylonjs.com/how_to/webvr_helper
  133296. */
  133297. export class VRExperienceHelper {
  133298. /** Options to modify the vr experience helper's behavior. */
  133299. webVROptions: VRExperienceHelperOptions;
  133300. private _scene;
  133301. private _position;
  133302. private _btnVR;
  133303. private _btnVRDisplayed;
  133304. private _webVRsupported;
  133305. private _webVRready;
  133306. private _webVRrequesting;
  133307. private _webVRpresenting;
  133308. private _hasEnteredVR;
  133309. private _fullscreenVRpresenting;
  133310. private _inputElement;
  133311. private _webVRCamera;
  133312. private _vrDeviceOrientationCamera;
  133313. private _deviceOrientationCamera;
  133314. private _existingCamera;
  133315. private _onKeyDown;
  133316. private _onVrDisplayPresentChange;
  133317. private _onVRDisplayChanged;
  133318. private _onVRRequestPresentStart;
  133319. private _onVRRequestPresentComplete;
  133320. /**
  133321. * 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)
  133322. */
  133323. enableGazeEvenWhenNoPointerLock: boolean;
  133324. /**
  133325. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  133326. */
  133327. exitVROnDoubleTap: boolean;
  133328. /**
  133329. * Observable raised right before entering VR.
  133330. */
  133331. onEnteringVRObservable: Observable<VRExperienceHelper>;
  133332. /**
  133333. * Observable raised when entering VR has completed.
  133334. */
  133335. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  133336. /**
  133337. * Observable raised when exiting VR.
  133338. */
  133339. onExitingVRObservable: Observable<VRExperienceHelper>;
  133340. /**
  133341. * Observable raised when controller mesh is loaded.
  133342. */
  133343. onControllerMeshLoadedObservable: Observable<WebVRController>;
  133344. /** Return this.onEnteringVRObservable
  133345. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  133346. */
  133347. get onEnteringVR(): Observable<VRExperienceHelper>;
  133348. /** Return this.onExitingVRObservable
  133349. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  133350. */
  133351. get onExitingVR(): Observable<VRExperienceHelper>;
  133352. /** Return this.onControllerMeshLoadedObservable
  133353. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  133354. */
  133355. get onControllerMeshLoaded(): Observable<WebVRController>;
  133356. private _rayLength;
  133357. private _useCustomVRButton;
  133358. private _teleportationRequested;
  133359. private _teleportActive;
  133360. private _floorMeshName;
  133361. private _floorMeshesCollection;
  133362. private _teleportationMode;
  133363. private _teleportationTime;
  133364. private _teleportationSpeed;
  133365. private _teleportationEasing;
  133366. private _rotationAllowed;
  133367. private _teleportBackwardsVector;
  133368. private _teleportationTarget;
  133369. private _isDefaultTeleportationTarget;
  133370. private _postProcessMove;
  133371. private _teleportationFillColor;
  133372. private _teleportationBorderColor;
  133373. private _rotationAngle;
  133374. private _haloCenter;
  133375. private _cameraGazer;
  133376. private _padSensibilityUp;
  133377. private _padSensibilityDown;
  133378. private _leftController;
  133379. private _rightController;
  133380. private _gazeColor;
  133381. private _laserColor;
  133382. private _pickedLaserColor;
  133383. private _pickedGazeColor;
  133384. /**
  133385. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  133386. */
  133387. onNewMeshSelected: Observable<AbstractMesh>;
  133388. /**
  133389. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  133390. * This observable will provide the mesh and the controller used to select the mesh
  133391. */
  133392. onMeshSelectedWithController: Observable<{
  133393. mesh: AbstractMesh;
  133394. controller: WebVRController;
  133395. }>;
  133396. /**
  133397. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  133398. */
  133399. onNewMeshPicked: Observable<PickingInfo>;
  133400. private _circleEase;
  133401. /**
  133402. * Observable raised before camera teleportation
  133403. */
  133404. onBeforeCameraTeleport: Observable<Vector3>;
  133405. /**
  133406. * Observable raised after camera teleportation
  133407. */
  133408. onAfterCameraTeleport: Observable<Vector3>;
  133409. /**
  133410. * Observable raised when current selected mesh gets unselected
  133411. */
  133412. onSelectedMeshUnselected: Observable<AbstractMesh>;
  133413. private _raySelectionPredicate;
  133414. /**
  133415. * To be optionaly changed by user to define custom ray selection
  133416. */
  133417. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  133418. /**
  133419. * To be optionaly changed by user to define custom selection logic (after ray selection)
  133420. */
  133421. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  133422. /**
  133423. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  133424. */
  133425. teleportationEnabled: boolean;
  133426. private _defaultHeight;
  133427. private _teleportationInitialized;
  133428. private _interactionsEnabled;
  133429. private _interactionsRequested;
  133430. private _displayGaze;
  133431. private _displayLaserPointer;
  133432. /**
  133433. * The mesh used to display where the user is going to teleport.
  133434. */
  133435. get teleportationTarget(): Mesh;
  133436. /**
  133437. * Sets the mesh to be used to display where the user is going to teleport.
  133438. */
  133439. set teleportationTarget(value: Mesh);
  133440. /**
  133441. * 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
  133442. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  133443. * See https://doc.babylonjs.com/resources/baking_transformations
  133444. */
  133445. get gazeTrackerMesh(): Mesh;
  133446. set gazeTrackerMesh(value: Mesh);
  133447. /**
  133448. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  133449. */
  133450. updateGazeTrackerScale: boolean;
  133451. /**
  133452. * If the gaze trackers color should be updated when selecting meshes
  133453. */
  133454. updateGazeTrackerColor: boolean;
  133455. /**
  133456. * If the controller laser color should be updated when selecting meshes
  133457. */
  133458. updateControllerLaserColor: boolean;
  133459. /**
  133460. * The gaze tracking mesh corresponding to the left controller
  133461. */
  133462. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  133463. /**
  133464. * The gaze tracking mesh corresponding to the right controller
  133465. */
  133466. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  133467. /**
  133468. * If the ray of the gaze should be displayed.
  133469. */
  133470. get displayGaze(): boolean;
  133471. /**
  133472. * Sets if the ray of the gaze should be displayed.
  133473. */
  133474. set displayGaze(value: boolean);
  133475. /**
  133476. * If the ray of the LaserPointer should be displayed.
  133477. */
  133478. get displayLaserPointer(): boolean;
  133479. /**
  133480. * Sets if the ray of the LaserPointer should be displayed.
  133481. */
  133482. set displayLaserPointer(value: boolean);
  133483. /**
  133484. * The deviceOrientationCamera used as the camera when not in VR.
  133485. */
  133486. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  133487. /**
  133488. * Based on the current WebVR support, returns the current VR camera used.
  133489. */
  133490. get currentVRCamera(): Nullable<Camera>;
  133491. /**
  133492. * The webVRCamera which is used when in VR.
  133493. */
  133494. get webVRCamera(): WebVRFreeCamera;
  133495. /**
  133496. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  133497. */
  133498. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  133499. /**
  133500. * The html button that is used to trigger entering into VR.
  133501. */
  133502. get vrButton(): Nullable<HTMLButtonElement>;
  133503. private get _teleportationRequestInitiated();
  133504. /**
  133505. * Defines whether or not Pointer lock should be requested when switching to
  133506. * full screen.
  133507. */
  133508. requestPointerLockOnFullScreen: boolean;
  133509. /**
  133510. * If asking to force XR, this will be populated with the default xr experience
  133511. */
  133512. xr: WebXRDefaultExperience;
  133513. /**
  133514. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  133515. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  133516. */
  133517. xrTestDone: boolean;
  133518. /**
  133519. * Instantiates a VRExperienceHelper.
  133520. * Helps to quickly add VR support to an existing scene.
  133521. * @param scene The scene the VRExperienceHelper belongs to.
  133522. * @param webVROptions Options to modify the vr experience helper's behavior.
  133523. */
  133524. constructor(scene: Scene,
  133525. /** Options to modify the vr experience helper's behavior. */
  133526. webVROptions?: VRExperienceHelperOptions);
  133527. private completeVRInit;
  133528. private _onDefaultMeshLoaded;
  133529. private _onResize;
  133530. private _onFullscreenChange;
  133531. /**
  133532. * Gets a value indicating if we are currently in VR mode.
  133533. */
  133534. get isInVRMode(): boolean;
  133535. private onVrDisplayPresentChange;
  133536. private onVRDisplayChanged;
  133537. private moveButtonToBottomRight;
  133538. private displayVRButton;
  133539. private updateButtonVisibility;
  133540. private _cachedAngularSensibility;
  133541. /**
  133542. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  133543. * Otherwise, will use the fullscreen API.
  133544. */
  133545. enterVR(): void;
  133546. /**
  133547. * Attempt to exit VR, or fullscreen.
  133548. */
  133549. exitVR(): void;
  133550. /**
  133551. * The position of the vr experience helper.
  133552. */
  133553. get position(): Vector3;
  133554. /**
  133555. * Sets the position of the vr experience helper.
  133556. */
  133557. set position(value: Vector3);
  133558. /**
  133559. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  133560. */
  133561. enableInteractions(): void;
  133562. private get _noControllerIsActive();
  133563. private beforeRender;
  133564. private _isTeleportationFloor;
  133565. /**
  133566. * Adds a floor mesh to be used for teleportation.
  133567. * @param floorMesh the mesh to be used for teleportation.
  133568. */
  133569. addFloorMesh(floorMesh: Mesh): void;
  133570. /**
  133571. * Removes a floor mesh from being used for teleportation.
  133572. * @param floorMesh the mesh to be removed.
  133573. */
  133574. removeFloorMesh(floorMesh: Mesh): void;
  133575. /**
  133576. * Enables interactions and teleportation using the VR controllers and gaze.
  133577. * @param vrTeleportationOptions options to modify teleportation behavior.
  133578. */
  133579. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  133580. private _onNewGamepadConnected;
  133581. private _tryEnableInteractionOnController;
  133582. private _onNewGamepadDisconnected;
  133583. private _enableInteractionOnController;
  133584. private _checkTeleportWithRay;
  133585. private _checkRotate;
  133586. private _checkTeleportBackwards;
  133587. private _enableTeleportationOnController;
  133588. private _createTeleportationCircles;
  133589. private _displayTeleportationTarget;
  133590. private _hideTeleportationTarget;
  133591. private _rotateCamera;
  133592. private _moveTeleportationSelectorTo;
  133593. private _workingVector;
  133594. private _workingQuaternion;
  133595. private _workingMatrix;
  133596. /**
  133597. * Time Constant Teleportation Mode
  133598. */
  133599. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  133600. /**
  133601. * Speed Constant Teleportation Mode
  133602. */
  133603. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  133604. /**
  133605. * Teleports the users feet to the desired location
  133606. * @param location The location where the user's feet should be placed
  133607. */
  133608. teleportCamera(location: Vector3): void;
  133609. private _convertNormalToDirectionOfRay;
  133610. private _castRayAndSelectObject;
  133611. private _notifySelectedMeshUnselected;
  133612. /**
  133613. * Permanently set new colors for the laser pointer
  133614. * @param color the new laser color
  133615. * @param pickedColor the new laser color when picked mesh detected
  133616. */
  133617. setLaserColor(color: Color3, pickedColor?: Color3): void;
  133618. /**
  133619. * Set lighting enabled / disabled on the laser pointer of both controllers
  133620. * @param enabled should the lighting be enabled on the laser pointer
  133621. */
  133622. setLaserLightingState(enabled?: boolean): void;
  133623. /**
  133624. * Permanently set new colors for the gaze pointer
  133625. * @param color the new gaze color
  133626. * @param pickedColor the new gaze color when picked mesh detected
  133627. */
  133628. setGazeColor(color: Color3, pickedColor?: Color3): void;
  133629. /**
  133630. * Sets the color of the laser ray from the vr controllers.
  133631. * @param color new color for the ray.
  133632. */
  133633. changeLaserColor(color: Color3): void;
  133634. /**
  133635. * Sets the color of the ray from the vr headsets gaze.
  133636. * @param color new color for the ray.
  133637. */
  133638. changeGazeColor(color: Color3): void;
  133639. /**
  133640. * Exits VR and disposes of the vr experience helper
  133641. */
  133642. dispose(): void;
  133643. /**
  133644. * Gets the name of the VRExperienceHelper class
  133645. * @returns "VRExperienceHelper"
  133646. */
  133647. getClassName(): string;
  133648. }
  133649. }
  133650. declare module BABYLON {
  133651. /**
  133652. * Contains an array of blocks representing the octree
  133653. */
  133654. export interface IOctreeContainer<T> {
  133655. /**
  133656. * Blocks within the octree
  133657. */
  133658. blocks: Array<OctreeBlock<T>>;
  133659. }
  133660. /**
  133661. * Class used to store a cell in an octree
  133662. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133663. */
  133664. export class OctreeBlock<T> {
  133665. /**
  133666. * Gets the content of the current block
  133667. */
  133668. entries: T[];
  133669. /**
  133670. * Gets the list of block children
  133671. */
  133672. blocks: Array<OctreeBlock<T>>;
  133673. private _depth;
  133674. private _maxDepth;
  133675. private _capacity;
  133676. private _minPoint;
  133677. private _maxPoint;
  133678. private _boundingVectors;
  133679. private _creationFunc;
  133680. /**
  133681. * Creates a new block
  133682. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  133683. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  133684. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  133685. * @param depth defines the current depth of this block in the octree
  133686. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  133687. * @param creationFunc defines a callback to call when an element is added to the block
  133688. */
  133689. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  133690. /**
  133691. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  133692. */
  133693. get capacity(): number;
  133694. /**
  133695. * Gets the minimum vector (in world space) of the block's bounding box
  133696. */
  133697. get minPoint(): Vector3;
  133698. /**
  133699. * Gets the maximum vector (in world space) of the block's bounding box
  133700. */
  133701. get maxPoint(): Vector3;
  133702. /**
  133703. * Add a new element to this block
  133704. * @param entry defines the element to add
  133705. */
  133706. addEntry(entry: T): void;
  133707. /**
  133708. * Remove an element from this block
  133709. * @param entry defines the element to remove
  133710. */
  133711. removeEntry(entry: T): void;
  133712. /**
  133713. * Add an array of elements to this block
  133714. * @param entries defines the array of elements to add
  133715. */
  133716. addEntries(entries: T[]): void;
  133717. /**
  133718. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  133719. * @param frustumPlanes defines the frustum planes to test
  133720. * @param selection defines the array to store current content if selection is positive
  133721. * @param allowDuplicate defines if the selection array can contains duplicated entries
  133722. */
  133723. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  133724. /**
  133725. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  133726. * @param sphereCenter defines the bounding sphere center
  133727. * @param sphereRadius defines the bounding sphere radius
  133728. * @param selection defines the array to store current content if selection is positive
  133729. * @param allowDuplicate defines if the selection array can contains duplicated entries
  133730. */
  133731. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  133732. /**
  133733. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  133734. * @param ray defines the ray to test with
  133735. * @param selection defines the array to store current content if selection is positive
  133736. */
  133737. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  133738. /**
  133739. * Subdivide the content into child blocks (this block will then be empty)
  133740. */
  133741. createInnerBlocks(): void;
  133742. /**
  133743. * @hidden
  133744. */
  133745. 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;
  133746. }
  133747. }
  133748. declare module BABYLON {
  133749. /**
  133750. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  133751. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133752. */
  133753. export class Octree<T> {
  133754. /** 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.) */
  133755. maxDepth: number;
  133756. /**
  133757. * Blocks within the octree containing objects
  133758. */
  133759. blocks: Array<OctreeBlock<T>>;
  133760. /**
  133761. * Content stored in the octree
  133762. */
  133763. dynamicContent: T[];
  133764. private _maxBlockCapacity;
  133765. private _selectionContent;
  133766. private _creationFunc;
  133767. /**
  133768. * Creates a octree
  133769. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133770. * @param creationFunc function to be used to instatiate the octree
  133771. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  133772. * @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.)
  133773. */
  133774. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  133775. /** 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.) */
  133776. maxDepth?: number);
  133777. /**
  133778. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  133779. * @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);
  133780. * @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);
  133781. * @param entries meshes to be added to the octree blocks
  133782. */
  133783. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  133784. /**
  133785. * Adds a mesh to the octree
  133786. * @param entry Mesh to add to the octree
  133787. */
  133788. addMesh(entry: T): void;
  133789. /**
  133790. * Remove an element from the octree
  133791. * @param entry defines the element to remove
  133792. */
  133793. removeMesh(entry: T): void;
  133794. /**
  133795. * Selects an array of meshes within the frustum
  133796. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  133797. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  133798. * @returns array of meshes within the frustum
  133799. */
  133800. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  133801. /**
  133802. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  133803. * @param sphereCenter defines the bounding sphere center
  133804. * @param sphereRadius defines the bounding sphere radius
  133805. * @param allowDuplicate defines if the selection array can contains duplicated entries
  133806. * @returns an array of objects that intersect the sphere
  133807. */
  133808. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  133809. /**
  133810. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  133811. * @param ray defines the ray to test with
  133812. * @returns array of intersected objects
  133813. */
  133814. intersectsRay(ray: Ray): SmartArray<T>;
  133815. /**
  133816. * Adds a mesh into the octree block if it intersects the block
  133817. */
  133818. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  133819. /**
  133820. * Adds a submesh into the octree block if it intersects the block
  133821. */
  133822. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  133823. }
  133824. }
  133825. declare module BABYLON {
  133826. interface Scene {
  133827. /**
  133828. * @hidden
  133829. * Backing Filed
  133830. */
  133831. _selectionOctree: Octree<AbstractMesh>;
  133832. /**
  133833. * Gets the octree used to boost mesh selection (picking)
  133834. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133835. */
  133836. selectionOctree: Octree<AbstractMesh>;
  133837. /**
  133838. * Creates or updates the octree used to boost selection (picking)
  133839. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133840. * @param maxCapacity defines the maximum capacity per leaf
  133841. * @param maxDepth defines the maximum depth of the octree
  133842. * @returns an octree of AbstractMesh
  133843. */
  133844. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  133845. }
  133846. interface AbstractMesh {
  133847. /**
  133848. * @hidden
  133849. * Backing Field
  133850. */
  133851. _submeshesOctree: Octree<SubMesh>;
  133852. /**
  133853. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  133854. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  133855. * @param maxCapacity defines the maximum size of each block (64 by default)
  133856. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  133857. * @returns the new octree
  133858. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  133859. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133860. */
  133861. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  133862. }
  133863. /**
  133864. * Defines the octree scene component responsible to manage any octrees
  133865. * in a given scene.
  133866. */
  133867. export class OctreeSceneComponent {
  133868. /**
  133869. * The component name help to identify the component in the list of scene components.
  133870. */
  133871. readonly name: string;
  133872. /**
  133873. * The scene the component belongs to.
  133874. */
  133875. scene: Scene;
  133876. /**
  133877. * Indicates if the meshes have been checked to make sure they are isEnabled()
  133878. */
  133879. readonly checksIsEnabled: boolean;
  133880. /**
  133881. * Creates a new instance of the component for the given scene
  133882. * @param scene Defines the scene to register the component in
  133883. */
  133884. constructor(scene: Scene);
  133885. /**
  133886. * Registers the component in a given scene
  133887. */
  133888. register(): void;
  133889. /**
  133890. * Return the list of active meshes
  133891. * @returns the list of active meshes
  133892. */
  133893. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  133894. /**
  133895. * Return the list of active sub meshes
  133896. * @param mesh The mesh to get the candidates sub meshes from
  133897. * @returns the list of active sub meshes
  133898. */
  133899. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  133900. private _tempRay;
  133901. /**
  133902. * Return the list of sub meshes intersecting with a given local ray
  133903. * @param mesh defines the mesh to find the submesh for
  133904. * @param localRay defines the ray in local space
  133905. * @returns the list of intersecting sub meshes
  133906. */
  133907. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  133908. /**
  133909. * Return the list of sub meshes colliding with a collider
  133910. * @param mesh defines the mesh to find the submesh for
  133911. * @param collider defines the collider to evaluate the collision against
  133912. * @returns the list of colliding sub meshes
  133913. */
  133914. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  133915. /**
  133916. * Rebuilds the elements related to this component in case of
  133917. * context lost for instance.
  133918. */
  133919. rebuild(): void;
  133920. /**
  133921. * Disposes the component and the associated ressources.
  133922. */
  133923. dispose(): void;
  133924. }
  133925. }
  133926. declare module BABYLON {
  133927. /**
  133928. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  133929. */
  133930. export class Gizmo implements IDisposable {
  133931. /** The utility layer the gizmo will be added to */
  133932. gizmoLayer: UtilityLayerRenderer;
  133933. /**
  133934. * The root mesh of the gizmo
  133935. */
  133936. _rootMesh: Mesh;
  133937. private _attachedMesh;
  133938. private _attachedNode;
  133939. /**
  133940. * Ratio for the scale of the gizmo (Default: 1)
  133941. */
  133942. protected _scaleRatio: number;
  133943. /**
  133944. * boolean updated by pointermove when a gizmo mesh is hovered
  133945. */
  133946. protected _isHovered: boolean;
  133947. /**
  133948. * Ratio for the scale of the gizmo (Default: 1)
  133949. */
  133950. set scaleRatio(value: number);
  133951. get scaleRatio(): number;
  133952. /**
  133953. * True when the mouse pointer is hovered a gizmo mesh
  133954. */
  133955. get isHovered(): boolean;
  133956. /**
  133957. * If a custom mesh has been set (Default: false)
  133958. */
  133959. protected _customMeshSet: boolean;
  133960. /**
  133961. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  133962. * * When set, interactions will be enabled
  133963. */
  133964. get attachedMesh(): Nullable<AbstractMesh>;
  133965. set attachedMesh(value: Nullable<AbstractMesh>);
  133966. /**
  133967. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  133968. * * When set, interactions will be enabled
  133969. */
  133970. get attachedNode(): Nullable<Node>;
  133971. set attachedNode(value: Nullable<Node>);
  133972. /**
  133973. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  133974. * @param mesh The mesh to replace the default mesh of the gizmo
  133975. */
  133976. setCustomMesh(mesh: Mesh): void;
  133977. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  133978. /**
  133979. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  133980. */
  133981. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133982. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133983. /**
  133984. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  133985. */
  133986. updateGizmoPositionToMatchAttachedMesh: boolean;
  133987. /**
  133988. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  133989. */
  133990. updateScale: boolean;
  133991. protected _interactionsEnabled: boolean;
  133992. protected _attachedNodeChanged(value: Nullable<Node>): void;
  133993. private _beforeRenderObserver;
  133994. private _tempQuaternion;
  133995. private _tempVector;
  133996. private _tempVector2;
  133997. private _tempMatrix1;
  133998. private _tempMatrix2;
  133999. private _rightHandtoLeftHandMatrix;
  134000. /**
  134001. * Creates a gizmo
  134002. * @param gizmoLayer The utility layer the gizmo will be added to
  134003. */
  134004. constructor(
  134005. /** The utility layer the gizmo will be added to */
  134006. gizmoLayer?: UtilityLayerRenderer);
  134007. /**
  134008. * Updates the gizmo to match the attached mesh's position/rotation
  134009. */
  134010. protected _update(): void;
  134011. /**
  134012. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  134013. * @param value Node, TransformNode or mesh
  134014. */
  134015. protected _matrixChanged(): void;
  134016. /**
  134017. * Disposes of the gizmo
  134018. */
  134019. dispose(): void;
  134020. }
  134021. }
  134022. declare module BABYLON {
  134023. /**
  134024. * Single plane drag gizmo
  134025. */
  134026. export class PlaneDragGizmo extends Gizmo {
  134027. /**
  134028. * Drag behavior responsible for the gizmos dragging interactions
  134029. */
  134030. dragBehavior: PointerDragBehavior;
  134031. private _pointerObserver;
  134032. /**
  134033. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134034. */
  134035. snapDistance: number;
  134036. /**
  134037. * Event that fires each time the gizmo snaps to a new location.
  134038. * * snapDistance is the the change in distance
  134039. */
  134040. onSnapObservable: Observable<{
  134041. snapDistance: number;
  134042. }>;
  134043. private _plane;
  134044. private _coloredMaterial;
  134045. private _hoverMaterial;
  134046. private _isEnabled;
  134047. private _parent;
  134048. /** @hidden */
  134049. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  134050. /** @hidden */
  134051. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134052. /**
  134053. * Creates a PlaneDragGizmo
  134054. * @param gizmoLayer The utility layer the gizmo will be added to
  134055. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  134056. * @param color The color of the gizmo
  134057. */
  134058. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  134059. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134060. /**
  134061. * If the gizmo is enabled
  134062. */
  134063. set isEnabled(value: boolean);
  134064. get isEnabled(): boolean;
  134065. /**
  134066. * Disposes of the gizmo
  134067. */
  134068. dispose(): void;
  134069. }
  134070. }
  134071. declare module BABYLON {
  134072. /**
  134073. * Gizmo that enables dragging a mesh along 3 axis
  134074. */
  134075. export class PositionGizmo extends Gizmo {
  134076. /**
  134077. * Internal gizmo used for interactions on the x axis
  134078. */
  134079. xGizmo: AxisDragGizmo;
  134080. /**
  134081. * Internal gizmo used for interactions on the y axis
  134082. */
  134083. yGizmo: AxisDragGizmo;
  134084. /**
  134085. * Internal gizmo used for interactions on the z axis
  134086. */
  134087. zGizmo: AxisDragGizmo;
  134088. /**
  134089. * Internal gizmo used for interactions on the yz plane
  134090. */
  134091. xPlaneGizmo: PlaneDragGizmo;
  134092. /**
  134093. * Internal gizmo used for interactions on the xz plane
  134094. */
  134095. yPlaneGizmo: PlaneDragGizmo;
  134096. /**
  134097. * Internal gizmo used for interactions on the xy plane
  134098. */
  134099. zPlaneGizmo: PlaneDragGizmo;
  134100. /**
  134101. * private variables
  134102. */
  134103. private _meshAttached;
  134104. private _nodeAttached;
  134105. private _snapDistance;
  134106. /** Fires an event when any of it's sub gizmos are dragged */
  134107. onDragStartObservable: Observable<unknown>;
  134108. /** Fires an event when any of it's sub gizmos are released from dragging */
  134109. onDragEndObservable: Observable<unknown>;
  134110. /**
  134111. * If set to true, planar drag is enabled
  134112. */
  134113. private _planarGizmoEnabled;
  134114. get attachedMesh(): Nullable<AbstractMesh>;
  134115. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134116. get attachedNode(): Nullable<Node>;
  134117. set attachedNode(node: Nullable<Node>);
  134118. /**
  134119. * True when the mouse pointer is hovering a gizmo mesh
  134120. */
  134121. get isHovered(): boolean;
  134122. /**
  134123. * Creates a PositionGizmo
  134124. * @param gizmoLayer The utility layer the gizmo will be added to
  134125. @param thickness display gizmo axis thickness
  134126. */
  134127. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  134128. /**
  134129. * If the planar drag gizmo is enabled
  134130. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  134131. */
  134132. set planarGizmoEnabled(value: boolean);
  134133. get planarGizmoEnabled(): boolean;
  134134. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134135. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134136. /**
  134137. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134138. */
  134139. set snapDistance(value: number);
  134140. get snapDistance(): number;
  134141. /**
  134142. * Ratio for the scale of the gizmo (Default: 1)
  134143. */
  134144. set scaleRatio(value: number);
  134145. get scaleRatio(): number;
  134146. /**
  134147. * Disposes of the gizmo
  134148. */
  134149. dispose(): void;
  134150. /**
  134151. * CustomMeshes are not supported by this gizmo
  134152. * @param mesh The mesh to replace the default mesh of the gizmo
  134153. */
  134154. setCustomMesh(mesh: Mesh): void;
  134155. }
  134156. }
  134157. declare module BABYLON {
  134158. /**
  134159. * Single axis drag gizmo
  134160. */
  134161. export class AxisDragGizmo extends Gizmo {
  134162. /**
  134163. * Drag behavior responsible for the gizmos dragging interactions
  134164. */
  134165. dragBehavior: PointerDragBehavior;
  134166. private _pointerObserver;
  134167. /**
  134168. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134169. */
  134170. snapDistance: number;
  134171. /**
  134172. * Event that fires each time the gizmo snaps to a new location.
  134173. * * snapDistance is the the change in distance
  134174. */
  134175. onSnapObservable: Observable<{
  134176. snapDistance: number;
  134177. }>;
  134178. private _isEnabled;
  134179. private _parent;
  134180. private _arrow;
  134181. private _coloredMaterial;
  134182. private _hoverMaterial;
  134183. /** @hidden */
  134184. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  134185. /** @hidden */
  134186. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134187. /**
  134188. * Creates an AxisDragGizmo
  134189. * @param gizmoLayer The utility layer the gizmo will be added to
  134190. * @param dragAxis The axis which the gizmo will be able to drag on
  134191. * @param color The color of the gizmo
  134192. * @param thickness display gizmo axis thickness
  134193. */
  134194. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  134195. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134196. /**
  134197. * If the gizmo is enabled
  134198. */
  134199. set isEnabled(value: boolean);
  134200. get isEnabled(): boolean;
  134201. /**
  134202. * Disposes of the gizmo
  134203. */
  134204. dispose(): void;
  134205. }
  134206. }
  134207. declare module BABYLON.Debug {
  134208. /**
  134209. * The Axes viewer will show 3 axes in a specific point in space
  134210. */
  134211. export class AxesViewer {
  134212. private _xAxis;
  134213. private _yAxis;
  134214. private _zAxis;
  134215. private _scaleLinesFactor;
  134216. private _instanced;
  134217. /**
  134218. * Gets the hosting scene
  134219. */
  134220. scene: Nullable<Scene>;
  134221. /**
  134222. * Gets or sets a number used to scale line length
  134223. */
  134224. scaleLines: number;
  134225. /** Gets the node hierarchy used to render x-axis */
  134226. get xAxis(): TransformNode;
  134227. /** Gets the node hierarchy used to render y-axis */
  134228. get yAxis(): TransformNode;
  134229. /** Gets the node hierarchy used to render z-axis */
  134230. get zAxis(): TransformNode;
  134231. /**
  134232. * Creates a new AxesViewer
  134233. * @param scene defines the hosting scene
  134234. * @param scaleLines defines a number used to scale line length (1 by default)
  134235. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  134236. * @param xAxis defines the node hierarchy used to render the x-axis
  134237. * @param yAxis defines the node hierarchy used to render the y-axis
  134238. * @param zAxis defines the node hierarchy used to render the z-axis
  134239. */
  134240. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  134241. /**
  134242. * Force the viewer to update
  134243. * @param position defines the position of the viewer
  134244. * @param xaxis defines the x axis of the viewer
  134245. * @param yaxis defines the y axis of the viewer
  134246. * @param zaxis defines the z axis of the viewer
  134247. */
  134248. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  134249. /**
  134250. * Creates an instance of this axes viewer.
  134251. * @returns a new axes viewer with instanced meshes
  134252. */
  134253. createInstance(): AxesViewer;
  134254. /** Releases resources */
  134255. dispose(): void;
  134256. private static _SetRenderingGroupId;
  134257. }
  134258. }
  134259. declare module BABYLON.Debug {
  134260. /**
  134261. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  134262. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  134263. */
  134264. export class BoneAxesViewer extends AxesViewer {
  134265. /**
  134266. * Gets or sets the target mesh where to display the axes viewer
  134267. */
  134268. mesh: Nullable<Mesh>;
  134269. /**
  134270. * Gets or sets the target bone where to display the axes viewer
  134271. */
  134272. bone: Nullable<Bone>;
  134273. /** Gets current position */
  134274. pos: Vector3;
  134275. /** Gets direction of X axis */
  134276. xaxis: Vector3;
  134277. /** Gets direction of Y axis */
  134278. yaxis: Vector3;
  134279. /** Gets direction of Z axis */
  134280. zaxis: Vector3;
  134281. /**
  134282. * Creates a new BoneAxesViewer
  134283. * @param scene defines the hosting scene
  134284. * @param bone defines the target bone
  134285. * @param mesh defines the target mesh
  134286. * @param scaleLines defines a scaling factor for line length (1 by default)
  134287. */
  134288. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  134289. /**
  134290. * Force the viewer to update
  134291. */
  134292. update(): void;
  134293. /** Releases resources */
  134294. dispose(): void;
  134295. }
  134296. }
  134297. declare module BABYLON {
  134298. /**
  134299. * Interface used to define scene explorer extensibility option
  134300. */
  134301. export interface IExplorerExtensibilityOption {
  134302. /**
  134303. * Define the option label
  134304. */
  134305. label: string;
  134306. /**
  134307. * Defines the action to execute on click
  134308. */
  134309. action: (entity: any) => void;
  134310. }
  134311. /**
  134312. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  134313. */
  134314. export interface IExplorerExtensibilityGroup {
  134315. /**
  134316. * Defines a predicate to test if a given type mut be extended
  134317. */
  134318. predicate: (entity: any) => boolean;
  134319. /**
  134320. * Gets the list of options added to a type
  134321. */
  134322. entries: IExplorerExtensibilityOption[];
  134323. }
  134324. /**
  134325. * Interface used to define the options to use to create the Inspector
  134326. */
  134327. export interface IInspectorOptions {
  134328. /**
  134329. * Display in overlay mode (default: false)
  134330. */
  134331. overlay?: boolean;
  134332. /**
  134333. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  134334. */
  134335. globalRoot?: HTMLElement;
  134336. /**
  134337. * Display the Scene explorer
  134338. */
  134339. showExplorer?: boolean;
  134340. /**
  134341. * Display the property inspector
  134342. */
  134343. showInspector?: boolean;
  134344. /**
  134345. * Display in embed mode (both panes on the right)
  134346. */
  134347. embedMode?: boolean;
  134348. /**
  134349. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  134350. */
  134351. handleResize?: boolean;
  134352. /**
  134353. * Allow the panes to popup (default: true)
  134354. */
  134355. enablePopup?: boolean;
  134356. /**
  134357. * Allow the panes to be closed by users (default: true)
  134358. */
  134359. enableClose?: boolean;
  134360. /**
  134361. * Optional list of extensibility entries
  134362. */
  134363. explorerExtensibility?: IExplorerExtensibilityGroup[];
  134364. /**
  134365. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  134366. */
  134367. inspectorURL?: string;
  134368. /**
  134369. * Optional initial tab (default to DebugLayerTab.Properties)
  134370. */
  134371. initialTab?: DebugLayerTab;
  134372. }
  134373. interface Scene {
  134374. /**
  134375. * @hidden
  134376. * Backing field
  134377. */
  134378. _debugLayer: DebugLayer;
  134379. /**
  134380. * Gets the debug layer (aka Inspector) associated with the scene
  134381. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134382. */
  134383. debugLayer: DebugLayer;
  134384. }
  134385. /**
  134386. * Enum of inspector action tab
  134387. */
  134388. export enum DebugLayerTab {
  134389. /**
  134390. * Properties tag (default)
  134391. */
  134392. Properties = 0,
  134393. /**
  134394. * Debug tab
  134395. */
  134396. Debug = 1,
  134397. /**
  134398. * Statistics tab
  134399. */
  134400. Statistics = 2,
  134401. /**
  134402. * Tools tab
  134403. */
  134404. Tools = 3,
  134405. /**
  134406. * Settings tab
  134407. */
  134408. Settings = 4
  134409. }
  134410. /**
  134411. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134412. * what is happening in your scene
  134413. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134414. */
  134415. export class DebugLayer {
  134416. /**
  134417. * Define the url to get the inspector script from.
  134418. * By default it uses the babylonjs CDN.
  134419. * @ignoreNaming
  134420. */
  134421. static InspectorURL: string;
  134422. private _scene;
  134423. private BJSINSPECTOR;
  134424. private _onPropertyChangedObservable?;
  134425. /**
  134426. * Observable triggered when a property is changed through the inspector.
  134427. */
  134428. get onPropertyChangedObservable(): any;
  134429. /**
  134430. * Instantiates a new debug layer.
  134431. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134432. * what is happening in your scene
  134433. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134434. * @param scene Defines the scene to inspect
  134435. */
  134436. constructor(scene: Scene);
  134437. /** Creates the inspector window. */
  134438. private _createInspector;
  134439. /**
  134440. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  134441. * @param entity defines the entity to select
  134442. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  134443. */
  134444. select(entity: any, lineContainerTitles?: string | string[]): void;
  134445. /** Get the inspector from bundle or global */
  134446. private _getGlobalInspector;
  134447. /**
  134448. * Get if the inspector is visible or not.
  134449. * @returns true if visible otherwise, false
  134450. */
  134451. isVisible(): boolean;
  134452. /**
  134453. * Hide the inspector and close its window.
  134454. */
  134455. hide(): void;
  134456. /**
  134457. * Update the scene in the inspector
  134458. */
  134459. setAsActiveScene(): void;
  134460. /**
  134461. * Launch the debugLayer.
  134462. * @param config Define the configuration of the inspector
  134463. * @return a promise fulfilled when the debug layer is visible
  134464. */
  134465. show(config?: IInspectorOptions): Promise<DebugLayer>;
  134466. }
  134467. }
  134468. declare module BABYLON {
  134469. /**
  134470. * Class containing static functions to help procedurally build meshes
  134471. */
  134472. export class BoxBuilder {
  134473. /**
  134474. * Creates a box mesh
  134475. * * The parameter `size` sets the size (float) of each box side (default 1)
  134476. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134477. * * 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)
  134478. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134482. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134483. * @param name defines the name of the mesh
  134484. * @param options defines the options used to create the mesh
  134485. * @param scene defines the hosting scene
  134486. * @returns the box mesh
  134487. */
  134488. static CreateBox(name: string, options: {
  134489. size?: number;
  134490. width?: number;
  134491. height?: number;
  134492. depth?: number;
  134493. faceUV?: Vector4[];
  134494. faceColors?: Color4[];
  134495. sideOrientation?: number;
  134496. frontUVs?: Vector4;
  134497. backUVs?: Vector4;
  134498. wrap?: boolean;
  134499. topBaseAt?: number;
  134500. bottomBaseAt?: number;
  134501. updatable?: boolean;
  134502. }, scene?: Nullable<Scene>): Mesh;
  134503. }
  134504. }
  134505. declare module BABYLON.Debug {
  134506. /**
  134507. * Used to show the physics impostor around the specific mesh
  134508. */
  134509. export class PhysicsViewer {
  134510. /** @hidden */
  134511. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  134512. /** @hidden */
  134513. protected _meshes: Array<Nullable<AbstractMesh>>;
  134514. /** @hidden */
  134515. protected _scene: Nullable<Scene>;
  134516. /** @hidden */
  134517. protected _numMeshes: number;
  134518. /** @hidden */
  134519. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  134520. private _renderFunction;
  134521. private _utilityLayer;
  134522. private _debugBoxMesh;
  134523. private _debugSphereMesh;
  134524. private _debugCylinderMesh;
  134525. private _debugMaterial;
  134526. private _debugMeshMeshes;
  134527. /**
  134528. * Creates a new PhysicsViewer
  134529. * @param scene defines the hosting scene
  134530. */
  134531. constructor(scene: Scene);
  134532. /** @hidden */
  134533. protected _updateDebugMeshes(): void;
  134534. /**
  134535. * Renders a specified physic impostor
  134536. * @param impostor defines the impostor to render
  134537. * @param targetMesh defines the mesh represented by the impostor
  134538. * @returns the new debug mesh used to render the impostor
  134539. */
  134540. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  134541. /**
  134542. * Hides a specified physic impostor
  134543. * @param impostor defines the impostor to hide
  134544. */
  134545. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  134546. private _getDebugMaterial;
  134547. private _getDebugBoxMesh;
  134548. private _getDebugSphereMesh;
  134549. private _getDebugCylinderMesh;
  134550. private _getDebugMeshMesh;
  134551. private _getDebugMesh;
  134552. /** Releases all resources */
  134553. dispose(): void;
  134554. }
  134555. }
  134556. declare module BABYLON {
  134557. /**
  134558. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134559. * in order to better appreciate the issue one might have.
  134560. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134561. */
  134562. export class RayHelper {
  134563. /**
  134564. * Defines the ray we are currently tryin to visualize.
  134565. */
  134566. ray: Nullable<Ray>;
  134567. private _renderPoints;
  134568. private _renderLine;
  134569. private _renderFunction;
  134570. private _scene;
  134571. private _onAfterRenderObserver;
  134572. private _onAfterStepObserver;
  134573. private _attachedToMesh;
  134574. private _meshSpaceDirection;
  134575. private _meshSpaceOrigin;
  134576. /**
  134577. * Helper function to create a colored helper in a scene in one line.
  134578. * @param ray Defines the ray we are currently tryin to visualize
  134579. * @param scene Defines the scene the ray is used in
  134580. * @param color Defines the color we want to see the ray in
  134581. * @returns The newly created ray helper.
  134582. */
  134583. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  134584. /**
  134585. * Instantiate a new ray helper.
  134586. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134587. * in order to better appreciate the issue one might have.
  134588. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134589. * @param ray Defines the ray we are currently tryin to visualize
  134590. */
  134591. constructor(ray: Ray);
  134592. /**
  134593. * Shows the ray we are willing to debug.
  134594. * @param scene Defines the scene the ray needs to be rendered in
  134595. * @param color Defines the color the ray needs to be rendered in
  134596. */
  134597. show(scene: Scene, color?: Color3): void;
  134598. /**
  134599. * Hides the ray we are debugging.
  134600. */
  134601. hide(): void;
  134602. private _render;
  134603. /**
  134604. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  134605. * @param mesh Defines the mesh we want the helper attached to
  134606. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  134607. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  134608. * @param length Defines the length of the ray
  134609. */
  134610. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  134611. /**
  134612. * Detach the ray helper from the mesh it has previously been attached to.
  134613. */
  134614. detachFromMesh(): void;
  134615. private _updateToMesh;
  134616. /**
  134617. * Dispose the helper and release its associated resources.
  134618. */
  134619. dispose(): void;
  134620. }
  134621. }
  134622. declare module BABYLON {
  134623. /**
  134624. * Defines the options associated with the creation of a SkeletonViewer.
  134625. */
  134626. export interface ISkeletonViewerOptions {
  134627. /** Should the system pause animations before building the Viewer? */
  134628. pauseAnimations: boolean;
  134629. /** Should the system return the skeleton to rest before building? */
  134630. returnToRest: boolean;
  134631. /** public Display Mode of the Viewer */
  134632. displayMode: number;
  134633. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  134634. displayOptions: ISkeletonViewerDisplayOptions;
  134635. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  134636. computeBonesUsingShaders: boolean;
  134637. /** Flag ignore non weighted bones */
  134638. useAllBones: boolean;
  134639. }
  134640. /**
  134641. * Defines how to display the various bone meshes for the viewer.
  134642. */
  134643. export interface ISkeletonViewerDisplayOptions {
  134644. /** How far down to start tapering the bone spurs */
  134645. midStep?: number;
  134646. /** How big is the midStep? */
  134647. midStepFactor?: number;
  134648. /** Base for the Sphere Size */
  134649. sphereBaseSize?: number;
  134650. /** The ratio of the sphere to the longest bone in units */
  134651. sphereScaleUnit?: number;
  134652. /** Ratio for the Sphere Size */
  134653. sphereFactor?: number;
  134654. /** Whether a spur should attach its far end to the child bone position */
  134655. spurFollowsChild?: boolean;
  134656. /** Whether to show local axes or not */
  134657. showLocalAxes?: boolean;
  134658. /** Length of each local axis */
  134659. localAxesSize?: number;
  134660. }
  134661. /**
  134662. * Defines the constructor options for the BoneWeight Shader.
  134663. */
  134664. export interface IBoneWeightShaderOptions {
  134665. /** Skeleton to Map */
  134666. skeleton: Skeleton;
  134667. /** Colors for Uninfluenced bones */
  134668. colorBase?: Color3;
  134669. /** Colors for 0.0-0.25 Weight bones */
  134670. colorZero?: Color3;
  134671. /** Color for 0.25-0.5 Weight Influence */
  134672. colorQuarter?: Color3;
  134673. /** Color for 0.5-0.75 Weight Influence */
  134674. colorHalf?: Color3;
  134675. /** Color for 0.75-1 Weight Influence */
  134676. colorFull?: Color3;
  134677. /** Color for Zero Weight Influence */
  134678. targetBoneIndex?: number;
  134679. }
  134680. /**
  134681. * Simple structure of the gradient steps for the Color Map.
  134682. */
  134683. export interface ISkeletonMapShaderColorMapKnot {
  134684. /** Color of the Knot */
  134685. color: Color3;
  134686. /** Location of the Knot */
  134687. location: number;
  134688. }
  134689. /**
  134690. * Defines the constructor options for the SkeletonMap Shader.
  134691. */
  134692. export interface ISkeletonMapShaderOptions {
  134693. /** Skeleton to Map */
  134694. skeleton: Skeleton;
  134695. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  134696. colorMap?: ISkeletonMapShaderColorMapKnot[];
  134697. }
  134698. }
  134699. declare module BABYLON {
  134700. /**
  134701. * Class containing static functions to help procedurally build meshes
  134702. */
  134703. export class RibbonBuilder {
  134704. /**
  134705. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134706. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134707. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134708. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134709. * * 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
  134710. * * 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
  134711. * * 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
  134712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134713. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134714. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134715. * * 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
  134716. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134717. * * 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
  134718. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134720. * @param name defines the name of the mesh
  134721. * @param options defines the options used to create the mesh
  134722. * @param scene defines the hosting scene
  134723. * @returns the ribbon mesh
  134724. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134725. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134726. */
  134727. static CreateRibbon(name: string, options: {
  134728. pathArray: Vector3[][];
  134729. closeArray?: boolean;
  134730. closePath?: boolean;
  134731. offset?: number;
  134732. updatable?: boolean;
  134733. sideOrientation?: number;
  134734. frontUVs?: Vector4;
  134735. backUVs?: Vector4;
  134736. instance?: Mesh;
  134737. invertUV?: boolean;
  134738. uvs?: Vector2[];
  134739. colors?: Color4[];
  134740. }, scene?: Nullable<Scene>): Mesh;
  134741. }
  134742. }
  134743. declare module BABYLON {
  134744. /**
  134745. * Class containing static functions to help procedurally build meshes
  134746. */
  134747. export class ShapeBuilder {
  134748. /**
  134749. * 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.
  134750. * * 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.
  134751. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134752. * * 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.
  134753. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134754. * * 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
  134755. * * 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
  134756. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134759. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134761. * @param name defines the name of the mesh
  134762. * @param options defines the options used to create the mesh
  134763. * @param scene defines the hosting scene
  134764. * @returns the extruded shape mesh
  134765. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134766. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134767. */
  134768. static ExtrudeShape(name: string, options: {
  134769. shape: Vector3[];
  134770. path: Vector3[];
  134771. scale?: number;
  134772. rotation?: number;
  134773. cap?: number;
  134774. updatable?: boolean;
  134775. sideOrientation?: number;
  134776. frontUVs?: Vector4;
  134777. backUVs?: Vector4;
  134778. instance?: Mesh;
  134779. invertUV?: boolean;
  134780. }, scene?: Nullable<Scene>): Mesh;
  134781. /**
  134782. * Creates an custom extruded shape mesh.
  134783. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134784. * * 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.
  134785. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134786. * * 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
  134787. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134788. * * 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
  134789. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134790. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134791. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134792. * * 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
  134793. * * 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
  134794. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134795. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134796. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134797. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134799. * @param name defines the name of the mesh
  134800. * @param options defines the options used to create the mesh
  134801. * @param scene defines the hosting scene
  134802. * @returns the custom extruded shape mesh
  134803. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134804. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134805. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134806. */
  134807. static ExtrudeShapeCustom(name: string, options: {
  134808. shape: Vector3[];
  134809. path: Vector3[];
  134810. scaleFunction?: any;
  134811. rotationFunction?: any;
  134812. ribbonCloseArray?: boolean;
  134813. ribbonClosePath?: boolean;
  134814. cap?: number;
  134815. updatable?: boolean;
  134816. sideOrientation?: number;
  134817. frontUVs?: Vector4;
  134818. backUVs?: Vector4;
  134819. instance?: Mesh;
  134820. invertUV?: boolean;
  134821. }, scene?: Nullable<Scene>): Mesh;
  134822. private static _ExtrudeShapeGeneric;
  134823. }
  134824. }
  134825. declare module BABYLON.Debug {
  134826. /**
  134827. * Class used to render a debug view of a given skeleton
  134828. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  134829. */
  134830. export class SkeletonViewer {
  134831. /** defines the skeleton to render */
  134832. skeleton: Skeleton;
  134833. /** defines the mesh attached to the skeleton */
  134834. mesh: AbstractMesh;
  134835. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  134836. autoUpdateBonesMatrices: boolean;
  134837. /** defines the rendering group id to use with the viewer */
  134838. renderingGroupId: number;
  134839. /** is the options for the viewer */
  134840. options: Partial<ISkeletonViewerOptions>;
  134841. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  134842. static readonly DISPLAY_LINES: number;
  134843. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  134844. static readonly DISPLAY_SPHERES: number;
  134845. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  134846. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  134847. /** public static method to create a BoneWeight Shader
  134848. * @param options The constructor options
  134849. * @param scene The scene that the shader is scoped to
  134850. * @returns The created ShaderMaterial
  134851. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  134852. */
  134853. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  134854. /** public static method to create a BoneWeight Shader
  134855. * @param options The constructor options
  134856. * @param scene The scene that the shader is scoped to
  134857. * @returns The created ShaderMaterial
  134858. */
  134859. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  134860. /** private static method to create a BoneWeight Shader
  134861. * @param size The size of the buffer to create (usually the bone count)
  134862. * @param colorMap The gradient data to generate
  134863. * @param scene The scene that the shader is scoped to
  134864. * @returns an Array of floats from the color gradient values
  134865. */
  134866. private static _CreateBoneMapColorBuffer;
  134867. /** If SkeletonViewer scene scope. */
  134868. private _scene;
  134869. /** Gets or sets the color used to render the skeleton */
  134870. color: Color3;
  134871. /** Array of the points of the skeleton fo the line view. */
  134872. private _debugLines;
  134873. /** The SkeletonViewers Mesh. */
  134874. private _debugMesh;
  134875. /** The local axes Meshes. */
  134876. private _localAxes;
  134877. /** If SkeletonViewer is enabled. */
  134878. private _isEnabled;
  134879. /** If SkeletonViewer is ready. */
  134880. private _ready;
  134881. /** SkeletonViewer render observable. */
  134882. private _obs;
  134883. /** The Utility Layer to render the gizmos in. */
  134884. private _utilityLayer;
  134885. private _boneIndices;
  134886. /** Gets the Scene. */
  134887. get scene(): Scene;
  134888. /** Gets the utilityLayer. */
  134889. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  134890. /** Checks Ready Status. */
  134891. get isReady(): Boolean;
  134892. /** Sets Ready Status. */
  134893. set ready(value: boolean);
  134894. /** Gets the debugMesh */
  134895. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  134896. /** Sets the debugMesh */
  134897. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  134898. /** Gets the displayMode */
  134899. get displayMode(): number;
  134900. /** Sets the displayMode */
  134901. set displayMode(value: number);
  134902. /**
  134903. * Creates a new SkeletonViewer
  134904. * @param skeleton defines the skeleton to render
  134905. * @param mesh defines the mesh attached to the skeleton
  134906. * @param scene defines the hosting scene
  134907. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  134908. * @param renderingGroupId defines the rendering group id to use with the viewer
  134909. * @param options All of the extra constructor options for the SkeletonViewer
  134910. */
  134911. constructor(
  134912. /** defines the skeleton to render */
  134913. skeleton: Skeleton,
  134914. /** defines the mesh attached to the skeleton */
  134915. mesh: AbstractMesh,
  134916. /** The Scene scope*/
  134917. scene: Scene,
  134918. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  134919. autoUpdateBonesMatrices?: boolean,
  134920. /** defines the rendering group id to use with the viewer */
  134921. renderingGroupId?: number,
  134922. /** is the options for the viewer */
  134923. options?: Partial<ISkeletonViewerOptions>);
  134924. /** The Dynamic bindings for the update functions */
  134925. private _bindObs;
  134926. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  134927. update(): void;
  134928. /** Gets or sets a boolean indicating if the viewer is enabled */
  134929. set isEnabled(value: boolean);
  134930. get isEnabled(): boolean;
  134931. private _getBonePosition;
  134932. private _getLinesForBonesWithLength;
  134933. private _getLinesForBonesNoLength;
  134934. /** function to revert the mesh and scene back to the initial state. */
  134935. private _revert;
  134936. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  134937. private _getAbsoluteBindPoseToRef;
  134938. /** function to build and bind sphere joint points and spur bone representations. */
  134939. private _buildSpheresAndSpurs;
  134940. private _buildLocalAxes;
  134941. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  134942. private _displayLinesUpdate;
  134943. /** Changes the displayMode of the skeleton viewer
  134944. * @param mode The displayMode numerical value
  134945. */
  134946. changeDisplayMode(mode: number): void;
  134947. /** Sets a display option of the skeleton viewer
  134948. *
  134949. * | Option | Type | Default | Description |
  134950. * | ---------------- | ------- | ------- | ----------- |
  134951. * | 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`. |
  134952. * | 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`. |
  134953. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  134954. * | 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`. |
  134955. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  134956. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  134957. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  134958. *
  134959. * @param option String of the option name
  134960. * @param value The numerical option value
  134961. */
  134962. changeDisplayOptions(option: string, value: number): void;
  134963. /** Release associated resources */
  134964. dispose(): void;
  134965. }
  134966. }
  134967. declare module BABYLON {
  134968. /**
  134969. * Enum for Device Types
  134970. */
  134971. export enum DeviceType {
  134972. /** Generic */
  134973. Generic = 0,
  134974. /** Keyboard */
  134975. Keyboard = 1,
  134976. /** Mouse */
  134977. Mouse = 2,
  134978. /** Touch Pointers */
  134979. Touch = 3,
  134980. /** PS4 Dual Shock */
  134981. DualShock = 4,
  134982. /** Xbox */
  134983. Xbox = 5,
  134984. /** Switch Controller */
  134985. Switch = 6
  134986. }
  134987. /**
  134988. * Enum for All Pointers (Touch/Mouse)
  134989. */
  134990. export enum PointerInput {
  134991. /** Horizontal Axis */
  134992. Horizontal = 0,
  134993. /** Vertical Axis */
  134994. Vertical = 1,
  134995. /** Left Click or Touch */
  134996. LeftClick = 2,
  134997. /** Middle Click */
  134998. MiddleClick = 3,
  134999. /** Right Click */
  135000. RightClick = 4,
  135001. /** Browser Back */
  135002. BrowserBack = 5,
  135003. /** Browser Forward */
  135004. BrowserForward = 6
  135005. }
  135006. /**
  135007. * Enum for Dual Shock Gamepad
  135008. */
  135009. export enum DualShockInput {
  135010. /** Cross */
  135011. Cross = 0,
  135012. /** Circle */
  135013. Circle = 1,
  135014. /** Square */
  135015. Square = 2,
  135016. /** Triangle */
  135017. Triangle = 3,
  135018. /** L1 */
  135019. L1 = 4,
  135020. /** R1 */
  135021. R1 = 5,
  135022. /** L2 */
  135023. L2 = 6,
  135024. /** R2 */
  135025. R2 = 7,
  135026. /** Share */
  135027. Share = 8,
  135028. /** Options */
  135029. Options = 9,
  135030. /** L3 */
  135031. L3 = 10,
  135032. /** R3 */
  135033. R3 = 11,
  135034. /** DPadUp */
  135035. DPadUp = 12,
  135036. /** DPadDown */
  135037. DPadDown = 13,
  135038. /** DPadLeft */
  135039. DPadLeft = 14,
  135040. /** DRight */
  135041. DPadRight = 15,
  135042. /** Home */
  135043. Home = 16,
  135044. /** TouchPad */
  135045. TouchPad = 17,
  135046. /** LStickXAxis */
  135047. LStickXAxis = 18,
  135048. /** LStickYAxis */
  135049. LStickYAxis = 19,
  135050. /** RStickXAxis */
  135051. RStickXAxis = 20,
  135052. /** RStickYAxis */
  135053. RStickYAxis = 21
  135054. }
  135055. /**
  135056. * Enum for Xbox Gamepad
  135057. */
  135058. export enum XboxInput {
  135059. /** A */
  135060. A = 0,
  135061. /** B */
  135062. B = 1,
  135063. /** X */
  135064. X = 2,
  135065. /** Y */
  135066. Y = 3,
  135067. /** LB */
  135068. LB = 4,
  135069. /** RB */
  135070. RB = 5,
  135071. /** LT */
  135072. LT = 6,
  135073. /** RT */
  135074. RT = 7,
  135075. /** Back */
  135076. Back = 8,
  135077. /** Start */
  135078. Start = 9,
  135079. /** LS */
  135080. LS = 10,
  135081. /** RS */
  135082. RS = 11,
  135083. /** DPadUp */
  135084. DPadUp = 12,
  135085. /** DPadDown */
  135086. DPadDown = 13,
  135087. /** DPadLeft */
  135088. DPadLeft = 14,
  135089. /** DRight */
  135090. DPadRight = 15,
  135091. /** Home */
  135092. Home = 16,
  135093. /** LStickXAxis */
  135094. LStickXAxis = 17,
  135095. /** LStickYAxis */
  135096. LStickYAxis = 18,
  135097. /** RStickXAxis */
  135098. RStickXAxis = 19,
  135099. /** RStickYAxis */
  135100. RStickYAxis = 20
  135101. }
  135102. /**
  135103. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  135104. */
  135105. export enum SwitchInput {
  135106. /** B */
  135107. B = 0,
  135108. /** A */
  135109. A = 1,
  135110. /** Y */
  135111. Y = 2,
  135112. /** X */
  135113. X = 3,
  135114. /** L */
  135115. L = 4,
  135116. /** R */
  135117. R = 5,
  135118. /** ZL */
  135119. ZL = 6,
  135120. /** ZR */
  135121. ZR = 7,
  135122. /** Minus */
  135123. Minus = 8,
  135124. /** Plus */
  135125. Plus = 9,
  135126. /** LS */
  135127. LS = 10,
  135128. /** RS */
  135129. RS = 11,
  135130. /** DPadUp */
  135131. DPadUp = 12,
  135132. /** DPadDown */
  135133. DPadDown = 13,
  135134. /** DPadLeft */
  135135. DPadLeft = 14,
  135136. /** DRight */
  135137. DPadRight = 15,
  135138. /** Home */
  135139. Home = 16,
  135140. /** Capture */
  135141. Capture = 17,
  135142. /** LStickXAxis */
  135143. LStickXAxis = 18,
  135144. /** LStickYAxis */
  135145. LStickYAxis = 19,
  135146. /** RStickXAxis */
  135147. RStickXAxis = 20,
  135148. /** RStickYAxis */
  135149. RStickYAxis = 21
  135150. }
  135151. }
  135152. declare module BABYLON {
  135153. /**
  135154. * This class will take all inputs from Keyboard, Pointer, and
  135155. * any Gamepads and provide a polling system that all devices
  135156. * will use. This class assumes that there will only be one
  135157. * pointer device and one keyboard.
  135158. */
  135159. export class DeviceInputSystem implements IDisposable {
  135160. /**
  135161. * Callback to be triggered when a device is connected
  135162. */
  135163. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135164. /**
  135165. * Callback to be triggered when a device is disconnected
  135166. */
  135167. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135168. /**
  135169. * Callback to be triggered when event driven input is updated
  135170. */
  135171. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  135172. private _inputs;
  135173. private _gamepads;
  135174. private _keyboardActive;
  135175. private _pointerActive;
  135176. private _elementToAttachTo;
  135177. private _keyboardDownEvent;
  135178. private _keyboardUpEvent;
  135179. private _pointerMoveEvent;
  135180. private _pointerDownEvent;
  135181. private _pointerUpEvent;
  135182. private _gamepadConnectedEvent;
  135183. private _gamepadDisconnectedEvent;
  135184. private static _MAX_KEYCODES;
  135185. private static _MAX_POINTER_INPUTS;
  135186. private constructor();
  135187. /**
  135188. * Creates a new DeviceInputSystem instance
  135189. * @param engine Engine to pull input element from
  135190. * @returns The new instance
  135191. */
  135192. static Create(engine: Engine): DeviceInputSystem;
  135193. /**
  135194. * Checks for current device input value, given an id and input index
  135195. * @param deviceName Id of connected device
  135196. * @param inputIndex Index of device input
  135197. * @returns Current value of input
  135198. */
  135199. /**
  135200. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  135201. * @param deviceType Enum specifiying device type
  135202. * @param deviceSlot "Slot" or index that device is referenced in
  135203. * @param inputIndex Id of input to be checked
  135204. * @returns Current value of input
  135205. */
  135206. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  135207. /**
  135208. * Dispose of all the eventlisteners
  135209. */
  135210. dispose(): void;
  135211. /**
  135212. * Add device and inputs to device array
  135213. * @param deviceType Enum specifiying device type
  135214. * @param deviceSlot "Slot" or index that device is referenced in
  135215. * @param numberOfInputs Number of input entries to create for given device
  135216. */
  135217. private _registerDevice;
  135218. /**
  135219. * Given a specific device name, remove that device from the device map
  135220. * @param deviceType Enum specifiying device type
  135221. * @param deviceSlot "Slot" or index that device is referenced in
  135222. */
  135223. private _unregisterDevice;
  135224. /**
  135225. * Handle all actions that come from keyboard interaction
  135226. */
  135227. private _handleKeyActions;
  135228. /**
  135229. * Handle all actions that come from pointer interaction
  135230. */
  135231. private _handlePointerActions;
  135232. /**
  135233. * Handle all actions that come from gamepad interaction
  135234. */
  135235. private _handleGamepadActions;
  135236. /**
  135237. * Update all non-event based devices with each frame
  135238. * @param deviceType Enum specifiying device type
  135239. * @param deviceSlot "Slot" or index that device is referenced in
  135240. * @param inputIndex Id of input to be checked
  135241. */
  135242. private _updateDevice;
  135243. /**
  135244. * Gets DeviceType from the device name
  135245. * @param deviceName Name of Device from DeviceInputSystem
  135246. * @returns DeviceType enum value
  135247. */
  135248. private _getGamepadDeviceType;
  135249. }
  135250. }
  135251. declare module BABYLON {
  135252. /**
  135253. * Type to handle enforcement of inputs
  135254. */
  135255. 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;
  135256. }
  135257. declare module BABYLON {
  135258. /**
  135259. * Class that handles all input for a specific device
  135260. */
  135261. export class DeviceSource<T extends DeviceType> {
  135262. /** Type of device */
  135263. readonly deviceType: DeviceType;
  135264. /** "Slot" or index that device is referenced in */
  135265. readonly deviceSlot: number;
  135266. /**
  135267. * Observable to handle device input changes per device
  135268. */
  135269. readonly onInputChangedObservable: Observable<{
  135270. inputIndex: DeviceInput<T>;
  135271. previousState: Nullable<number>;
  135272. currentState: Nullable<number>;
  135273. }>;
  135274. private readonly _deviceInputSystem;
  135275. /**
  135276. * Default Constructor
  135277. * @param deviceInputSystem Reference to DeviceInputSystem
  135278. * @param deviceType Type of device
  135279. * @param deviceSlot "Slot" or index that device is referenced in
  135280. */
  135281. constructor(deviceInputSystem: DeviceInputSystem,
  135282. /** Type of device */
  135283. deviceType: DeviceType,
  135284. /** "Slot" or index that device is referenced in */
  135285. deviceSlot?: number);
  135286. /**
  135287. * Get input for specific input
  135288. * @param inputIndex index of specific input on device
  135289. * @returns Input value from DeviceInputSystem
  135290. */
  135291. getInput(inputIndex: DeviceInput<T>): number;
  135292. }
  135293. /**
  135294. * Class to keep track of devices
  135295. */
  135296. export class DeviceSourceManager implements IDisposable {
  135297. /**
  135298. * Observable to be triggered when before a device is connected
  135299. */
  135300. readonly onBeforeDeviceConnectedObservable: Observable<{
  135301. deviceType: DeviceType;
  135302. deviceSlot: number;
  135303. }>;
  135304. /**
  135305. * Observable to be triggered when before a device is disconnected
  135306. */
  135307. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  135308. deviceType: DeviceType;
  135309. deviceSlot: number;
  135310. }>;
  135311. /**
  135312. * Observable to be triggered when after a device is connected
  135313. */
  135314. readonly onAfterDeviceConnectedObservable: Observable<{
  135315. deviceType: DeviceType;
  135316. deviceSlot: number;
  135317. }>;
  135318. /**
  135319. * Observable to be triggered when after a device is disconnected
  135320. */
  135321. readonly onAfterDeviceDisconnectedObservable: Observable<{
  135322. deviceType: DeviceType;
  135323. deviceSlot: number;
  135324. }>;
  135325. private readonly _devices;
  135326. private readonly _firstDevice;
  135327. private readonly _deviceInputSystem;
  135328. /**
  135329. * Default Constructor
  135330. * @param engine engine to pull input element from
  135331. */
  135332. constructor(engine: Engine);
  135333. /**
  135334. * Gets a DeviceSource, given a type and slot
  135335. * @param deviceType Enum specifying device type
  135336. * @param deviceSlot "Slot" or index that device is referenced in
  135337. * @returns DeviceSource object
  135338. */
  135339. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  135340. /**
  135341. * Gets an array of DeviceSource objects for a given device type
  135342. * @param deviceType Enum specifying device type
  135343. * @returns Array of DeviceSource objects
  135344. */
  135345. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  135346. /**
  135347. * Dispose of DeviceInputSystem and other parts
  135348. */
  135349. dispose(): void;
  135350. /**
  135351. * Function to add device name to device list
  135352. * @param deviceType Enum specifying device type
  135353. * @param deviceSlot "Slot" or index that device is referenced in
  135354. */
  135355. private _addDevice;
  135356. /**
  135357. * Function to remove device name to device list
  135358. * @param deviceType Enum specifying device type
  135359. * @param deviceSlot "Slot" or index that device is referenced in
  135360. */
  135361. private _removeDevice;
  135362. /**
  135363. * Updates array storing first connected device of each type
  135364. * @param type Type of Device
  135365. */
  135366. private _updateFirstDevices;
  135367. }
  135368. }
  135369. declare module BABYLON {
  135370. /**
  135371. * Options to create the null engine
  135372. */
  135373. export class NullEngineOptions {
  135374. /**
  135375. * Render width (Default: 512)
  135376. */
  135377. renderWidth: number;
  135378. /**
  135379. * Render height (Default: 256)
  135380. */
  135381. renderHeight: number;
  135382. /**
  135383. * Texture size (Default: 512)
  135384. */
  135385. textureSize: number;
  135386. /**
  135387. * If delta time between frames should be constant
  135388. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135389. */
  135390. deterministicLockstep: boolean;
  135391. /**
  135392. * Maximum about of steps between frames (Default: 4)
  135393. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135394. */
  135395. lockstepMaxSteps: number;
  135396. /**
  135397. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  135398. */
  135399. useHighPrecisionMatrix?: boolean;
  135400. }
  135401. /**
  135402. * The null engine class provides support for headless version of babylon.js.
  135403. * This can be used in server side scenario or for testing purposes
  135404. */
  135405. export class NullEngine extends Engine {
  135406. private _options;
  135407. /**
  135408. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  135409. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135410. * @returns true if engine is in deterministic lock step mode
  135411. */
  135412. isDeterministicLockStep(): boolean;
  135413. /**
  135414. * Gets the max steps when engine is running in deterministic lock step
  135415. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135416. * @returns the max steps
  135417. */
  135418. getLockstepMaxSteps(): number;
  135419. /**
  135420. * Gets the current hardware scaling level.
  135421. * By default the hardware scaling level is computed from the window device ratio.
  135422. * 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.
  135423. * @returns a number indicating the current hardware scaling level
  135424. */
  135425. getHardwareScalingLevel(): number;
  135426. constructor(options?: NullEngineOptions);
  135427. /**
  135428. * Creates a vertex buffer
  135429. * @param vertices the data for the vertex buffer
  135430. * @returns the new WebGL static buffer
  135431. */
  135432. createVertexBuffer(vertices: FloatArray): DataBuffer;
  135433. /**
  135434. * Creates a new index buffer
  135435. * @param indices defines the content of the index buffer
  135436. * @param updatable defines if the index buffer must be updatable
  135437. * @returns a new webGL buffer
  135438. */
  135439. createIndexBuffer(indices: IndicesArray): DataBuffer;
  135440. /**
  135441. * Clear the current render buffer or the current render target (if any is set up)
  135442. * @param color defines the color to use
  135443. * @param backBuffer defines if the back buffer must be cleared
  135444. * @param depth defines if the depth buffer must be cleared
  135445. * @param stencil defines if the stencil buffer must be cleared
  135446. */
  135447. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  135448. /**
  135449. * Gets the current render width
  135450. * @param useScreen defines if screen size must be used (or the current render target if any)
  135451. * @returns a number defining the current render width
  135452. */
  135453. getRenderWidth(useScreen?: boolean): number;
  135454. /**
  135455. * Gets the current render height
  135456. * @param useScreen defines if screen size must be used (or the current render target if any)
  135457. * @returns a number defining the current render height
  135458. */
  135459. getRenderHeight(useScreen?: boolean): number;
  135460. /**
  135461. * Set the WebGL's viewport
  135462. * @param viewport defines the viewport element to be used
  135463. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  135464. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  135465. */
  135466. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  135467. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  135468. /**
  135469. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  135470. * @param pipelineContext defines the pipeline context to use
  135471. * @param uniformsNames defines the list of uniform names
  135472. * @returns an array of webGL uniform locations
  135473. */
  135474. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  135475. /**
  135476. * Gets the lsit of active attributes for a given webGL program
  135477. * @param pipelineContext defines the pipeline context to use
  135478. * @param attributesNames defines the list of attribute names to get
  135479. * @returns an array of indices indicating the offset of each attribute
  135480. */
  135481. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  135482. /**
  135483. * Binds an effect to the webGL context
  135484. * @param effect defines the effect to bind
  135485. */
  135486. bindSamplers(effect: Effect): void;
  135487. /**
  135488. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  135489. * @param effect defines the effect to activate
  135490. */
  135491. enableEffect(effect: Effect): void;
  135492. /**
  135493. * Set various states to the webGL context
  135494. * @param culling defines backface culling state
  135495. * @param zOffset defines the value to apply to zOffset (0 by default)
  135496. * @param force defines if states must be applied even if cache is up to date
  135497. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  135498. */
  135499. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  135500. /**
  135501. * Set the value of an uniform to an array of int32
  135502. * @param uniform defines the webGL uniform location where to store the value
  135503. * @param array defines the array of int32 to store
  135504. * @returns true if value was set
  135505. */
  135506. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135507. /**
  135508. * Set the value of an uniform to an array of int32 (stored as vec2)
  135509. * @param uniform defines the webGL uniform location where to store the value
  135510. * @param array defines the array of int32 to store
  135511. * @returns true if value was set
  135512. */
  135513. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135514. /**
  135515. * Set the value of an uniform to an array of int32 (stored as vec3)
  135516. * @param uniform defines the webGL uniform location where to store the value
  135517. * @param array defines the array of int32 to store
  135518. * @returns true if value was set
  135519. */
  135520. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135521. /**
  135522. * Set the value of an uniform to an array of int32 (stored as vec4)
  135523. * @param uniform defines the webGL uniform location where to store the value
  135524. * @param array defines the array of int32 to store
  135525. * @returns true if value was set
  135526. */
  135527. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135528. /**
  135529. * Set the value of an uniform to an array of float32
  135530. * @param uniform defines the webGL uniform location where to store the value
  135531. * @param array defines the array of float32 to store
  135532. * @returns true if value was set
  135533. */
  135534. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135535. /**
  135536. * Set the value of an uniform to an array of float32 (stored as vec2)
  135537. * @param uniform defines the webGL uniform location where to store the value
  135538. * @param array defines the array of float32 to store
  135539. * @returns true if value was set
  135540. */
  135541. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135542. /**
  135543. * Set the value of an uniform to an array of float32 (stored as vec3)
  135544. * @param uniform defines the webGL uniform location where to store the value
  135545. * @param array defines the array of float32 to store
  135546. * @returns true if value was set
  135547. */
  135548. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135549. /**
  135550. * Set the value of an uniform to an array of float32 (stored as vec4)
  135551. * @param uniform defines the webGL uniform location where to store the value
  135552. * @param array defines the array of float32 to store
  135553. * @returns true if value was set
  135554. */
  135555. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135556. /**
  135557. * Set the value of an uniform to an array of number
  135558. * @param uniform defines the webGL uniform location where to store the value
  135559. * @param array defines the array of number to store
  135560. * @returns true if value was set
  135561. */
  135562. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  135563. /**
  135564. * Set the value of an uniform to an array of number (stored as vec2)
  135565. * @param uniform defines the webGL uniform location where to store the value
  135566. * @param array defines the array of number to store
  135567. * @returns true if value was set
  135568. */
  135569. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  135570. /**
  135571. * Set the value of an uniform to an array of number (stored as vec3)
  135572. * @param uniform defines the webGL uniform location where to store the value
  135573. * @param array defines the array of number to store
  135574. * @returns true if value was set
  135575. */
  135576. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  135577. /**
  135578. * Set the value of an uniform to an array of number (stored as vec4)
  135579. * @param uniform defines the webGL uniform location where to store the value
  135580. * @param array defines the array of number to store
  135581. * @returns true if value was set
  135582. */
  135583. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  135584. /**
  135585. * Set the value of an uniform to an array of float32 (stored as matrices)
  135586. * @param uniform defines the webGL uniform location where to store the value
  135587. * @param matrices defines the array of float32 to store
  135588. * @returns true if value was set
  135589. */
  135590. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  135591. /**
  135592. * Set the value of an uniform to a matrix (3x3)
  135593. * @param uniform defines the webGL uniform location where to store the value
  135594. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  135595. * @returns true if value was set
  135596. */
  135597. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135598. /**
  135599. * Set the value of an uniform to a matrix (2x2)
  135600. * @param uniform defines the webGL uniform location where to store the value
  135601. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  135602. * @returns true if value was set
  135603. */
  135604. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135605. /**
  135606. * Set the value of an uniform to a number (float)
  135607. * @param uniform defines the webGL uniform location where to store the value
  135608. * @param value defines the float number to store
  135609. * @returns true if value was set
  135610. */
  135611. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  135612. /**
  135613. * Set the value of an uniform to a vec2
  135614. * @param uniform defines the webGL uniform location where to store the value
  135615. * @param x defines the 1st component of the value
  135616. * @param y defines the 2nd component of the value
  135617. * @returns true if value was set
  135618. */
  135619. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  135620. /**
  135621. * Set the value of an uniform to a vec3
  135622. * @param uniform defines the webGL uniform location where to store the value
  135623. * @param x defines the 1st component of the value
  135624. * @param y defines the 2nd component of the value
  135625. * @param z defines the 3rd component of the value
  135626. * @returns true if value was set
  135627. */
  135628. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  135629. /**
  135630. * Set the value of an uniform to a boolean
  135631. * @param uniform defines the webGL uniform location where to store the value
  135632. * @param bool defines the boolean to store
  135633. * @returns true if value was set
  135634. */
  135635. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  135636. /**
  135637. * Set the value of an uniform to a vec4
  135638. * @param uniform defines the webGL uniform location where to store the value
  135639. * @param x defines the 1st component of the value
  135640. * @param y defines the 2nd component of the value
  135641. * @param z defines the 3rd component of the value
  135642. * @param w defines the 4th component of the value
  135643. * @returns true if value was set
  135644. */
  135645. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  135646. /**
  135647. * Sets the current alpha mode
  135648. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  135649. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  135650. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  135651. */
  135652. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  135653. /**
  135654. * Bind webGl buffers directly to the webGL context
  135655. * @param vertexBuffers defines the vertex buffer to bind
  135656. * @param indexBuffer defines the index buffer to bind
  135657. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  135658. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  135659. * @param effect defines the effect associated with the vertex buffer
  135660. */
  135661. bindBuffers(vertexBuffers: {
  135662. [key: string]: VertexBuffer;
  135663. }, indexBuffer: DataBuffer, effect: Effect): void;
  135664. /**
  135665. * Force the entire cache to be cleared
  135666. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  135667. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  135668. */
  135669. wipeCaches(bruteForce?: boolean): void;
  135670. /**
  135671. * Send a draw order
  135672. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  135673. * @param indexStart defines the starting index
  135674. * @param indexCount defines the number of index to draw
  135675. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135676. */
  135677. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  135678. /**
  135679. * Draw a list of indexed primitives
  135680. * @param fillMode defines the primitive to use
  135681. * @param indexStart defines the starting index
  135682. * @param indexCount defines the number of index to draw
  135683. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135684. */
  135685. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  135686. /**
  135687. * Draw a list of unindexed primitives
  135688. * @param fillMode defines the primitive to use
  135689. * @param verticesStart defines the index of first vertex to draw
  135690. * @param verticesCount defines the count of vertices to draw
  135691. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135692. */
  135693. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  135694. /** @hidden */
  135695. _createTexture(): WebGLTexture;
  135696. /** @hidden */
  135697. _releaseTexture(texture: InternalTexture): void;
  135698. /**
  135699. * Usually called from Texture.ts.
  135700. * Passed information to create a WebGLTexture
  135701. * @param urlArg defines a value which contains one of the following:
  135702. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  135703. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  135704. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  135705. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  135706. * @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)
  135707. * @param scene needed for loading to the correct scene
  135708. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  135709. * @param onLoad optional callback to be called upon successful completion
  135710. * @param onError optional callback to be called upon failure
  135711. * @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
  135712. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  135713. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  135714. * @param forcedExtension defines the extension to use to pick the right loader
  135715. * @param mimeType defines an optional mime type
  135716. * @returns a InternalTexture for assignment back into BABYLON.Texture
  135717. */
  135718. 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;
  135719. /**
  135720. * Creates a new render target texture
  135721. * @param size defines the size of the texture
  135722. * @param options defines the options used to create the texture
  135723. * @returns a new render target texture stored in an InternalTexture
  135724. */
  135725. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  135726. /**
  135727. * Update the sampling mode of a given texture
  135728. * @param samplingMode defines the required sampling mode
  135729. * @param texture defines the texture to update
  135730. */
  135731. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  135732. /**
  135733. * Binds the frame buffer to the specified texture.
  135734. * @param texture The texture to render to or null for the default canvas
  135735. * @param faceIndex The face of the texture to render to in case of cube texture
  135736. * @param requiredWidth The width of the target to render to
  135737. * @param requiredHeight The height of the target to render to
  135738. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  135739. * @param lodLevel defines le lod level to bind to the frame buffer
  135740. */
  135741. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  135742. /**
  135743. * Unbind the current render target texture from the webGL context
  135744. * @param texture defines the render target texture to unbind
  135745. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  135746. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  135747. */
  135748. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  135749. /**
  135750. * Creates a dynamic vertex buffer
  135751. * @param vertices the data for the dynamic vertex buffer
  135752. * @returns the new WebGL dynamic buffer
  135753. */
  135754. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  135755. /**
  135756. * Update the content of a dynamic texture
  135757. * @param texture defines the texture to update
  135758. * @param canvas defines the canvas containing the source
  135759. * @param invertY defines if data must be stored with Y axis inverted
  135760. * @param premulAlpha defines if alpha is stored as premultiplied
  135761. * @param format defines the format of the data
  135762. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  135763. */
  135764. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  135765. /**
  135766. * Gets a boolean indicating if all created effects are ready
  135767. * @returns true if all effects are ready
  135768. */
  135769. areAllEffectsReady(): boolean;
  135770. /**
  135771. * @hidden
  135772. * Get the current error code of the webGL context
  135773. * @returns the error code
  135774. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  135775. */
  135776. getError(): number;
  135777. /** @hidden */
  135778. _getUnpackAlignement(): number;
  135779. /** @hidden */
  135780. _unpackFlipY(value: boolean): void;
  135781. /**
  135782. * Update a dynamic index buffer
  135783. * @param indexBuffer defines the target index buffer
  135784. * @param indices defines the data to update
  135785. * @param offset defines the offset in the target index buffer where update should start
  135786. */
  135787. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  135788. /**
  135789. * Updates a dynamic vertex buffer.
  135790. * @param vertexBuffer the vertex buffer to update
  135791. * @param vertices the data used to update the vertex buffer
  135792. * @param byteOffset the byte offset of the data (optional)
  135793. * @param byteLength the byte length of the data (optional)
  135794. */
  135795. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  135796. /** @hidden */
  135797. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  135798. /** @hidden */
  135799. _bindTexture(channel: number, texture: InternalTexture): void;
  135800. protected _deleteBuffer(buffer: WebGLBuffer): void;
  135801. /**
  135802. * 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
  135803. */
  135804. releaseEffects(): void;
  135805. displayLoadingUI(): void;
  135806. hideLoadingUI(): void;
  135807. /** @hidden */
  135808. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  135809. /** @hidden */
  135810. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  135811. /** @hidden */
  135812. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  135813. /** @hidden */
  135814. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  135815. }
  135816. }
  135817. declare module BABYLON {
  135818. /**
  135819. * @hidden
  135820. **/
  135821. export class _TimeToken {
  135822. _startTimeQuery: Nullable<WebGLQuery>;
  135823. _endTimeQuery: Nullable<WebGLQuery>;
  135824. _timeElapsedQuery: Nullable<WebGLQuery>;
  135825. _timeElapsedQueryEnded: boolean;
  135826. }
  135827. }
  135828. declare module BABYLON {
  135829. /** @hidden */
  135830. export class _OcclusionDataStorage {
  135831. /** @hidden */
  135832. occlusionInternalRetryCounter: number;
  135833. /** @hidden */
  135834. isOcclusionQueryInProgress: boolean;
  135835. /** @hidden */
  135836. isOccluded: boolean;
  135837. /** @hidden */
  135838. occlusionRetryCount: number;
  135839. /** @hidden */
  135840. occlusionType: number;
  135841. /** @hidden */
  135842. occlusionQueryAlgorithmType: number;
  135843. }
  135844. interface Engine {
  135845. /**
  135846. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  135847. * @return the new query
  135848. */
  135849. createQuery(): WebGLQuery;
  135850. /**
  135851. * Delete and release a webGL query
  135852. * @param query defines the query to delete
  135853. * @return the current engine
  135854. */
  135855. deleteQuery(query: WebGLQuery): Engine;
  135856. /**
  135857. * Check if a given query has resolved and got its value
  135858. * @param query defines the query to check
  135859. * @returns true if the query got its value
  135860. */
  135861. isQueryResultAvailable(query: WebGLQuery): boolean;
  135862. /**
  135863. * Gets the value of a given query
  135864. * @param query defines the query to check
  135865. * @returns the value of the query
  135866. */
  135867. getQueryResult(query: WebGLQuery): number;
  135868. /**
  135869. * Initiates an occlusion query
  135870. * @param algorithmType defines the algorithm to use
  135871. * @param query defines the query to use
  135872. * @returns the current engine
  135873. * @see https://doc.babylonjs.com/features/occlusionquery
  135874. */
  135875. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  135876. /**
  135877. * Ends an occlusion query
  135878. * @see https://doc.babylonjs.com/features/occlusionquery
  135879. * @param algorithmType defines the algorithm to use
  135880. * @returns the current engine
  135881. */
  135882. endOcclusionQuery(algorithmType: number): Engine;
  135883. /**
  135884. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  135885. * Please note that only one query can be issued at a time
  135886. * @returns a time token used to track the time span
  135887. */
  135888. startTimeQuery(): Nullable<_TimeToken>;
  135889. /**
  135890. * Ends a time query
  135891. * @param token defines the token used to measure the time span
  135892. * @returns the time spent (in ns)
  135893. */
  135894. endTimeQuery(token: _TimeToken): int;
  135895. /** @hidden */
  135896. _currentNonTimestampToken: Nullable<_TimeToken>;
  135897. /** @hidden */
  135898. _createTimeQuery(): WebGLQuery;
  135899. /** @hidden */
  135900. _deleteTimeQuery(query: WebGLQuery): void;
  135901. /** @hidden */
  135902. _getGlAlgorithmType(algorithmType: number): number;
  135903. /** @hidden */
  135904. _getTimeQueryResult(query: WebGLQuery): any;
  135905. /** @hidden */
  135906. _getTimeQueryAvailability(query: WebGLQuery): any;
  135907. }
  135908. interface AbstractMesh {
  135909. /**
  135910. * Backing filed
  135911. * @hidden
  135912. */
  135913. __occlusionDataStorage: _OcclusionDataStorage;
  135914. /**
  135915. * Access property
  135916. * @hidden
  135917. */
  135918. _occlusionDataStorage: _OcclusionDataStorage;
  135919. /**
  135920. * 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.
  135921. * The default value is -1 which means don't break the query and wait till the result
  135922. * @see https://doc.babylonjs.com/features/occlusionquery
  135923. */
  135924. occlusionRetryCount: number;
  135925. /**
  135926. * 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:
  135927. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  135928. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  135929. * * 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.
  135930. * @see https://doc.babylonjs.com/features/occlusionquery
  135931. */
  135932. occlusionType: number;
  135933. /**
  135934. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  135935. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  135936. * * 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.
  135937. * @see https://doc.babylonjs.com/features/occlusionquery
  135938. */
  135939. occlusionQueryAlgorithmType: number;
  135940. /**
  135941. * 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
  135942. * @see https://doc.babylonjs.com/features/occlusionquery
  135943. */
  135944. isOccluded: boolean;
  135945. /**
  135946. * Flag to check the progress status of the query
  135947. * @see https://doc.babylonjs.com/features/occlusionquery
  135948. */
  135949. isOcclusionQueryInProgress: boolean;
  135950. }
  135951. }
  135952. declare module BABYLON {
  135953. /** @hidden */
  135954. export var _forceTransformFeedbackToBundle: boolean;
  135955. interface Engine {
  135956. /**
  135957. * Creates a webGL transform feedback object
  135958. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  135959. * @returns the webGL transform feedback object
  135960. */
  135961. createTransformFeedback(): WebGLTransformFeedback;
  135962. /**
  135963. * Delete a webGL transform feedback object
  135964. * @param value defines the webGL transform feedback object to delete
  135965. */
  135966. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  135967. /**
  135968. * Bind a webGL transform feedback object to the webgl context
  135969. * @param value defines the webGL transform feedback object to bind
  135970. */
  135971. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  135972. /**
  135973. * Begins a transform feedback operation
  135974. * @param usePoints defines if points or triangles must be used
  135975. */
  135976. beginTransformFeedback(usePoints: boolean): void;
  135977. /**
  135978. * Ends a transform feedback operation
  135979. */
  135980. endTransformFeedback(): void;
  135981. /**
  135982. * Specify the varyings to use with transform feedback
  135983. * @param program defines the associated webGL program
  135984. * @param value defines the list of strings representing the varying names
  135985. */
  135986. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  135987. /**
  135988. * Bind a webGL buffer for a transform feedback operation
  135989. * @param value defines the webGL buffer to bind
  135990. */
  135991. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  135992. }
  135993. }
  135994. declare module BABYLON {
  135995. /**
  135996. * Class used to define an additional view for the engine
  135997. * @see https://doc.babylonjs.com/how_to/multi_canvases
  135998. */
  135999. export class EngineView {
  136000. /** Defines the canvas where to render the view */
  136001. target: HTMLCanvasElement;
  136002. /** Defines an optional camera used to render the view (will use active camera else) */
  136003. camera?: Camera;
  136004. }
  136005. interface Engine {
  136006. /**
  136007. * Gets or sets the HTML element to use for attaching events
  136008. */
  136009. inputElement: Nullable<HTMLElement>;
  136010. /**
  136011. * Gets the current engine view
  136012. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136013. */
  136014. activeView: Nullable<EngineView>;
  136015. /** Gets or sets the list of views */
  136016. views: EngineView[];
  136017. /**
  136018. * Register a new child canvas
  136019. * @param canvas defines the canvas to register
  136020. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  136021. * @returns the associated view
  136022. */
  136023. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  136024. /**
  136025. * Remove a registered child canvas
  136026. * @param canvas defines the canvas to remove
  136027. * @returns the current engine
  136028. */
  136029. unRegisterView(canvas: HTMLCanvasElement): Engine;
  136030. }
  136031. }
  136032. declare module BABYLON {
  136033. interface Engine {
  136034. /** @hidden */
  136035. _excludedCompressedTextures: string[];
  136036. /** @hidden */
  136037. _textureFormatInUse: string;
  136038. /**
  136039. * Gets the list of texture formats supported
  136040. */
  136041. readonly texturesSupported: Array<string>;
  136042. /**
  136043. * Gets the texture format in use
  136044. */
  136045. readonly textureFormatInUse: Nullable<string>;
  136046. /**
  136047. * Set the compressed texture extensions or file names to skip.
  136048. *
  136049. * @param skippedFiles defines the list of those texture files you want to skip
  136050. * Example: [".dds", ".env", "myfile.png"]
  136051. */
  136052. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  136053. /**
  136054. * Set the compressed texture format to use, based on the formats you have, and the formats
  136055. * supported by the hardware / browser.
  136056. *
  136057. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  136058. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  136059. * to API arguments needed to compressed textures. This puts the burden on the container
  136060. * generator to house the arcane code for determining these for current & future formats.
  136061. *
  136062. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  136063. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  136064. *
  136065. * Note: The result of this call is not taken into account when a texture is base64.
  136066. *
  136067. * @param formatsAvailable defines the list of those format families you have created
  136068. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  136069. *
  136070. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  136071. * @returns The extension selected.
  136072. */
  136073. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  136074. }
  136075. }
  136076. declare module BABYLON {
  136077. /** @hidden */
  136078. export var rgbdEncodePixelShader: {
  136079. name: string;
  136080. shader: string;
  136081. };
  136082. }
  136083. declare module BABYLON {
  136084. /**
  136085. * Raw texture data and descriptor sufficient for WebGL texture upload
  136086. */
  136087. export interface EnvironmentTextureInfo {
  136088. /**
  136089. * Version of the environment map
  136090. */
  136091. version: number;
  136092. /**
  136093. * Width of image
  136094. */
  136095. width: number;
  136096. /**
  136097. * Irradiance information stored in the file.
  136098. */
  136099. irradiance: any;
  136100. /**
  136101. * Specular information stored in the file.
  136102. */
  136103. specular: any;
  136104. }
  136105. /**
  136106. * Defines One Image in the file. It requires only the position in the file
  136107. * as well as the length.
  136108. */
  136109. interface BufferImageData {
  136110. /**
  136111. * Length of the image data.
  136112. */
  136113. length: number;
  136114. /**
  136115. * Position of the data from the null terminator delimiting the end of the JSON.
  136116. */
  136117. position: number;
  136118. }
  136119. /**
  136120. * Defines the specular data enclosed in the file.
  136121. * This corresponds to the version 1 of the data.
  136122. */
  136123. export interface EnvironmentTextureSpecularInfoV1 {
  136124. /**
  136125. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  136126. */
  136127. specularDataPosition?: number;
  136128. /**
  136129. * This contains all the images data needed to reconstruct the cubemap.
  136130. */
  136131. mipmaps: Array<BufferImageData>;
  136132. /**
  136133. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  136134. */
  136135. lodGenerationScale: number;
  136136. }
  136137. /**
  136138. * Sets of helpers addressing the serialization and deserialization of environment texture
  136139. * stored in a BabylonJS env file.
  136140. * Those files are usually stored as .env files.
  136141. */
  136142. export class EnvironmentTextureTools {
  136143. /**
  136144. * Magic number identifying the env file.
  136145. */
  136146. private static _MagicBytes;
  136147. /**
  136148. * Gets the environment info from an env file.
  136149. * @param data The array buffer containing the .env bytes.
  136150. * @returns the environment file info (the json header) if successfully parsed.
  136151. */
  136152. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  136153. /**
  136154. * Creates an environment texture from a loaded cube texture.
  136155. * @param texture defines the cube texture to convert in env file
  136156. * @return a promise containing the environment data if succesfull.
  136157. */
  136158. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  136159. /**
  136160. * Creates a JSON representation of the spherical data.
  136161. * @param texture defines the texture containing the polynomials
  136162. * @return the JSON representation of the spherical info
  136163. */
  136164. private static _CreateEnvTextureIrradiance;
  136165. /**
  136166. * Creates the ArrayBufferViews used for initializing environment texture image data.
  136167. * @param data the image data
  136168. * @param info parameters that determine what views will be created for accessing the underlying buffer
  136169. * @return the views described by info providing access to the underlying buffer
  136170. */
  136171. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  136172. /**
  136173. * Uploads the texture info contained in the env file to the GPU.
  136174. * @param texture defines the internal texture to upload to
  136175. * @param data defines the data to load
  136176. * @param info defines the texture info retrieved through the GetEnvInfo method
  136177. * @returns a promise
  136178. */
  136179. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  136180. private static _OnImageReadyAsync;
  136181. /**
  136182. * Uploads the levels of image data to the GPU.
  136183. * @param texture defines the internal texture to upload to
  136184. * @param imageData defines the array buffer views of image data [mipmap][face]
  136185. * @returns a promise
  136186. */
  136187. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  136188. /**
  136189. * Uploads spherical polynomials information to the texture.
  136190. * @param texture defines the texture we are trying to upload the information to
  136191. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  136192. */
  136193. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  136194. /** @hidden */
  136195. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  136196. }
  136197. }
  136198. declare module BABYLON {
  136199. /**
  136200. * Class used to inline functions in shader code
  136201. */
  136202. export class ShaderCodeInliner {
  136203. private static readonly _RegexpFindFunctionNameAndType;
  136204. private _sourceCode;
  136205. private _functionDescr;
  136206. private _numMaxIterations;
  136207. /** Gets or sets the token used to mark the functions to inline */
  136208. inlineToken: string;
  136209. /** Gets or sets the debug mode */
  136210. debug: boolean;
  136211. /** Gets the code after the inlining process */
  136212. get code(): string;
  136213. /**
  136214. * Initializes the inliner
  136215. * @param sourceCode shader code source to inline
  136216. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  136217. */
  136218. constructor(sourceCode: string, numMaxIterations?: number);
  136219. /**
  136220. * Start the processing of the shader code
  136221. */
  136222. processCode(): void;
  136223. private _collectFunctions;
  136224. private _processInlining;
  136225. private _extractBetweenMarkers;
  136226. private _skipWhitespaces;
  136227. private _removeComments;
  136228. private _replaceFunctionCallsByCode;
  136229. private _findBackward;
  136230. private _escapeRegExp;
  136231. private _replaceNames;
  136232. }
  136233. }
  136234. declare module BABYLON {
  136235. /**
  136236. * Container for accessors for natively-stored mesh data buffers.
  136237. */
  136238. class NativeDataBuffer extends DataBuffer {
  136239. /**
  136240. * Accessor value used to identify/retrieve a natively-stored index buffer.
  136241. */
  136242. nativeIndexBuffer?: any;
  136243. /**
  136244. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  136245. */
  136246. nativeVertexBuffer?: any;
  136247. }
  136248. /** @hidden */
  136249. class NativeTexture extends InternalTexture {
  136250. getInternalTexture(): InternalTexture;
  136251. getViewCount(): number;
  136252. }
  136253. /** @hidden */
  136254. export class NativeEngine extends Engine {
  136255. private readonly _native;
  136256. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  136257. private readonly INVALID_HANDLE;
  136258. private _boundBuffersVertexArray;
  136259. private _currentDepthTest;
  136260. getHardwareScalingLevel(): number;
  136261. constructor();
  136262. dispose(): void;
  136263. /**
  136264. * Can be used to override the current requestAnimationFrame requester.
  136265. * @hidden
  136266. */
  136267. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  136268. /**
  136269. * Override default engine behavior.
  136270. * @param color
  136271. * @param backBuffer
  136272. * @param depth
  136273. * @param stencil
  136274. */
  136275. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  136276. /**
  136277. * Gets host document
  136278. * @returns the host document object
  136279. */
  136280. getHostDocument(): Nullable<Document>;
  136281. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  136282. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  136283. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  136284. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  136285. [key: string]: VertexBuffer;
  136286. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136287. bindBuffers(vertexBuffers: {
  136288. [key: string]: VertexBuffer;
  136289. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136290. recordVertexArrayObject(vertexBuffers: {
  136291. [key: string]: VertexBuffer;
  136292. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  136293. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136294. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136295. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  136296. /**
  136297. * Draw a list of indexed primitives
  136298. * @param fillMode defines the primitive to use
  136299. * @param indexStart defines the starting index
  136300. * @param indexCount defines the number of index to draw
  136301. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136302. */
  136303. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  136304. /**
  136305. * Draw a list of unindexed primitives
  136306. * @param fillMode defines the primitive to use
  136307. * @param verticesStart defines the index of first vertex to draw
  136308. * @param verticesCount defines the count of vertices to draw
  136309. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136310. */
  136311. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  136312. createPipelineContext(): IPipelineContext;
  136313. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  136314. /** @hidden */
  136315. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  136316. /** @hidden */
  136317. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  136318. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136319. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136320. protected _setProgram(program: WebGLProgram): void;
  136321. _releaseEffect(effect: Effect): void;
  136322. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  136323. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  136324. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  136325. bindSamplers(effect: Effect): void;
  136326. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  136327. getRenderWidth(useScreen?: boolean): number;
  136328. getRenderHeight(useScreen?: boolean): number;
  136329. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  136330. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  136331. /**
  136332. * Set the z offset to apply to current rendering
  136333. * @param value defines the offset to apply
  136334. */
  136335. setZOffset(value: number): void;
  136336. /**
  136337. * Gets the current value of the zOffset
  136338. * @returns the current zOffset state
  136339. */
  136340. getZOffset(): number;
  136341. /**
  136342. * Enable or disable depth buffering
  136343. * @param enable defines the state to set
  136344. */
  136345. setDepthBuffer(enable: boolean): void;
  136346. /**
  136347. * Gets a boolean indicating if depth writing is enabled
  136348. * @returns the current depth writing state
  136349. */
  136350. getDepthWrite(): boolean;
  136351. setDepthFunctionToGreater(): void;
  136352. setDepthFunctionToGreaterOrEqual(): void;
  136353. setDepthFunctionToLess(): void;
  136354. setDepthFunctionToLessOrEqual(): void;
  136355. /**
  136356. * Enable or disable depth writing
  136357. * @param enable defines the state to set
  136358. */
  136359. setDepthWrite(enable: boolean): void;
  136360. /**
  136361. * Enable or disable color writing
  136362. * @param enable defines the state to set
  136363. */
  136364. setColorWrite(enable: boolean): void;
  136365. /**
  136366. * Gets a boolean indicating if color writing is enabled
  136367. * @returns the current color writing state
  136368. */
  136369. getColorWrite(): boolean;
  136370. /**
  136371. * Sets alpha constants used by some alpha blending modes
  136372. * @param r defines the red component
  136373. * @param g defines the green component
  136374. * @param b defines the blue component
  136375. * @param a defines the alpha component
  136376. */
  136377. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  136378. /**
  136379. * Sets the current alpha mode
  136380. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  136381. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  136382. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136383. */
  136384. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  136385. /**
  136386. * Gets the current alpha mode
  136387. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136388. * @returns the current alpha mode
  136389. */
  136390. getAlphaMode(): number;
  136391. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  136392. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136393. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136394. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136395. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136396. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136397. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136398. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136399. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136400. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  136401. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  136402. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  136403. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  136404. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  136405. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136406. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136407. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  136408. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  136409. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  136410. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  136411. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  136412. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  136413. wipeCaches(bruteForce?: boolean): void;
  136414. _createTexture(): WebGLTexture;
  136415. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  136416. /**
  136417. * Update the content of a dynamic texture
  136418. * @param texture defines the texture to update
  136419. * @param canvas defines the canvas containing the source
  136420. * @param invertY defines if data must be stored with Y axis inverted
  136421. * @param premulAlpha defines if alpha is stored as premultiplied
  136422. * @param format defines the format of the data
  136423. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  136424. */
  136425. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  136426. /**
  136427. * Usually called from Texture.ts.
  136428. * Passed information to create a WebGLTexture
  136429. * @param url defines a value which contains one of the following:
  136430. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  136431. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  136432. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  136433. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  136434. * @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)
  136435. * @param scene needed for loading to the correct scene
  136436. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  136437. * @param onLoad optional callback to be called upon successful completion
  136438. * @param onError optional callback to be called upon failure
  136439. * @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
  136440. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  136441. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  136442. * @param forcedExtension defines the extension to use to pick the right loader
  136443. * @param mimeType defines an optional mime type
  136444. * @returns a InternalTexture for assignment back into BABYLON.Texture
  136445. */
  136446. 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;
  136447. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  136448. _releaseFramebufferObjects(texture: InternalTexture): void;
  136449. /**
  136450. * Creates a cube texture
  136451. * @param rootUrl defines the url where the files to load is located
  136452. * @param scene defines the current scene
  136453. * @param files defines the list of files to load (1 per face)
  136454. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  136455. * @param onLoad defines an optional callback raised when the texture is loaded
  136456. * @param onError defines an optional callback raised if there is an issue to load the texture
  136457. * @param format defines the format of the data
  136458. * @param forcedExtension defines the extension to use to pick the right loader
  136459. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  136460. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  136461. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  136462. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  136463. * @returns the cube texture as an InternalTexture
  136464. */
  136465. 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;
  136466. createRenderTargetTexture(size: number | {
  136467. width: number;
  136468. height: number;
  136469. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  136470. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  136471. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  136472. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  136473. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  136474. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  136475. /**
  136476. * Updates a dynamic vertex buffer.
  136477. * @param vertexBuffer the vertex buffer to update
  136478. * @param data the data used to update the vertex buffer
  136479. * @param byteOffset the byte offset of the data (optional)
  136480. * @param byteLength the byte length of the data (optional)
  136481. */
  136482. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  136483. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  136484. private _updateAnisotropicLevel;
  136485. private _getAddressMode;
  136486. /** @hidden */
  136487. _bindTexture(channel: number, texture: InternalTexture): void;
  136488. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  136489. releaseEffects(): void;
  136490. /** @hidden */
  136491. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136492. /** @hidden */
  136493. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136494. /** @hidden */
  136495. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136496. /** @hidden */
  136497. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  136498. private _getNativeSamplingMode;
  136499. private _getNativeTextureFormat;
  136500. private _getNativeAlphaMode;
  136501. private _getNativeAttribType;
  136502. }
  136503. }
  136504. declare module BABYLON {
  136505. /**
  136506. * Gather the list of clipboard event types as constants.
  136507. */
  136508. export class ClipboardEventTypes {
  136509. /**
  136510. * The clipboard event is fired when a copy command is active (pressed).
  136511. */
  136512. static readonly COPY: number;
  136513. /**
  136514. * The clipboard event is fired when a cut command is active (pressed).
  136515. */
  136516. static readonly CUT: number;
  136517. /**
  136518. * The clipboard event is fired when a paste command is active (pressed).
  136519. */
  136520. static readonly PASTE: number;
  136521. }
  136522. /**
  136523. * This class is used to store clipboard related info for the onClipboardObservable event.
  136524. */
  136525. export class ClipboardInfo {
  136526. /**
  136527. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136528. */
  136529. type: number;
  136530. /**
  136531. * Defines the related dom event
  136532. */
  136533. event: ClipboardEvent;
  136534. /**
  136535. *Creates an instance of ClipboardInfo.
  136536. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  136537. * @param event Defines the related dom event
  136538. */
  136539. constructor(
  136540. /**
  136541. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136542. */
  136543. type: number,
  136544. /**
  136545. * Defines the related dom event
  136546. */
  136547. event: ClipboardEvent);
  136548. /**
  136549. * Get the clipboard event's type from the keycode.
  136550. * @param keyCode Defines the keyCode for the current keyboard event.
  136551. * @return {number}
  136552. */
  136553. static GetTypeFromCharacter(keyCode: number): number;
  136554. }
  136555. }
  136556. declare module BABYLON {
  136557. /**
  136558. * Google Daydream controller
  136559. */
  136560. export class DaydreamController extends WebVRController {
  136561. /**
  136562. * Base Url for the controller model.
  136563. */
  136564. static MODEL_BASE_URL: string;
  136565. /**
  136566. * File name for the controller model.
  136567. */
  136568. static MODEL_FILENAME: string;
  136569. /**
  136570. * Gamepad Id prefix used to identify Daydream Controller.
  136571. */
  136572. static readonly GAMEPAD_ID_PREFIX: string;
  136573. /**
  136574. * Creates a new DaydreamController from a gamepad
  136575. * @param vrGamepad the gamepad that the controller should be created from
  136576. */
  136577. constructor(vrGamepad: any);
  136578. /**
  136579. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136580. * @param scene scene in which to add meshes
  136581. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136582. */
  136583. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136584. /**
  136585. * Called once for each button that changed state since the last frame
  136586. * @param buttonIdx Which button index changed
  136587. * @param state New state of the button
  136588. * @param changes Which properties on the state changed since last frame
  136589. */
  136590. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136591. }
  136592. }
  136593. declare module BABYLON {
  136594. /**
  136595. * Gear VR Controller
  136596. */
  136597. export class GearVRController extends WebVRController {
  136598. /**
  136599. * Base Url for the controller model.
  136600. */
  136601. static MODEL_BASE_URL: string;
  136602. /**
  136603. * File name for the controller model.
  136604. */
  136605. static MODEL_FILENAME: string;
  136606. /**
  136607. * Gamepad Id prefix used to identify this controller.
  136608. */
  136609. static readonly GAMEPAD_ID_PREFIX: string;
  136610. private readonly _buttonIndexToObservableNameMap;
  136611. /**
  136612. * Creates a new GearVRController from a gamepad
  136613. * @param vrGamepad the gamepad that the controller should be created from
  136614. */
  136615. constructor(vrGamepad: any);
  136616. /**
  136617. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136618. * @param scene scene in which to add meshes
  136619. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136620. */
  136621. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136622. /**
  136623. * Called once for each button that changed state since the last frame
  136624. * @param buttonIdx Which button index changed
  136625. * @param state New state of the button
  136626. * @param changes Which properties on the state changed since last frame
  136627. */
  136628. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136629. }
  136630. }
  136631. declare module BABYLON {
  136632. /**
  136633. * Generic Controller
  136634. */
  136635. export class GenericController extends WebVRController {
  136636. /**
  136637. * Base Url for the controller model.
  136638. */
  136639. static readonly MODEL_BASE_URL: string;
  136640. /**
  136641. * File name for the controller model.
  136642. */
  136643. static readonly MODEL_FILENAME: string;
  136644. /**
  136645. * Creates a new GenericController from a gamepad
  136646. * @param vrGamepad the gamepad that the controller should be created from
  136647. */
  136648. constructor(vrGamepad: any);
  136649. /**
  136650. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136651. * @param scene scene in which to add meshes
  136652. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136653. */
  136654. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136655. /**
  136656. * Called once for each button that changed state since the last frame
  136657. * @param buttonIdx Which button index changed
  136658. * @param state New state of the button
  136659. * @param changes Which properties on the state changed since last frame
  136660. */
  136661. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136662. }
  136663. }
  136664. declare module BABYLON {
  136665. /**
  136666. * Oculus Touch Controller
  136667. */
  136668. export class OculusTouchController extends WebVRController {
  136669. /**
  136670. * Base Url for the controller model.
  136671. */
  136672. static MODEL_BASE_URL: string;
  136673. /**
  136674. * File name for the left controller model.
  136675. */
  136676. static MODEL_LEFT_FILENAME: string;
  136677. /**
  136678. * File name for the right controller model.
  136679. */
  136680. static MODEL_RIGHT_FILENAME: string;
  136681. /**
  136682. * Base Url for the Quest controller model.
  136683. */
  136684. static QUEST_MODEL_BASE_URL: string;
  136685. /**
  136686. * @hidden
  136687. * If the controllers are running on a device that needs the updated Quest controller models
  136688. */
  136689. static _IsQuest: boolean;
  136690. /**
  136691. * Fired when the secondary trigger on this controller is modified
  136692. */
  136693. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  136694. /**
  136695. * Fired when the thumb rest on this controller is modified
  136696. */
  136697. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  136698. /**
  136699. * Creates a new OculusTouchController from a gamepad
  136700. * @param vrGamepad the gamepad that the controller should be created from
  136701. */
  136702. constructor(vrGamepad: any);
  136703. /**
  136704. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136705. * @param scene scene in which to add meshes
  136706. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136707. */
  136708. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136709. /**
  136710. * Fired when the A button on this controller is modified
  136711. */
  136712. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136713. /**
  136714. * Fired when the B button on this controller is modified
  136715. */
  136716. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136717. /**
  136718. * Fired when the X button on this controller is modified
  136719. */
  136720. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136721. /**
  136722. * Fired when the Y button on this controller is modified
  136723. */
  136724. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136725. /**
  136726. * Called once for each button that changed state since the last frame
  136727. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  136728. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  136729. * 2) secondary trigger (same)
  136730. * 3) A (right) X (left), touch, pressed = value
  136731. * 4) B / Y
  136732. * 5) thumb rest
  136733. * @param buttonIdx Which button index changed
  136734. * @param state New state of the button
  136735. * @param changes Which properties on the state changed since last frame
  136736. */
  136737. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136738. }
  136739. }
  136740. declare module BABYLON {
  136741. /**
  136742. * Vive Controller
  136743. */
  136744. export class ViveController extends WebVRController {
  136745. /**
  136746. * Base Url for the controller model.
  136747. */
  136748. static MODEL_BASE_URL: string;
  136749. /**
  136750. * File name for the controller model.
  136751. */
  136752. static MODEL_FILENAME: string;
  136753. /**
  136754. * Creates a new ViveController from a gamepad
  136755. * @param vrGamepad the gamepad that the controller should be created from
  136756. */
  136757. constructor(vrGamepad: any);
  136758. /**
  136759. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136760. * @param scene scene in which to add meshes
  136761. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136762. */
  136763. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136764. /**
  136765. * Fired when the left button on this controller is modified
  136766. */
  136767. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136768. /**
  136769. * Fired when the right button on this controller is modified
  136770. */
  136771. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136772. /**
  136773. * Fired when the menu button on this controller is modified
  136774. */
  136775. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136776. /**
  136777. * Called once for each button that changed state since the last frame
  136778. * Vive mapping:
  136779. * 0: touchpad
  136780. * 1: trigger
  136781. * 2: left AND right buttons
  136782. * 3: menu button
  136783. * @param buttonIdx Which button index changed
  136784. * @param state New state of the button
  136785. * @param changes Which properties on the state changed since last frame
  136786. */
  136787. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136788. }
  136789. }
  136790. declare module BABYLON {
  136791. /**
  136792. * Defines the WindowsMotionController object that the state of the windows motion controller
  136793. */
  136794. export class WindowsMotionController extends WebVRController {
  136795. /**
  136796. * The base url used to load the left and right controller models
  136797. */
  136798. static MODEL_BASE_URL: string;
  136799. /**
  136800. * The name of the left controller model file
  136801. */
  136802. static MODEL_LEFT_FILENAME: string;
  136803. /**
  136804. * The name of the right controller model file
  136805. */
  136806. static MODEL_RIGHT_FILENAME: string;
  136807. /**
  136808. * The controller name prefix for this controller type
  136809. */
  136810. static readonly GAMEPAD_ID_PREFIX: string;
  136811. /**
  136812. * The controller id pattern for this controller type
  136813. */
  136814. private static readonly GAMEPAD_ID_PATTERN;
  136815. private _loadedMeshInfo;
  136816. protected readonly _mapping: {
  136817. buttons: string[];
  136818. buttonMeshNames: {
  136819. trigger: string;
  136820. menu: string;
  136821. grip: string;
  136822. thumbstick: string;
  136823. trackpad: string;
  136824. };
  136825. buttonObservableNames: {
  136826. trigger: string;
  136827. menu: string;
  136828. grip: string;
  136829. thumbstick: string;
  136830. trackpad: string;
  136831. };
  136832. axisMeshNames: string[];
  136833. pointingPoseMeshName: string;
  136834. };
  136835. /**
  136836. * Fired when the trackpad on this controller is clicked
  136837. */
  136838. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  136839. /**
  136840. * Fired when the trackpad on this controller is modified
  136841. */
  136842. onTrackpadValuesChangedObservable: Observable<StickValues>;
  136843. /**
  136844. * The current x and y values of this controller's trackpad
  136845. */
  136846. trackpad: StickValues;
  136847. /**
  136848. * Creates a new WindowsMotionController from a gamepad
  136849. * @param vrGamepad the gamepad that the controller should be created from
  136850. */
  136851. constructor(vrGamepad: any);
  136852. /**
  136853. * Fired when the trigger on this controller is modified
  136854. */
  136855. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136856. /**
  136857. * Fired when the menu button on this controller is modified
  136858. */
  136859. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136860. /**
  136861. * Fired when the grip button on this controller is modified
  136862. */
  136863. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136864. /**
  136865. * Fired when the thumbstick button on this controller is modified
  136866. */
  136867. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136868. /**
  136869. * Fired when the touchpad button on this controller is modified
  136870. */
  136871. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136872. /**
  136873. * Fired when the touchpad values on this controller are modified
  136874. */
  136875. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  136876. protected _updateTrackpad(): void;
  136877. /**
  136878. * Called once per frame by the engine.
  136879. */
  136880. update(): void;
  136881. /**
  136882. * Called once for each button that changed state since the last frame
  136883. * @param buttonIdx Which button index changed
  136884. * @param state New state of the button
  136885. * @param changes Which properties on the state changed since last frame
  136886. */
  136887. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136888. /**
  136889. * Moves the buttons on the controller mesh based on their current state
  136890. * @param buttonName the name of the button to move
  136891. * @param buttonValue the value of the button which determines the buttons new position
  136892. */
  136893. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  136894. /**
  136895. * Moves the axis on the controller mesh based on its current state
  136896. * @param axis the index of the axis
  136897. * @param axisValue the value of the axis which determines the meshes new position
  136898. * @hidden
  136899. */
  136900. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  136901. /**
  136902. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136903. * @param scene scene in which to add meshes
  136904. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136905. */
  136906. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  136907. /**
  136908. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  136909. * can be transformed by button presses and axes values, based on this._mapping.
  136910. *
  136911. * @param scene scene in which the meshes exist
  136912. * @param meshes list of meshes that make up the controller model to process
  136913. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  136914. */
  136915. private processModel;
  136916. private createMeshInfo;
  136917. /**
  136918. * Gets the ray of the controller in the direction the controller is pointing
  136919. * @param length the length the resulting ray should be
  136920. * @returns a ray in the direction the controller is pointing
  136921. */
  136922. getForwardRay(length?: number): Ray;
  136923. /**
  136924. * Disposes of the controller
  136925. */
  136926. dispose(): void;
  136927. }
  136928. /**
  136929. * This class represents a new windows motion controller in XR.
  136930. */
  136931. export class XRWindowsMotionController extends WindowsMotionController {
  136932. /**
  136933. * Changing the original WIndowsMotionController mapping to fir the new mapping
  136934. */
  136935. protected readonly _mapping: {
  136936. buttons: string[];
  136937. buttonMeshNames: {
  136938. trigger: string;
  136939. menu: string;
  136940. grip: string;
  136941. thumbstick: string;
  136942. trackpad: string;
  136943. };
  136944. buttonObservableNames: {
  136945. trigger: string;
  136946. menu: string;
  136947. grip: string;
  136948. thumbstick: string;
  136949. trackpad: string;
  136950. };
  136951. axisMeshNames: string[];
  136952. pointingPoseMeshName: string;
  136953. };
  136954. /**
  136955. * Construct a new XR-Based windows motion controller
  136956. *
  136957. * @param gamepadInfo the gamepad object from the browser
  136958. */
  136959. constructor(gamepadInfo: any);
  136960. /**
  136961. * holds the thumbstick values (X,Y)
  136962. */
  136963. thumbstickValues: StickValues;
  136964. /**
  136965. * Fired when the thumbstick on this controller is clicked
  136966. */
  136967. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  136968. /**
  136969. * Fired when the thumbstick on this controller is modified
  136970. */
  136971. onThumbstickValuesChangedObservable: Observable<StickValues>;
  136972. /**
  136973. * Fired when the touchpad button on this controller is modified
  136974. */
  136975. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  136976. /**
  136977. * Fired when the touchpad values on this controller are modified
  136978. */
  136979. onTrackpadValuesChangedObservable: Observable<StickValues>;
  136980. /**
  136981. * Fired when the thumbstick button on this controller is modified
  136982. * here to prevent breaking changes
  136983. */
  136984. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136985. /**
  136986. * updating the thumbstick(!) and not the trackpad.
  136987. * This is named this way due to the difference between WebVR and XR and to avoid
  136988. * changing the parent class.
  136989. */
  136990. protected _updateTrackpad(): void;
  136991. /**
  136992. * Disposes the class with joy
  136993. */
  136994. dispose(): void;
  136995. }
  136996. }
  136997. declare module BABYLON {
  136998. /**
  136999. * Class containing static functions to help procedurally build meshes
  137000. */
  137001. export class PolyhedronBuilder {
  137002. /**
  137003. * Creates a polyhedron mesh
  137004. * * 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
  137005. * * The parameter `size` (positive float, default 1) sets the polygon size
  137006. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  137007. * * 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`
  137008. * * 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
  137009. * * 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)`)
  137010. * * 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
  137011. * * 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
  137012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137015. * @param name defines the name of the mesh
  137016. * @param options defines the options used to create the mesh
  137017. * @param scene defines the hosting scene
  137018. * @returns the polyhedron mesh
  137019. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  137020. */
  137021. static CreatePolyhedron(name: string, options: {
  137022. type?: number;
  137023. size?: number;
  137024. sizeX?: number;
  137025. sizeY?: number;
  137026. sizeZ?: number;
  137027. custom?: any;
  137028. faceUV?: Vector4[];
  137029. faceColors?: Color4[];
  137030. flat?: boolean;
  137031. updatable?: boolean;
  137032. sideOrientation?: number;
  137033. frontUVs?: Vector4;
  137034. backUVs?: Vector4;
  137035. }, scene?: Nullable<Scene>): Mesh;
  137036. }
  137037. }
  137038. declare module BABYLON {
  137039. /**
  137040. * Gizmo that enables scaling a mesh along 3 axis
  137041. */
  137042. export class ScaleGizmo extends Gizmo {
  137043. /**
  137044. * Internal gizmo used for interactions on the x axis
  137045. */
  137046. xGizmo: AxisScaleGizmo;
  137047. /**
  137048. * Internal gizmo used for interactions on the y axis
  137049. */
  137050. yGizmo: AxisScaleGizmo;
  137051. /**
  137052. * Internal gizmo used for interactions on the z axis
  137053. */
  137054. zGizmo: AxisScaleGizmo;
  137055. /**
  137056. * Internal gizmo used to scale all axis equally
  137057. */
  137058. uniformScaleGizmo: AxisScaleGizmo;
  137059. private _meshAttached;
  137060. private _nodeAttached;
  137061. private _snapDistance;
  137062. private _uniformScalingMesh;
  137063. private _octahedron;
  137064. private _sensitivity;
  137065. /** Fires an event when any of it's sub gizmos are dragged */
  137066. onDragStartObservable: Observable<unknown>;
  137067. /** Fires an event when any of it's sub gizmos are released from dragging */
  137068. onDragEndObservable: Observable<unknown>;
  137069. get attachedMesh(): Nullable<AbstractMesh>;
  137070. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137071. get attachedNode(): Nullable<Node>;
  137072. set attachedNode(node: Nullable<Node>);
  137073. /**
  137074. * True when the mouse pointer is hovering a gizmo mesh
  137075. */
  137076. get isHovered(): boolean;
  137077. /**
  137078. * Creates a ScaleGizmo
  137079. * @param gizmoLayer The utility layer the gizmo will be added to
  137080. * @param thickness display gizmo axis thickness
  137081. */
  137082. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  137083. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137084. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137085. /**
  137086. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137087. */
  137088. set snapDistance(value: number);
  137089. get snapDistance(): number;
  137090. /**
  137091. * Ratio for the scale of the gizmo (Default: 1)
  137092. */
  137093. set scaleRatio(value: number);
  137094. get scaleRatio(): number;
  137095. /**
  137096. * Sensitivity factor for dragging (Default: 1)
  137097. */
  137098. set sensitivity(value: number);
  137099. get sensitivity(): number;
  137100. /**
  137101. * Disposes of the gizmo
  137102. */
  137103. dispose(): void;
  137104. }
  137105. }
  137106. declare module BABYLON {
  137107. /**
  137108. * Single axis scale gizmo
  137109. */
  137110. export class AxisScaleGizmo extends Gizmo {
  137111. /**
  137112. * Drag behavior responsible for the gizmos dragging interactions
  137113. */
  137114. dragBehavior: PointerDragBehavior;
  137115. private _pointerObserver;
  137116. /**
  137117. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137118. */
  137119. snapDistance: number;
  137120. /**
  137121. * Event that fires each time the gizmo snaps to a new location.
  137122. * * snapDistance is the the change in distance
  137123. */
  137124. onSnapObservable: Observable<{
  137125. snapDistance: number;
  137126. }>;
  137127. /**
  137128. * If the scaling operation should be done on all axis (default: false)
  137129. */
  137130. uniformScaling: boolean;
  137131. /**
  137132. * Custom sensitivity value for the drag strength
  137133. */
  137134. sensitivity: number;
  137135. private _isEnabled;
  137136. private _parent;
  137137. private _arrow;
  137138. private _coloredMaterial;
  137139. private _hoverMaterial;
  137140. /**
  137141. * Creates an AxisScaleGizmo
  137142. * @param gizmoLayer The utility layer the gizmo will be added to
  137143. * @param dragAxis The axis which the gizmo will be able to scale on
  137144. * @param color The color of the gizmo
  137145. * @param thickness display gizmo axis thickness
  137146. */
  137147. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  137148. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137149. /**
  137150. * If the gizmo is enabled
  137151. */
  137152. set isEnabled(value: boolean);
  137153. get isEnabled(): boolean;
  137154. /**
  137155. * Disposes of the gizmo
  137156. */
  137157. dispose(): void;
  137158. /**
  137159. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  137160. * @param mesh The mesh to replace the default mesh of the gizmo
  137161. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  137162. */
  137163. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  137164. }
  137165. }
  137166. declare module BABYLON {
  137167. /**
  137168. * Bounding box gizmo
  137169. */
  137170. export class BoundingBoxGizmo extends Gizmo {
  137171. private _lineBoundingBox;
  137172. private _rotateSpheresParent;
  137173. private _scaleBoxesParent;
  137174. private _boundingDimensions;
  137175. private _renderObserver;
  137176. private _pointerObserver;
  137177. private _scaleDragSpeed;
  137178. private _tmpQuaternion;
  137179. private _tmpVector;
  137180. private _tmpRotationMatrix;
  137181. /**
  137182. * 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)
  137183. */
  137184. ignoreChildren: boolean;
  137185. /**
  137186. * 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)
  137187. */
  137188. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  137189. /**
  137190. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  137191. */
  137192. rotationSphereSize: number;
  137193. /**
  137194. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  137195. */
  137196. scaleBoxSize: number;
  137197. /**
  137198. * 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)
  137199. */
  137200. fixedDragMeshScreenSize: boolean;
  137201. /**
  137202. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  137203. */
  137204. fixedDragMeshScreenSizeDistanceFactor: number;
  137205. /**
  137206. * Fired when a rotation sphere or scale box is dragged
  137207. */
  137208. onDragStartObservable: Observable<{}>;
  137209. /**
  137210. * Fired when a scale box is dragged
  137211. */
  137212. onScaleBoxDragObservable: Observable<{}>;
  137213. /**
  137214. * Fired when a scale box drag is ended
  137215. */
  137216. onScaleBoxDragEndObservable: Observable<{}>;
  137217. /**
  137218. * Fired when a rotation sphere is dragged
  137219. */
  137220. onRotationSphereDragObservable: Observable<{}>;
  137221. /**
  137222. * Fired when a rotation sphere drag is ended
  137223. */
  137224. onRotationSphereDragEndObservable: Observable<{}>;
  137225. /**
  137226. * 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)
  137227. */
  137228. scalePivot: Nullable<Vector3>;
  137229. /**
  137230. * Mesh used as a pivot to rotate the attached node
  137231. */
  137232. private _anchorMesh;
  137233. private _existingMeshScale;
  137234. private _dragMesh;
  137235. private pointerDragBehavior;
  137236. private coloredMaterial;
  137237. private hoverColoredMaterial;
  137238. /**
  137239. * Sets the color of the bounding box gizmo
  137240. * @param color the color to set
  137241. */
  137242. setColor(color: Color3): void;
  137243. /**
  137244. * Creates an BoundingBoxGizmo
  137245. * @param gizmoLayer The utility layer the gizmo will be added to
  137246. * @param color The color of the gizmo
  137247. */
  137248. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  137249. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  137250. private _selectNode;
  137251. /**
  137252. * Updates the bounding box information for the Gizmo
  137253. */
  137254. updateBoundingBox(): void;
  137255. private _updateRotationSpheres;
  137256. private _updateScaleBoxes;
  137257. /**
  137258. * Enables rotation on the specified axis and disables rotation on the others
  137259. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  137260. */
  137261. setEnabledRotationAxis(axis: string): void;
  137262. /**
  137263. * Enables/disables scaling
  137264. * @param enable if scaling should be enabled
  137265. * @param homogeneousScaling defines if scaling should only be homogeneous
  137266. */
  137267. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  137268. private _updateDummy;
  137269. /**
  137270. * Enables a pointer drag behavior on the bounding box of the gizmo
  137271. */
  137272. enableDragBehavior(): void;
  137273. /**
  137274. * Disposes of the gizmo
  137275. */
  137276. dispose(): void;
  137277. /**
  137278. * 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)
  137279. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  137280. * @returns the bounding box mesh with the passed in mesh as a child
  137281. */
  137282. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  137283. /**
  137284. * CustomMeshes are not supported by this gizmo
  137285. * @param mesh The mesh to replace the default mesh of the gizmo
  137286. */
  137287. setCustomMesh(mesh: Mesh): void;
  137288. }
  137289. }
  137290. declare module BABYLON {
  137291. /**
  137292. * Single plane rotation gizmo
  137293. */
  137294. export class PlaneRotationGizmo extends Gizmo {
  137295. /**
  137296. * Drag behavior responsible for the gizmos dragging interactions
  137297. */
  137298. dragBehavior: PointerDragBehavior;
  137299. private _pointerObserver;
  137300. /**
  137301. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  137302. */
  137303. snapDistance: number;
  137304. /**
  137305. * Event that fires each time the gizmo snaps to a new location.
  137306. * * snapDistance is the the change in distance
  137307. */
  137308. onSnapObservable: Observable<{
  137309. snapDistance: number;
  137310. }>;
  137311. private _isEnabled;
  137312. private _parent;
  137313. /**
  137314. * Creates a PlaneRotationGizmo
  137315. * @param gizmoLayer The utility layer the gizmo will be added to
  137316. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  137317. * @param color The color of the gizmo
  137318. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137319. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137320. * @param thickness display gizmo axis thickness
  137321. */
  137322. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  137323. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137324. /**
  137325. * If the gizmo is enabled
  137326. */
  137327. set isEnabled(value: boolean);
  137328. get isEnabled(): boolean;
  137329. /**
  137330. * Disposes of the gizmo
  137331. */
  137332. dispose(): void;
  137333. }
  137334. }
  137335. declare module BABYLON {
  137336. /**
  137337. * Gizmo that enables rotating a mesh along 3 axis
  137338. */
  137339. export class RotationGizmo extends Gizmo {
  137340. /**
  137341. * Internal gizmo used for interactions on the x axis
  137342. */
  137343. xGizmo: PlaneRotationGizmo;
  137344. /**
  137345. * Internal gizmo used for interactions on the y axis
  137346. */
  137347. yGizmo: PlaneRotationGizmo;
  137348. /**
  137349. * Internal gizmo used for interactions on the z axis
  137350. */
  137351. zGizmo: PlaneRotationGizmo;
  137352. /** Fires an event when any of it's sub gizmos are dragged */
  137353. onDragStartObservable: Observable<unknown>;
  137354. /** Fires an event when any of it's sub gizmos are released from dragging */
  137355. onDragEndObservable: Observable<unknown>;
  137356. private _meshAttached;
  137357. private _nodeAttached;
  137358. get attachedMesh(): Nullable<AbstractMesh>;
  137359. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137360. get attachedNode(): Nullable<Node>;
  137361. set attachedNode(node: Nullable<Node>);
  137362. /**
  137363. * True when the mouse pointer is hovering a gizmo mesh
  137364. */
  137365. get isHovered(): boolean;
  137366. /**
  137367. * Creates a RotationGizmo
  137368. * @param gizmoLayer The utility layer the gizmo will be added to
  137369. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137370. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137371. * @param thickness display gizmo axis thickness
  137372. */
  137373. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  137374. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137375. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137376. /**
  137377. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137378. */
  137379. set snapDistance(value: number);
  137380. get snapDistance(): number;
  137381. /**
  137382. * Ratio for the scale of the gizmo (Default: 1)
  137383. */
  137384. set scaleRatio(value: number);
  137385. get scaleRatio(): number;
  137386. /**
  137387. * Disposes of the gizmo
  137388. */
  137389. dispose(): void;
  137390. /**
  137391. * CustomMeshes are not supported by this gizmo
  137392. * @param mesh The mesh to replace the default mesh of the gizmo
  137393. */
  137394. setCustomMesh(mesh: Mesh): void;
  137395. }
  137396. }
  137397. declare module BABYLON {
  137398. /**
  137399. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  137400. */
  137401. export class GizmoManager implements IDisposable {
  137402. private scene;
  137403. /**
  137404. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  137405. */
  137406. gizmos: {
  137407. positionGizmo: Nullable<PositionGizmo>;
  137408. rotationGizmo: Nullable<RotationGizmo>;
  137409. scaleGizmo: Nullable<ScaleGizmo>;
  137410. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  137411. };
  137412. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  137413. clearGizmoOnEmptyPointerEvent: boolean;
  137414. /** Fires an event when the manager is attached to a mesh */
  137415. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  137416. /** Fires an event when the manager is attached to a node */
  137417. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  137418. private _gizmosEnabled;
  137419. private _pointerObserver;
  137420. private _attachedMesh;
  137421. private _attachedNode;
  137422. private _boundingBoxColor;
  137423. private _defaultUtilityLayer;
  137424. private _defaultKeepDepthUtilityLayer;
  137425. private _thickness;
  137426. /**
  137427. * When bounding box gizmo is enabled, this can be used to track drag/end events
  137428. */
  137429. boundingBoxDragBehavior: SixDofDragBehavior;
  137430. /**
  137431. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  137432. */
  137433. attachableMeshes: Nullable<Array<AbstractMesh>>;
  137434. /**
  137435. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  137436. */
  137437. attachableNodes: Nullable<Array<Node>>;
  137438. /**
  137439. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  137440. */
  137441. usePointerToAttachGizmos: boolean;
  137442. /**
  137443. * Utility layer that the bounding box gizmo belongs to
  137444. */
  137445. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  137446. /**
  137447. * Utility layer that all gizmos besides bounding box belong to
  137448. */
  137449. get utilityLayer(): UtilityLayerRenderer;
  137450. /**
  137451. * True when the mouse pointer is hovering a gizmo mesh
  137452. */
  137453. get isHovered(): boolean;
  137454. /**
  137455. * Instatiates a gizmo manager
  137456. * @param scene the scene to overlay the gizmos on top of
  137457. * @param thickness display gizmo axis thickness
  137458. */
  137459. constructor(scene: Scene, thickness?: number);
  137460. /**
  137461. * Attaches a set of gizmos to the specified mesh
  137462. * @param mesh The mesh the gizmo's should be attached to
  137463. */
  137464. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  137465. /**
  137466. * Attaches a set of gizmos to the specified node
  137467. * @param node The node the gizmo's should be attached to
  137468. */
  137469. attachToNode(node: Nullable<Node>): void;
  137470. /**
  137471. * If the position gizmo is enabled
  137472. */
  137473. set positionGizmoEnabled(value: boolean);
  137474. get positionGizmoEnabled(): boolean;
  137475. /**
  137476. * If the rotation gizmo is enabled
  137477. */
  137478. set rotationGizmoEnabled(value: boolean);
  137479. get rotationGizmoEnabled(): boolean;
  137480. /**
  137481. * If the scale gizmo is enabled
  137482. */
  137483. set scaleGizmoEnabled(value: boolean);
  137484. get scaleGizmoEnabled(): boolean;
  137485. /**
  137486. * If the boundingBox gizmo is enabled
  137487. */
  137488. set boundingBoxGizmoEnabled(value: boolean);
  137489. get boundingBoxGizmoEnabled(): boolean;
  137490. /**
  137491. * Disposes of the gizmo manager
  137492. */
  137493. dispose(): void;
  137494. }
  137495. }
  137496. declare module BABYLON {
  137497. /**
  137498. * A directional light is defined by a direction (what a surprise!).
  137499. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  137500. * 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.
  137501. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137502. */
  137503. export class DirectionalLight extends ShadowLight {
  137504. private _shadowFrustumSize;
  137505. /**
  137506. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  137507. */
  137508. get shadowFrustumSize(): number;
  137509. /**
  137510. * Specifies a fix frustum size for the shadow generation.
  137511. */
  137512. set shadowFrustumSize(value: number);
  137513. private _shadowOrthoScale;
  137514. /**
  137515. * Gets the shadow projection scale against the optimal computed one.
  137516. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137517. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137518. */
  137519. get shadowOrthoScale(): number;
  137520. /**
  137521. * Sets the shadow projection scale against the optimal computed one.
  137522. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137523. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137524. */
  137525. set shadowOrthoScale(value: number);
  137526. /**
  137527. * Automatically compute the projection matrix to best fit (including all the casters)
  137528. * on each frame.
  137529. */
  137530. autoUpdateExtends: boolean;
  137531. /**
  137532. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  137533. * on each frame. autoUpdateExtends must be set to true for this to work
  137534. */
  137535. autoCalcShadowZBounds: boolean;
  137536. private _orthoLeft;
  137537. private _orthoRight;
  137538. private _orthoTop;
  137539. private _orthoBottom;
  137540. /**
  137541. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  137542. * The directional light is emitted from everywhere in the given direction.
  137543. * It can cast shadows.
  137544. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137545. * @param name The friendly name of the light
  137546. * @param direction The direction of the light
  137547. * @param scene The scene the light belongs to
  137548. */
  137549. constructor(name: string, direction: Vector3, scene: Scene);
  137550. /**
  137551. * Returns the string "DirectionalLight".
  137552. * @return The class name
  137553. */
  137554. getClassName(): string;
  137555. /**
  137556. * Returns the integer 1.
  137557. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137558. */
  137559. getTypeID(): number;
  137560. /**
  137561. * Sets the passed matrix "matrix" as 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 _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137565. /**
  137566. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  137567. * Returns the DirectionalLight Shadow projection matrix.
  137568. */
  137569. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  137570. /**
  137571. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  137572. * Returns the DirectionalLight Shadow projection matrix.
  137573. */
  137574. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137575. protected _buildUniformLayout(): void;
  137576. /**
  137577. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  137578. * @param effect The effect to update
  137579. * @param lightIndex The index of the light in the effect to update
  137580. * @returns The directional light
  137581. */
  137582. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  137583. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  137584. /**
  137585. * Gets the minZ used for shadow according to both the scene and the light.
  137586. *
  137587. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137588. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137589. * @param activeCamera The camera we are returning the min for
  137590. * @returns the depth min z
  137591. */
  137592. getDepthMinZ(activeCamera: Camera): number;
  137593. /**
  137594. * Gets the maxZ used for shadow according to both the scene and the light.
  137595. *
  137596. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137597. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137598. * @param activeCamera The camera we are returning the max for
  137599. * @returns the depth max z
  137600. */
  137601. getDepthMaxZ(activeCamera: Camera): number;
  137602. /**
  137603. * Prepares the list of defines specific to the light type.
  137604. * @param defines the list of defines
  137605. * @param lightIndex defines the index of the light for the effect
  137606. */
  137607. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137608. }
  137609. }
  137610. declare module BABYLON {
  137611. /**
  137612. * Class containing static functions to help procedurally build meshes
  137613. */
  137614. export class HemisphereBuilder {
  137615. /**
  137616. * Creates a hemisphere mesh
  137617. * @param name defines the name of the mesh
  137618. * @param options defines the options used to create the mesh
  137619. * @param scene defines the hosting scene
  137620. * @returns the hemisphere mesh
  137621. */
  137622. static CreateHemisphere(name: string, options: {
  137623. segments?: number;
  137624. diameter?: number;
  137625. sideOrientation?: number;
  137626. }, scene: any): Mesh;
  137627. }
  137628. }
  137629. declare module BABYLON {
  137630. /**
  137631. * A spot light is defined by a position, a direction, an angle, and an exponent.
  137632. * These values define a cone of light starting from the position, emitting toward the direction.
  137633. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  137634. * and the exponent defines the speed of the decay of the light with distance (reach).
  137635. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137636. */
  137637. export class SpotLight extends ShadowLight {
  137638. private _angle;
  137639. private _innerAngle;
  137640. private _cosHalfAngle;
  137641. private _lightAngleScale;
  137642. private _lightAngleOffset;
  137643. /**
  137644. * Gets the cone angle of the spot light in Radians.
  137645. */
  137646. get angle(): number;
  137647. /**
  137648. * Sets the cone angle of the spot light in Radians.
  137649. */
  137650. set angle(value: number);
  137651. /**
  137652. * Only used in gltf falloff mode, this defines the angle where
  137653. * the directional falloff will start before cutting at angle which could be seen
  137654. * as outer angle.
  137655. */
  137656. get innerAngle(): number;
  137657. /**
  137658. * Only used in gltf falloff mode, this defines the angle where
  137659. * the directional falloff will start before cutting at angle which could be seen
  137660. * as outer angle.
  137661. */
  137662. set innerAngle(value: number);
  137663. private _shadowAngleScale;
  137664. /**
  137665. * Allows scaling the angle of the light for shadow generation only.
  137666. */
  137667. get shadowAngleScale(): number;
  137668. /**
  137669. * Allows scaling the angle of the light for shadow generation only.
  137670. */
  137671. set shadowAngleScale(value: number);
  137672. /**
  137673. * The light decay speed with the distance from the emission spot.
  137674. */
  137675. exponent: number;
  137676. private _projectionTextureMatrix;
  137677. /**
  137678. * Allows reading the projecton texture
  137679. */
  137680. get projectionTextureMatrix(): Matrix;
  137681. protected _projectionTextureLightNear: number;
  137682. /**
  137683. * Gets the near clip of the Spotlight for texture projection.
  137684. */
  137685. get projectionTextureLightNear(): number;
  137686. /**
  137687. * Sets the near clip of the Spotlight for texture projection.
  137688. */
  137689. set projectionTextureLightNear(value: number);
  137690. protected _projectionTextureLightFar: number;
  137691. /**
  137692. * Gets the far clip of the Spotlight for texture projection.
  137693. */
  137694. get projectionTextureLightFar(): number;
  137695. /**
  137696. * Sets the far clip of the Spotlight for texture projection.
  137697. */
  137698. set projectionTextureLightFar(value: number);
  137699. protected _projectionTextureUpDirection: Vector3;
  137700. /**
  137701. * Gets the Up vector of the Spotlight for texture projection.
  137702. */
  137703. get projectionTextureUpDirection(): Vector3;
  137704. /**
  137705. * Sets the Up vector of the Spotlight for texture projection.
  137706. */
  137707. set projectionTextureUpDirection(value: Vector3);
  137708. private _projectionTexture;
  137709. /**
  137710. * Gets the projection texture of the light.
  137711. */
  137712. get projectionTexture(): Nullable<BaseTexture>;
  137713. /**
  137714. * Sets the projection texture of the light.
  137715. */
  137716. set projectionTexture(value: Nullable<BaseTexture>);
  137717. private _projectionTextureViewLightDirty;
  137718. private _projectionTextureProjectionLightDirty;
  137719. private _projectionTextureDirty;
  137720. private _projectionTextureViewTargetVector;
  137721. private _projectionTextureViewLightMatrix;
  137722. private _projectionTextureProjectionLightMatrix;
  137723. private _projectionTextureScalingMatrix;
  137724. /**
  137725. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  137726. * It can cast shadows.
  137727. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137728. * @param name The light friendly name
  137729. * @param position The position of the spot light in the scene
  137730. * @param direction The direction of the light in the scene
  137731. * @param angle The cone angle of the light in Radians
  137732. * @param exponent The light decay speed with the distance from the emission spot
  137733. * @param scene The scene the lights belongs to
  137734. */
  137735. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  137736. /**
  137737. * Returns the string "SpotLight".
  137738. * @returns the class name
  137739. */
  137740. getClassName(): string;
  137741. /**
  137742. * Returns the integer 2.
  137743. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137744. */
  137745. getTypeID(): number;
  137746. /**
  137747. * Overrides the direction setter to recompute the projection texture view light Matrix.
  137748. */
  137749. protected _setDirection(value: Vector3): void;
  137750. /**
  137751. * Overrides the position setter to recompute the projection texture view light Matrix.
  137752. */
  137753. protected _setPosition(value: Vector3): void;
  137754. /**
  137755. * 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.
  137756. * Returns the SpotLight.
  137757. */
  137758. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137759. protected _computeProjectionTextureViewLightMatrix(): void;
  137760. protected _computeProjectionTextureProjectionLightMatrix(): void;
  137761. /**
  137762. * Main function for light texture projection matrix computing.
  137763. */
  137764. protected _computeProjectionTextureMatrix(): void;
  137765. protected _buildUniformLayout(): void;
  137766. private _computeAngleValues;
  137767. /**
  137768. * Sets the passed Effect "effect" with the Light textures.
  137769. * @param effect The effect to update
  137770. * @param lightIndex The index of the light in the effect to update
  137771. * @returns The light
  137772. */
  137773. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  137774. /**
  137775. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  137776. * @param effect The effect to update
  137777. * @param lightIndex The index of the light in the effect to update
  137778. * @returns The spot light
  137779. */
  137780. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  137781. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  137782. /**
  137783. * Disposes the light and the associated resources.
  137784. */
  137785. dispose(): void;
  137786. /**
  137787. * Prepares the list of defines specific to the light type.
  137788. * @param defines the list of defines
  137789. * @param lightIndex defines the index of the light for the effect
  137790. */
  137791. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137792. }
  137793. }
  137794. declare module BABYLON {
  137795. /**
  137796. * Gizmo that enables viewing a light
  137797. */
  137798. export class LightGizmo extends Gizmo {
  137799. private _lightMesh;
  137800. private _material;
  137801. private _cachedPosition;
  137802. private _cachedForward;
  137803. private _attachedMeshParent;
  137804. private _pointerObserver;
  137805. /**
  137806. * Event that fires each time the gizmo is clicked
  137807. */
  137808. onClickedObservable: Observable<Light>;
  137809. /**
  137810. * Creates a LightGizmo
  137811. * @param gizmoLayer The utility layer the gizmo will be added to
  137812. */
  137813. constructor(gizmoLayer?: UtilityLayerRenderer);
  137814. private _light;
  137815. /**
  137816. * The light that the gizmo is attached to
  137817. */
  137818. set light(light: Nullable<Light>);
  137819. get light(): Nullable<Light>;
  137820. /**
  137821. * Gets the material used to render the light gizmo
  137822. */
  137823. get material(): StandardMaterial;
  137824. /**
  137825. * @hidden
  137826. * Updates the gizmo to match the attached mesh's position/rotation
  137827. */
  137828. protected _update(): void;
  137829. private static _Scale;
  137830. /**
  137831. * Creates the lines for a light mesh
  137832. */
  137833. private static _CreateLightLines;
  137834. /**
  137835. * Disposes of the light gizmo
  137836. */
  137837. dispose(): void;
  137838. private static _CreateHemisphericLightMesh;
  137839. private static _CreatePointLightMesh;
  137840. private static _CreateSpotLightMesh;
  137841. private static _CreateDirectionalLightMesh;
  137842. }
  137843. }
  137844. declare module BABYLON {
  137845. /**
  137846. * Gizmo that enables viewing a camera
  137847. */
  137848. export class CameraGizmo extends Gizmo {
  137849. private _cameraMesh;
  137850. private _cameraLinesMesh;
  137851. private _material;
  137852. private _pointerObserver;
  137853. /**
  137854. * Event that fires each time the gizmo is clicked
  137855. */
  137856. onClickedObservable: Observable<Camera>;
  137857. /**
  137858. * Creates a CameraGizmo
  137859. * @param gizmoLayer The utility layer the gizmo will be added to
  137860. */
  137861. constructor(gizmoLayer?: UtilityLayerRenderer);
  137862. private _camera;
  137863. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  137864. get displayFrustum(): boolean;
  137865. set displayFrustum(value: boolean);
  137866. /**
  137867. * The camera that the gizmo is attached to
  137868. */
  137869. set camera(camera: Nullable<Camera>);
  137870. get camera(): Nullable<Camera>;
  137871. /**
  137872. * Gets the material used to render the camera gizmo
  137873. */
  137874. get material(): StandardMaterial;
  137875. /**
  137876. * @hidden
  137877. * Updates the gizmo to match the attached mesh's position/rotation
  137878. */
  137879. protected _update(): void;
  137880. private static _Scale;
  137881. private _invProjection;
  137882. /**
  137883. * Disposes of the camera gizmo
  137884. */
  137885. dispose(): void;
  137886. private static _CreateCameraMesh;
  137887. private static _CreateCameraFrustum;
  137888. }
  137889. }
  137890. declare module BABYLON {
  137891. /** @hidden */
  137892. export var backgroundFragmentDeclaration: {
  137893. name: string;
  137894. shader: string;
  137895. };
  137896. }
  137897. declare module BABYLON {
  137898. /** @hidden */
  137899. export var backgroundUboDeclaration: {
  137900. name: string;
  137901. shader: string;
  137902. };
  137903. }
  137904. declare module BABYLON {
  137905. /** @hidden */
  137906. export var backgroundPixelShader: {
  137907. name: string;
  137908. shader: string;
  137909. };
  137910. }
  137911. declare module BABYLON {
  137912. /** @hidden */
  137913. export var backgroundVertexDeclaration: {
  137914. name: string;
  137915. shader: string;
  137916. };
  137917. }
  137918. declare module BABYLON {
  137919. /** @hidden */
  137920. export var backgroundVertexShader: {
  137921. name: string;
  137922. shader: string;
  137923. };
  137924. }
  137925. declare module BABYLON {
  137926. /**
  137927. * Background material used to create an efficient environement around your scene.
  137928. */
  137929. export class BackgroundMaterial extends PushMaterial {
  137930. /**
  137931. * Standard reflectance value at parallel view angle.
  137932. */
  137933. static StandardReflectance0: number;
  137934. /**
  137935. * Standard reflectance value at grazing angle.
  137936. */
  137937. static StandardReflectance90: number;
  137938. protected _primaryColor: Color3;
  137939. /**
  137940. * Key light Color (multiply against the environement texture)
  137941. */
  137942. primaryColor: Color3;
  137943. protected __perceptualColor: Nullable<Color3>;
  137944. /**
  137945. * Experimental Internal Use Only.
  137946. *
  137947. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  137948. * This acts as a helper to set the primary color to a more "human friendly" value.
  137949. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  137950. * output color as close as possible from the chosen value.
  137951. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  137952. * part of lighting setup.)
  137953. */
  137954. get _perceptualColor(): Nullable<Color3>;
  137955. set _perceptualColor(value: Nullable<Color3>);
  137956. protected _primaryColorShadowLevel: float;
  137957. /**
  137958. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  137959. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  137960. */
  137961. get primaryColorShadowLevel(): float;
  137962. set primaryColorShadowLevel(value: float);
  137963. protected _primaryColorHighlightLevel: float;
  137964. /**
  137965. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  137966. * The primary color is used at the level chosen to define what the white area would look.
  137967. */
  137968. get primaryColorHighlightLevel(): float;
  137969. set primaryColorHighlightLevel(value: float);
  137970. protected _reflectionTexture: Nullable<BaseTexture>;
  137971. /**
  137972. * Reflection Texture used in the material.
  137973. * Should be author in a specific way for the best result (refer to the documentation).
  137974. */
  137975. reflectionTexture: Nullable<BaseTexture>;
  137976. protected _reflectionBlur: float;
  137977. /**
  137978. * Reflection Texture level of blur.
  137979. *
  137980. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  137981. * texture twice.
  137982. */
  137983. reflectionBlur: float;
  137984. protected _diffuseTexture: Nullable<BaseTexture>;
  137985. /**
  137986. * Diffuse Texture used in the material.
  137987. * Should be author in a specific way for the best result (refer to the documentation).
  137988. */
  137989. diffuseTexture: Nullable<BaseTexture>;
  137990. protected _shadowLights: Nullable<IShadowLight[]>;
  137991. /**
  137992. * Specify the list of lights casting shadow on the material.
  137993. * All scene shadow lights will be included if null.
  137994. */
  137995. shadowLights: Nullable<IShadowLight[]>;
  137996. protected _shadowLevel: float;
  137997. /**
  137998. * Helps adjusting the shadow to a softer level if required.
  137999. * 0 means black shadows and 1 means no shadows.
  138000. */
  138001. shadowLevel: float;
  138002. protected _sceneCenter: Vector3;
  138003. /**
  138004. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  138005. * It is usually zero but might be interesting to modify according to your setup.
  138006. */
  138007. sceneCenter: Vector3;
  138008. protected _opacityFresnel: boolean;
  138009. /**
  138010. * This helps specifying that the material is falling off to the sky box at grazing angle.
  138011. * This helps ensuring a nice transition when the camera goes under the ground.
  138012. */
  138013. opacityFresnel: boolean;
  138014. protected _reflectionFresnel: boolean;
  138015. /**
  138016. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  138017. * This helps adding a mirror texture on the ground.
  138018. */
  138019. reflectionFresnel: boolean;
  138020. protected _reflectionFalloffDistance: number;
  138021. /**
  138022. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  138023. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  138024. */
  138025. reflectionFalloffDistance: number;
  138026. protected _reflectionAmount: number;
  138027. /**
  138028. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  138029. */
  138030. reflectionAmount: number;
  138031. protected _reflectionReflectance0: number;
  138032. /**
  138033. * This specifies the weight of the reflection at grazing angle.
  138034. */
  138035. reflectionReflectance0: number;
  138036. protected _reflectionReflectance90: number;
  138037. /**
  138038. * This specifies the weight of the reflection at a perpendicular point of view.
  138039. */
  138040. reflectionReflectance90: number;
  138041. /**
  138042. * Sets the reflection reflectance fresnel values according to the default standard
  138043. * empirically know to work well :-)
  138044. */
  138045. set reflectionStandardFresnelWeight(value: number);
  138046. protected _useRGBColor: boolean;
  138047. /**
  138048. * Helps to directly use the maps channels instead of their level.
  138049. */
  138050. useRGBColor: boolean;
  138051. protected _enableNoise: boolean;
  138052. /**
  138053. * This helps reducing the banding effect that could occur on the background.
  138054. */
  138055. enableNoise: boolean;
  138056. /**
  138057. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  138058. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  138059. * Recommended to be keep at 1.0 except for special cases.
  138060. */
  138061. get fovMultiplier(): number;
  138062. set fovMultiplier(value: number);
  138063. private _fovMultiplier;
  138064. /**
  138065. * Enable the FOV adjustment feature controlled by fovMultiplier.
  138066. */
  138067. useEquirectangularFOV: boolean;
  138068. private _maxSimultaneousLights;
  138069. /**
  138070. * Number of Simultaneous lights allowed on the material.
  138071. */
  138072. maxSimultaneousLights: int;
  138073. private _shadowOnly;
  138074. /**
  138075. * Make the material only render shadows
  138076. */
  138077. shadowOnly: boolean;
  138078. /**
  138079. * Default configuration related to image processing available in the Background Material.
  138080. */
  138081. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  138082. /**
  138083. * Keep track of the image processing observer to allow dispose and replace.
  138084. */
  138085. private _imageProcessingObserver;
  138086. /**
  138087. * Attaches a new image processing configuration to the PBR Material.
  138088. * @param configuration (if null the scene configuration will be use)
  138089. */
  138090. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  138091. /**
  138092. * Gets the image processing configuration used either in this material.
  138093. */
  138094. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  138095. /**
  138096. * Sets the Default image processing configuration used either in the this material.
  138097. *
  138098. * If sets to null, the scene one is in use.
  138099. */
  138100. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  138101. /**
  138102. * Gets wether the color curves effect is enabled.
  138103. */
  138104. get cameraColorCurvesEnabled(): boolean;
  138105. /**
  138106. * Sets wether the color curves effect is enabled.
  138107. */
  138108. set cameraColorCurvesEnabled(value: boolean);
  138109. /**
  138110. * Gets wether the color grading effect is enabled.
  138111. */
  138112. get cameraColorGradingEnabled(): boolean;
  138113. /**
  138114. * Gets wether the color grading effect is enabled.
  138115. */
  138116. set cameraColorGradingEnabled(value: boolean);
  138117. /**
  138118. * Gets wether tonemapping is enabled or not.
  138119. */
  138120. get cameraToneMappingEnabled(): boolean;
  138121. /**
  138122. * Sets wether tonemapping is enabled or not
  138123. */
  138124. set cameraToneMappingEnabled(value: boolean);
  138125. /**
  138126. * The camera exposure used on this material.
  138127. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138128. * This corresponds to a photographic exposure.
  138129. */
  138130. get cameraExposure(): float;
  138131. /**
  138132. * The camera exposure used on this material.
  138133. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138134. * This corresponds to a photographic exposure.
  138135. */
  138136. set cameraExposure(value: float);
  138137. /**
  138138. * Gets The camera contrast used on this material.
  138139. */
  138140. get cameraContrast(): float;
  138141. /**
  138142. * Sets The camera contrast used on this material.
  138143. */
  138144. set cameraContrast(value: float);
  138145. /**
  138146. * Gets the Color Grading 2D Lookup Texture.
  138147. */
  138148. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  138149. /**
  138150. * Sets the Color Grading 2D Lookup Texture.
  138151. */
  138152. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  138153. /**
  138154. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138155. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138156. * 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;
  138157. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138158. */
  138159. get cameraColorCurves(): Nullable<ColorCurves>;
  138160. /**
  138161. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138162. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138163. * 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;
  138164. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138165. */
  138166. set cameraColorCurves(value: Nullable<ColorCurves>);
  138167. /**
  138168. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  138169. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  138170. */
  138171. switchToBGR: boolean;
  138172. private _renderTargets;
  138173. private _reflectionControls;
  138174. private _white;
  138175. private _primaryShadowColor;
  138176. private _primaryHighlightColor;
  138177. /**
  138178. * Instantiates a Background Material in the given scene
  138179. * @param name The friendly name of the material
  138180. * @param scene The scene to add the material to
  138181. */
  138182. constructor(name: string, scene: Scene);
  138183. /**
  138184. * Gets a boolean indicating that current material needs to register RTT
  138185. */
  138186. get hasRenderTargetTextures(): boolean;
  138187. /**
  138188. * The entire material has been created in order to prevent overdraw.
  138189. * @returns false
  138190. */
  138191. needAlphaTesting(): boolean;
  138192. /**
  138193. * The entire material has been created in order to prevent overdraw.
  138194. * @returns true if blending is enable
  138195. */
  138196. needAlphaBlending(): boolean;
  138197. /**
  138198. * Checks wether the material is ready to be rendered for a given mesh.
  138199. * @param mesh The mesh to render
  138200. * @param subMesh The submesh to check against
  138201. * @param useInstances Specify wether or not the material is used with instances
  138202. * @returns true if all the dependencies are ready (Textures, Effects...)
  138203. */
  138204. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  138205. /**
  138206. * Compute the primary color according to the chosen perceptual color.
  138207. */
  138208. private _computePrimaryColorFromPerceptualColor;
  138209. /**
  138210. * Compute the highlights and shadow colors according to their chosen levels.
  138211. */
  138212. private _computePrimaryColors;
  138213. /**
  138214. * Build the uniform buffer used in the material.
  138215. */
  138216. buildUniformLayout(): void;
  138217. /**
  138218. * Unbind the material.
  138219. */
  138220. unbind(): void;
  138221. /**
  138222. * Bind only the world matrix to the material.
  138223. * @param world The world matrix to bind.
  138224. */
  138225. bindOnlyWorldMatrix(world: Matrix): void;
  138226. /**
  138227. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  138228. * @param world The world matrix to bind.
  138229. * @param subMesh The submesh to bind for.
  138230. */
  138231. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  138232. /**
  138233. * Checks to see if a texture is used in the material.
  138234. * @param texture - Base texture to use.
  138235. * @returns - Boolean specifying if a texture is used in the material.
  138236. */
  138237. hasTexture(texture: BaseTexture): boolean;
  138238. /**
  138239. * Dispose the material.
  138240. * @param forceDisposeEffect Force disposal of the associated effect.
  138241. * @param forceDisposeTextures Force disposal of the associated textures.
  138242. */
  138243. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  138244. /**
  138245. * Clones the material.
  138246. * @param name The cloned name.
  138247. * @returns The cloned material.
  138248. */
  138249. clone(name: string): BackgroundMaterial;
  138250. /**
  138251. * Serializes the current material to its JSON representation.
  138252. * @returns The JSON representation.
  138253. */
  138254. serialize(): any;
  138255. /**
  138256. * Gets the class name of the material
  138257. * @returns "BackgroundMaterial"
  138258. */
  138259. getClassName(): string;
  138260. /**
  138261. * Parse a JSON input to create back a background material.
  138262. * @param source The JSON data to parse
  138263. * @param scene The scene to create the parsed material in
  138264. * @param rootUrl The root url of the assets the material depends upon
  138265. * @returns the instantiated BackgroundMaterial.
  138266. */
  138267. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  138268. }
  138269. }
  138270. declare module BABYLON {
  138271. /**
  138272. * Represents the different options available during the creation of
  138273. * a Environment helper.
  138274. *
  138275. * This can control the default ground, skybox and image processing setup of your scene.
  138276. */
  138277. export interface IEnvironmentHelperOptions {
  138278. /**
  138279. * Specifies whether or not to create a ground.
  138280. * True by default.
  138281. */
  138282. createGround: boolean;
  138283. /**
  138284. * Specifies the ground size.
  138285. * 15 by default.
  138286. */
  138287. groundSize: number;
  138288. /**
  138289. * The texture used on the ground for the main color.
  138290. * Comes from the BabylonJS CDN by default.
  138291. *
  138292. * Remarks: Can be either a texture or a url.
  138293. */
  138294. groundTexture: string | BaseTexture;
  138295. /**
  138296. * The color mixed in the ground texture by default.
  138297. * BabylonJS clearColor by default.
  138298. */
  138299. groundColor: Color3;
  138300. /**
  138301. * Specifies the ground opacity.
  138302. * 1 by default.
  138303. */
  138304. groundOpacity: number;
  138305. /**
  138306. * Enables the ground to receive shadows.
  138307. * True by default.
  138308. */
  138309. enableGroundShadow: boolean;
  138310. /**
  138311. * Helps preventing the shadow to be fully black on the ground.
  138312. * 0.5 by default.
  138313. */
  138314. groundShadowLevel: number;
  138315. /**
  138316. * Creates a mirror texture attach to the ground.
  138317. * false by default.
  138318. */
  138319. enableGroundMirror: boolean;
  138320. /**
  138321. * Specifies the ground mirror size ratio.
  138322. * 0.3 by default as the default kernel is 64.
  138323. */
  138324. groundMirrorSizeRatio: number;
  138325. /**
  138326. * Specifies the ground mirror blur kernel size.
  138327. * 64 by default.
  138328. */
  138329. groundMirrorBlurKernel: number;
  138330. /**
  138331. * Specifies the ground mirror visibility amount.
  138332. * 1 by default
  138333. */
  138334. groundMirrorAmount: number;
  138335. /**
  138336. * Specifies the ground mirror reflectance weight.
  138337. * This uses the standard weight of the background material to setup the fresnel effect
  138338. * of the mirror.
  138339. * 1 by default.
  138340. */
  138341. groundMirrorFresnelWeight: number;
  138342. /**
  138343. * Specifies the ground mirror Falloff distance.
  138344. * This can helps reducing the size of the reflection.
  138345. * 0 by Default.
  138346. */
  138347. groundMirrorFallOffDistance: number;
  138348. /**
  138349. * Specifies the ground mirror texture type.
  138350. * Unsigned Int by Default.
  138351. */
  138352. groundMirrorTextureType: number;
  138353. /**
  138354. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  138355. * the shown objects.
  138356. */
  138357. groundYBias: number;
  138358. /**
  138359. * Specifies whether or not to create a skybox.
  138360. * True by default.
  138361. */
  138362. createSkybox: boolean;
  138363. /**
  138364. * Specifies the skybox size.
  138365. * 20 by default.
  138366. */
  138367. skyboxSize: number;
  138368. /**
  138369. * The texture used on the skybox for the main color.
  138370. * Comes from the BabylonJS CDN by default.
  138371. *
  138372. * Remarks: Can be either a texture or a url.
  138373. */
  138374. skyboxTexture: string | BaseTexture;
  138375. /**
  138376. * The color mixed in the skybox texture by default.
  138377. * BabylonJS clearColor by default.
  138378. */
  138379. skyboxColor: Color3;
  138380. /**
  138381. * The background rotation around the Y axis of the scene.
  138382. * This helps aligning the key lights of your scene with the background.
  138383. * 0 by default.
  138384. */
  138385. backgroundYRotation: number;
  138386. /**
  138387. * Compute automatically the size of the elements to best fit with the scene.
  138388. */
  138389. sizeAuto: boolean;
  138390. /**
  138391. * Default position of the rootMesh if autoSize is not true.
  138392. */
  138393. rootPosition: Vector3;
  138394. /**
  138395. * Sets up the image processing in the scene.
  138396. * true by default.
  138397. */
  138398. setupImageProcessing: boolean;
  138399. /**
  138400. * The texture used as your environment texture in the scene.
  138401. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  138402. *
  138403. * Remarks: Can be either a texture or a url.
  138404. */
  138405. environmentTexture: string | BaseTexture;
  138406. /**
  138407. * The value of the exposure to apply to the scene.
  138408. * 0.6 by default if setupImageProcessing is true.
  138409. */
  138410. cameraExposure: number;
  138411. /**
  138412. * The value of the contrast to apply to the scene.
  138413. * 1.6 by default if setupImageProcessing is true.
  138414. */
  138415. cameraContrast: number;
  138416. /**
  138417. * Specifies whether or not tonemapping should be enabled in the scene.
  138418. * true by default if setupImageProcessing is true.
  138419. */
  138420. toneMappingEnabled: boolean;
  138421. }
  138422. /**
  138423. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  138424. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  138425. * It also helps with the default setup of your imageProcessing configuration.
  138426. */
  138427. export class EnvironmentHelper {
  138428. /**
  138429. * Default ground texture URL.
  138430. */
  138431. private static _groundTextureCDNUrl;
  138432. /**
  138433. * Default skybox texture URL.
  138434. */
  138435. private static _skyboxTextureCDNUrl;
  138436. /**
  138437. * Default environment texture URL.
  138438. */
  138439. private static _environmentTextureCDNUrl;
  138440. /**
  138441. * Creates the default options for the helper.
  138442. */
  138443. private static _getDefaultOptions;
  138444. private _rootMesh;
  138445. /**
  138446. * Gets the root mesh created by the helper.
  138447. */
  138448. get rootMesh(): Mesh;
  138449. private _skybox;
  138450. /**
  138451. * Gets the skybox created by the helper.
  138452. */
  138453. get skybox(): Nullable<Mesh>;
  138454. private _skyboxTexture;
  138455. /**
  138456. * Gets the skybox texture created by the helper.
  138457. */
  138458. get skyboxTexture(): Nullable<BaseTexture>;
  138459. private _skyboxMaterial;
  138460. /**
  138461. * Gets the skybox material created by the helper.
  138462. */
  138463. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  138464. private _ground;
  138465. /**
  138466. * Gets the ground mesh created by the helper.
  138467. */
  138468. get ground(): Nullable<Mesh>;
  138469. private _groundTexture;
  138470. /**
  138471. * Gets the ground texture created by the helper.
  138472. */
  138473. get groundTexture(): Nullable<BaseTexture>;
  138474. private _groundMirror;
  138475. /**
  138476. * Gets the ground mirror created by the helper.
  138477. */
  138478. get groundMirror(): Nullable<MirrorTexture>;
  138479. /**
  138480. * Gets the ground mirror render list to helps pushing the meshes
  138481. * you wish in the ground reflection.
  138482. */
  138483. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  138484. private _groundMaterial;
  138485. /**
  138486. * Gets the ground material created by the helper.
  138487. */
  138488. get groundMaterial(): Nullable<BackgroundMaterial>;
  138489. /**
  138490. * Stores the creation options.
  138491. */
  138492. private readonly _scene;
  138493. private _options;
  138494. /**
  138495. * This observable will be notified with any error during the creation of the environment,
  138496. * mainly texture creation errors.
  138497. */
  138498. onErrorObservable: Observable<{
  138499. message?: string;
  138500. exception?: any;
  138501. }>;
  138502. /**
  138503. * constructor
  138504. * @param options Defines the options we want to customize the helper
  138505. * @param scene The scene to add the material to
  138506. */
  138507. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  138508. /**
  138509. * Updates the background according to the new options
  138510. * @param options
  138511. */
  138512. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  138513. /**
  138514. * Sets the primary color of all the available elements.
  138515. * @param color the main color to affect to the ground and the background
  138516. */
  138517. setMainColor(color: Color3): void;
  138518. /**
  138519. * Setup the image processing according to the specified options.
  138520. */
  138521. private _setupImageProcessing;
  138522. /**
  138523. * Setup the environment texture according to the specified options.
  138524. */
  138525. private _setupEnvironmentTexture;
  138526. /**
  138527. * Setup the background according to the specified options.
  138528. */
  138529. private _setupBackground;
  138530. /**
  138531. * Get the scene sizes according to the setup.
  138532. */
  138533. private _getSceneSize;
  138534. /**
  138535. * Setup the ground according to the specified options.
  138536. */
  138537. private _setupGround;
  138538. /**
  138539. * Setup the ground material according to the specified options.
  138540. */
  138541. private _setupGroundMaterial;
  138542. /**
  138543. * Setup the ground diffuse texture according to the specified options.
  138544. */
  138545. private _setupGroundDiffuseTexture;
  138546. /**
  138547. * Setup the ground mirror texture according to the specified options.
  138548. */
  138549. private _setupGroundMirrorTexture;
  138550. /**
  138551. * Setup the ground to receive the mirror texture.
  138552. */
  138553. private _setupMirrorInGroundMaterial;
  138554. /**
  138555. * Setup the skybox according to the specified options.
  138556. */
  138557. private _setupSkybox;
  138558. /**
  138559. * Setup the skybox material according to the specified options.
  138560. */
  138561. private _setupSkyboxMaterial;
  138562. /**
  138563. * Setup the skybox reflection texture according to the specified options.
  138564. */
  138565. private _setupSkyboxReflectionTexture;
  138566. private _errorHandler;
  138567. /**
  138568. * Dispose all the elements created by the Helper.
  138569. */
  138570. dispose(): void;
  138571. }
  138572. }
  138573. declare module BABYLON {
  138574. /**
  138575. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  138576. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  138577. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  138578. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138579. */
  138580. export abstract class TextureDome<T extends Texture> extends TransformNode {
  138581. protected onError: Nullable<(message?: string, exception?: any) => void>;
  138582. /**
  138583. * Define the source as a Monoscopic panoramic 360/180.
  138584. */
  138585. static readonly MODE_MONOSCOPIC: number;
  138586. /**
  138587. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  138588. */
  138589. static readonly MODE_TOPBOTTOM: number;
  138590. /**
  138591. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  138592. */
  138593. static readonly MODE_SIDEBYSIDE: number;
  138594. private _halfDome;
  138595. protected _useDirectMapping: boolean;
  138596. /**
  138597. * The texture being displayed on the sphere
  138598. */
  138599. protected _texture: T;
  138600. /**
  138601. * Gets the texture being displayed on the sphere
  138602. */
  138603. get texture(): T;
  138604. /**
  138605. * Sets the texture being displayed on the sphere
  138606. */
  138607. set texture(newTexture: T);
  138608. /**
  138609. * The skybox material
  138610. */
  138611. protected _material: BackgroundMaterial;
  138612. /**
  138613. * The surface used for the dome
  138614. */
  138615. protected _mesh: Mesh;
  138616. /**
  138617. * Gets the mesh used for the dome.
  138618. */
  138619. get mesh(): Mesh;
  138620. /**
  138621. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  138622. */
  138623. private _halfDomeMask;
  138624. /**
  138625. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  138626. * Also see the options.resolution property.
  138627. */
  138628. get fovMultiplier(): number;
  138629. set fovMultiplier(value: number);
  138630. protected _textureMode: number;
  138631. /**
  138632. * Gets or set the current texture mode for the texture. It can be:
  138633. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138634. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138635. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138636. */
  138637. get textureMode(): number;
  138638. /**
  138639. * Sets the current texture mode for the texture. It can be:
  138640. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138641. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138642. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138643. */
  138644. set textureMode(value: number);
  138645. /**
  138646. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  138647. */
  138648. get halfDome(): boolean;
  138649. /**
  138650. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  138651. */
  138652. set halfDome(enabled: boolean);
  138653. /**
  138654. * Oberserver used in Stereoscopic VR Mode.
  138655. */
  138656. private _onBeforeCameraRenderObserver;
  138657. /**
  138658. * Observable raised when an error occured while loading the 360 image
  138659. */
  138660. onLoadErrorObservable: Observable<string>;
  138661. /**
  138662. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  138663. * @param name Element's name, child elements will append suffixes for their own names.
  138664. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  138665. * @param options An object containing optional or exposed sub element properties
  138666. */
  138667. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  138668. resolution?: number;
  138669. clickToPlay?: boolean;
  138670. autoPlay?: boolean;
  138671. loop?: boolean;
  138672. size?: number;
  138673. poster?: string;
  138674. faceForward?: boolean;
  138675. useDirectMapping?: boolean;
  138676. halfDomeMode?: boolean;
  138677. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  138678. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  138679. protected _changeTextureMode(value: number): void;
  138680. /**
  138681. * Releases resources associated with this node.
  138682. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  138683. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  138684. */
  138685. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  138686. }
  138687. }
  138688. declare module BABYLON {
  138689. /**
  138690. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  138691. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  138692. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  138693. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138694. */
  138695. export class PhotoDome extends TextureDome<Texture> {
  138696. /**
  138697. * Define the image as a Monoscopic panoramic 360 image.
  138698. */
  138699. static readonly MODE_MONOSCOPIC: number;
  138700. /**
  138701. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  138702. */
  138703. static readonly MODE_TOPBOTTOM: number;
  138704. /**
  138705. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  138706. */
  138707. static readonly MODE_SIDEBYSIDE: number;
  138708. /**
  138709. * Gets or sets the texture being displayed on the sphere
  138710. */
  138711. get photoTexture(): Texture;
  138712. /**
  138713. * sets the texture being displayed on the sphere
  138714. */
  138715. set photoTexture(value: Texture);
  138716. /**
  138717. * Gets the current video mode for the video. It can be:
  138718. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138719. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138720. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138721. */
  138722. get imageMode(): number;
  138723. /**
  138724. * Sets the current video mode for the video. It can be:
  138725. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138726. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138727. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138728. */
  138729. set imageMode(value: number);
  138730. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  138731. }
  138732. }
  138733. declare module BABYLON {
  138734. /**
  138735. * Direct draw surface info
  138736. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  138737. */
  138738. export interface DDSInfo {
  138739. /**
  138740. * Width of the texture
  138741. */
  138742. width: number;
  138743. /**
  138744. * Width of the texture
  138745. */
  138746. height: number;
  138747. /**
  138748. * Number of Mipmaps for the texture
  138749. * @see https://en.wikipedia.org/wiki/Mipmap
  138750. */
  138751. mipmapCount: number;
  138752. /**
  138753. * If the textures format is a known fourCC format
  138754. * @see https://www.fourcc.org/
  138755. */
  138756. isFourCC: boolean;
  138757. /**
  138758. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  138759. */
  138760. isRGB: boolean;
  138761. /**
  138762. * If the texture is a lumincance format
  138763. */
  138764. isLuminance: boolean;
  138765. /**
  138766. * If this is a cube texture
  138767. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  138768. */
  138769. isCube: boolean;
  138770. /**
  138771. * If the texture is a compressed format eg. FOURCC_DXT1
  138772. */
  138773. isCompressed: boolean;
  138774. /**
  138775. * The dxgiFormat of the texture
  138776. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  138777. */
  138778. dxgiFormat: number;
  138779. /**
  138780. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  138781. */
  138782. textureType: number;
  138783. /**
  138784. * Sphericle polynomial created for the dds texture
  138785. */
  138786. sphericalPolynomial?: SphericalPolynomial;
  138787. }
  138788. /**
  138789. * Class used to provide DDS decompression tools
  138790. */
  138791. export class DDSTools {
  138792. /**
  138793. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  138794. */
  138795. static StoreLODInAlphaChannel: boolean;
  138796. /**
  138797. * Gets DDS information from an array buffer
  138798. * @param data defines the array buffer view to read data from
  138799. * @returns the DDS information
  138800. */
  138801. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  138802. private static _FloatView;
  138803. private static _Int32View;
  138804. private static _ToHalfFloat;
  138805. private static _FromHalfFloat;
  138806. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  138807. private static _GetHalfFloatRGBAArrayBuffer;
  138808. private static _GetFloatRGBAArrayBuffer;
  138809. private static _GetFloatAsUIntRGBAArrayBuffer;
  138810. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  138811. private static _GetRGBAArrayBuffer;
  138812. private static _ExtractLongWordOrder;
  138813. private static _GetRGBArrayBuffer;
  138814. private static _GetLuminanceArrayBuffer;
  138815. /**
  138816. * Uploads DDS Levels to a Babylon Texture
  138817. * @hidden
  138818. */
  138819. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  138820. }
  138821. interface ThinEngine {
  138822. /**
  138823. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  138824. * @param rootUrl defines the url where the file to load is located
  138825. * @param scene defines the current scene
  138826. * @param lodScale defines scale to apply to the mip map selection
  138827. * @param lodOffset defines offset to apply to the mip map selection
  138828. * @param onLoad defines an optional callback raised when the texture is loaded
  138829. * @param onError defines an optional callback raised if there is an issue to load the texture
  138830. * @param format defines the format of the data
  138831. * @param forcedExtension defines the extension to use to pick the right loader
  138832. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  138833. * @returns the cube texture as an InternalTexture
  138834. */
  138835. 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;
  138836. }
  138837. }
  138838. declare module BABYLON {
  138839. /**
  138840. * Implementation of the DDS Texture Loader.
  138841. * @hidden
  138842. */
  138843. export class _DDSTextureLoader implements IInternalTextureLoader {
  138844. /**
  138845. * Defines wether the loader supports cascade loading the different faces.
  138846. */
  138847. readonly supportCascades: boolean;
  138848. /**
  138849. * This returns if the loader support the current file information.
  138850. * @param extension defines the file extension of the file being loaded
  138851. * @returns true if the loader can load the specified file
  138852. */
  138853. canLoad(extension: string): boolean;
  138854. /**
  138855. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138856. * @param data contains the texture data
  138857. * @param texture defines the BabylonJS internal texture
  138858. * @param createPolynomials will be true if polynomials have been requested
  138859. * @param onLoad defines the callback to trigger once the texture is ready
  138860. * @param onError defines the callback to trigger in case of error
  138861. */
  138862. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138863. /**
  138864. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138865. * @param data contains the texture data
  138866. * @param texture defines the BabylonJS internal texture
  138867. * @param callback defines the method to call once ready to upload
  138868. */
  138869. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138870. }
  138871. }
  138872. declare module BABYLON {
  138873. /**
  138874. * Implementation of the ENV Texture Loader.
  138875. * @hidden
  138876. */
  138877. export class _ENVTextureLoader implements IInternalTextureLoader {
  138878. /**
  138879. * Defines wether the loader supports cascade loading the different faces.
  138880. */
  138881. readonly supportCascades: boolean;
  138882. /**
  138883. * This returns if the loader support the current file information.
  138884. * @param extension defines the file extension of the file being loaded
  138885. * @returns true if the loader can load the specified file
  138886. */
  138887. canLoad(extension: string): boolean;
  138888. /**
  138889. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138890. * @param data contains the texture data
  138891. * @param texture defines the BabylonJS internal texture
  138892. * @param createPolynomials will be true if polynomials have been requested
  138893. * @param onLoad defines the callback to trigger once the texture is ready
  138894. * @param onError defines the callback to trigger in case of error
  138895. */
  138896. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138897. /**
  138898. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138899. * @param data contains the texture data
  138900. * @param texture defines the BabylonJS internal texture
  138901. * @param callback defines the method to call once ready to upload
  138902. */
  138903. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138904. }
  138905. }
  138906. declare module BABYLON {
  138907. /**
  138908. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138909. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138910. */
  138911. export class KhronosTextureContainer {
  138912. /** contents of the KTX container file */
  138913. data: ArrayBufferView;
  138914. private static HEADER_LEN;
  138915. private static COMPRESSED_2D;
  138916. private static COMPRESSED_3D;
  138917. private static TEX_2D;
  138918. private static TEX_3D;
  138919. /**
  138920. * Gets the openGL type
  138921. */
  138922. glType: number;
  138923. /**
  138924. * Gets the openGL type size
  138925. */
  138926. glTypeSize: number;
  138927. /**
  138928. * Gets the openGL format
  138929. */
  138930. glFormat: number;
  138931. /**
  138932. * Gets the openGL internal format
  138933. */
  138934. glInternalFormat: number;
  138935. /**
  138936. * Gets the base internal format
  138937. */
  138938. glBaseInternalFormat: number;
  138939. /**
  138940. * Gets image width in pixel
  138941. */
  138942. pixelWidth: number;
  138943. /**
  138944. * Gets image height in pixel
  138945. */
  138946. pixelHeight: number;
  138947. /**
  138948. * Gets image depth in pixels
  138949. */
  138950. pixelDepth: number;
  138951. /**
  138952. * Gets the number of array elements
  138953. */
  138954. numberOfArrayElements: number;
  138955. /**
  138956. * Gets the number of faces
  138957. */
  138958. numberOfFaces: number;
  138959. /**
  138960. * Gets the number of mipmap levels
  138961. */
  138962. numberOfMipmapLevels: number;
  138963. /**
  138964. * Gets the bytes of key value data
  138965. */
  138966. bytesOfKeyValueData: number;
  138967. /**
  138968. * Gets the load type
  138969. */
  138970. loadType: number;
  138971. /**
  138972. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  138973. */
  138974. isInvalid: boolean;
  138975. /**
  138976. * Creates a new KhronosTextureContainer
  138977. * @param data contents of the KTX container file
  138978. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  138979. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  138980. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  138981. */
  138982. constructor(
  138983. /** contents of the KTX container file */
  138984. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  138985. /**
  138986. * Uploads KTX content to a Babylon Texture.
  138987. * It is assumed that the texture has already been created & is currently bound
  138988. * @hidden
  138989. */
  138990. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  138991. private _upload2DCompressedLevels;
  138992. /**
  138993. * Checks if the given data starts with a KTX file identifier.
  138994. * @param data the data to check
  138995. * @returns true if the data is a KTX file or false otherwise
  138996. */
  138997. static IsValid(data: ArrayBufferView): boolean;
  138998. }
  138999. }
  139000. declare module BABYLON {
  139001. /**
  139002. * Helper class to push actions to a pool of workers.
  139003. */
  139004. export class WorkerPool implements IDisposable {
  139005. private _workerInfos;
  139006. private _pendingActions;
  139007. /**
  139008. * Constructor
  139009. * @param workers Array of workers to use for actions
  139010. */
  139011. constructor(workers: Array<Worker>);
  139012. /**
  139013. * Terminates all workers and clears any pending actions.
  139014. */
  139015. dispose(): void;
  139016. /**
  139017. * Pushes an action to the worker pool. If all the workers are active, the action will be
  139018. * pended until a worker has completed its action.
  139019. * @param action The action to perform. Call onComplete when the action is complete.
  139020. */
  139021. push(action: (worker: Worker, onComplete: () => void) => void): void;
  139022. private _execute;
  139023. }
  139024. }
  139025. declare module BABYLON {
  139026. /**
  139027. * Class for loading KTX2 files
  139028. */
  139029. export class KhronosTextureContainer2 {
  139030. private static _WorkerPoolPromise?;
  139031. private static _Initialized;
  139032. private static _Ktx2Decoder;
  139033. /**
  139034. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  139035. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  139036. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  139037. * Urls you can change:
  139038. * URLConfig.jsDecoderModule
  139039. * URLConfig.wasmUASTCToASTC
  139040. * URLConfig.wasmUASTCToBC7
  139041. * URLConfig.jsMSCTranscoder
  139042. * URLConfig.wasmMSCTranscoder
  139043. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  139044. */
  139045. static URLConfig: {
  139046. jsDecoderModule: string;
  139047. wasmUASTCToASTC: null;
  139048. wasmUASTCToBC7: null;
  139049. jsMSCTranscoder: null;
  139050. wasmMSCTranscoder: null;
  139051. };
  139052. /**
  139053. * Default number of workers used to handle data decoding
  139054. */
  139055. static DefaultNumWorkers: number;
  139056. private static GetDefaultNumWorkers;
  139057. private _engine;
  139058. private static _CreateWorkerPool;
  139059. /**
  139060. * Constructor
  139061. * @param engine The engine to use
  139062. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  139063. */
  139064. constructor(engine: ThinEngine, numWorkers?: number);
  139065. /** @hidden */
  139066. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  139067. /**
  139068. * Stop all async operations and release resources.
  139069. */
  139070. dispose(): void;
  139071. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  139072. /**
  139073. * Checks if the given data starts with a KTX2 file identifier.
  139074. * @param data the data to check
  139075. * @returns true if the data is a KTX2 file or false otherwise
  139076. */
  139077. static IsValid(data: ArrayBufferView): boolean;
  139078. }
  139079. }
  139080. declare module BABYLON {
  139081. /**
  139082. * Implementation of the KTX Texture Loader.
  139083. * @hidden
  139084. */
  139085. export class _KTXTextureLoader implements IInternalTextureLoader {
  139086. /**
  139087. * Defines wether the loader supports cascade loading the different faces.
  139088. */
  139089. readonly supportCascades: boolean;
  139090. /**
  139091. * This returns if the loader support the current file information.
  139092. * @param extension defines the file extension of the file being loaded
  139093. * @param mimeType defines the optional mime type of the file being loaded
  139094. * @returns true if the loader can load the specified file
  139095. */
  139096. canLoad(extension: string, mimeType?: string): boolean;
  139097. /**
  139098. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139099. * @param data contains the texture data
  139100. * @param texture defines the BabylonJS internal texture
  139101. * @param createPolynomials will be true if polynomials have been requested
  139102. * @param onLoad defines the callback to trigger once the texture is ready
  139103. * @param onError defines the callback to trigger in case of error
  139104. */
  139105. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139106. /**
  139107. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139108. * @param data contains the texture data
  139109. * @param texture defines the BabylonJS internal texture
  139110. * @param callback defines the method to call once ready to upload
  139111. */
  139112. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  139113. }
  139114. }
  139115. declare module BABYLON {
  139116. /** @hidden */
  139117. export var _forceSceneHelpersToBundle: boolean;
  139118. interface Scene {
  139119. /**
  139120. * Creates a default light for the scene.
  139121. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  139122. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  139123. */
  139124. createDefaultLight(replace?: boolean): void;
  139125. /**
  139126. * Creates a default camera for the scene.
  139127. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  139128. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139129. * @param replace has default false, when true replaces the active camera in the scene
  139130. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  139131. */
  139132. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139133. /**
  139134. * Creates a default camera and a default light.
  139135. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  139136. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139137. * @param replace has the default false, when true replaces the active camera/light in the scene
  139138. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  139139. */
  139140. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139141. /**
  139142. * Creates a new sky box
  139143. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  139144. * @param environmentTexture defines the texture to use as environment texture
  139145. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  139146. * @param scale defines the overall scale of the skybox
  139147. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  139148. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  139149. * @returns a new mesh holding the sky box
  139150. */
  139151. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  139152. /**
  139153. * Creates a new environment
  139154. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  139155. * @param options defines the options you can use to configure the environment
  139156. * @returns the new EnvironmentHelper
  139157. */
  139158. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  139159. /**
  139160. * Creates a new VREXperienceHelper
  139161. * @see https://doc.babylonjs.com/how_to/webvr_helper
  139162. * @param webVROptions defines the options used to create the new VREXperienceHelper
  139163. * @returns a new VREXperienceHelper
  139164. */
  139165. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  139166. /**
  139167. * Creates a new WebXRDefaultExperience
  139168. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  139169. * @param options experience options
  139170. * @returns a promise for a new WebXRDefaultExperience
  139171. */
  139172. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  139173. }
  139174. }
  139175. declare module BABYLON {
  139176. /**
  139177. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  139178. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  139179. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  139180. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139181. */
  139182. export class VideoDome extends TextureDome<VideoTexture> {
  139183. /**
  139184. * Define the video source as a Monoscopic panoramic 360 video.
  139185. */
  139186. static readonly MODE_MONOSCOPIC: number;
  139187. /**
  139188. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  139189. */
  139190. static readonly MODE_TOPBOTTOM: number;
  139191. /**
  139192. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  139193. */
  139194. static readonly MODE_SIDEBYSIDE: number;
  139195. /**
  139196. * Get the video texture associated with this video dome
  139197. */
  139198. get videoTexture(): VideoTexture;
  139199. /**
  139200. * Get the video mode of this dome
  139201. */
  139202. get videoMode(): number;
  139203. /**
  139204. * Set the video mode of this dome.
  139205. * @see textureMode
  139206. */
  139207. set videoMode(value: number);
  139208. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  139209. }
  139210. }
  139211. declare module BABYLON {
  139212. /**
  139213. * This class can be used to get instrumentation data from a Babylon engine
  139214. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139215. */
  139216. export class EngineInstrumentation implements IDisposable {
  139217. /**
  139218. * Define the instrumented engine.
  139219. */
  139220. engine: Engine;
  139221. private _captureGPUFrameTime;
  139222. private _gpuFrameTimeToken;
  139223. private _gpuFrameTime;
  139224. private _captureShaderCompilationTime;
  139225. private _shaderCompilationTime;
  139226. private _onBeginFrameObserver;
  139227. private _onEndFrameObserver;
  139228. private _onBeforeShaderCompilationObserver;
  139229. private _onAfterShaderCompilationObserver;
  139230. /**
  139231. * Gets the perf counter used for GPU frame time
  139232. */
  139233. get gpuFrameTimeCounter(): PerfCounter;
  139234. /**
  139235. * Gets the GPU frame time capture status
  139236. */
  139237. get captureGPUFrameTime(): boolean;
  139238. /**
  139239. * Enable or disable the GPU frame time capture
  139240. */
  139241. set captureGPUFrameTime(value: boolean);
  139242. /**
  139243. * Gets the perf counter used for shader compilation time
  139244. */
  139245. get shaderCompilationTimeCounter(): PerfCounter;
  139246. /**
  139247. * Gets the shader compilation time capture status
  139248. */
  139249. get captureShaderCompilationTime(): boolean;
  139250. /**
  139251. * Enable or disable the shader compilation time capture
  139252. */
  139253. set captureShaderCompilationTime(value: boolean);
  139254. /**
  139255. * Instantiates a new engine instrumentation.
  139256. * This class can be used to get instrumentation data from a Babylon engine
  139257. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139258. * @param engine Defines the engine to instrument
  139259. */
  139260. constructor(
  139261. /**
  139262. * Define the instrumented engine.
  139263. */
  139264. engine: Engine);
  139265. /**
  139266. * Dispose and release associated resources.
  139267. */
  139268. dispose(): void;
  139269. }
  139270. }
  139271. declare module BABYLON {
  139272. /**
  139273. * This class can be used to get instrumentation data from a Babylon engine
  139274. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139275. */
  139276. export class SceneInstrumentation implements IDisposable {
  139277. /**
  139278. * Defines the scene to instrument
  139279. */
  139280. scene: Scene;
  139281. private _captureActiveMeshesEvaluationTime;
  139282. private _activeMeshesEvaluationTime;
  139283. private _captureRenderTargetsRenderTime;
  139284. private _renderTargetsRenderTime;
  139285. private _captureFrameTime;
  139286. private _frameTime;
  139287. private _captureRenderTime;
  139288. private _renderTime;
  139289. private _captureInterFrameTime;
  139290. private _interFrameTime;
  139291. private _captureParticlesRenderTime;
  139292. private _particlesRenderTime;
  139293. private _captureSpritesRenderTime;
  139294. private _spritesRenderTime;
  139295. private _capturePhysicsTime;
  139296. private _physicsTime;
  139297. private _captureAnimationsTime;
  139298. private _animationsTime;
  139299. private _captureCameraRenderTime;
  139300. private _cameraRenderTime;
  139301. private _onBeforeActiveMeshesEvaluationObserver;
  139302. private _onAfterActiveMeshesEvaluationObserver;
  139303. private _onBeforeRenderTargetsRenderObserver;
  139304. private _onAfterRenderTargetsRenderObserver;
  139305. private _onAfterRenderObserver;
  139306. private _onBeforeDrawPhaseObserver;
  139307. private _onAfterDrawPhaseObserver;
  139308. private _onBeforeAnimationsObserver;
  139309. private _onBeforeParticlesRenderingObserver;
  139310. private _onAfterParticlesRenderingObserver;
  139311. private _onBeforeSpritesRenderingObserver;
  139312. private _onAfterSpritesRenderingObserver;
  139313. private _onBeforePhysicsObserver;
  139314. private _onAfterPhysicsObserver;
  139315. private _onAfterAnimationsObserver;
  139316. private _onBeforeCameraRenderObserver;
  139317. private _onAfterCameraRenderObserver;
  139318. /**
  139319. * Gets the perf counter used for active meshes evaluation time
  139320. */
  139321. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  139322. /**
  139323. * Gets the active meshes evaluation time capture status
  139324. */
  139325. get captureActiveMeshesEvaluationTime(): boolean;
  139326. /**
  139327. * Enable or disable the active meshes evaluation time capture
  139328. */
  139329. set captureActiveMeshesEvaluationTime(value: boolean);
  139330. /**
  139331. * Gets the perf counter used for render targets render time
  139332. */
  139333. get renderTargetsRenderTimeCounter(): PerfCounter;
  139334. /**
  139335. * Gets the render targets render time capture status
  139336. */
  139337. get captureRenderTargetsRenderTime(): boolean;
  139338. /**
  139339. * Enable or disable the render targets render time capture
  139340. */
  139341. set captureRenderTargetsRenderTime(value: boolean);
  139342. /**
  139343. * Gets the perf counter used for particles render time
  139344. */
  139345. get particlesRenderTimeCounter(): PerfCounter;
  139346. /**
  139347. * Gets the particles render time capture status
  139348. */
  139349. get captureParticlesRenderTime(): boolean;
  139350. /**
  139351. * Enable or disable the particles render time capture
  139352. */
  139353. set captureParticlesRenderTime(value: boolean);
  139354. /**
  139355. * Gets the perf counter used for sprites render time
  139356. */
  139357. get spritesRenderTimeCounter(): PerfCounter;
  139358. /**
  139359. * Gets the sprites render time capture status
  139360. */
  139361. get captureSpritesRenderTime(): boolean;
  139362. /**
  139363. * Enable or disable the sprites render time capture
  139364. */
  139365. set captureSpritesRenderTime(value: boolean);
  139366. /**
  139367. * Gets the perf counter used for physics time
  139368. */
  139369. get physicsTimeCounter(): PerfCounter;
  139370. /**
  139371. * Gets the physics time capture status
  139372. */
  139373. get capturePhysicsTime(): boolean;
  139374. /**
  139375. * Enable or disable the physics time capture
  139376. */
  139377. set capturePhysicsTime(value: boolean);
  139378. /**
  139379. * Gets the perf counter used for animations time
  139380. */
  139381. get animationsTimeCounter(): PerfCounter;
  139382. /**
  139383. * Gets the animations time capture status
  139384. */
  139385. get captureAnimationsTime(): boolean;
  139386. /**
  139387. * Enable or disable the animations time capture
  139388. */
  139389. set captureAnimationsTime(value: boolean);
  139390. /**
  139391. * Gets the perf counter used for frame time capture
  139392. */
  139393. get frameTimeCounter(): PerfCounter;
  139394. /**
  139395. * Gets the frame time capture status
  139396. */
  139397. get captureFrameTime(): boolean;
  139398. /**
  139399. * Enable or disable the frame time capture
  139400. */
  139401. set captureFrameTime(value: boolean);
  139402. /**
  139403. * Gets the perf counter used for inter-frames time capture
  139404. */
  139405. get interFrameTimeCounter(): PerfCounter;
  139406. /**
  139407. * Gets the inter-frames time capture status
  139408. */
  139409. get captureInterFrameTime(): boolean;
  139410. /**
  139411. * Enable or disable the inter-frames time capture
  139412. */
  139413. set captureInterFrameTime(value: boolean);
  139414. /**
  139415. * Gets the perf counter used for render time capture
  139416. */
  139417. get renderTimeCounter(): PerfCounter;
  139418. /**
  139419. * Gets the render time capture status
  139420. */
  139421. get captureRenderTime(): boolean;
  139422. /**
  139423. * Enable or disable the render time capture
  139424. */
  139425. set captureRenderTime(value: boolean);
  139426. /**
  139427. * Gets the perf counter used for camera render time capture
  139428. */
  139429. get cameraRenderTimeCounter(): PerfCounter;
  139430. /**
  139431. * Gets the camera render time capture status
  139432. */
  139433. get captureCameraRenderTime(): boolean;
  139434. /**
  139435. * Enable or disable the camera render time capture
  139436. */
  139437. set captureCameraRenderTime(value: boolean);
  139438. /**
  139439. * Gets the perf counter used for draw calls
  139440. */
  139441. get drawCallsCounter(): PerfCounter;
  139442. /**
  139443. * Instantiates a new scene instrumentation.
  139444. * This class can be used to get instrumentation data from a Babylon engine
  139445. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139446. * @param scene Defines the scene to instrument
  139447. */
  139448. constructor(
  139449. /**
  139450. * Defines the scene to instrument
  139451. */
  139452. scene: Scene);
  139453. /**
  139454. * Dispose and release associated resources.
  139455. */
  139456. dispose(): void;
  139457. }
  139458. }
  139459. declare module BABYLON {
  139460. /** @hidden */
  139461. export var glowMapGenerationPixelShader: {
  139462. name: string;
  139463. shader: string;
  139464. };
  139465. }
  139466. declare module BABYLON {
  139467. /** @hidden */
  139468. export var glowMapGenerationVertexShader: {
  139469. name: string;
  139470. shader: string;
  139471. };
  139472. }
  139473. declare module BABYLON {
  139474. /**
  139475. * Effect layer options. This helps customizing the behaviour
  139476. * of the effect layer.
  139477. */
  139478. export interface IEffectLayerOptions {
  139479. /**
  139480. * Multiplication factor apply to the canvas size to compute the render target size
  139481. * used to generated the objects (the smaller the faster).
  139482. */
  139483. mainTextureRatio: number;
  139484. /**
  139485. * Enforces a fixed size texture to ensure effect stability across devices.
  139486. */
  139487. mainTextureFixedSize?: number;
  139488. /**
  139489. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  139490. */
  139491. alphaBlendingMode: number;
  139492. /**
  139493. * The camera attached to the layer.
  139494. */
  139495. camera: Nullable<Camera>;
  139496. /**
  139497. * The rendering group to draw the layer in.
  139498. */
  139499. renderingGroupId: number;
  139500. }
  139501. /**
  139502. * The effect layer Helps adding post process effect blended with the main pass.
  139503. *
  139504. * This can be for instance use to generate glow or higlight effects on the scene.
  139505. *
  139506. * The effect layer class can not be used directly and is intented to inherited from to be
  139507. * customized per effects.
  139508. */
  139509. export abstract class EffectLayer {
  139510. private _vertexBuffers;
  139511. private _indexBuffer;
  139512. private _cachedDefines;
  139513. private _effectLayerMapGenerationEffect;
  139514. private _effectLayerOptions;
  139515. private _mergeEffect;
  139516. protected _scene: Scene;
  139517. protected _engine: Engine;
  139518. protected _maxSize: number;
  139519. protected _mainTextureDesiredSize: ISize;
  139520. protected _mainTexture: RenderTargetTexture;
  139521. protected _shouldRender: boolean;
  139522. protected _postProcesses: PostProcess[];
  139523. protected _textures: BaseTexture[];
  139524. protected _emissiveTextureAndColor: {
  139525. texture: Nullable<BaseTexture>;
  139526. color: Color4;
  139527. };
  139528. /**
  139529. * The name of the layer
  139530. */
  139531. name: string;
  139532. /**
  139533. * The clear color of the texture used to generate the glow map.
  139534. */
  139535. neutralColor: Color4;
  139536. /**
  139537. * Specifies whether the highlight layer is enabled or not.
  139538. */
  139539. isEnabled: boolean;
  139540. /**
  139541. * Gets the camera attached to the layer.
  139542. */
  139543. get camera(): Nullable<Camera>;
  139544. /**
  139545. * Gets the rendering group id the layer should render in.
  139546. */
  139547. get renderingGroupId(): number;
  139548. set renderingGroupId(renderingGroupId: number);
  139549. /**
  139550. * An event triggered when the effect layer has been disposed.
  139551. */
  139552. onDisposeObservable: Observable<EffectLayer>;
  139553. /**
  139554. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  139555. */
  139556. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  139557. /**
  139558. * An event triggered when the generated texture is being merged in the scene.
  139559. */
  139560. onBeforeComposeObservable: Observable<EffectLayer>;
  139561. /**
  139562. * An event triggered when the mesh is rendered into the effect render target.
  139563. */
  139564. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  139565. /**
  139566. * An event triggered after the mesh has been rendered into the effect render target.
  139567. */
  139568. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  139569. /**
  139570. * An event triggered when the generated texture has been merged in the scene.
  139571. */
  139572. onAfterComposeObservable: Observable<EffectLayer>;
  139573. /**
  139574. * An event triggered when the efffect layer changes its size.
  139575. */
  139576. onSizeChangedObservable: Observable<EffectLayer>;
  139577. /** @hidden */
  139578. static _SceneComponentInitialization: (scene: Scene) => void;
  139579. /**
  139580. * Instantiates a new effect Layer and references it in the scene.
  139581. * @param name The name of the layer
  139582. * @param scene The scene to use the layer in
  139583. */
  139584. constructor(
  139585. /** The Friendly of the effect in the scene */
  139586. name: string, scene: Scene);
  139587. /**
  139588. * Get the effect name of the layer.
  139589. * @return The effect name
  139590. */
  139591. abstract getEffectName(): string;
  139592. /**
  139593. * Checks for the readiness of the element composing the layer.
  139594. * @param subMesh the mesh to check for
  139595. * @param useInstances specify whether or not to use instances to render the mesh
  139596. * @return true if ready otherwise, false
  139597. */
  139598. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139599. /**
  139600. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139601. * @returns true if the effect requires stencil during the main canvas render pass.
  139602. */
  139603. abstract needStencil(): boolean;
  139604. /**
  139605. * Create the merge effect. This is the shader use to blit the information back
  139606. * to the main canvas at the end of the scene rendering.
  139607. * @returns The effect containing the shader used to merge the effect on the main canvas
  139608. */
  139609. protected abstract _createMergeEffect(): Effect;
  139610. /**
  139611. * Creates the render target textures and post processes used in the effect layer.
  139612. */
  139613. protected abstract _createTextureAndPostProcesses(): void;
  139614. /**
  139615. * Implementation specific of rendering the generating effect on the main canvas.
  139616. * @param effect The effect used to render through
  139617. */
  139618. protected abstract _internalRender(effect: Effect): void;
  139619. /**
  139620. * Sets the required values for both the emissive texture and and the main color.
  139621. */
  139622. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139623. /**
  139624. * Free any resources and references associated to a mesh.
  139625. * Internal use
  139626. * @param mesh The mesh to free.
  139627. */
  139628. abstract _disposeMesh(mesh: Mesh): void;
  139629. /**
  139630. * Serializes this layer (Glow or Highlight for example)
  139631. * @returns a serialized layer object
  139632. */
  139633. abstract serialize?(): any;
  139634. /**
  139635. * Initializes the effect layer with the required options.
  139636. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  139637. */
  139638. protected _init(options: Partial<IEffectLayerOptions>): void;
  139639. /**
  139640. * Generates the index buffer of the full screen quad blending to the main canvas.
  139641. */
  139642. private _generateIndexBuffer;
  139643. /**
  139644. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  139645. */
  139646. private _generateVertexBuffer;
  139647. /**
  139648. * Sets the main texture desired size which is the closest power of two
  139649. * of the engine canvas size.
  139650. */
  139651. private _setMainTextureSize;
  139652. /**
  139653. * Creates the main texture for the effect layer.
  139654. */
  139655. protected _createMainTexture(): void;
  139656. /**
  139657. * Adds specific effects defines.
  139658. * @param defines The defines to add specifics to.
  139659. */
  139660. protected _addCustomEffectDefines(defines: string[]): void;
  139661. /**
  139662. * Checks for the readiness of the element composing the layer.
  139663. * @param subMesh the mesh to check for
  139664. * @param useInstances specify whether or not to use instances to render the mesh
  139665. * @param emissiveTexture the associated emissive texture used to generate the glow
  139666. * @return true if ready otherwise, false
  139667. */
  139668. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  139669. /**
  139670. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  139671. */
  139672. render(): void;
  139673. /**
  139674. * Determine if a given mesh will be used in the current effect.
  139675. * @param mesh mesh to test
  139676. * @returns true if the mesh will be used
  139677. */
  139678. hasMesh(mesh: AbstractMesh): boolean;
  139679. /**
  139680. * Returns true if the layer contains information to display, otherwise false.
  139681. * @returns true if the glow layer should be rendered
  139682. */
  139683. shouldRender(): boolean;
  139684. /**
  139685. * Returns true if the mesh should render, otherwise false.
  139686. * @param mesh The mesh to render
  139687. * @returns true if it should render otherwise false
  139688. */
  139689. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  139690. /**
  139691. * Returns true if the mesh can be rendered, otherwise false.
  139692. * @param mesh The mesh to render
  139693. * @param material The material used on the mesh
  139694. * @returns true if it can be rendered otherwise false
  139695. */
  139696. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139697. /**
  139698. * Returns true if the mesh should render, otherwise false.
  139699. * @param mesh The mesh to render
  139700. * @returns true if it should render otherwise false
  139701. */
  139702. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  139703. /**
  139704. * Renders the submesh passed in parameter to the generation map.
  139705. */
  139706. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  139707. /**
  139708. * Defines whether the current material of the mesh should be use to render the effect.
  139709. * @param mesh defines the current mesh to render
  139710. */
  139711. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139712. /**
  139713. * Rebuild the required buffers.
  139714. * @hidden Internal use only.
  139715. */
  139716. _rebuild(): void;
  139717. /**
  139718. * Dispose only the render target textures and post process.
  139719. */
  139720. private _disposeTextureAndPostProcesses;
  139721. /**
  139722. * Dispose the highlight layer and free resources.
  139723. */
  139724. dispose(): void;
  139725. /**
  139726. * Gets the class name of the effect layer
  139727. * @returns the string with the class name of the effect layer
  139728. */
  139729. getClassName(): string;
  139730. /**
  139731. * Creates an effect layer from parsed effect layer data
  139732. * @param parsedEffectLayer defines effect layer data
  139733. * @param scene defines the current scene
  139734. * @param rootUrl defines the root URL containing the effect layer information
  139735. * @returns a parsed effect Layer
  139736. */
  139737. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  139738. }
  139739. }
  139740. declare module BABYLON {
  139741. interface AbstractScene {
  139742. /**
  139743. * The list of effect layers (highlights/glow) added to the scene
  139744. * @see https://doc.babylonjs.com/how_to/highlight_layer
  139745. * @see https://doc.babylonjs.com/how_to/glow_layer
  139746. */
  139747. effectLayers: Array<EffectLayer>;
  139748. /**
  139749. * Removes the given effect layer from this scene.
  139750. * @param toRemove defines the effect layer to remove
  139751. * @returns the index of the removed effect layer
  139752. */
  139753. removeEffectLayer(toRemove: EffectLayer): number;
  139754. /**
  139755. * Adds the given effect layer to this scene
  139756. * @param newEffectLayer defines the effect layer to add
  139757. */
  139758. addEffectLayer(newEffectLayer: EffectLayer): void;
  139759. }
  139760. /**
  139761. * Defines the layer scene component responsible to manage any effect layers
  139762. * in a given scene.
  139763. */
  139764. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  139765. /**
  139766. * The component name helpfull to identify the component in the list of scene components.
  139767. */
  139768. readonly name: string;
  139769. /**
  139770. * The scene the component belongs to.
  139771. */
  139772. scene: Scene;
  139773. private _engine;
  139774. private _renderEffects;
  139775. private _needStencil;
  139776. private _previousStencilState;
  139777. /**
  139778. * Creates a new instance of the component for the given scene
  139779. * @param scene Defines the scene to register the component in
  139780. */
  139781. constructor(scene: Scene);
  139782. /**
  139783. * Registers the component in a given scene
  139784. */
  139785. register(): void;
  139786. /**
  139787. * Rebuilds the elements related to this component in case of
  139788. * context lost for instance.
  139789. */
  139790. rebuild(): void;
  139791. /**
  139792. * Serializes the component data to the specified json object
  139793. * @param serializationObject The object to serialize to
  139794. */
  139795. serialize(serializationObject: any): void;
  139796. /**
  139797. * Adds all the elements from the container to the scene
  139798. * @param container the container holding the elements
  139799. */
  139800. addFromContainer(container: AbstractScene): void;
  139801. /**
  139802. * Removes all the elements in the container from the scene
  139803. * @param container contains the elements to remove
  139804. * @param dispose if the removed element should be disposed (default: false)
  139805. */
  139806. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139807. /**
  139808. * Disposes the component and the associated ressources.
  139809. */
  139810. dispose(): void;
  139811. private _isReadyForMesh;
  139812. private _renderMainTexture;
  139813. private _setStencil;
  139814. private _setStencilBack;
  139815. private _draw;
  139816. private _drawCamera;
  139817. private _drawRenderingGroup;
  139818. }
  139819. }
  139820. declare module BABYLON {
  139821. /** @hidden */
  139822. export var glowMapMergePixelShader: {
  139823. name: string;
  139824. shader: string;
  139825. };
  139826. }
  139827. declare module BABYLON {
  139828. /** @hidden */
  139829. export var glowMapMergeVertexShader: {
  139830. name: string;
  139831. shader: string;
  139832. };
  139833. }
  139834. declare module BABYLON {
  139835. interface AbstractScene {
  139836. /**
  139837. * Return a the first highlight layer of the scene with a given name.
  139838. * @param name The name of the highlight layer to look for.
  139839. * @return The highlight layer if found otherwise null.
  139840. */
  139841. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  139842. }
  139843. /**
  139844. * Glow layer options. This helps customizing the behaviour
  139845. * of the glow layer.
  139846. */
  139847. export interface IGlowLayerOptions {
  139848. /**
  139849. * Multiplication factor apply to the canvas size to compute the render target size
  139850. * used to generated the glowing objects (the smaller the faster).
  139851. */
  139852. mainTextureRatio: number;
  139853. /**
  139854. * Enforces a fixed size texture to ensure resize independant blur.
  139855. */
  139856. mainTextureFixedSize?: number;
  139857. /**
  139858. * How big is the kernel of the blur texture.
  139859. */
  139860. blurKernelSize: number;
  139861. /**
  139862. * The camera attached to the layer.
  139863. */
  139864. camera: Nullable<Camera>;
  139865. /**
  139866. * Enable MSAA by chosing the number of samples.
  139867. */
  139868. mainTextureSamples?: number;
  139869. /**
  139870. * The rendering group to draw the layer in.
  139871. */
  139872. renderingGroupId: number;
  139873. }
  139874. /**
  139875. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  139876. *
  139877. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  139878. *
  139879. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  139880. */
  139881. export class GlowLayer extends EffectLayer {
  139882. /**
  139883. * Effect Name of the layer.
  139884. */
  139885. static readonly EffectName: string;
  139886. /**
  139887. * The default blur kernel size used for the glow.
  139888. */
  139889. static DefaultBlurKernelSize: number;
  139890. /**
  139891. * The default texture size ratio used for the glow.
  139892. */
  139893. static DefaultTextureRatio: number;
  139894. /**
  139895. * Sets the kernel size of the blur.
  139896. */
  139897. set blurKernelSize(value: number);
  139898. /**
  139899. * Gets the kernel size of the blur.
  139900. */
  139901. get blurKernelSize(): number;
  139902. /**
  139903. * Sets the glow intensity.
  139904. */
  139905. set intensity(value: number);
  139906. /**
  139907. * Gets the glow intensity.
  139908. */
  139909. get intensity(): number;
  139910. private _options;
  139911. private _intensity;
  139912. private _horizontalBlurPostprocess1;
  139913. private _verticalBlurPostprocess1;
  139914. private _horizontalBlurPostprocess2;
  139915. private _verticalBlurPostprocess2;
  139916. private _blurTexture1;
  139917. private _blurTexture2;
  139918. private _postProcesses1;
  139919. private _postProcesses2;
  139920. private _includedOnlyMeshes;
  139921. private _excludedMeshes;
  139922. private _meshesUsingTheirOwnMaterials;
  139923. /**
  139924. * Callback used to let the user override the color selection on a per mesh basis
  139925. */
  139926. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  139927. /**
  139928. * Callback used to let the user override the texture selection on a per mesh basis
  139929. */
  139930. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  139931. /**
  139932. * Instantiates a new glow Layer and references it to the scene.
  139933. * @param name The name of the layer
  139934. * @param scene The scene to use the layer in
  139935. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  139936. */
  139937. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  139938. /**
  139939. * Get the effect name of the layer.
  139940. * @return The effect name
  139941. */
  139942. getEffectName(): string;
  139943. /**
  139944. * Create the merge effect. This is the shader use to blit the information back
  139945. * to the main canvas at the end of the scene rendering.
  139946. */
  139947. protected _createMergeEffect(): Effect;
  139948. /**
  139949. * Creates the render target textures and post processes used in the glow layer.
  139950. */
  139951. protected _createTextureAndPostProcesses(): void;
  139952. /**
  139953. * Checks for the readiness of the element composing the layer.
  139954. * @param subMesh the mesh to check for
  139955. * @param useInstances specify wether or not to use instances to render the mesh
  139956. * @param emissiveTexture the associated emissive texture used to generate the glow
  139957. * @return true if ready otherwise, false
  139958. */
  139959. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139960. /**
  139961. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139962. */
  139963. needStencil(): boolean;
  139964. /**
  139965. * Returns true if the mesh can be rendered, otherwise false.
  139966. * @param mesh The mesh to render
  139967. * @param material The material used on the mesh
  139968. * @returns true if it can be rendered otherwise false
  139969. */
  139970. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139971. /**
  139972. * Implementation specific of rendering the generating effect on the main canvas.
  139973. * @param effect The effect used to render through
  139974. */
  139975. protected _internalRender(effect: Effect): void;
  139976. /**
  139977. * Sets the required values for both the emissive texture and and the main color.
  139978. */
  139979. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139980. /**
  139981. * Returns true if the mesh should render, otherwise false.
  139982. * @param mesh The mesh to render
  139983. * @returns true if it should render otherwise false
  139984. */
  139985. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139986. /**
  139987. * Adds specific effects defines.
  139988. * @param defines The defines to add specifics to.
  139989. */
  139990. protected _addCustomEffectDefines(defines: string[]): void;
  139991. /**
  139992. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  139993. * @param mesh The mesh to exclude from the glow layer
  139994. */
  139995. addExcludedMesh(mesh: Mesh): void;
  139996. /**
  139997. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  139998. * @param mesh The mesh to remove
  139999. */
  140000. removeExcludedMesh(mesh: Mesh): void;
  140001. /**
  140002. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  140003. * @param mesh The mesh to include in the glow layer
  140004. */
  140005. addIncludedOnlyMesh(mesh: Mesh): void;
  140006. /**
  140007. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  140008. * @param mesh The mesh to remove
  140009. */
  140010. removeIncludedOnlyMesh(mesh: Mesh): void;
  140011. /**
  140012. * Determine if a given mesh will be used in the glow layer
  140013. * @param mesh The mesh to test
  140014. * @returns true if the mesh will be highlighted by the current glow layer
  140015. */
  140016. hasMesh(mesh: AbstractMesh): boolean;
  140017. /**
  140018. * Defines whether the current material of the mesh should be use to render the effect.
  140019. * @param mesh defines the current mesh to render
  140020. */
  140021. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140022. /**
  140023. * Add a mesh to be rendered through its own material and not with emissive only.
  140024. * @param mesh The mesh for which we need to use its material
  140025. */
  140026. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  140027. /**
  140028. * Remove a mesh from being rendered through its own material and not with emissive only.
  140029. * @param mesh The mesh for which we need to not use its material
  140030. */
  140031. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  140032. /**
  140033. * Free any resources and references associated to a mesh.
  140034. * Internal use
  140035. * @param mesh The mesh to free.
  140036. * @hidden
  140037. */
  140038. _disposeMesh(mesh: Mesh): void;
  140039. /**
  140040. * Gets the class name of the effect layer
  140041. * @returns the string with the class name of the effect layer
  140042. */
  140043. getClassName(): string;
  140044. /**
  140045. * Serializes this glow layer
  140046. * @returns a serialized glow layer object
  140047. */
  140048. serialize(): any;
  140049. /**
  140050. * Creates a Glow Layer from parsed glow layer data
  140051. * @param parsedGlowLayer defines glow layer data
  140052. * @param scene defines the current scene
  140053. * @param rootUrl defines the root URL containing the glow layer information
  140054. * @returns a parsed Glow Layer
  140055. */
  140056. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  140057. }
  140058. }
  140059. declare module BABYLON {
  140060. /** @hidden */
  140061. export var glowBlurPostProcessPixelShader: {
  140062. name: string;
  140063. shader: string;
  140064. };
  140065. }
  140066. declare module BABYLON {
  140067. interface AbstractScene {
  140068. /**
  140069. * Return a the first highlight layer of the scene with a given name.
  140070. * @param name The name of the highlight layer to look for.
  140071. * @return The highlight layer if found otherwise null.
  140072. */
  140073. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  140074. }
  140075. /**
  140076. * Highlight layer options. This helps customizing the behaviour
  140077. * of the highlight layer.
  140078. */
  140079. export interface IHighlightLayerOptions {
  140080. /**
  140081. * Multiplication factor apply to the canvas size to compute the render target size
  140082. * used to generated the glowing objects (the smaller the faster).
  140083. */
  140084. mainTextureRatio: number;
  140085. /**
  140086. * Enforces a fixed size texture to ensure resize independant blur.
  140087. */
  140088. mainTextureFixedSize?: number;
  140089. /**
  140090. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  140091. * of the picture to blur (the smaller the faster).
  140092. */
  140093. blurTextureSizeRatio: number;
  140094. /**
  140095. * How big in texel of the blur texture is the vertical blur.
  140096. */
  140097. blurVerticalSize: number;
  140098. /**
  140099. * How big in texel of the blur texture is the horizontal blur.
  140100. */
  140101. blurHorizontalSize: number;
  140102. /**
  140103. * Alpha blending mode used to apply the blur. Default is combine.
  140104. */
  140105. alphaBlendingMode: number;
  140106. /**
  140107. * The camera attached to the layer.
  140108. */
  140109. camera: Nullable<Camera>;
  140110. /**
  140111. * Should we display highlight as a solid stroke?
  140112. */
  140113. isStroke?: boolean;
  140114. /**
  140115. * The rendering group to draw the layer in.
  140116. */
  140117. renderingGroupId: number;
  140118. }
  140119. /**
  140120. * The highlight layer Helps adding a glow effect around a mesh.
  140121. *
  140122. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  140123. * glowy meshes to your scene.
  140124. *
  140125. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  140126. */
  140127. export class HighlightLayer extends EffectLayer {
  140128. name: string;
  140129. /**
  140130. * Effect Name of the highlight layer.
  140131. */
  140132. static readonly EffectName: string;
  140133. /**
  140134. * The neutral color used during the preparation of the glow effect.
  140135. * This is black by default as the blend operation is a blend operation.
  140136. */
  140137. static NeutralColor: Color4;
  140138. /**
  140139. * Stencil value used for glowing meshes.
  140140. */
  140141. static GlowingMeshStencilReference: number;
  140142. /**
  140143. * Stencil value used for the other meshes in the scene.
  140144. */
  140145. static NormalMeshStencilReference: number;
  140146. /**
  140147. * Specifies whether or not the inner glow is ACTIVE in the layer.
  140148. */
  140149. innerGlow: boolean;
  140150. /**
  140151. * Specifies whether or not the outer glow is ACTIVE in the layer.
  140152. */
  140153. outerGlow: boolean;
  140154. /**
  140155. * Specifies the horizontal size of the blur.
  140156. */
  140157. set blurHorizontalSize(value: number);
  140158. /**
  140159. * Specifies the vertical size of the blur.
  140160. */
  140161. set blurVerticalSize(value: number);
  140162. /**
  140163. * Gets the horizontal size of the blur.
  140164. */
  140165. get blurHorizontalSize(): number;
  140166. /**
  140167. * Gets the vertical size of the blur.
  140168. */
  140169. get blurVerticalSize(): number;
  140170. /**
  140171. * An event triggered when the highlight layer is being blurred.
  140172. */
  140173. onBeforeBlurObservable: Observable<HighlightLayer>;
  140174. /**
  140175. * An event triggered when the highlight layer has been blurred.
  140176. */
  140177. onAfterBlurObservable: Observable<HighlightLayer>;
  140178. private _instanceGlowingMeshStencilReference;
  140179. private _options;
  140180. private _downSamplePostprocess;
  140181. private _horizontalBlurPostprocess;
  140182. private _verticalBlurPostprocess;
  140183. private _blurTexture;
  140184. private _meshes;
  140185. private _excludedMeshes;
  140186. /**
  140187. * Instantiates a new highlight Layer and references it to the scene..
  140188. * @param name The name of the layer
  140189. * @param scene The scene to use the layer in
  140190. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  140191. */
  140192. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  140193. /**
  140194. * Get the effect name of the layer.
  140195. * @return The effect name
  140196. */
  140197. getEffectName(): string;
  140198. /**
  140199. * Create the merge effect. This is the shader use to blit the information back
  140200. * to the main canvas at the end of the scene rendering.
  140201. */
  140202. protected _createMergeEffect(): Effect;
  140203. /**
  140204. * Creates the render target textures and post processes used in the highlight layer.
  140205. */
  140206. protected _createTextureAndPostProcesses(): void;
  140207. /**
  140208. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  140209. */
  140210. needStencil(): boolean;
  140211. /**
  140212. * Checks for the readiness of the element composing the layer.
  140213. * @param subMesh the mesh to check for
  140214. * @param useInstances specify wether or not to use instances to render the mesh
  140215. * @param emissiveTexture the associated emissive texture used to generate the glow
  140216. * @return true if ready otherwise, false
  140217. */
  140218. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140219. /**
  140220. * Implementation specific of rendering the generating effect on the main canvas.
  140221. * @param effect The effect used to render through
  140222. */
  140223. protected _internalRender(effect: Effect): void;
  140224. /**
  140225. * Returns true if the layer contains information to display, otherwise false.
  140226. */
  140227. shouldRender(): boolean;
  140228. /**
  140229. * Returns true if the mesh should render, otherwise false.
  140230. * @param mesh The mesh to render
  140231. * @returns true if it should render otherwise false
  140232. */
  140233. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140234. /**
  140235. * Returns true if the mesh can be rendered, otherwise false.
  140236. * @param mesh The mesh to render
  140237. * @param material The material used on the mesh
  140238. * @returns true if it can be rendered otherwise false
  140239. */
  140240. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140241. /**
  140242. * Adds specific effects defines.
  140243. * @param defines The defines to add specifics to.
  140244. */
  140245. protected _addCustomEffectDefines(defines: string[]): void;
  140246. /**
  140247. * Sets the required values for both the emissive texture and and the main color.
  140248. */
  140249. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140250. /**
  140251. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  140252. * @param mesh The mesh to exclude from the highlight layer
  140253. */
  140254. addExcludedMesh(mesh: Mesh): void;
  140255. /**
  140256. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  140257. * @param mesh The mesh to highlight
  140258. */
  140259. removeExcludedMesh(mesh: Mesh): void;
  140260. /**
  140261. * Determine if a given mesh will be highlighted by the current HighlightLayer
  140262. * @param mesh mesh to test
  140263. * @returns true if the mesh will be highlighted by the current HighlightLayer
  140264. */
  140265. hasMesh(mesh: AbstractMesh): boolean;
  140266. /**
  140267. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  140268. * @param mesh The mesh to highlight
  140269. * @param color The color of the highlight
  140270. * @param glowEmissiveOnly Extract the glow from the emissive texture
  140271. */
  140272. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  140273. /**
  140274. * Remove a mesh from the highlight layer in order to make it stop glowing.
  140275. * @param mesh The mesh to highlight
  140276. */
  140277. removeMesh(mesh: Mesh): void;
  140278. /**
  140279. * Remove all the meshes currently referenced in the highlight layer
  140280. */
  140281. removeAllMeshes(): void;
  140282. /**
  140283. * Force the stencil to the normal expected value for none glowing parts
  140284. */
  140285. private _defaultStencilReference;
  140286. /**
  140287. * Free any resources and references associated to a mesh.
  140288. * Internal use
  140289. * @param mesh The mesh to free.
  140290. * @hidden
  140291. */
  140292. _disposeMesh(mesh: Mesh): void;
  140293. /**
  140294. * Dispose the highlight layer and free resources.
  140295. */
  140296. dispose(): void;
  140297. /**
  140298. * Gets the class name of the effect layer
  140299. * @returns the string with the class name of the effect layer
  140300. */
  140301. getClassName(): string;
  140302. /**
  140303. * Serializes this Highlight layer
  140304. * @returns a serialized Highlight layer object
  140305. */
  140306. serialize(): any;
  140307. /**
  140308. * Creates a Highlight layer from parsed Highlight layer data
  140309. * @param parsedHightlightLayer defines the Highlight layer data
  140310. * @param scene defines the current scene
  140311. * @param rootUrl defines the root URL containing the Highlight layer information
  140312. * @returns a parsed Highlight layer
  140313. */
  140314. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  140315. }
  140316. }
  140317. declare module BABYLON {
  140318. interface AbstractScene {
  140319. /**
  140320. * The list of layers (background and foreground) of the scene
  140321. */
  140322. layers: Array<Layer>;
  140323. }
  140324. /**
  140325. * Defines the layer scene component responsible to manage any layers
  140326. * in a given scene.
  140327. */
  140328. export class LayerSceneComponent implements ISceneComponent {
  140329. /**
  140330. * The component name helpfull to identify the component in the list of scene components.
  140331. */
  140332. readonly name: string;
  140333. /**
  140334. * The scene the component belongs to.
  140335. */
  140336. scene: Scene;
  140337. private _engine;
  140338. /**
  140339. * Creates a new instance of the component for the given scene
  140340. * @param scene Defines the scene to register the component in
  140341. */
  140342. constructor(scene: Scene);
  140343. /**
  140344. * Registers the component in a given scene
  140345. */
  140346. register(): void;
  140347. /**
  140348. * Rebuilds the elements related to this component in case of
  140349. * context lost for instance.
  140350. */
  140351. rebuild(): void;
  140352. /**
  140353. * Disposes the component and the associated ressources.
  140354. */
  140355. dispose(): void;
  140356. private _draw;
  140357. private _drawCameraPredicate;
  140358. private _drawCameraBackground;
  140359. private _drawCameraForeground;
  140360. private _drawRenderTargetPredicate;
  140361. private _drawRenderTargetBackground;
  140362. private _drawRenderTargetForeground;
  140363. /**
  140364. * Adds all the elements from the container to the scene
  140365. * @param container the container holding the elements
  140366. */
  140367. addFromContainer(container: AbstractScene): void;
  140368. /**
  140369. * Removes all the elements in the container from the scene
  140370. * @param container contains the elements to remove
  140371. * @param dispose if the removed element should be disposed (default: false)
  140372. */
  140373. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140374. }
  140375. }
  140376. declare module BABYLON {
  140377. /** @hidden */
  140378. export var layerPixelShader: {
  140379. name: string;
  140380. shader: string;
  140381. };
  140382. }
  140383. declare module BABYLON {
  140384. /** @hidden */
  140385. export var layerVertexShader: {
  140386. name: string;
  140387. shader: string;
  140388. };
  140389. }
  140390. declare module BABYLON {
  140391. /**
  140392. * This represents a full screen 2d layer.
  140393. * This can be useful to display a picture in the background of your scene for instance.
  140394. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140395. */
  140396. export class Layer {
  140397. /**
  140398. * Define the name of the layer.
  140399. */
  140400. name: string;
  140401. /**
  140402. * Define the texture the layer should display.
  140403. */
  140404. texture: Nullable<Texture>;
  140405. /**
  140406. * Is the layer in background or foreground.
  140407. */
  140408. isBackground: boolean;
  140409. /**
  140410. * Define the color of the layer (instead of texture).
  140411. */
  140412. color: Color4;
  140413. /**
  140414. * Define the scale of the layer in order to zoom in out of the texture.
  140415. */
  140416. scale: Vector2;
  140417. /**
  140418. * Define an offset for the layer in order to shift the texture.
  140419. */
  140420. offset: Vector2;
  140421. /**
  140422. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  140423. */
  140424. alphaBlendingMode: number;
  140425. /**
  140426. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  140427. * Alpha test will not mix with the background color in case of transparency.
  140428. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  140429. */
  140430. alphaTest: boolean;
  140431. /**
  140432. * Define a mask to restrict the layer to only some of the scene cameras.
  140433. */
  140434. layerMask: number;
  140435. /**
  140436. * Define the list of render target the layer is visible into.
  140437. */
  140438. renderTargetTextures: RenderTargetTexture[];
  140439. /**
  140440. * Define if the layer is only used in renderTarget or if it also
  140441. * renders in the main frame buffer of the canvas.
  140442. */
  140443. renderOnlyInRenderTargetTextures: boolean;
  140444. private _scene;
  140445. private _vertexBuffers;
  140446. private _indexBuffer;
  140447. private _effect;
  140448. private _previousDefines;
  140449. /**
  140450. * An event triggered when the layer is disposed.
  140451. */
  140452. onDisposeObservable: Observable<Layer>;
  140453. private _onDisposeObserver;
  140454. /**
  140455. * Back compatibility with callback before the onDisposeObservable existed.
  140456. * The set callback will be triggered when the layer has been disposed.
  140457. */
  140458. set onDispose(callback: () => void);
  140459. /**
  140460. * An event triggered before rendering the scene
  140461. */
  140462. onBeforeRenderObservable: Observable<Layer>;
  140463. private _onBeforeRenderObserver;
  140464. /**
  140465. * Back compatibility with callback before the onBeforeRenderObservable existed.
  140466. * The set callback will be triggered just before rendering the layer.
  140467. */
  140468. set onBeforeRender(callback: () => void);
  140469. /**
  140470. * An event triggered after rendering the scene
  140471. */
  140472. onAfterRenderObservable: Observable<Layer>;
  140473. private _onAfterRenderObserver;
  140474. /**
  140475. * Back compatibility with callback before the onAfterRenderObservable existed.
  140476. * The set callback will be triggered just after rendering the layer.
  140477. */
  140478. set onAfterRender(callback: () => void);
  140479. /**
  140480. * Instantiates a new layer.
  140481. * This represents a full screen 2d layer.
  140482. * This can be useful to display a picture in the background of your scene for instance.
  140483. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140484. * @param name Define the name of the layer in the scene
  140485. * @param imgUrl Define the url of the texture to display in the layer
  140486. * @param scene Define the scene the layer belongs to
  140487. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  140488. * @param color Defines a color for the layer
  140489. */
  140490. constructor(
  140491. /**
  140492. * Define the name of the layer.
  140493. */
  140494. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  140495. private _createIndexBuffer;
  140496. /** @hidden */
  140497. _rebuild(): void;
  140498. /**
  140499. * Renders the layer in the scene.
  140500. */
  140501. render(): void;
  140502. /**
  140503. * Disposes and releases the associated ressources.
  140504. */
  140505. dispose(): void;
  140506. }
  140507. }
  140508. declare module BABYLON {
  140509. /** @hidden */
  140510. export var lensFlarePixelShader: {
  140511. name: string;
  140512. shader: string;
  140513. };
  140514. }
  140515. declare module BABYLON {
  140516. /** @hidden */
  140517. export var lensFlareVertexShader: {
  140518. name: string;
  140519. shader: string;
  140520. };
  140521. }
  140522. declare module BABYLON {
  140523. /**
  140524. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140525. * It is usually composed of several `lensFlare`.
  140526. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140527. */
  140528. export class LensFlareSystem {
  140529. /**
  140530. * Define the name of the lens flare system
  140531. */
  140532. name: string;
  140533. /**
  140534. * List of lens flares used in this system.
  140535. */
  140536. lensFlares: LensFlare[];
  140537. /**
  140538. * Define a limit from the border the lens flare can be visible.
  140539. */
  140540. borderLimit: number;
  140541. /**
  140542. * Define a viewport border we do not want to see the lens flare in.
  140543. */
  140544. viewportBorder: number;
  140545. /**
  140546. * Define a predicate which could limit the list of meshes able to occlude the effect.
  140547. */
  140548. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  140549. /**
  140550. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  140551. */
  140552. layerMask: number;
  140553. /**
  140554. * Define the id of the lens flare system in the scene.
  140555. * (equal to name by default)
  140556. */
  140557. id: string;
  140558. private _scene;
  140559. private _emitter;
  140560. private _vertexBuffers;
  140561. private _indexBuffer;
  140562. private _effect;
  140563. private _positionX;
  140564. private _positionY;
  140565. private _isEnabled;
  140566. /** @hidden */
  140567. static _SceneComponentInitialization: (scene: Scene) => void;
  140568. /**
  140569. * Instantiates a lens flare system.
  140570. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140571. * It is usually composed of several `lensFlare`.
  140572. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140573. * @param name Define the name of the lens flare system in the scene
  140574. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  140575. * @param scene Define the scene the lens flare system belongs to
  140576. */
  140577. constructor(
  140578. /**
  140579. * Define the name of the lens flare system
  140580. */
  140581. name: string, emitter: any, scene: Scene);
  140582. /**
  140583. * Define if the lens flare system is enabled.
  140584. */
  140585. get isEnabled(): boolean;
  140586. set isEnabled(value: boolean);
  140587. /**
  140588. * Get the scene the effects belongs to.
  140589. * @returns the scene holding the lens flare system
  140590. */
  140591. getScene(): Scene;
  140592. /**
  140593. * Get the emitter of the lens flare system.
  140594. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140595. * @returns the emitter of the lens flare system
  140596. */
  140597. getEmitter(): any;
  140598. /**
  140599. * Set the emitter of the lens flare system.
  140600. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140601. * @param newEmitter Define the new emitter of the system
  140602. */
  140603. setEmitter(newEmitter: any): void;
  140604. /**
  140605. * Get the lens flare system emitter position.
  140606. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  140607. * @returns the position
  140608. */
  140609. getEmitterPosition(): Vector3;
  140610. /**
  140611. * @hidden
  140612. */
  140613. computeEffectivePosition(globalViewport: Viewport): boolean;
  140614. /** @hidden */
  140615. _isVisible(): boolean;
  140616. /**
  140617. * @hidden
  140618. */
  140619. render(): boolean;
  140620. /**
  140621. * Dispose and release the lens flare with its associated resources.
  140622. */
  140623. dispose(): void;
  140624. /**
  140625. * Parse a lens flare system from a JSON repressentation
  140626. * @param parsedLensFlareSystem Define the JSON to parse
  140627. * @param scene Define the scene the parsed system should be instantiated in
  140628. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  140629. * @returns the parsed system
  140630. */
  140631. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  140632. /**
  140633. * Serialize the current Lens Flare System into a JSON representation.
  140634. * @returns the serialized JSON
  140635. */
  140636. serialize(): any;
  140637. }
  140638. }
  140639. declare module BABYLON {
  140640. /**
  140641. * This represents one of the lens effect in a `lensFlareSystem`.
  140642. * It controls one of the indiviual texture used in the effect.
  140643. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140644. */
  140645. export class LensFlare {
  140646. /**
  140647. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140648. */
  140649. size: number;
  140650. /**
  140651. * 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.
  140652. */
  140653. position: number;
  140654. /**
  140655. * Define the lens color.
  140656. */
  140657. color: Color3;
  140658. /**
  140659. * Define the lens texture.
  140660. */
  140661. texture: Nullable<Texture>;
  140662. /**
  140663. * Define the alpha mode to render this particular lens.
  140664. */
  140665. alphaMode: number;
  140666. private _system;
  140667. /**
  140668. * Creates a new Lens Flare.
  140669. * This represents one of the lens effect in a `lensFlareSystem`.
  140670. * It controls one of the indiviual texture used in the effect.
  140671. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140672. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  140673. * @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.
  140674. * @param color Define the lens color
  140675. * @param imgUrl Define the lens texture url
  140676. * @param system Define the `lensFlareSystem` this flare is part of
  140677. * @returns The newly created Lens Flare
  140678. */
  140679. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  140680. /**
  140681. * Instantiates a new Lens Flare.
  140682. * This represents one of the lens effect in a `lensFlareSystem`.
  140683. * It controls one of the indiviual texture used in the effect.
  140684. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140685. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  140686. * @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.
  140687. * @param color Define the lens color
  140688. * @param imgUrl Define the lens texture url
  140689. * @param system Define the `lensFlareSystem` this flare is part of
  140690. */
  140691. constructor(
  140692. /**
  140693. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140694. */
  140695. size: number,
  140696. /**
  140697. * 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.
  140698. */
  140699. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  140700. /**
  140701. * Dispose and release the lens flare with its associated resources.
  140702. */
  140703. dispose(): void;
  140704. }
  140705. }
  140706. declare module BABYLON {
  140707. interface AbstractScene {
  140708. /**
  140709. * The list of lens flare system added to the scene
  140710. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140711. */
  140712. lensFlareSystems: Array<LensFlareSystem>;
  140713. /**
  140714. * Removes the given lens flare system from this scene.
  140715. * @param toRemove The lens flare system to remove
  140716. * @returns The index of the removed lens flare system
  140717. */
  140718. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  140719. /**
  140720. * Adds the given lens flare system to this scene
  140721. * @param newLensFlareSystem The lens flare system to add
  140722. */
  140723. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  140724. /**
  140725. * Gets a lens flare system using its name
  140726. * @param name defines the name to look for
  140727. * @returns the lens flare system or null if not found
  140728. */
  140729. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  140730. /**
  140731. * Gets a lens flare system using its id
  140732. * @param id defines the id to look for
  140733. * @returns the lens flare system or null if not found
  140734. */
  140735. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  140736. }
  140737. /**
  140738. * Defines the lens flare scene component responsible to manage any lens flares
  140739. * in a given scene.
  140740. */
  140741. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  140742. /**
  140743. * The component name helpfull to identify the component in the list of scene components.
  140744. */
  140745. readonly name: string;
  140746. /**
  140747. * The scene the component belongs to.
  140748. */
  140749. scene: Scene;
  140750. /**
  140751. * Creates a new instance of the component for the given scene
  140752. * @param scene Defines the scene to register the component in
  140753. */
  140754. constructor(scene: Scene);
  140755. /**
  140756. * Registers the component in a given scene
  140757. */
  140758. register(): void;
  140759. /**
  140760. * Rebuilds the elements related to this component in case of
  140761. * context lost for instance.
  140762. */
  140763. rebuild(): void;
  140764. /**
  140765. * Adds all the elements from the container to the scene
  140766. * @param container the container holding the elements
  140767. */
  140768. addFromContainer(container: AbstractScene): void;
  140769. /**
  140770. * Removes all the elements in the container from the scene
  140771. * @param container contains the elements to remove
  140772. * @param dispose if the removed element should be disposed (default: false)
  140773. */
  140774. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140775. /**
  140776. * Serializes the component data to the specified json object
  140777. * @param serializationObject The object to serialize to
  140778. */
  140779. serialize(serializationObject: any): void;
  140780. /**
  140781. * Disposes the component and the associated ressources.
  140782. */
  140783. dispose(): void;
  140784. private _draw;
  140785. }
  140786. }
  140787. declare module BABYLON {
  140788. /** @hidden */
  140789. export var depthPixelShader: {
  140790. name: string;
  140791. shader: string;
  140792. };
  140793. }
  140794. declare module BABYLON {
  140795. /** @hidden */
  140796. export var depthVertexShader: {
  140797. name: string;
  140798. shader: string;
  140799. };
  140800. }
  140801. declare module BABYLON {
  140802. /**
  140803. * This represents a depth renderer in Babylon.
  140804. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  140805. */
  140806. export class DepthRenderer {
  140807. private _scene;
  140808. private _depthMap;
  140809. private _effect;
  140810. private readonly _storeNonLinearDepth;
  140811. private readonly _clearColor;
  140812. /** Get if the depth renderer is using packed depth or not */
  140813. readonly isPacked: boolean;
  140814. private _cachedDefines;
  140815. private _camera;
  140816. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  140817. enabled: boolean;
  140818. /**
  140819. * Specifiess that the depth renderer will only be used within
  140820. * the camera it is created for.
  140821. * This can help forcing its rendering during the camera processing.
  140822. */
  140823. useOnlyInActiveCamera: boolean;
  140824. /** @hidden */
  140825. static _SceneComponentInitialization: (scene: Scene) => void;
  140826. /**
  140827. * Instantiates a depth renderer
  140828. * @param scene The scene the renderer belongs to
  140829. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  140830. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  140831. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140832. */
  140833. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  140834. /**
  140835. * Creates the depth rendering effect and checks if the effect is ready.
  140836. * @param subMesh The submesh to be used to render the depth map of
  140837. * @param useInstances If multiple world instances should be used
  140838. * @returns if the depth renderer is ready to render the depth map
  140839. */
  140840. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140841. /**
  140842. * Gets the texture which the depth map will be written to.
  140843. * @returns The depth map texture
  140844. */
  140845. getDepthMap(): RenderTargetTexture;
  140846. /**
  140847. * Disposes of the depth renderer.
  140848. */
  140849. dispose(): void;
  140850. }
  140851. }
  140852. declare module BABYLON {
  140853. /** @hidden */
  140854. export var minmaxReduxPixelShader: {
  140855. name: string;
  140856. shader: string;
  140857. };
  140858. }
  140859. declare module BABYLON {
  140860. /**
  140861. * This class computes a min/max reduction from a texture: it means it computes the minimum
  140862. * and maximum values from all values of the texture.
  140863. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  140864. * The source values are read from the red channel of the texture.
  140865. */
  140866. export class MinMaxReducer {
  140867. /**
  140868. * Observable triggered when the computation has been performed
  140869. */
  140870. onAfterReductionPerformed: Observable<{
  140871. min: number;
  140872. max: number;
  140873. }>;
  140874. protected _camera: Camera;
  140875. protected _sourceTexture: Nullable<RenderTargetTexture>;
  140876. protected _reductionSteps: Nullable<Array<PostProcess>>;
  140877. protected _postProcessManager: PostProcessManager;
  140878. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  140879. protected _forceFullscreenViewport: boolean;
  140880. /**
  140881. * Creates a min/max reducer
  140882. * @param camera The camera to use for the post processes
  140883. */
  140884. constructor(camera: Camera);
  140885. /**
  140886. * Gets the texture used to read the values from.
  140887. */
  140888. get sourceTexture(): Nullable<RenderTargetTexture>;
  140889. /**
  140890. * Sets the source texture to read the values from.
  140891. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  140892. * because in such textures '1' value must not be taken into account to compute the maximum
  140893. * as this value is used to clear the texture.
  140894. * Note that the computation is not activated by calling this function, you must call activate() for that!
  140895. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  140896. * @param depthRedux Indicates if the texture is a depth texture or not
  140897. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  140898. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140899. */
  140900. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140901. /**
  140902. * Defines the refresh rate of the computation.
  140903. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140904. */
  140905. get refreshRate(): number;
  140906. set refreshRate(value: number);
  140907. protected _activated: boolean;
  140908. /**
  140909. * Gets the activation status of the reducer
  140910. */
  140911. get activated(): boolean;
  140912. /**
  140913. * Activates the reduction computation.
  140914. * When activated, the observers registered in onAfterReductionPerformed are
  140915. * called after the compuation is performed
  140916. */
  140917. activate(): void;
  140918. /**
  140919. * Deactivates the reduction computation.
  140920. */
  140921. deactivate(): void;
  140922. /**
  140923. * Disposes the min/max reducer
  140924. * @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.
  140925. */
  140926. dispose(disposeAll?: boolean): void;
  140927. }
  140928. }
  140929. declare module BABYLON {
  140930. /**
  140931. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  140932. */
  140933. export class DepthReducer extends MinMaxReducer {
  140934. private _depthRenderer;
  140935. private _depthRendererId;
  140936. /**
  140937. * Gets the depth renderer used for the computation.
  140938. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  140939. */
  140940. get depthRenderer(): Nullable<DepthRenderer>;
  140941. /**
  140942. * Creates a depth reducer
  140943. * @param camera The camera used to render the depth texture
  140944. */
  140945. constructor(camera: Camera);
  140946. /**
  140947. * Sets the depth renderer to use to generate the depth map
  140948. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  140949. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  140950. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140951. */
  140952. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  140953. /** @hidden */
  140954. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140955. /**
  140956. * Activates the reduction computation.
  140957. * When activated, the observers registered in onAfterReductionPerformed are
  140958. * called after the compuation is performed
  140959. */
  140960. activate(): void;
  140961. /**
  140962. * Deactivates the reduction computation.
  140963. */
  140964. deactivate(): void;
  140965. /**
  140966. * Disposes the depth reducer
  140967. * @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.
  140968. */
  140969. dispose(disposeAll?: boolean): void;
  140970. }
  140971. }
  140972. declare module BABYLON {
  140973. /**
  140974. * A CSM implementation allowing casting shadows on large scenes.
  140975. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140976. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  140977. */
  140978. export class CascadedShadowGenerator extends ShadowGenerator {
  140979. private static readonly frustumCornersNDCSpace;
  140980. /**
  140981. * Name of the CSM class
  140982. */
  140983. static CLASSNAME: string;
  140984. /**
  140985. * Defines the default number of cascades used by the CSM.
  140986. */
  140987. static readonly DEFAULT_CASCADES_COUNT: number;
  140988. /**
  140989. * Defines the minimum number of cascades used by the CSM.
  140990. */
  140991. static readonly MIN_CASCADES_COUNT: number;
  140992. /**
  140993. * Defines the maximum number of cascades used by the CSM.
  140994. */
  140995. static readonly MAX_CASCADES_COUNT: number;
  140996. protected _validateFilter(filter: number): number;
  140997. /**
  140998. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  140999. */
  141000. penumbraDarkness: number;
  141001. private _numCascades;
  141002. /**
  141003. * Gets or set the number of cascades used by the CSM.
  141004. */
  141005. get numCascades(): number;
  141006. set numCascades(value: number);
  141007. /**
  141008. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  141009. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  141010. */
  141011. stabilizeCascades: boolean;
  141012. private _freezeShadowCastersBoundingInfo;
  141013. private _freezeShadowCastersBoundingInfoObservable;
  141014. /**
  141015. * Enables or disables the shadow casters bounding info computation.
  141016. * If your shadow casters don't move, you can disable this feature.
  141017. * If it is enabled, the bounding box computation is done every frame.
  141018. */
  141019. get freezeShadowCastersBoundingInfo(): boolean;
  141020. set freezeShadowCastersBoundingInfo(freeze: boolean);
  141021. private _scbiMin;
  141022. private _scbiMax;
  141023. protected _computeShadowCastersBoundingInfo(): void;
  141024. protected _shadowCastersBoundingInfo: BoundingInfo;
  141025. /**
  141026. * Gets or sets the shadow casters bounding info.
  141027. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  141028. * so that the system won't overwrite the bounds you provide
  141029. */
  141030. get shadowCastersBoundingInfo(): BoundingInfo;
  141031. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  141032. protected _breaksAreDirty: boolean;
  141033. protected _minDistance: number;
  141034. protected _maxDistance: number;
  141035. /**
  141036. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  141037. *
  141038. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  141039. * If you don't know these values, simply leave them to their defaults and don't call this function.
  141040. * @param min minimal distance for the breaks (default to 0.)
  141041. * @param max maximal distance for the breaks (default to 1.)
  141042. */
  141043. setMinMaxDistance(min: number, max: number): void;
  141044. /** Gets the minimal distance used in the cascade break computation */
  141045. get minDistance(): number;
  141046. /** Gets the maximal distance used in the cascade break computation */
  141047. get maxDistance(): number;
  141048. /**
  141049. * Gets the class name of that object
  141050. * @returns "CascadedShadowGenerator"
  141051. */
  141052. getClassName(): string;
  141053. private _cascadeMinExtents;
  141054. private _cascadeMaxExtents;
  141055. /**
  141056. * Gets a cascade minimum extents
  141057. * @param cascadeIndex index of the cascade
  141058. * @returns the minimum cascade extents
  141059. */
  141060. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  141061. /**
  141062. * Gets a cascade maximum extents
  141063. * @param cascadeIndex index of the cascade
  141064. * @returns the maximum cascade extents
  141065. */
  141066. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  141067. private _cascades;
  141068. private _currentLayer;
  141069. private _viewSpaceFrustumsZ;
  141070. private _viewMatrices;
  141071. private _projectionMatrices;
  141072. private _transformMatrices;
  141073. private _transformMatricesAsArray;
  141074. private _frustumLengths;
  141075. private _lightSizeUVCorrection;
  141076. private _depthCorrection;
  141077. private _frustumCornersWorldSpace;
  141078. private _frustumCenter;
  141079. private _shadowCameraPos;
  141080. private _shadowMaxZ;
  141081. /**
  141082. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  141083. * It defaults to camera.maxZ
  141084. */
  141085. get shadowMaxZ(): number;
  141086. /**
  141087. * Sets the shadow max z distance.
  141088. */
  141089. set shadowMaxZ(value: number);
  141090. protected _debug: boolean;
  141091. /**
  141092. * Gets or sets the debug flag.
  141093. * When enabled, the cascades are materialized by different colors on the screen.
  141094. */
  141095. get debug(): boolean;
  141096. set debug(dbg: boolean);
  141097. private _depthClamp;
  141098. /**
  141099. * Gets or sets the depth clamping value.
  141100. *
  141101. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  141102. * to account for the shadow casters far away.
  141103. *
  141104. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  141105. */
  141106. get depthClamp(): boolean;
  141107. set depthClamp(value: boolean);
  141108. private _cascadeBlendPercentage;
  141109. /**
  141110. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  141111. * It defaults to 0.1 (10% blending).
  141112. */
  141113. get cascadeBlendPercentage(): number;
  141114. set cascadeBlendPercentage(value: number);
  141115. private _lambda;
  141116. /**
  141117. * Gets or set the lambda parameter.
  141118. * This parameter is used to split the camera frustum and create the cascades.
  141119. * 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.
  141120. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  141121. */
  141122. get lambda(): number;
  141123. set lambda(value: number);
  141124. /**
  141125. * Gets the view matrix corresponding to a given cascade
  141126. * @param cascadeNum cascade to retrieve the view matrix from
  141127. * @returns the cascade view matrix
  141128. */
  141129. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  141130. /**
  141131. * Gets the projection matrix corresponding to a given cascade
  141132. * @param cascadeNum cascade to retrieve the projection matrix from
  141133. * @returns the cascade projection matrix
  141134. */
  141135. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  141136. /**
  141137. * Gets the transformation matrix corresponding to a given cascade
  141138. * @param cascadeNum cascade to retrieve the transformation matrix from
  141139. * @returns the cascade transformation matrix
  141140. */
  141141. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  141142. private _depthRenderer;
  141143. /**
  141144. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  141145. *
  141146. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  141147. *
  141148. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  141149. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  141150. * @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
  141151. */
  141152. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  141153. private _depthReducer;
  141154. private _autoCalcDepthBounds;
  141155. /**
  141156. * Gets or sets the autoCalcDepthBounds property.
  141157. *
  141158. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  141159. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  141160. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  141161. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  141162. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  141163. */
  141164. get autoCalcDepthBounds(): boolean;
  141165. set autoCalcDepthBounds(value: boolean);
  141166. /**
  141167. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  141168. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141169. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  141170. * for setting the refresh rate on the renderer yourself!
  141171. */
  141172. get autoCalcDepthBoundsRefreshRate(): number;
  141173. set autoCalcDepthBoundsRefreshRate(value: number);
  141174. /**
  141175. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  141176. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  141177. * you change the camera near/far planes!
  141178. */
  141179. splitFrustum(): void;
  141180. private _splitFrustum;
  141181. private _computeMatrices;
  141182. private _computeFrustumInWorldSpace;
  141183. private _computeCascadeFrustum;
  141184. /**
  141185. * Support test.
  141186. */
  141187. static get IsSupported(): boolean;
  141188. /** @hidden */
  141189. static _SceneComponentInitialization: (scene: Scene) => void;
  141190. /**
  141191. * Creates a Cascaded Shadow Generator object.
  141192. * A ShadowGenerator is the required tool to use the shadows.
  141193. * Each directional light casting shadows needs to use its own ShadowGenerator.
  141194. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141195. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  141196. * @param light The directional light object generating the shadows.
  141197. * @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.
  141198. */
  141199. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  141200. protected _initializeGenerator(): void;
  141201. protected _createTargetRenderTexture(): void;
  141202. protected _initializeShadowMap(): void;
  141203. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  141204. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  141205. /**
  141206. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  141207. * @param defines Defines of the material we want to update
  141208. * @param lightIndex Index of the light in the enabled light list of the material
  141209. */
  141210. prepareDefines(defines: any, lightIndex: number): void;
  141211. /**
  141212. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  141213. * defined in the generator but impacting the effect).
  141214. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  141215. * @param effect The effect we are binfing the information for
  141216. */
  141217. bindShadowLight(lightIndex: string, effect: Effect): void;
  141218. /**
  141219. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  141220. * (eq to view projection * shadow projection matrices)
  141221. * @returns The transform matrix used to create the shadow map
  141222. */
  141223. getTransformMatrix(): Matrix;
  141224. /**
  141225. * Disposes the ShadowGenerator.
  141226. * Returns nothing.
  141227. */
  141228. dispose(): void;
  141229. /**
  141230. * Serializes the shadow generator setup to a json object.
  141231. * @returns The serialized JSON object
  141232. */
  141233. serialize(): any;
  141234. /**
  141235. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  141236. * @param parsedShadowGenerator The JSON object to parse
  141237. * @param scene The scene to create the shadow map for
  141238. * @returns The parsed shadow generator
  141239. */
  141240. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  141241. }
  141242. }
  141243. declare module BABYLON {
  141244. /**
  141245. * Defines the shadow generator component responsible to manage any shadow generators
  141246. * in a given scene.
  141247. */
  141248. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  141249. /**
  141250. * The component name helpfull to identify the component in the list of scene components.
  141251. */
  141252. readonly name: string;
  141253. /**
  141254. * The scene the component belongs to.
  141255. */
  141256. scene: Scene;
  141257. /**
  141258. * Creates a new instance of the component for the given scene
  141259. * @param scene Defines the scene to register the component in
  141260. */
  141261. constructor(scene: Scene);
  141262. /**
  141263. * Registers the component in a given scene
  141264. */
  141265. register(): void;
  141266. /**
  141267. * Rebuilds the elements related to this component in case of
  141268. * context lost for instance.
  141269. */
  141270. rebuild(): void;
  141271. /**
  141272. * Serializes the component data to the specified json object
  141273. * @param serializationObject The object to serialize to
  141274. */
  141275. serialize(serializationObject: any): void;
  141276. /**
  141277. * Adds all the elements from the container to the scene
  141278. * @param container the container holding the elements
  141279. */
  141280. addFromContainer(container: AbstractScene): void;
  141281. /**
  141282. * Removes all the elements in the container from the scene
  141283. * @param container contains the elements to remove
  141284. * @param dispose if the removed element should be disposed (default: false)
  141285. */
  141286. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141287. /**
  141288. * Rebuilds the elements related to this component in case of
  141289. * context lost for instance.
  141290. */
  141291. dispose(): void;
  141292. private _gatherRenderTargets;
  141293. }
  141294. }
  141295. declare module BABYLON {
  141296. /**
  141297. * A point light is a light defined by an unique point in world space.
  141298. * The light is emitted in every direction from this point.
  141299. * A good example of a point light is a standard light bulb.
  141300. * Documentation: https://doc.babylonjs.com/babylon101/lights
  141301. */
  141302. export class PointLight extends ShadowLight {
  141303. private _shadowAngle;
  141304. /**
  141305. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141306. * This specifies what angle the shadow will use to be created.
  141307. *
  141308. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141309. */
  141310. get shadowAngle(): number;
  141311. /**
  141312. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141313. * This specifies what angle the shadow will use to be created.
  141314. *
  141315. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141316. */
  141317. set shadowAngle(value: number);
  141318. /**
  141319. * Gets the direction if it has been set.
  141320. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141321. */
  141322. get direction(): Vector3;
  141323. /**
  141324. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141325. */
  141326. set direction(value: Vector3);
  141327. /**
  141328. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  141329. * A PointLight emits the light in every direction.
  141330. * It can cast shadows.
  141331. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  141332. * ```javascript
  141333. * var pointLight = new PointLight("pl", camera.position, scene);
  141334. * ```
  141335. * Documentation : https://doc.babylonjs.com/babylon101/lights
  141336. * @param name The light friendly name
  141337. * @param position The position of the point light in the scene
  141338. * @param scene The scene the lights belongs to
  141339. */
  141340. constructor(name: string, position: Vector3, scene: Scene);
  141341. /**
  141342. * Returns the string "PointLight"
  141343. * @returns the class name
  141344. */
  141345. getClassName(): string;
  141346. /**
  141347. * Returns the integer 0.
  141348. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  141349. */
  141350. getTypeID(): number;
  141351. /**
  141352. * Specifies wether or not the shadowmap should be a cube texture.
  141353. * @returns true if the shadowmap needs to be a cube texture.
  141354. */
  141355. needCube(): boolean;
  141356. /**
  141357. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  141358. * @param faceIndex The index of the face we are computed the direction to generate shadow
  141359. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  141360. */
  141361. getShadowDirection(faceIndex?: number): Vector3;
  141362. /**
  141363. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  141364. * - fov = PI / 2
  141365. * - aspect ratio : 1.0
  141366. * - z-near and far equal to the active camera minZ and maxZ.
  141367. * Returns the PointLight.
  141368. */
  141369. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  141370. protected _buildUniformLayout(): void;
  141371. /**
  141372. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  141373. * @param effect The effect to update
  141374. * @param lightIndex The index of the light in the effect to update
  141375. * @returns The point light
  141376. */
  141377. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  141378. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  141379. /**
  141380. * Prepares the list of defines specific to the light type.
  141381. * @param defines the list of defines
  141382. * @param lightIndex defines the index of the light for the effect
  141383. */
  141384. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  141385. }
  141386. }
  141387. declare module BABYLON {
  141388. /**
  141389. * Header information of HDR texture files.
  141390. */
  141391. export interface HDRInfo {
  141392. /**
  141393. * The height of the texture in pixels.
  141394. */
  141395. height: number;
  141396. /**
  141397. * The width of the texture in pixels.
  141398. */
  141399. width: number;
  141400. /**
  141401. * The index of the beginning of the data in the binary file.
  141402. */
  141403. dataPosition: number;
  141404. }
  141405. /**
  141406. * This groups tools to convert HDR texture to native colors array.
  141407. */
  141408. export class HDRTools {
  141409. private static Ldexp;
  141410. private static Rgbe2float;
  141411. private static readStringLine;
  141412. /**
  141413. * Reads header information from an RGBE texture stored in a native array.
  141414. * More information on this format are available here:
  141415. * https://en.wikipedia.org/wiki/RGBE_image_format
  141416. *
  141417. * @param uint8array The binary file stored in native array.
  141418. * @return The header information.
  141419. */
  141420. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  141421. /**
  141422. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  141423. * This RGBE texture needs to store the information as a panorama.
  141424. *
  141425. * More information on this format are available here:
  141426. * https://en.wikipedia.org/wiki/RGBE_image_format
  141427. *
  141428. * @param buffer The binary file stored in an array buffer.
  141429. * @param size The expected size of the extracted cubemap.
  141430. * @return The Cube Map information.
  141431. */
  141432. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  141433. /**
  141434. * Returns the pixels data extracted from an RGBE texture.
  141435. * This pixels will be stored left to right up to down in the R G B order in one array.
  141436. *
  141437. * More information on this format are available here:
  141438. * https://en.wikipedia.org/wiki/RGBE_image_format
  141439. *
  141440. * @param uint8array The binary file stored in an array buffer.
  141441. * @param hdrInfo The header information of the file.
  141442. * @return The pixels data in RGB right to left up to down order.
  141443. */
  141444. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  141445. private static RGBE_ReadPixels_RLE;
  141446. private static RGBE_ReadPixels_NOT_RLE;
  141447. }
  141448. }
  141449. declare module BABYLON {
  141450. /**
  141451. * Effect Render Options
  141452. */
  141453. export interface IEffectRendererOptions {
  141454. /**
  141455. * Defines the vertices positions.
  141456. */
  141457. positions?: number[];
  141458. /**
  141459. * Defines the indices.
  141460. */
  141461. indices?: number[];
  141462. }
  141463. /**
  141464. * Helper class to render one or more effects.
  141465. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  141466. */
  141467. export class EffectRenderer {
  141468. private engine;
  141469. private static _DefaultOptions;
  141470. private _vertexBuffers;
  141471. private _indexBuffer;
  141472. private _fullscreenViewport;
  141473. /**
  141474. * Creates an effect renderer
  141475. * @param engine the engine to use for rendering
  141476. * @param options defines the options of the effect renderer
  141477. */
  141478. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  141479. /**
  141480. * Sets the current viewport in normalized coordinates 0-1
  141481. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  141482. */
  141483. setViewport(viewport?: Viewport): void;
  141484. /**
  141485. * Binds the embedded attributes buffer to the effect.
  141486. * @param effect Defines the effect to bind the attributes for
  141487. */
  141488. bindBuffers(effect: Effect): void;
  141489. /**
  141490. * Sets the current effect wrapper to use during draw.
  141491. * The effect needs to be ready before calling this api.
  141492. * This also sets the default full screen position attribute.
  141493. * @param effectWrapper Defines the effect to draw with
  141494. */
  141495. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  141496. /**
  141497. * Restores engine states
  141498. */
  141499. restoreStates(): void;
  141500. /**
  141501. * Draws a full screen quad.
  141502. */
  141503. draw(): void;
  141504. private isRenderTargetTexture;
  141505. /**
  141506. * renders one or more effects to a specified texture
  141507. * @param effectWrapper the effect to renderer
  141508. * @param outputTexture texture to draw to, if null it will render to the screen.
  141509. */
  141510. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  141511. /**
  141512. * Disposes of the effect renderer
  141513. */
  141514. dispose(): void;
  141515. }
  141516. /**
  141517. * Options to create an EffectWrapper
  141518. */
  141519. interface EffectWrapperCreationOptions {
  141520. /**
  141521. * Engine to use to create the effect
  141522. */
  141523. engine: ThinEngine;
  141524. /**
  141525. * Fragment shader for the effect
  141526. */
  141527. fragmentShader: string;
  141528. /**
  141529. * Use the shader store instead of direct source code
  141530. */
  141531. useShaderStore?: boolean;
  141532. /**
  141533. * Vertex shader for the effect
  141534. */
  141535. vertexShader?: string;
  141536. /**
  141537. * Attributes to use in the shader
  141538. */
  141539. attributeNames?: Array<string>;
  141540. /**
  141541. * Uniforms to use in the shader
  141542. */
  141543. uniformNames?: Array<string>;
  141544. /**
  141545. * Texture sampler names to use in the shader
  141546. */
  141547. samplerNames?: Array<string>;
  141548. /**
  141549. * Defines to use in the shader
  141550. */
  141551. defines?: Array<string>;
  141552. /**
  141553. * Callback when effect is compiled
  141554. */
  141555. onCompiled?: Nullable<(effect: Effect) => void>;
  141556. /**
  141557. * The friendly name of the effect displayed in Spector.
  141558. */
  141559. name?: string;
  141560. }
  141561. /**
  141562. * Wraps an effect to be used for rendering
  141563. */
  141564. export class EffectWrapper {
  141565. /**
  141566. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  141567. */
  141568. onApplyObservable: Observable<{}>;
  141569. /**
  141570. * The underlying effect
  141571. */
  141572. effect: Effect;
  141573. /**
  141574. * Creates an effect to be renderer
  141575. * @param creationOptions options to create the effect
  141576. */
  141577. constructor(creationOptions: EffectWrapperCreationOptions);
  141578. /**
  141579. * Disposes of the effect wrapper
  141580. */
  141581. dispose(): void;
  141582. }
  141583. }
  141584. declare module BABYLON {
  141585. /** @hidden */
  141586. export var hdrFilteringVertexShader: {
  141587. name: string;
  141588. shader: string;
  141589. };
  141590. }
  141591. declare module BABYLON {
  141592. /** @hidden */
  141593. export var hdrFilteringPixelShader: {
  141594. name: string;
  141595. shader: string;
  141596. };
  141597. }
  141598. declare module BABYLON {
  141599. /**
  141600. * Options for texture filtering
  141601. */
  141602. interface IHDRFilteringOptions {
  141603. /**
  141604. * Scales pixel intensity for the input HDR map.
  141605. */
  141606. hdrScale?: number;
  141607. /**
  141608. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  141609. */
  141610. quality?: number;
  141611. }
  141612. /**
  141613. * Filters HDR maps to get correct renderings of PBR reflections
  141614. */
  141615. export class HDRFiltering {
  141616. private _engine;
  141617. private _effectRenderer;
  141618. private _effectWrapper;
  141619. private _lodGenerationOffset;
  141620. private _lodGenerationScale;
  141621. /**
  141622. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  141623. * you care about baking speed.
  141624. */
  141625. quality: number;
  141626. /**
  141627. * Scales pixel intensity for the input HDR map.
  141628. */
  141629. hdrScale: number;
  141630. /**
  141631. * Instantiates HDR filter for reflection maps
  141632. *
  141633. * @param engine Thin engine
  141634. * @param options Options
  141635. */
  141636. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  141637. private _createRenderTarget;
  141638. private _prefilterInternal;
  141639. private _createEffect;
  141640. /**
  141641. * Get a value indicating if the filter is ready to be used
  141642. * @param texture Texture to filter
  141643. * @returns true if the filter is ready
  141644. */
  141645. isReady(texture: BaseTexture): boolean;
  141646. /**
  141647. * Prefilters a cube texture to have mipmap levels representing roughness values.
  141648. * Prefiltering will be invoked at the end of next rendering pass.
  141649. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  141650. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  141651. * @param texture Texture to filter
  141652. * @param onFinished Callback when filtering is done
  141653. * @return Promise called when prefiltering is done
  141654. */
  141655. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  141656. }
  141657. }
  141658. declare module BABYLON {
  141659. /**
  141660. * This represents a texture coming from an HDR input.
  141661. *
  141662. * The only supported format is currently panorama picture stored in RGBE format.
  141663. * Example of such files can be found on HDRLib: http://hdrlib.com/
  141664. */
  141665. export class HDRCubeTexture extends BaseTexture {
  141666. private static _facesMapping;
  141667. private _generateHarmonics;
  141668. private _noMipmap;
  141669. private _prefilterOnLoad;
  141670. private _textureMatrix;
  141671. private _size;
  141672. private _onLoad;
  141673. private _onError;
  141674. /**
  141675. * The texture URL.
  141676. */
  141677. url: string;
  141678. protected _isBlocking: boolean;
  141679. /**
  141680. * Sets wether or not the texture is blocking during loading.
  141681. */
  141682. set isBlocking(value: boolean);
  141683. /**
  141684. * Gets wether or not the texture is blocking during loading.
  141685. */
  141686. get isBlocking(): boolean;
  141687. protected _rotationY: number;
  141688. /**
  141689. * Sets texture matrix rotation angle around Y axis in radians.
  141690. */
  141691. set rotationY(value: number);
  141692. /**
  141693. * Gets texture matrix rotation angle around Y axis radians.
  141694. */
  141695. get rotationY(): number;
  141696. /**
  141697. * Gets or sets the center of the bounding box associated with the cube texture
  141698. * It must define where the camera used to render the texture was set
  141699. */
  141700. boundingBoxPosition: Vector3;
  141701. private _boundingBoxSize;
  141702. /**
  141703. * Gets or sets the size of the bounding box associated with the cube texture
  141704. * When defined, the cubemap will switch to local mode
  141705. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  141706. * @example https://www.babylonjs-playground.com/#RNASML
  141707. */
  141708. set boundingBoxSize(value: Vector3);
  141709. get boundingBoxSize(): Vector3;
  141710. /**
  141711. * Instantiates an HDRTexture from the following parameters.
  141712. *
  141713. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  141714. * @param sceneOrEngine The scene or engine the texture will be used in
  141715. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141716. * @param noMipmap Forces to not generate the mipmap if true
  141717. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  141718. * @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)
  141719. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  141720. */
  141721. 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>);
  141722. /**
  141723. * Get the current class name of the texture useful for serialization or dynamic coding.
  141724. * @returns "HDRCubeTexture"
  141725. */
  141726. getClassName(): string;
  141727. /**
  141728. * Occurs when the file is raw .hdr file.
  141729. */
  141730. private loadTexture;
  141731. clone(): HDRCubeTexture;
  141732. delayLoad(): void;
  141733. /**
  141734. * Get the texture reflection matrix used to rotate/transform the reflection.
  141735. * @returns the reflection matrix
  141736. */
  141737. getReflectionTextureMatrix(): Matrix;
  141738. /**
  141739. * Set the texture reflection matrix used to rotate/transform the reflection.
  141740. * @param value Define the reflection matrix to set
  141741. */
  141742. setReflectionTextureMatrix(value: Matrix): void;
  141743. /**
  141744. * Parses a JSON representation of an HDR Texture in order to create the texture
  141745. * @param parsedTexture Define the JSON representation
  141746. * @param scene Define the scene the texture should be created in
  141747. * @param rootUrl Define the root url in case we need to load relative dependencies
  141748. * @returns the newly created texture after parsing
  141749. */
  141750. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  141751. serialize(): any;
  141752. }
  141753. }
  141754. declare module BABYLON {
  141755. /**
  141756. * Class used to control physics engine
  141757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141758. */
  141759. export class PhysicsEngine implements IPhysicsEngine {
  141760. private _physicsPlugin;
  141761. /**
  141762. * Global value used to control the smallest number supported by the simulation
  141763. */
  141764. static Epsilon: number;
  141765. private _impostors;
  141766. private _joints;
  141767. private _subTimeStep;
  141768. /**
  141769. * Gets the gravity vector used by the simulation
  141770. */
  141771. gravity: Vector3;
  141772. /**
  141773. * Factory used to create the default physics plugin.
  141774. * @returns The default physics plugin
  141775. */
  141776. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  141777. /**
  141778. * Creates a new Physics Engine
  141779. * @param gravity defines the gravity vector used by the simulation
  141780. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  141781. */
  141782. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  141783. /**
  141784. * Sets the gravity vector used by the simulation
  141785. * @param gravity defines the gravity vector to use
  141786. */
  141787. setGravity(gravity: Vector3): void;
  141788. /**
  141789. * Set the time step of the physics engine.
  141790. * Default is 1/60.
  141791. * To slow it down, enter 1/600 for example.
  141792. * To speed it up, 1/30
  141793. * @param newTimeStep defines the new timestep to apply to this world.
  141794. */
  141795. setTimeStep(newTimeStep?: number): void;
  141796. /**
  141797. * Get the time step of the physics engine.
  141798. * @returns the current time step
  141799. */
  141800. getTimeStep(): number;
  141801. /**
  141802. * Set the sub time step of the physics engine.
  141803. * Default is 0 meaning there is no sub steps
  141804. * To increase physics resolution precision, set a small value (like 1 ms)
  141805. * @param subTimeStep defines the new sub timestep used for physics resolution.
  141806. */
  141807. setSubTimeStep(subTimeStep?: number): void;
  141808. /**
  141809. * Get the sub time step of the physics engine.
  141810. * @returns the current sub time step
  141811. */
  141812. getSubTimeStep(): number;
  141813. /**
  141814. * Release all resources
  141815. */
  141816. dispose(): void;
  141817. /**
  141818. * Gets the name of the current physics plugin
  141819. * @returns the name of the plugin
  141820. */
  141821. getPhysicsPluginName(): string;
  141822. /**
  141823. * Adding a new impostor for the impostor tracking.
  141824. * This will be done by the impostor itself.
  141825. * @param impostor the impostor to add
  141826. */
  141827. addImpostor(impostor: PhysicsImpostor): void;
  141828. /**
  141829. * Remove an impostor from the engine.
  141830. * This impostor and its mesh will not longer be updated by the physics engine.
  141831. * @param impostor the impostor to remove
  141832. */
  141833. removeImpostor(impostor: PhysicsImpostor): void;
  141834. /**
  141835. * Add a joint to the physics engine
  141836. * @param mainImpostor defines the main impostor to which the joint is added.
  141837. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  141838. * @param joint defines the joint that will connect both impostors.
  141839. */
  141840. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141841. /**
  141842. * Removes a joint from the simulation
  141843. * @param mainImpostor defines the impostor used with the joint
  141844. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  141845. * @param joint defines the joint to remove
  141846. */
  141847. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141848. /**
  141849. * Called by the scene. No need to call it.
  141850. * @param delta defines the timespam between frames
  141851. */
  141852. _step(delta: number): void;
  141853. /**
  141854. * Gets the current plugin used to run the simulation
  141855. * @returns current plugin
  141856. */
  141857. getPhysicsPlugin(): IPhysicsEnginePlugin;
  141858. /**
  141859. * Gets the list of physic impostors
  141860. * @returns an array of PhysicsImpostor
  141861. */
  141862. getImpostors(): Array<PhysicsImpostor>;
  141863. /**
  141864. * Gets the impostor for a physics enabled object
  141865. * @param object defines the object impersonated by the impostor
  141866. * @returns the PhysicsImpostor or null if not found
  141867. */
  141868. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  141869. /**
  141870. * Gets the impostor for a physics body object
  141871. * @param body defines physics body used by the impostor
  141872. * @returns the PhysicsImpostor or null if not found
  141873. */
  141874. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  141875. /**
  141876. * Does a raycast in the physics world
  141877. * @param from when should the ray start?
  141878. * @param to when should the ray end?
  141879. * @returns PhysicsRaycastResult
  141880. */
  141881. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141882. }
  141883. }
  141884. declare module BABYLON {
  141885. /** @hidden */
  141886. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  141887. private _useDeltaForWorldStep;
  141888. world: any;
  141889. name: string;
  141890. private _physicsMaterials;
  141891. private _fixedTimeStep;
  141892. private _cannonRaycastResult;
  141893. private _raycastResult;
  141894. private _physicsBodysToRemoveAfterStep;
  141895. private _firstFrame;
  141896. BJSCANNON: any;
  141897. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  141898. setGravity(gravity: Vector3): void;
  141899. setTimeStep(timeStep: number): void;
  141900. getTimeStep(): number;
  141901. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141902. private _removeMarkedPhysicsBodiesFromWorld;
  141903. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141904. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141905. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141906. private _processChildMeshes;
  141907. removePhysicsBody(impostor: PhysicsImpostor): void;
  141908. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141909. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141910. private _addMaterial;
  141911. private _checkWithEpsilon;
  141912. private _createShape;
  141913. private _createHeightmap;
  141914. private _minus90X;
  141915. private _plus90X;
  141916. private _tmpPosition;
  141917. private _tmpDeltaPosition;
  141918. private _tmpUnityRotation;
  141919. private _updatePhysicsBodyTransformation;
  141920. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141921. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141922. isSupported(): boolean;
  141923. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141924. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141925. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141926. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141927. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141928. getBodyMass(impostor: PhysicsImpostor): number;
  141929. getBodyFriction(impostor: PhysicsImpostor): number;
  141930. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141931. getBodyRestitution(impostor: PhysicsImpostor): number;
  141932. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141933. sleepBody(impostor: PhysicsImpostor): void;
  141934. wakeUpBody(impostor: PhysicsImpostor): void;
  141935. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  141936. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141937. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141938. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141939. getRadius(impostor: PhysicsImpostor): number;
  141940. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141941. dispose(): void;
  141942. private _extendNamespace;
  141943. /**
  141944. * Does a raycast in the physics world
  141945. * @param from when should the ray start?
  141946. * @param to when should the ray end?
  141947. * @returns PhysicsRaycastResult
  141948. */
  141949. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141950. }
  141951. }
  141952. declare module BABYLON {
  141953. /** @hidden */
  141954. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  141955. private _useDeltaForWorldStep;
  141956. world: any;
  141957. name: string;
  141958. BJSOIMO: any;
  141959. private _raycastResult;
  141960. private _fixedTimeStep;
  141961. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  141962. setGravity(gravity: Vector3): void;
  141963. setTimeStep(timeStep: number): void;
  141964. getTimeStep(): number;
  141965. private _tmpImpostorsArray;
  141966. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141967. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141968. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141969. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141970. private _tmpPositionVector;
  141971. removePhysicsBody(impostor: PhysicsImpostor): void;
  141972. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141973. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141974. isSupported(): boolean;
  141975. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141976. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141977. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141978. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141979. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141980. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141981. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141982. getBodyMass(impostor: PhysicsImpostor): number;
  141983. getBodyFriction(impostor: PhysicsImpostor): number;
  141984. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141985. getBodyRestitution(impostor: PhysicsImpostor): number;
  141986. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141987. sleepBody(impostor: PhysicsImpostor): void;
  141988. wakeUpBody(impostor: PhysicsImpostor): void;
  141989. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141990. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  141991. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  141992. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141993. getRadius(impostor: PhysicsImpostor): number;
  141994. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141995. dispose(): void;
  141996. /**
  141997. * Does a raycast in the physics world
  141998. * @param from when should the ray start?
  141999. * @param to when should the ray end?
  142000. * @returns PhysicsRaycastResult
  142001. */
  142002. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142003. }
  142004. }
  142005. declare module BABYLON {
  142006. /**
  142007. * AmmoJS Physics plugin
  142008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142009. * @see https://github.com/kripken/ammo.js/
  142010. */
  142011. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  142012. private _useDeltaForWorldStep;
  142013. /**
  142014. * Reference to the Ammo library
  142015. */
  142016. bjsAMMO: any;
  142017. /**
  142018. * Created ammoJS world which physics bodies are added to
  142019. */
  142020. world: any;
  142021. /**
  142022. * Name of the plugin
  142023. */
  142024. name: string;
  142025. private _timeStep;
  142026. private _fixedTimeStep;
  142027. private _maxSteps;
  142028. private _tmpQuaternion;
  142029. private _tmpAmmoTransform;
  142030. private _tmpAmmoQuaternion;
  142031. private _tmpAmmoConcreteContactResultCallback;
  142032. private _collisionConfiguration;
  142033. private _dispatcher;
  142034. private _overlappingPairCache;
  142035. private _solver;
  142036. private _softBodySolver;
  142037. private _tmpAmmoVectorA;
  142038. private _tmpAmmoVectorB;
  142039. private _tmpAmmoVectorC;
  142040. private _tmpAmmoVectorD;
  142041. private _tmpContactCallbackResult;
  142042. private _tmpAmmoVectorRCA;
  142043. private _tmpAmmoVectorRCB;
  142044. private _raycastResult;
  142045. private static readonly DISABLE_COLLISION_FLAG;
  142046. private static readonly KINEMATIC_FLAG;
  142047. private static readonly DISABLE_DEACTIVATION_FLAG;
  142048. /**
  142049. * Initializes the ammoJS plugin
  142050. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  142051. * @param ammoInjection can be used to inject your own ammo reference
  142052. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  142053. */
  142054. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  142055. /**
  142056. * Sets the gravity of the physics world (m/(s^2))
  142057. * @param gravity Gravity to set
  142058. */
  142059. setGravity(gravity: Vector3): void;
  142060. /**
  142061. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  142062. * @param timeStep timestep to use in seconds
  142063. */
  142064. setTimeStep(timeStep: number): void;
  142065. /**
  142066. * 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)
  142067. * @param fixedTimeStep fixedTimeStep to use in seconds
  142068. */
  142069. setFixedTimeStep(fixedTimeStep: number): void;
  142070. /**
  142071. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  142072. * @param maxSteps the maximum number of steps by the physics engine per frame
  142073. */
  142074. setMaxSteps(maxSteps: number): void;
  142075. /**
  142076. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  142077. * @returns the current timestep in seconds
  142078. */
  142079. getTimeStep(): number;
  142080. /**
  142081. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  142082. */
  142083. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  142084. private _isImpostorInContact;
  142085. private _isImpostorPairInContact;
  142086. private _stepSimulation;
  142087. /**
  142088. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  142089. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  142090. * After the step the babylon meshes are set to the position of the physics imposters
  142091. * @param delta amount of time to step forward
  142092. * @param impostors array of imposters to update before/after the step
  142093. */
  142094. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142095. /**
  142096. * Update babylon mesh to match physics world object
  142097. * @param impostor imposter to match
  142098. */
  142099. private _afterSoftStep;
  142100. /**
  142101. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142102. * @param impostor imposter to match
  142103. */
  142104. private _ropeStep;
  142105. /**
  142106. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142107. * @param impostor imposter to match
  142108. */
  142109. private _softbodyOrClothStep;
  142110. private _tmpMatrix;
  142111. /**
  142112. * Applies an impulse on the imposter
  142113. * @param impostor imposter to apply impulse to
  142114. * @param force amount of force to be applied to the imposter
  142115. * @param contactPoint the location to apply the impulse on the imposter
  142116. */
  142117. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142118. /**
  142119. * Applies a force on the imposter
  142120. * @param impostor imposter to apply force
  142121. * @param force amount of force to be applied to the imposter
  142122. * @param contactPoint the location to apply the force on the imposter
  142123. */
  142124. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142125. /**
  142126. * Creates a physics body using the plugin
  142127. * @param impostor the imposter to create the physics body on
  142128. */
  142129. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142130. /**
  142131. * Removes the physics body from the imposter and disposes of the body's memory
  142132. * @param impostor imposter to remove the physics body from
  142133. */
  142134. removePhysicsBody(impostor: PhysicsImpostor): void;
  142135. /**
  142136. * Generates a joint
  142137. * @param impostorJoint the imposter joint to create the joint with
  142138. */
  142139. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142140. /**
  142141. * Removes a joint
  142142. * @param impostorJoint the imposter joint to remove the joint from
  142143. */
  142144. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142145. private _addMeshVerts;
  142146. /**
  142147. * Initialise the soft body vertices to match its object's (mesh) vertices
  142148. * Softbody vertices (nodes) are in world space and to match this
  142149. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  142150. * @param impostor to create the softbody for
  142151. */
  142152. private _softVertexData;
  142153. /**
  142154. * Create an impostor's soft body
  142155. * @param impostor to create the softbody for
  142156. */
  142157. private _createSoftbody;
  142158. /**
  142159. * Create cloth for an impostor
  142160. * @param impostor to create the softbody for
  142161. */
  142162. private _createCloth;
  142163. /**
  142164. * Create rope for an impostor
  142165. * @param impostor to create the softbody for
  142166. */
  142167. private _createRope;
  142168. /**
  142169. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  142170. * @param impostor to create the custom physics shape for
  142171. */
  142172. private _createCustom;
  142173. private _addHullVerts;
  142174. private _createShape;
  142175. /**
  142176. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  142177. * @param impostor imposter containing the physics body and babylon object
  142178. */
  142179. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142180. /**
  142181. * Sets the babylon object's position/rotation from the physics body's position/rotation
  142182. * @param impostor imposter containing the physics body and babylon object
  142183. * @param newPosition new position
  142184. * @param newRotation new rotation
  142185. */
  142186. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142187. /**
  142188. * If this plugin is supported
  142189. * @returns true if its supported
  142190. */
  142191. isSupported(): boolean;
  142192. /**
  142193. * Sets the linear velocity of the physics body
  142194. * @param impostor imposter to set the velocity on
  142195. * @param velocity velocity to set
  142196. */
  142197. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142198. /**
  142199. * Sets the angular velocity of the physics body
  142200. * @param impostor imposter to set the velocity on
  142201. * @param velocity velocity to set
  142202. */
  142203. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142204. /**
  142205. * gets the linear velocity
  142206. * @param impostor imposter to get linear velocity from
  142207. * @returns linear velocity
  142208. */
  142209. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142210. /**
  142211. * gets the angular velocity
  142212. * @param impostor imposter to get angular velocity from
  142213. * @returns angular velocity
  142214. */
  142215. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142216. /**
  142217. * Sets the mass of physics body
  142218. * @param impostor imposter to set the mass on
  142219. * @param mass mass to set
  142220. */
  142221. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142222. /**
  142223. * Gets the mass of the physics body
  142224. * @param impostor imposter to get the mass from
  142225. * @returns mass
  142226. */
  142227. getBodyMass(impostor: PhysicsImpostor): number;
  142228. /**
  142229. * Gets friction of the impostor
  142230. * @param impostor impostor to get friction from
  142231. * @returns friction value
  142232. */
  142233. getBodyFriction(impostor: PhysicsImpostor): number;
  142234. /**
  142235. * Sets friction of the impostor
  142236. * @param impostor impostor to set friction on
  142237. * @param friction friction value
  142238. */
  142239. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142240. /**
  142241. * Gets restitution of the impostor
  142242. * @param impostor impostor to get restitution from
  142243. * @returns restitution value
  142244. */
  142245. getBodyRestitution(impostor: PhysicsImpostor): number;
  142246. /**
  142247. * Sets resitution of the impostor
  142248. * @param impostor impostor to set resitution on
  142249. * @param restitution resitution value
  142250. */
  142251. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142252. /**
  142253. * Gets pressure inside the impostor
  142254. * @param impostor impostor to get pressure from
  142255. * @returns pressure value
  142256. */
  142257. getBodyPressure(impostor: PhysicsImpostor): number;
  142258. /**
  142259. * Sets pressure inside a soft body impostor
  142260. * Cloth and rope must remain 0 pressure
  142261. * @param impostor impostor to set pressure on
  142262. * @param pressure pressure value
  142263. */
  142264. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  142265. /**
  142266. * Gets stiffness of the impostor
  142267. * @param impostor impostor to get stiffness from
  142268. * @returns pressure value
  142269. */
  142270. getBodyStiffness(impostor: PhysicsImpostor): number;
  142271. /**
  142272. * Sets stiffness of the impostor
  142273. * @param impostor impostor to set stiffness on
  142274. * @param stiffness stiffness value from 0 to 1
  142275. */
  142276. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  142277. /**
  142278. * Gets velocityIterations of the impostor
  142279. * @param impostor impostor to get velocity iterations from
  142280. * @returns velocityIterations value
  142281. */
  142282. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  142283. /**
  142284. * Sets velocityIterations of the impostor
  142285. * @param impostor impostor to set velocity iterations on
  142286. * @param velocityIterations velocityIterations value
  142287. */
  142288. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  142289. /**
  142290. * Gets positionIterations of the impostor
  142291. * @param impostor impostor to get position iterations from
  142292. * @returns positionIterations value
  142293. */
  142294. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  142295. /**
  142296. * Sets positionIterations of the impostor
  142297. * @param impostor impostor to set position on
  142298. * @param positionIterations positionIterations value
  142299. */
  142300. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  142301. /**
  142302. * Append an anchor to a cloth object
  142303. * @param impostor is the cloth impostor to add anchor to
  142304. * @param otherImpostor is the rigid impostor to anchor to
  142305. * @param width ratio across width from 0 to 1
  142306. * @param height ratio up height from 0 to 1
  142307. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  142308. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142309. */
  142310. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142311. /**
  142312. * Append an hook to a rope object
  142313. * @param impostor is the rope impostor to add hook to
  142314. * @param otherImpostor is the rigid impostor to hook to
  142315. * @param length ratio along the rope from 0 to 1
  142316. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  142317. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142318. */
  142319. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142320. /**
  142321. * Sleeps the physics body and stops it from being active
  142322. * @param impostor impostor to sleep
  142323. */
  142324. sleepBody(impostor: PhysicsImpostor): void;
  142325. /**
  142326. * Activates the physics body
  142327. * @param impostor impostor to activate
  142328. */
  142329. wakeUpBody(impostor: PhysicsImpostor): void;
  142330. /**
  142331. * Updates the distance parameters of the joint
  142332. * @param joint joint to update
  142333. * @param maxDistance maximum distance of the joint
  142334. * @param minDistance minimum distance of the joint
  142335. */
  142336. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142337. /**
  142338. * Sets a motor on the joint
  142339. * @param joint joint to set motor on
  142340. * @param speed speed of the motor
  142341. * @param maxForce maximum force of the motor
  142342. * @param motorIndex index of the motor
  142343. */
  142344. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  142345. /**
  142346. * Sets the motors limit
  142347. * @param joint joint to set limit on
  142348. * @param upperLimit upper limit
  142349. * @param lowerLimit lower limit
  142350. */
  142351. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  142352. /**
  142353. * Syncs the position and rotation of a mesh with the impostor
  142354. * @param mesh mesh to sync
  142355. * @param impostor impostor to update the mesh with
  142356. */
  142357. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142358. /**
  142359. * Gets the radius of the impostor
  142360. * @param impostor impostor to get radius from
  142361. * @returns the radius
  142362. */
  142363. getRadius(impostor: PhysicsImpostor): number;
  142364. /**
  142365. * Gets the box size of the impostor
  142366. * @param impostor impostor to get box size from
  142367. * @param result the resulting box size
  142368. */
  142369. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142370. /**
  142371. * Disposes of the impostor
  142372. */
  142373. dispose(): void;
  142374. /**
  142375. * Does a raycast in the physics world
  142376. * @param from when should the ray start?
  142377. * @param to when should the ray end?
  142378. * @returns PhysicsRaycastResult
  142379. */
  142380. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142381. }
  142382. }
  142383. declare module BABYLON {
  142384. interface AbstractScene {
  142385. /**
  142386. * The list of reflection probes added to the scene
  142387. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142388. */
  142389. reflectionProbes: Array<ReflectionProbe>;
  142390. /**
  142391. * Removes the given reflection probe from this scene.
  142392. * @param toRemove The reflection probe to remove
  142393. * @returns The index of the removed reflection probe
  142394. */
  142395. removeReflectionProbe(toRemove: ReflectionProbe): number;
  142396. /**
  142397. * Adds the given reflection probe to this scene.
  142398. * @param newReflectionProbe The reflection probe to add
  142399. */
  142400. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  142401. }
  142402. /**
  142403. * Class used to generate realtime reflection / refraction cube textures
  142404. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142405. */
  142406. export class ReflectionProbe {
  142407. /** defines the name of the probe */
  142408. name: string;
  142409. private _scene;
  142410. private _renderTargetTexture;
  142411. private _projectionMatrix;
  142412. private _viewMatrix;
  142413. private _target;
  142414. private _add;
  142415. private _attachedMesh;
  142416. private _invertYAxis;
  142417. /** Gets or sets probe position (center of the cube map) */
  142418. position: Vector3;
  142419. /**
  142420. * Creates a new reflection probe
  142421. * @param name defines the name of the probe
  142422. * @param size defines the texture resolution (for each face)
  142423. * @param scene defines the hosting scene
  142424. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  142425. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  142426. */
  142427. constructor(
  142428. /** defines the name of the probe */
  142429. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  142430. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  142431. get samples(): number;
  142432. set samples(value: number);
  142433. /** Gets or sets the refresh rate to use (on every frame by default) */
  142434. get refreshRate(): number;
  142435. set refreshRate(value: number);
  142436. /**
  142437. * Gets the hosting scene
  142438. * @returns a Scene
  142439. */
  142440. getScene(): Scene;
  142441. /** Gets the internal CubeTexture used to render to */
  142442. get cubeTexture(): RenderTargetTexture;
  142443. /** Gets the list of meshes to render */
  142444. get renderList(): Nullable<AbstractMesh[]>;
  142445. /**
  142446. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  142447. * @param mesh defines the mesh to attach to
  142448. */
  142449. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  142450. /**
  142451. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  142452. * @param renderingGroupId The rendering group id corresponding to its index
  142453. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  142454. */
  142455. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  142456. /**
  142457. * Clean all associated resources
  142458. */
  142459. dispose(): void;
  142460. /**
  142461. * Converts the reflection probe information to a readable string for debug purpose.
  142462. * @param fullDetails Supports for multiple levels of logging within scene loading
  142463. * @returns the human readable reflection probe info
  142464. */
  142465. toString(fullDetails?: boolean): string;
  142466. /**
  142467. * Get the class name of the relfection probe.
  142468. * @returns "ReflectionProbe"
  142469. */
  142470. getClassName(): string;
  142471. /**
  142472. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  142473. * @returns The JSON representation of the texture
  142474. */
  142475. serialize(): any;
  142476. /**
  142477. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  142478. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  142479. * @param scene Define the scene the parsed reflection probe should be instantiated in
  142480. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  142481. * @returns The parsed reflection probe if successful
  142482. */
  142483. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  142484. }
  142485. }
  142486. declare module BABYLON {
  142487. /** @hidden */
  142488. export var _BabylonLoaderRegistered: boolean;
  142489. /**
  142490. * Helps setting up some configuration for the babylon file loader.
  142491. */
  142492. export class BabylonFileLoaderConfiguration {
  142493. /**
  142494. * The loader does not allow injecting custom physix engine into the plugins.
  142495. * Unfortunately in ES6, we need to manually inject them into the plugin.
  142496. * So you could set this variable to your engine import to make it work.
  142497. */
  142498. static LoaderInjectedPhysicsEngine: any;
  142499. }
  142500. }
  142501. declare module BABYLON {
  142502. /**
  142503. * The Physically based simple base material of BJS.
  142504. *
  142505. * This enables better naming and convention enforcements on top of the pbrMaterial.
  142506. * It is used as the base class for both the specGloss and metalRough conventions.
  142507. */
  142508. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  142509. /**
  142510. * Number of Simultaneous lights allowed on the material.
  142511. */
  142512. maxSimultaneousLights: number;
  142513. /**
  142514. * If sets to true, disables all the lights affecting the material.
  142515. */
  142516. disableLighting: boolean;
  142517. /**
  142518. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  142519. */
  142520. environmentTexture: BaseTexture;
  142521. /**
  142522. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  142523. */
  142524. invertNormalMapX: boolean;
  142525. /**
  142526. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  142527. */
  142528. invertNormalMapY: boolean;
  142529. /**
  142530. * Normal map used in the model.
  142531. */
  142532. normalTexture: BaseTexture;
  142533. /**
  142534. * Emissivie color used to self-illuminate the model.
  142535. */
  142536. emissiveColor: Color3;
  142537. /**
  142538. * Emissivie texture used to self-illuminate the model.
  142539. */
  142540. emissiveTexture: BaseTexture;
  142541. /**
  142542. * Occlusion Channel Strenght.
  142543. */
  142544. occlusionStrength: number;
  142545. /**
  142546. * Occlusion Texture of the material (adding extra occlusion effects).
  142547. */
  142548. occlusionTexture: BaseTexture;
  142549. /**
  142550. * Defines the alpha limits in alpha test mode.
  142551. */
  142552. alphaCutOff: number;
  142553. /**
  142554. * Gets the current double sided mode.
  142555. */
  142556. get doubleSided(): boolean;
  142557. /**
  142558. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  142559. */
  142560. set doubleSided(value: boolean);
  142561. /**
  142562. * Stores the pre-calculated light information of a mesh in a texture.
  142563. */
  142564. lightmapTexture: BaseTexture;
  142565. /**
  142566. * If true, the light map contains occlusion information instead of lighting info.
  142567. */
  142568. useLightmapAsShadowmap: boolean;
  142569. /**
  142570. * Instantiates a new PBRMaterial instance.
  142571. *
  142572. * @param name The material name
  142573. * @param scene The scene the material will be use in.
  142574. */
  142575. constructor(name: string, scene: Scene);
  142576. getClassName(): string;
  142577. }
  142578. }
  142579. declare module BABYLON {
  142580. /**
  142581. * The PBR material of BJS following the metal roughness convention.
  142582. *
  142583. * This fits to the PBR convention in the GLTF definition:
  142584. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  142585. */
  142586. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  142587. /**
  142588. * The base color has two different interpretations depending on the value of metalness.
  142589. * When the material is a metal, the base color is the specific measured reflectance value
  142590. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  142591. * of the material.
  142592. */
  142593. baseColor: Color3;
  142594. /**
  142595. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  142596. * well as opacity information in the alpha channel.
  142597. */
  142598. baseTexture: BaseTexture;
  142599. /**
  142600. * Specifies the metallic scalar value of the material.
  142601. * Can also be used to scale the metalness values of the metallic texture.
  142602. */
  142603. metallic: number;
  142604. /**
  142605. * Specifies the roughness scalar value of the material.
  142606. * Can also be used to scale the roughness values of the metallic texture.
  142607. */
  142608. roughness: number;
  142609. /**
  142610. * Texture containing both the metallic value in the B channel and the
  142611. * roughness value in the G channel to keep better precision.
  142612. */
  142613. metallicRoughnessTexture: BaseTexture;
  142614. /**
  142615. * Instantiates a new PBRMetalRoughnessMaterial instance.
  142616. *
  142617. * @param name The material name
  142618. * @param scene The scene the material will be use in.
  142619. */
  142620. constructor(name: string, scene: Scene);
  142621. /**
  142622. * Return the currrent class name of the material.
  142623. */
  142624. getClassName(): string;
  142625. /**
  142626. * Makes a duplicate of the current material.
  142627. * @param name - name to use for the new material.
  142628. */
  142629. clone(name: string): PBRMetallicRoughnessMaterial;
  142630. /**
  142631. * Serialize the material to a parsable JSON object.
  142632. */
  142633. serialize(): any;
  142634. /**
  142635. * Parses a JSON object correponding to the serialize function.
  142636. */
  142637. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  142638. }
  142639. }
  142640. declare module BABYLON {
  142641. /**
  142642. * The PBR material of BJS following the specular glossiness convention.
  142643. *
  142644. * This fits to the PBR convention in the GLTF definition:
  142645. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  142646. */
  142647. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  142648. /**
  142649. * Specifies the diffuse color of the material.
  142650. */
  142651. diffuseColor: Color3;
  142652. /**
  142653. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  142654. * channel.
  142655. */
  142656. diffuseTexture: BaseTexture;
  142657. /**
  142658. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  142659. */
  142660. specularColor: Color3;
  142661. /**
  142662. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  142663. */
  142664. glossiness: number;
  142665. /**
  142666. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  142667. */
  142668. specularGlossinessTexture: BaseTexture;
  142669. /**
  142670. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  142671. *
  142672. * @param name The material name
  142673. * @param scene The scene the material will be use in.
  142674. */
  142675. constructor(name: string, scene: Scene);
  142676. /**
  142677. * Return the currrent class name of the material.
  142678. */
  142679. getClassName(): string;
  142680. /**
  142681. * Makes a duplicate of the current material.
  142682. * @param name - name to use for the new material.
  142683. */
  142684. clone(name: string): PBRSpecularGlossinessMaterial;
  142685. /**
  142686. * Serialize the material to a parsable JSON object.
  142687. */
  142688. serialize(): any;
  142689. /**
  142690. * Parses a JSON object correponding to the serialize function.
  142691. */
  142692. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  142693. }
  142694. }
  142695. declare module BABYLON {
  142696. /**
  142697. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  142698. * It can help converting any input color in a desired output one. This can then be used to create effects
  142699. * from sepia, black and white to sixties or futuristic rendering...
  142700. *
  142701. * The only supported format is currently 3dl.
  142702. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  142703. */
  142704. export class ColorGradingTexture extends BaseTexture {
  142705. /**
  142706. * The texture URL.
  142707. */
  142708. url: string;
  142709. /**
  142710. * Empty line regex stored for GC.
  142711. */
  142712. private static _noneEmptyLineRegex;
  142713. private _textureMatrix;
  142714. private _onLoad;
  142715. /**
  142716. * Instantiates a ColorGradingTexture from the following parameters.
  142717. *
  142718. * @param url The location of the color gradind data (currently only supporting 3dl)
  142719. * @param sceneOrEngine The scene or engine the texture will be used in
  142720. * @param onLoad defines a callback triggered when the texture has been loaded
  142721. */
  142722. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  142723. /**
  142724. * Fires the onload event from the constructor if requested.
  142725. */
  142726. private _triggerOnLoad;
  142727. /**
  142728. * Returns the texture matrix used in most of the material.
  142729. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  142730. */
  142731. getTextureMatrix(): Matrix;
  142732. /**
  142733. * Occurs when the file being loaded is a .3dl LUT file.
  142734. */
  142735. private load3dlTexture;
  142736. /**
  142737. * Starts the loading process of the texture.
  142738. */
  142739. private loadTexture;
  142740. /**
  142741. * Clones the color gradind texture.
  142742. */
  142743. clone(): ColorGradingTexture;
  142744. /**
  142745. * Called during delayed load for textures.
  142746. */
  142747. delayLoad(): void;
  142748. /**
  142749. * Parses a color grading texture serialized by Babylon.
  142750. * @param parsedTexture The texture information being parsedTexture
  142751. * @param scene The scene to load the texture in
  142752. * @param rootUrl The root url of the data assets to load
  142753. * @return A color gradind texture
  142754. */
  142755. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  142756. /**
  142757. * Serializes the LUT texture to json format.
  142758. */
  142759. serialize(): any;
  142760. }
  142761. }
  142762. declare module BABYLON {
  142763. /**
  142764. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  142765. */
  142766. export class EquiRectangularCubeTexture extends BaseTexture {
  142767. /** The six faces of the cube. */
  142768. private static _FacesMapping;
  142769. private _noMipmap;
  142770. private _onLoad;
  142771. private _onError;
  142772. /** The size of the cubemap. */
  142773. private _size;
  142774. /** The buffer of the image. */
  142775. private _buffer;
  142776. /** The width of the input image. */
  142777. private _width;
  142778. /** The height of the input image. */
  142779. private _height;
  142780. /** The URL to the image. */
  142781. url: string;
  142782. /**
  142783. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  142784. * @param url The location of the image
  142785. * @param scene The scene the texture will be used in
  142786. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142787. * @param noMipmap Forces to not generate the mipmap if true
  142788. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142789. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142790. * @param onLoad — defines a callback called when texture is loaded
  142791. * @param onError — defines a callback called if there is an error
  142792. */
  142793. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  142794. /**
  142795. * Load the image data, by putting the image on a canvas and extracting its buffer.
  142796. */
  142797. private loadImage;
  142798. /**
  142799. * Convert the image buffer into a cubemap and create a CubeTexture.
  142800. */
  142801. private loadTexture;
  142802. /**
  142803. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  142804. * @param buffer The ArrayBuffer that should be converted.
  142805. * @returns The buffer as Float32Array.
  142806. */
  142807. private getFloat32ArrayFromArrayBuffer;
  142808. /**
  142809. * Get the current class name of the texture useful for serialization or dynamic coding.
  142810. * @returns "EquiRectangularCubeTexture"
  142811. */
  142812. getClassName(): string;
  142813. /**
  142814. * Create a clone of the current EquiRectangularCubeTexture and return it.
  142815. * @returns A clone of the current EquiRectangularCubeTexture.
  142816. */
  142817. clone(): EquiRectangularCubeTexture;
  142818. }
  142819. }
  142820. declare module BABYLON {
  142821. /**
  142822. * Defines the options related to the creation of an HtmlElementTexture
  142823. */
  142824. export interface IHtmlElementTextureOptions {
  142825. /**
  142826. * Defines wether mip maps should be created or not.
  142827. */
  142828. generateMipMaps?: boolean;
  142829. /**
  142830. * Defines the sampling mode of the texture.
  142831. */
  142832. samplingMode?: number;
  142833. /**
  142834. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  142835. */
  142836. engine: Nullable<ThinEngine>;
  142837. /**
  142838. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  142839. */
  142840. scene: Nullable<Scene>;
  142841. }
  142842. /**
  142843. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  142844. * To be as efficient as possible depending on your constraints nothing aside the first upload
  142845. * is automatically managed.
  142846. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  142847. * in your application.
  142848. *
  142849. * As the update is not automatic, you need to call them manually.
  142850. */
  142851. export class HtmlElementTexture extends BaseTexture {
  142852. /**
  142853. * The texture URL.
  142854. */
  142855. element: HTMLVideoElement | HTMLCanvasElement;
  142856. private static readonly DefaultOptions;
  142857. private _textureMatrix;
  142858. private _isVideo;
  142859. private _generateMipMaps;
  142860. private _samplingMode;
  142861. /**
  142862. * Instantiates a HtmlElementTexture from the following parameters.
  142863. *
  142864. * @param name Defines the name of the texture
  142865. * @param element Defines the video or canvas the texture is filled with
  142866. * @param options Defines the other none mandatory texture creation options
  142867. */
  142868. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  142869. private _createInternalTexture;
  142870. /**
  142871. * Returns the texture matrix used in most of the material.
  142872. */
  142873. getTextureMatrix(): Matrix;
  142874. /**
  142875. * Updates the content of the texture.
  142876. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  142877. */
  142878. update(invertY?: Nullable<boolean>): void;
  142879. }
  142880. }
  142881. declare module BABYLON {
  142882. /**
  142883. * Based on jsTGALoader - Javascript loader for TGA file
  142884. * By Vincent Thibault
  142885. * @see http://blog.robrowser.com/javascript-tga-loader.html
  142886. */
  142887. export class TGATools {
  142888. private static _TYPE_INDEXED;
  142889. private static _TYPE_RGB;
  142890. private static _TYPE_GREY;
  142891. private static _TYPE_RLE_INDEXED;
  142892. private static _TYPE_RLE_RGB;
  142893. private static _TYPE_RLE_GREY;
  142894. private static _ORIGIN_MASK;
  142895. private static _ORIGIN_SHIFT;
  142896. private static _ORIGIN_BL;
  142897. private static _ORIGIN_BR;
  142898. private static _ORIGIN_UL;
  142899. private static _ORIGIN_UR;
  142900. /**
  142901. * Gets the header of a TGA file
  142902. * @param data defines the TGA data
  142903. * @returns the header
  142904. */
  142905. static GetTGAHeader(data: Uint8Array): any;
  142906. /**
  142907. * Uploads TGA content to a Babylon Texture
  142908. * @hidden
  142909. */
  142910. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  142911. /** @hidden */
  142912. 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;
  142913. /** @hidden */
  142914. 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;
  142915. /** @hidden */
  142916. 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;
  142917. /** @hidden */
  142918. 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;
  142919. /** @hidden */
  142920. 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;
  142921. /** @hidden */
  142922. 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;
  142923. }
  142924. }
  142925. declare module BABYLON {
  142926. /**
  142927. * Implementation of the TGA Texture Loader.
  142928. * @hidden
  142929. */
  142930. export class _TGATextureLoader implements IInternalTextureLoader {
  142931. /**
  142932. * Defines wether the loader supports cascade loading the different faces.
  142933. */
  142934. readonly supportCascades: boolean;
  142935. /**
  142936. * This returns if the loader support the current file information.
  142937. * @param extension defines the file extension of the file being loaded
  142938. * @returns true if the loader can load the specified file
  142939. */
  142940. canLoad(extension: string): boolean;
  142941. /**
  142942. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142943. * @param data contains the texture data
  142944. * @param texture defines the BabylonJS internal texture
  142945. * @param createPolynomials will be true if polynomials have been requested
  142946. * @param onLoad defines the callback to trigger once the texture is ready
  142947. * @param onError defines the callback to trigger in case of error
  142948. */
  142949. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142950. /**
  142951. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142952. * @param data contains the texture data
  142953. * @param texture defines the BabylonJS internal texture
  142954. * @param callback defines the method to call once ready to upload
  142955. */
  142956. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142957. }
  142958. }
  142959. declare module BABYLON {
  142960. /**
  142961. * Info about the .basis files
  142962. */
  142963. class BasisFileInfo {
  142964. /**
  142965. * If the file has alpha
  142966. */
  142967. hasAlpha: boolean;
  142968. /**
  142969. * Info about each image of the basis file
  142970. */
  142971. images: Array<{
  142972. levels: Array<{
  142973. width: number;
  142974. height: number;
  142975. transcodedPixels: ArrayBufferView;
  142976. }>;
  142977. }>;
  142978. }
  142979. /**
  142980. * Result of transcoding a basis file
  142981. */
  142982. class TranscodeResult {
  142983. /**
  142984. * Info about the .basis file
  142985. */
  142986. fileInfo: BasisFileInfo;
  142987. /**
  142988. * Format to use when loading the file
  142989. */
  142990. format: number;
  142991. }
  142992. /**
  142993. * Configuration options for the Basis transcoder
  142994. */
  142995. export class BasisTranscodeConfiguration {
  142996. /**
  142997. * Supported compression formats used to determine the supported output format of the transcoder
  142998. */
  142999. supportedCompressionFormats?: {
  143000. /**
  143001. * etc1 compression format
  143002. */
  143003. etc1?: boolean;
  143004. /**
  143005. * s3tc compression format
  143006. */
  143007. s3tc?: boolean;
  143008. /**
  143009. * pvrtc compression format
  143010. */
  143011. pvrtc?: boolean;
  143012. /**
  143013. * etc2 compression format
  143014. */
  143015. etc2?: boolean;
  143016. };
  143017. /**
  143018. * If mipmap levels should be loaded for transcoded images (Default: true)
  143019. */
  143020. loadMipmapLevels?: boolean;
  143021. /**
  143022. * Index of a single image to load (Default: all images)
  143023. */
  143024. loadSingleImage?: number;
  143025. }
  143026. /**
  143027. * Used to load .Basis files
  143028. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  143029. */
  143030. export class BasisTools {
  143031. private static _IgnoreSupportedFormats;
  143032. /**
  143033. * URL to use when loading the basis transcoder
  143034. */
  143035. static JSModuleURL: string;
  143036. /**
  143037. * URL to use when loading the wasm module for the transcoder
  143038. */
  143039. static WasmModuleURL: string;
  143040. /**
  143041. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  143042. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  143043. * @returns internal format corresponding to the Basis format
  143044. */
  143045. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  143046. private static _WorkerPromise;
  143047. private static _Worker;
  143048. private static _actionId;
  143049. private static _CreateWorkerAsync;
  143050. /**
  143051. * Transcodes a loaded image file to compressed pixel data
  143052. * @param data image data to transcode
  143053. * @param config configuration options for the transcoding
  143054. * @returns a promise resulting in the transcoded image
  143055. */
  143056. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  143057. /**
  143058. * Loads a texture from the transcode result
  143059. * @param texture texture load to
  143060. * @param transcodeResult the result of transcoding the basis file to load from
  143061. */
  143062. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  143063. }
  143064. }
  143065. declare module BABYLON {
  143066. /**
  143067. * Loader for .basis file format
  143068. */
  143069. export class _BasisTextureLoader implements IInternalTextureLoader {
  143070. /**
  143071. * Defines whether the loader supports cascade loading the different faces.
  143072. */
  143073. readonly supportCascades: boolean;
  143074. /**
  143075. * This returns if the loader support the current file information.
  143076. * @param extension defines the file extension of the file being loaded
  143077. * @returns true if the loader can load the specified file
  143078. */
  143079. canLoad(extension: string): boolean;
  143080. /**
  143081. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  143082. * @param data contains the texture data
  143083. * @param texture defines the BabylonJS internal texture
  143084. * @param createPolynomials will be true if polynomials have been requested
  143085. * @param onLoad defines the callback to trigger once the texture is ready
  143086. * @param onError defines the callback to trigger in case of error
  143087. */
  143088. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  143089. /**
  143090. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  143091. * @param data contains the texture data
  143092. * @param texture defines the BabylonJS internal texture
  143093. * @param callback defines the method to call once ready to upload
  143094. */
  143095. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  143096. }
  143097. }
  143098. declare module BABYLON {
  143099. /**
  143100. * Defines the basic options interface of a TexturePacker Frame
  143101. */
  143102. export interface ITexturePackerFrame {
  143103. /**
  143104. * The frame ID
  143105. */
  143106. id: number;
  143107. /**
  143108. * The frames Scale
  143109. */
  143110. scale: Vector2;
  143111. /**
  143112. * The Frames offset
  143113. */
  143114. offset: Vector2;
  143115. }
  143116. /**
  143117. * This is a support class for frame Data on texture packer sets.
  143118. */
  143119. export class TexturePackerFrame implements ITexturePackerFrame {
  143120. /**
  143121. * The frame ID
  143122. */
  143123. id: number;
  143124. /**
  143125. * The frames Scale
  143126. */
  143127. scale: Vector2;
  143128. /**
  143129. * The Frames offset
  143130. */
  143131. offset: Vector2;
  143132. /**
  143133. * Initializes a texture package frame.
  143134. * @param id The numerical frame identifier
  143135. * @param scale Scalar Vector2 for UV frame
  143136. * @param offset Vector2 for the frame position in UV units.
  143137. * @returns TexturePackerFrame
  143138. */
  143139. constructor(id: number, scale: Vector2, offset: Vector2);
  143140. }
  143141. }
  143142. declare module BABYLON {
  143143. /**
  143144. * Defines the basic options interface of a TexturePacker
  143145. */
  143146. export interface ITexturePackerOptions {
  143147. /**
  143148. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  143149. */
  143150. map?: string[];
  143151. /**
  143152. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143153. */
  143154. uvsIn?: string;
  143155. /**
  143156. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143157. */
  143158. uvsOut?: string;
  143159. /**
  143160. * number representing the layout style. Defaults to LAYOUT_STRIP
  143161. */
  143162. layout?: number;
  143163. /**
  143164. * number of columns if using custom column count layout(2). This defaults to 4.
  143165. */
  143166. colnum?: number;
  143167. /**
  143168. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  143169. */
  143170. updateInputMeshes?: boolean;
  143171. /**
  143172. * boolean flag to dispose all the source textures. Defaults to true.
  143173. */
  143174. disposeSources?: boolean;
  143175. /**
  143176. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  143177. */
  143178. fillBlanks?: boolean;
  143179. /**
  143180. * string value representing the context fill style color. Defaults to 'black'.
  143181. */
  143182. customFillColor?: string;
  143183. /**
  143184. * Width and Height Value of each Frame in the TexturePacker Sets
  143185. */
  143186. frameSize?: number;
  143187. /**
  143188. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  143189. */
  143190. paddingRatio?: number;
  143191. /**
  143192. * Number that declares the fill method for the padding gutter.
  143193. */
  143194. paddingMode?: number;
  143195. /**
  143196. * If in SUBUV_COLOR padding mode what color to use.
  143197. */
  143198. paddingColor?: Color3 | Color4;
  143199. }
  143200. /**
  143201. * Defines the basic interface of a TexturePacker JSON File
  143202. */
  143203. export interface ITexturePackerJSON {
  143204. /**
  143205. * The frame ID
  143206. */
  143207. name: string;
  143208. /**
  143209. * The base64 channel data
  143210. */
  143211. sets: any;
  143212. /**
  143213. * The options of the Packer
  143214. */
  143215. options: ITexturePackerOptions;
  143216. /**
  143217. * The frame data of the Packer
  143218. */
  143219. frames: Array<number>;
  143220. }
  143221. /**
  143222. * This is a support class that generates a series of packed texture sets.
  143223. * @see https://doc.babylonjs.com/babylon101/materials
  143224. */
  143225. export class TexturePacker {
  143226. /** Packer Layout Constant 0 */
  143227. static readonly LAYOUT_STRIP: number;
  143228. /** Packer Layout Constant 1 */
  143229. static readonly LAYOUT_POWER2: number;
  143230. /** Packer Layout Constant 2 */
  143231. static readonly LAYOUT_COLNUM: number;
  143232. /** Packer Layout Constant 0 */
  143233. static readonly SUBUV_WRAP: number;
  143234. /** Packer Layout Constant 1 */
  143235. static readonly SUBUV_EXTEND: number;
  143236. /** Packer Layout Constant 2 */
  143237. static readonly SUBUV_COLOR: number;
  143238. /** The Name of the Texture Package */
  143239. name: string;
  143240. /** The scene scope of the TexturePacker */
  143241. scene: Scene;
  143242. /** The Meshes to target */
  143243. meshes: AbstractMesh[];
  143244. /** Arguments passed with the Constructor */
  143245. options: ITexturePackerOptions;
  143246. /** The promise that is started upon initialization */
  143247. promise: Nullable<Promise<TexturePacker | string>>;
  143248. /** The Container object for the channel sets that are generated */
  143249. sets: object;
  143250. /** The Container array for the frames that are generated */
  143251. frames: TexturePackerFrame[];
  143252. /** The expected number of textures the system is parsing. */
  143253. private _expecting;
  143254. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  143255. private _paddingValue;
  143256. /**
  143257. * Initializes a texture package series from an array of meshes or a single mesh.
  143258. * @param name The name of the package
  143259. * @param meshes The target meshes to compose the package from
  143260. * @param options The arguments that texture packer should follow while building.
  143261. * @param scene The scene which the textures are scoped to.
  143262. * @returns TexturePacker
  143263. */
  143264. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  143265. /**
  143266. * Starts the package process
  143267. * @param resolve The promises resolution function
  143268. * @returns TexturePacker
  143269. */
  143270. private _createFrames;
  143271. /**
  143272. * Calculates the Size of the Channel Sets
  143273. * @returns Vector2
  143274. */
  143275. private _calculateSize;
  143276. /**
  143277. * Calculates the UV data for the frames.
  143278. * @param baseSize the base frameSize
  143279. * @param padding the base frame padding
  143280. * @param dtSize size of the Dynamic Texture for that channel
  143281. * @param dtUnits is 1/dtSize
  143282. * @param update flag to update the input meshes
  143283. */
  143284. private _calculateMeshUVFrames;
  143285. /**
  143286. * Calculates the frames Offset.
  143287. * @param index of the frame
  143288. * @returns Vector2
  143289. */
  143290. private _getFrameOffset;
  143291. /**
  143292. * Updates a Mesh to the frame data
  143293. * @param mesh that is the target
  143294. * @param frameID or the frame index
  143295. */
  143296. private _updateMeshUV;
  143297. /**
  143298. * Updates a Meshes materials to use the texture packer channels
  143299. * @param m is the mesh to target
  143300. * @param force all channels on the packer to be set.
  143301. */
  143302. private _updateTextureReferences;
  143303. /**
  143304. * Public method to set a Mesh to a frame
  143305. * @param m that is the target
  143306. * @param frameID or the frame index
  143307. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  143308. */
  143309. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  143310. /**
  143311. * Starts the async promise to compile the texture packer.
  143312. * @returns Promise<void>
  143313. */
  143314. processAsync(): Promise<void>;
  143315. /**
  143316. * Disposes all textures associated with this packer
  143317. */
  143318. dispose(): void;
  143319. /**
  143320. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  143321. * @param imageType is the image type to use.
  143322. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  143323. */
  143324. download(imageType?: string, quality?: number): void;
  143325. /**
  143326. * Public method to load a texturePacker JSON file.
  143327. * @param data of the JSON file in string format.
  143328. */
  143329. updateFromJSON(data: string): void;
  143330. }
  143331. }
  143332. declare module BABYLON {
  143333. /**
  143334. * 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.
  143335. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143336. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143337. */
  143338. export class CustomProceduralTexture extends ProceduralTexture {
  143339. private _animate;
  143340. private _time;
  143341. private _config;
  143342. private _texturePath;
  143343. /**
  143344. * Instantiates a new Custom Procedural Texture.
  143345. * 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.
  143346. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143347. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143348. * @param name Define the name of the texture
  143349. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  143350. * @param size Define the size of the texture to create
  143351. * @param scene Define the scene the texture belongs to
  143352. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  143353. * @param generateMipMaps Define if the texture should creates mip maps or not
  143354. */
  143355. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143356. private _loadJson;
  143357. /**
  143358. * Is the texture ready to be used ? (rendered at least once)
  143359. * @returns true if ready, otherwise, false.
  143360. */
  143361. isReady(): boolean;
  143362. /**
  143363. * Render the texture to its associated render target.
  143364. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  143365. */
  143366. render(useCameraPostProcess?: boolean): void;
  143367. /**
  143368. * Update the list of dependant textures samplers in the shader.
  143369. */
  143370. updateTextures(): void;
  143371. /**
  143372. * Update the uniform values of the procedural texture in the shader.
  143373. */
  143374. updateShaderUniforms(): void;
  143375. /**
  143376. * Define if the texture animates or not.
  143377. */
  143378. get animate(): boolean;
  143379. set animate(value: boolean);
  143380. }
  143381. }
  143382. declare module BABYLON {
  143383. /** @hidden */
  143384. export var noisePixelShader: {
  143385. name: string;
  143386. shader: string;
  143387. };
  143388. }
  143389. declare module BABYLON {
  143390. /**
  143391. * Class used to generate noise procedural textures
  143392. */
  143393. export class NoiseProceduralTexture extends ProceduralTexture {
  143394. /** Gets or sets the start time (default is 0) */
  143395. time: number;
  143396. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  143397. brightness: number;
  143398. /** Defines the number of octaves to process */
  143399. octaves: number;
  143400. /** Defines the level of persistence (0.8 by default) */
  143401. persistence: number;
  143402. /** Gets or sets animation speed factor (default is 1) */
  143403. animationSpeedFactor: number;
  143404. /**
  143405. * Creates a new NoiseProceduralTexture
  143406. * @param name defines the name fo the texture
  143407. * @param size defines the size of the texture (default is 256)
  143408. * @param scene defines the hosting scene
  143409. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  143410. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  143411. */
  143412. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143413. private _updateShaderUniforms;
  143414. protected _getDefines(): string;
  143415. /** Generate the current state of the procedural texture */
  143416. render(useCameraPostProcess?: boolean): void;
  143417. /**
  143418. * Serializes this noise procedural texture
  143419. * @returns a serialized noise procedural texture object
  143420. */
  143421. serialize(): any;
  143422. /**
  143423. * Clone the texture.
  143424. * @returns the cloned texture
  143425. */
  143426. clone(): NoiseProceduralTexture;
  143427. /**
  143428. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  143429. * @param parsedTexture defines parsed texture data
  143430. * @param scene defines the current scene
  143431. * @param rootUrl defines the root URL containing noise procedural texture information
  143432. * @returns a parsed NoiseProceduralTexture
  143433. */
  143434. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  143435. }
  143436. }
  143437. declare module BABYLON {
  143438. /**
  143439. * Raw cube texture where the raw buffers are passed in
  143440. */
  143441. export class RawCubeTexture extends CubeTexture {
  143442. /**
  143443. * Creates a cube texture where the raw buffers are passed in.
  143444. * @param scene defines the scene the texture is attached to
  143445. * @param data defines the array of data to use to create each face
  143446. * @param size defines the size of the textures
  143447. * @param format defines the format of the data
  143448. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  143449. * @param generateMipMaps defines if the engine should generate the mip levels
  143450. * @param invertY defines if data must be stored with Y axis inverted
  143451. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  143452. * @param compression defines the compression used (null by default)
  143453. */
  143454. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  143455. /**
  143456. * Updates the raw cube texture.
  143457. * @param data defines the data to store
  143458. * @param format defines the data format
  143459. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  143460. * @param invertY defines if data must be stored with Y axis inverted
  143461. * @param compression defines the compression used (null by default)
  143462. * @param level defines which level of the texture to update
  143463. */
  143464. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  143465. /**
  143466. * Updates a raw cube texture with RGBD encoded data.
  143467. * @param data defines the array of data [mipmap][face] to use to create each face
  143468. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  143469. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  143470. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  143471. * @returns a promsie that resolves when the operation is complete
  143472. */
  143473. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  143474. /**
  143475. * Clones the raw cube texture.
  143476. * @return a new cube texture
  143477. */
  143478. clone(): CubeTexture;
  143479. /** @hidden */
  143480. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  143481. }
  143482. }
  143483. declare module BABYLON {
  143484. /**
  143485. * Class used to store 2D array textures containing user data
  143486. */
  143487. export class RawTexture2DArray extends Texture {
  143488. /** Gets or sets the texture format to use */
  143489. format: number;
  143490. /**
  143491. * Create a new RawTexture2DArray
  143492. * @param data defines the data of the texture
  143493. * @param width defines the width of the texture
  143494. * @param height defines the height of the texture
  143495. * @param depth defines the number of layers of the texture
  143496. * @param format defines the texture format to use
  143497. * @param scene defines the hosting scene
  143498. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143499. * @param invertY defines if texture must be stored with Y axis inverted
  143500. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143501. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143502. */
  143503. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143504. /** Gets or sets the texture format to use */
  143505. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143506. /**
  143507. * Update the texture with new data
  143508. * @param data defines the data to store in the texture
  143509. */
  143510. update(data: ArrayBufferView): void;
  143511. }
  143512. }
  143513. declare module BABYLON {
  143514. /**
  143515. * Class used to store 3D textures containing user data
  143516. */
  143517. export class RawTexture3D extends Texture {
  143518. /** Gets or sets the texture format to use */
  143519. format: number;
  143520. /**
  143521. * Create a new RawTexture3D
  143522. * @param data defines the data of the texture
  143523. * @param width defines the width of the texture
  143524. * @param height defines the height of the texture
  143525. * @param depth defines the depth of the texture
  143526. * @param format defines the texture format to use
  143527. * @param scene defines the hosting scene
  143528. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143529. * @param invertY defines if texture must be stored with Y axis inverted
  143530. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143531. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143532. */
  143533. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143534. /** Gets or sets the texture format to use */
  143535. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143536. /**
  143537. * Update the texture with new data
  143538. * @param data defines the data to store in the texture
  143539. */
  143540. update(data: ArrayBufferView): void;
  143541. }
  143542. }
  143543. declare module BABYLON {
  143544. /**
  143545. * Creates a refraction texture used by refraction channel of the standard material.
  143546. * It is like a mirror but to see through a material.
  143547. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143548. */
  143549. export class RefractionTexture extends RenderTargetTexture {
  143550. /**
  143551. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  143552. * 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.
  143553. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143554. */
  143555. refractionPlane: Plane;
  143556. /**
  143557. * Define how deep under the surface we should see.
  143558. */
  143559. depth: number;
  143560. /**
  143561. * Creates a refraction texture used by refraction channel of the standard material.
  143562. * It is like a mirror but to see through a material.
  143563. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143564. * @param name Define the texture name
  143565. * @param size Define the size of the underlying texture
  143566. * @param scene Define the scene the refraction belongs to
  143567. * @param generateMipMaps Define if we need to generate mips level for the refraction
  143568. */
  143569. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  143570. /**
  143571. * Clone the refraction texture.
  143572. * @returns the cloned texture
  143573. */
  143574. clone(): RefractionTexture;
  143575. /**
  143576. * Serialize the texture to a JSON representation you could use in Parse later on
  143577. * @returns the serialized JSON representation
  143578. */
  143579. serialize(): any;
  143580. }
  143581. }
  143582. declare module BABYLON {
  143583. /**
  143584. * Block used to add support for vertex skinning (bones)
  143585. */
  143586. export class BonesBlock extends NodeMaterialBlock {
  143587. /**
  143588. * Creates a new BonesBlock
  143589. * @param name defines the block name
  143590. */
  143591. constructor(name: string);
  143592. /**
  143593. * Initialize the block and prepare the context for build
  143594. * @param state defines the state that will be used for the build
  143595. */
  143596. initialize(state: NodeMaterialBuildState): void;
  143597. /**
  143598. * Gets the current class name
  143599. * @returns the class name
  143600. */
  143601. getClassName(): string;
  143602. /**
  143603. * Gets the matrix indices input component
  143604. */
  143605. get matricesIndices(): NodeMaterialConnectionPoint;
  143606. /**
  143607. * Gets the matrix weights input component
  143608. */
  143609. get matricesWeights(): NodeMaterialConnectionPoint;
  143610. /**
  143611. * Gets the extra matrix indices input component
  143612. */
  143613. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  143614. /**
  143615. * Gets the extra matrix weights input component
  143616. */
  143617. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  143618. /**
  143619. * Gets the world input component
  143620. */
  143621. get world(): NodeMaterialConnectionPoint;
  143622. /**
  143623. * Gets the output component
  143624. */
  143625. get output(): NodeMaterialConnectionPoint;
  143626. autoConfigure(material: NodeMaterial): void;
  143627. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  143628. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143629. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143630. protected _buildBlock(state: NodeMaterialBuildState): this;
  143631. }
  143632. }
  143633. declare module BABYLON {
  143634. /**
  143635. * Block used to add support for instances
  143636. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  143637. */
  143638. export class InstancesBlock extends NodeMaterialBlock {
  143639. /**
  143640. * Creates a new InstancesBlock
  143641. * @param name defines the block name
  143642. */
  143643. constructor(name: string);
  143644. /**
  143645. * Gets the current class name
  143646. * @returns the class name
  143647. */
  143648. getClassName(): string;
  143649. /**
  143650. * Gets the first world row input component
  143651. */
  143652. get world0(): NodeMaterialConnectionPoint;
  143653. /**
  143654. * Gets the second world row input component
  143655. */
  143656. get world1(): NodeMaterialConnectionPoint;
  143657. /**
  143658. * Gets the third world row input component
  143659. */
  143660. get world2(): NodeMaterialConnectionPoint;
  143661. /**
  143662. * Gets the forth world row input component
  143663. */
  143664. get world3(): NodeMaterialConnectionPoint;
  143665. /**
  143666. * Gets the world input component
  143667. */
  143668. get world(): NodeMaterialConnectionPoint;
  143669. /**
  143670. * Gets the output component
  143671. */
  143672. get output(): NodeMaterialConnectionPoint;
  143673. /**
  143674. * Gets the isntanceID component
  143675. */
  143676. get instanceID(): NodeMaterialConnectionPoint;
  143677. autoConfigure(material: NodeMaterial): void;
  143678. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  143679. protected _buildBlock(state: NodeMaterialBuildState): this;
  143680. }
  143681. }
  143682. declare module BABYLON {
  143683. /**
  143684. * Block used to add morph targets support to vertex shader
  143685. */
  143686. export class MorphTargetsBlock extends NodeMaterialBlock {
  143687. private _repeatableContentAnchor;
  143688. /**
  143689. * Create a new MorphTargetsBlock
  143690. * @param name defines the block name
  143691. */
  143692. constructor(name: string);
  143693. /**
  143694. * Gets the current class name
  143695. * @returns the class name
  143696. */
  143697. getClassName(): string;
  143698. /**
  143699. * Gets the position input component
  143700. */
  143701. get position(): NodeMaterialConnectionPoint;
  143702. /**
  143703. * Gets the normal input component
  143704. */
  143705. get normal(): NodeMaterialConnectionPoint;
  143706. /**
  143707. * Gets the tangent input component
  143708. */
  143709. get tangent(): NodeMaterialConnectionPoint;
  143710. /**
  143711. * Gets the tangent input component
  143712. */
  143713. get uv(): NodeMaterialConnectionPoint;
  143714. /**
  143715. * Gets the position output component
  143716. */
  143717. get positionOutput(): NodeMaterialConnectionPoint;
  143718. /**
  143719. * Gets the normal output component
  143720. */
  143721. get normalOutput(): NodeMaterialConnectionPoint;
  143722. /**
  143723. * Gets the tangent output component
  143724. */
  143725. get tangentOutput(): NodeMaterialConnectionPoint;
  143726. /**
  143727. * Gets the tangent output component
  143728. */
  143729. get uvOutput(): NodeMaterialConnectionPoint;
  143730. initialize(state: NodeMaterialBuildState): void;
  143731. autoConfigure(material: NodeMaterial): void;
  143732. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143733. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143734. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  143735. protected _buildBlock(state: NodeMaterialBuildState): this;
  143736. }
  143737. }
  143738. declare module BABYLON {
  143739. /**
  143740. * Block used to get data information from a light
  143741. */
  143742. export class LightInformationBlock extends NodeMaterialBlock {
  143743. private _lightDataUniformName;
  143744. private _lightColorUniformName;
  143745. private _lightTypeDefineName;
  143746. /**
  143747. * Gets or sets the light associated with this block
  143748. */
  143749. light: Nullable<Light>;
  143750. /**
  143751. * Creates a new LightInformationBlock
  143752. * @param name defines the block name
  143753. */
  143754. constructor(name: string);
  143755. /**
  143756. * Gets the current class name
  143757. * @returns the class name
  143758. */
  143759. getClassName(): string;
  143760. /**
  143761. * Gets the world position input component
  143762. */
  143763. get worldPosition(): NodeMaterialConnectionPoint;
  143764. /**
  143765. * Gets the direction output component
  143766. */
  143767. get direction(): NodeMaterialConnectionPoint;
  143768. /**
  143769. * Gets the direction output component
  143770. */
  143771. get color(): NodeMaterialConnectionPoint;
  143772. /**
  143773. * Gets the direction output component
  143774. */
  143775. get intensity(): NodeMaterialConnectionPoint;
  143776. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143777. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143778. protected _buildBlock(state: NodeMaterialBuildState): this;
  143779. serialize(): any;
  143780. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143781. }
  143782. }
  143783. declare module BABYLON {
  143784. /**
  143785. * Block used to add image processing support to fragment shader
  143786. */
  143787. export class ImageProcessingBlock extends NodeMaterialBlock {
  143788. /**
  143789. * Create a new ImageProcessingBlock
  143790. * @param name defines the block name
  143791. */
  143792. constructor(name: string);
  143793. /**
  143794. * Gets the current class name
  143795. * @returns the class name
  143796. */
  143797. getClassName(): string;
  143798. /**
  143799. * Gets the color input component
  143800. */
  143801. get color(): NodeMaterialConnectionPoint;
  143802. /**
  143803. * Gets the output component
  143804. */
  143805. get output(): NodeMaterialConnectionPoint;
  143806. /**
  143807. * Initialize the block and prepare the context for build
  143808. * @param state defines the state that will be used for the build
  143809. */
  143810. initialize(state: NodeMaterialBuildState): void;
  143811. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  143812. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143813. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143814. protected _buildBlock(state: NodeMaterialBuildState): this;
  143815. }
  143816. }
  143817. declare module BABYLON {
  143818. /**
  143819. * Block used to pertub normals based on a normal map
  143820. */
  143821. export class PerturbNormalBlock extends NodeMaterialBlock {
  143822. private _tangentSpaceParameterName;
  143823. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143824. invertX: boolean;
  143825. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  143826. invertY: boolean;
  143827. /**
  143828. * Create a new PerturbNormalBlock
  143829. * @param name defines the block name
  143830. */
  143831. constructor(name: string);
  143832. /**
  143833. * Gets the current class name
  143834. * @returns the class name
  143835. */
  143836. getClassName(): string;
  143837. /**
  143838. * Gets the world position input component
  143839. */
  143840. get worldPosition(): NodeMaterialConnectionPoint;
  143841. /**
  143842. * Gets the world normal input component
  143843. */
  143844. get worldNormal(): NodeMaterialConnectionPoint;
  143845. /**
  143846. * Gets the world tangent input component
  143847. */
  143848. get worldTangent(): NodeMaterialConnectionPoint;
  143849. /**
  143850. * Gets the uv input component
  143851. */
  143852. get uv(): NodeMaterialConnectionPoint;
  143853. /**
  143854. * Gets the normal map color input component
  143855. */
  143856. get normalMapColor(): NodeMaterialConnectionPoint;
  143857. /**
  143858. * Gets the strength input component
  143859. */
  143860. get strength(): NodeMaterialConnectionPoint;
  143861. /**
  143862. * Gets the output component
  143863. */
  143864. get output(): NodeMaterialConnectionPoint;
  143865. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143866. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143867. autoConfigure(material: NodeMaterial): void;
  143868. protected _buildBlock(state: NodeMaterialBuildState): this;
  143869. protected _dumpPropertiesCode(): string;
  143870. serialize(): any;
  143871. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143872. }
  143873. }
  143874. declare module BABYLON {
  143875. /**
  143876. * Block used to discard a pixel if a value is smaller than a cutoff
  143877. */
  143878. export class DiscardBlock extends NodeMaterialBlock {
  143879. /**
  143880. * Create a new DiscardBlock
  143881. * @param name defines the block name
  143882. */
  143883. constructor(name: string);
  143884. /**
  143885. * Gets the current class name
  143886. * @returns the class name
  143887. */
  143888. getClassName(): string;
  143889. /**
  143890. * Gets the color input component
  143891. */
  143892. get value(): NodeMaterialConnectionPoint;
  143893. /**
  143894. * Gets the cutoff input component
  143895. */
  143896. get cutoff(): NodeMaterialConnectionPoint;
  143897. protected _buildBlock(state: NodeMaterialBuildState): this;
  143898. }
  143899. }
  143900. declare module BABYLON {
  143901. /**
  143902. * Block used to test if the fragment shader is front facing
  143903. */
  143904. export class FrontFacingBlock extends NodeMaterialBlock {
  143905. /**
  143906. * Creates a new FrontFacingBlock
  143907. * @param name defines the block name
  143908. */
  143909. constructor(name: string);
  143910. /**
  143911. * Gets the current class name
  143912. * @returns the class name
  143913. */
  143914. getClassName(): string;
  143915. /**
  143916. * Gets the output component
  143917. */
  143918. get output(): NodeMaterialConnectionPoint;
  143919. protected _buildBlock(state: NodeMaterialBuildState): this;
  143920. }
  143921. }
  143922. declare module BABYLON {
  143923. /**
  143924. * Block used to get the derivative value on x and y of a given input
  143925. */
  143926. export class DerivativeBlock extends NodeMaterialBlock {
  143927. /**
  143928. * Create a new DerivativeBlock
  143929. * @param name defines the block name
  143930. */
  143931. constructor(name: string);
  143932. /**
  143933. * Gets the current class name
  143934. * @returns the class name
  143935. */
  143936. getClassName(): string;
  143937. /**
  143938. * Gets the input component
  143939. */
  143940. get input(): NodeMaterialConnectionPoint;
  143941. /**
  143942. * Gets the derivative output on x
  143943. */
  143944. get dx(): NodeMaterialConnectionPoint;
  143945. /**
  143946. * Gets the derivative output on y
  143947. */
  143948. get dy(): NodeMaterialConnectionPoint;
  143949. protected _buildBlock(state: NodeMaterialBuildState): this;
  143950. }
  143951. }
  143952. declare module BABYLON {
  143953. /**
  143954. * Block used to make gl_FragCoord available
  143955. */
  143956. export class FragCoordBlock extends NodeMaterialBlock {
  143957. /**
  143958. * Creates a new FragCoordBlock
  143959. * @param name defines the block name
  143960. */
  143961. constructor(name: string);
  143962. /**
  143963. * Gets the current class name
  143964. * @returns the class name
  143965. */
  143966. getClassName(): string;
  143967. /**
  143968. * Gets the xy component
  143969. */
  143970. get xy(): NodeMaterialConnectionPoint;
  143971. /**
  143972. * Gets the xyz component
  143973. */
  143974. get xyz(): NodeMaterialConnectionPoint;
  143975. /**
  143976. * Gets the xyzw component
  143977. */
  143978. get xyzw(): NodeMaterialConnectionPoint;
  143979. /**
  143980. * Gets the x component
  143981. */
  143982. get x(): NodeMaterialConnectionPoint;
  143983. /**
  143984. * Gets the y component
  143985. */
  143986. get y(): NodeMaterialConnectionPoint;
  143987. /**
  143988. * Gets the z component
  143989. */
  143990. get z(): NodeMaterialConnectionPoint;
  143991. /**
  143992. * Gets the w component
  143993. */
  143994. get output(): NodeMaterialConnectionPoint;
  143995. protected writeOutputs(state: NodeMaterialBuildState): string;
  143996. protected _buildBlock(state: NodeMaterialBuildState): this;
  143997. }
  143998. }
  143999. declare module BABYLON {
  144000. /**
  144001. * Block used to get the screen sizes
  144002. */
  144003. export class ScreenSizeBlock extends NodeMaterialBlock {
  144004. private _varName;
  144005. private _scene;
  144006. /**
  144007. * Creates a new ScreenSizeBlock
  144008. * @param name defines the block name
  144009. */
  144010. constructor(name: string);
  144011. /**
  144012. * Gets the current class name
  144013. * @returns the class name
  144014. */
  144015. getClassName(): string;
  144016. /**
  144017. * Gets the xy component
  144018. */
  144019. get xy(): NodeMaterialConnectionPoint;
  144020. /**
  144021. * Gets the x component
  144022. */
  144023. get x(): NodeMaterialConnectionPoint;
  144024. /**
  144025. * Gets the y component
  144026. */
  144027. get y(): NodeMaterialConnectionPoint;
  144028. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144029. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  144030. protected _buildBlock(state: NodeMaterialBuildState): this;
  144031. }
  144032. }
  144033. declare module BABYLON {
  144034. /**
  144035. * Block used to add support for scene fog
  144036. */
  144037. export class FogBlock extends NodeMaterialBlock {
  144038. private _fogDistanceName;
  144039. private _fogParameters;
  144040. /**
  144041. * Create a new FogBlock
  144042. * @param name defines the block name
  144043. */
  144044. constructor(name: string);
  144045. /**
  144046. * Gets the current class name
  144047. * @returns the class name
  144048. */
  144049. getClassName(): string;
  144050. /**
  144051. * Gets the world position input component
  144052. */
  144053. get worldPosition(): NodeMaterialConnectionPoint;
  144054. /**
  144055. * Gets the view input component
  144056. */
  144057. get view(): NodeMaterialConnectionPoint;
  144058. /**
  144059. * Gets the color input component
  144060. */
  144061. get input(): NodeMaterialConnectionPoint;
  144062. /**
  144063. * Gets the fog color input component
  144064. */
  144065. get fogColor(): NodeMaterialConnectionPoint;
  144066. /**
  144067. * Gets the output component
  144068. */
  144069. get output(): NodeMaterialConnectionPoint;
  144070. autoConfigure(material: NodeMaterial): void;
  144071. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144072. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144073. protected _buildBlock(state: NodeMaterialBuildState): this;
  144074. }
  144075. }
  144076. declare module BABYLON {
  144077. /**
  144078. * Block used to add light in the fragment shader
  144079. */
  144080. export class LightBlock extends NodeMaterialBlock {
  144081. private _lightId;
  144082. /**
  144083. * Gets or sets the light associated with this block
  144084. */
  144085. light: Nullable<Light>;
  144086. /**
  144087. * Create a new LightBlock
  144088. * @param name defines the block name
  144089. */
  144090. constructor(name: string);
  144091. /**
  144092. * Gets the current class name
  144093. * @returns the class name
  144094. */
  144095. getClassName(): string;
  144096. /**
  144097. * Gets the world position input component
  144098. */
  144099. get worldPosition(): NodeMaterialConnectionPoint;
  144100. /**
  144101. * Gets the world normal input component
  144102. */
  144103. get worldNormal(): NodeMaterialConnectionPoint;
  144104. /**
  144105. * Gets the camera (or eye) position component
  144106. */
  144107. get cameraPosition(): NodeMaterialConnectionPoint;
  144108. /**
  144109. * Gets the glossiness component
  144110. */
  144111. get glossiness(): NodeMaterialConnectionPoint;
  144112. /**
  144113. * Gets the glossinness power component
  144114. */
  144115. get glossPower(): NodeMaterialConnectionPoint;
  144116. /**
  144117. * Gets the diffuse color component
  144118. */
  144119. get diffuseColor(): NodeMaterialConnectionPoint;
  144120. /**
  144121. * Gets the specular color component
  144122. */
  144123. get specularColor(): NodeMaterialConnectionPoint;
  144124. /**
  144125. * Gets the diffuse output component
  144126. */
  144127. get diffuseOutput(): NodeMaterialConnectionPoint;
  144128. /**
  144129. * Gets the specular output component
  144130. */
  144131. get specularOutput(): NodeMaterialConnectionPoint;
  144132. /**
  144133. * Gets the shadow output component
  144134. */
  144135. get shadow(): NodeMaterialConnectionPoint;
  144136. autoConfigure(material: NodeMaterial): void;
  144137. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144138. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  144139. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144140. private _injectVertexCode;
  144141. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144142. serialize(): any;
  144143. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144144. }
  144145. }
  144146. declare module BABYLON {
  144147. /**
  144148. * Block used to read a reflection texture from a sampler
  144149. */
  144150. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  144151. /**
  144152. * Create a new ReflectionTextureBlock
  144153. * @param name defines the block name
  144154. */
  144155. constructor(name: string);
  144156. /**
  144157. * Gets the current class name
  144158. * @returns the class name
  144159. */
  144160. getClassName(): string;
  144161. /**
  144162. * Gets the world position input component
  144163. */
  144164. get position(): NodeMaterialConnectionPoint;
  144165. /**
  144166. * Gets the world position input component
  144167. */
  144168. get worldPosition(): NodeMaterialConnectionPoint;
  144169. /**
  144170. * Gets the world normal input component
  144171. */
  144172. get worldNormal(): NodeMaterialConnectionPoint;
  144173. /**
  144174. * Gets the world input component
  144175. */
  144176. get world(): NodeMaterialConnectionPoint;
  144177. /**
  144178. * Gets the camera (or eye) position component
  144179. */
  144180. get cameraPosition(): NodeMaterialConnectionPoint;
  144181. /**
  144182. * Gets the view input component
  144183. */
  144184. get view(): NodeMaterialConnectionPoint;
  144185. /**
  144186. * Gets the rgb output component
  144187. */
  144188. get rgb(): NodeMaterialConnectionPoint;
  144189. /**
  144190. * Gets the rgba output component
  144191. */
  144192. get rgba(): NodeMaterialConnectionPoint;
  144193. /**
  144194. * Gets the r output component
  144195. */
  144196. get r(): NodeMaterialConnectionPoint;
  144197. /**
  144198. * Gets the g output component
  144199. */
  144200. get g(): NodeMaterialConnectionPoint;
  144201. /**
  144202. * Gets the b output component
  144203. */
  144204. get b(): NodeMaterialConnectionPoint;
  144205. /**
  144206. * Gets the a output component
  144207. */
  144208. get a(): NodeMaterialConnectionPoint;
  144209. autoConfigure(material: NodeMaterial): void;
  144210. protected _buildBlock(state: NodeMaterialBuildState): this;
  144211. }
  144212. }
  144213. declare module BABYLON {
  144214. /**
  144215. * Block used to add 2 vectors
  144216. */
  144217. export class AddBlock extends NodeMaterialBlock {
  144218. /**
  144219. * Creates a new AddBlock
  144220. * @param name defines the block name
  144221. */
  144222. constructor(name: string);
  144223. /**
  144224. * Gets the current class name
  144225. * @returns the class name
  144226. */
  144227. getClassName(): string;
  144228. /**
  144229. * Gets the left operand input component
  144230. */
  144231. get left(): NodeMaterialConnectionPoint;
  144232. /**
  144233. * Gets the right operand input component
  144234. */
  144235. get right(): NodeMaterialConnectionPoint;
  144236. /**
  144237. * Gets the output component
  144238. */
  144239. get output(): NodeMaterialConnectionPoint;
  144240. protected _buildBlock(state: NodeMaterialBuildState): this;
  144241. }
  144242. }
  144243. declare module BABYLON {
  144244. /**
  144245. * Block used to scale a vector by a float
  144246. */
  144247. export class ScaleBlock extends NodeMaterialBlock {
  144248. /**
  144249. * Creates a new ScaleBlock
  144250. * @param name defines the block name
  144251. */
  144252. constructor(name: string);
  144253. /**
  144254. * Gets the current class name
  144255. * @returns the class name
  144256. */
  144257. getClassName(): string;
  144258. /**
  144259. * Gets the input component
  144260. */
  144261. get input(): NodeMaterialConnectionPoint;
  144262. /**
  144263. * Gets the factor input component
  144264. */
  144265. get factor(): NodeMaterialConnectionPoint;
  144266. /**
  144267. * Gets the output component
  144268. */
  144269. get output(): NodeMaterialConnectionPoint;
  144270. protected _buildBlock(state: NodeMaterialBuildState): this;
  144271. }
  144272. }
  144273. declare module BABYLON {
  144274. /**
  144275. * Block used to clamp a float
  144276. */
  144277. export class ClampBlock extends NodeMaterialBlock {
  144278. /** Gets or sets the minimum range */
  144279. minimum: number;
  144280. /** Gets or sets the maximum range */
  144281. maximum: number;
  144282. /**
  144283. * Creates a new ClampBlock
  144284. * @param name defines the block name
  144285. */
  144286. constructor(name: string);
  144287. /**
  144288. * Gets the current class name
  144289. * @returns the class name
  144290. */
  144291. getClassName(): string;
  144292. /**
  144293. * Gets the value input component
  144294. */
  144295. get value(): NodeMaterialConnectionPoint;
  144296. /**
  144297. * Gets the output component
  144298. */
  144299. get output(): NodeMaterialConnectionPoint;
  144300. protected _buildBlock(state: NodeMaterialBuildState): this;
  144301. protected _dumpPropertiesCode(): string;
  144302. serialize(): any;
  144303. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144304. }
  144305. }
  144306. declare module BABYLON {
  144307. /**
  144308. * Block used to apply a cross product between 2 vectors
  144309. */
  144310. export class CrossBlock extends NodeMaterialBlock {
  144311. /**
  144312. * Creates a new CrossBlock
  144313. * @param name defines the block name
  144314. */
  144315. constructor(name: string);
  144316. /**
  144317. * Gets the current class name
  144318. * @returns the class name
  144319. */
  144320. getClassName(): string;
  144321. /**
  144322. * Gets the left operand input component
  144323. */
  144324. get left(): NodeMaterialConnectionPoint;
  144325. /**
  144326. * Gets the right operand input component
  144327. */
  144328. get right(): NodeMaterialConnectionPoint;
  144329. /**
  144330. * Gets the output component
  144331. */
  144332. get output(): NodeMaterialConnectionPoint;
  144333. protected _buildBlock(state: NodeMaterialBuildState): this;
  144334. }
  144335. }
  144336. declare module BABYLON {
  144337. /**
  144338. * Block used to apply a dot product between 2 vectors
  144339. */
  144340. export class DotBlock extends NodeMaterialBlock {
  144341. /**
  144342. * Creates a new DotBlock
  144343. * @param name defines the block name
  144344. */
  144345. constructor(name: string);
  144346. /**
  144347. * Gets the current class name
  144348. * @returns the class name
  144349. */
  144350. getClassName(): string;
  144351. /**
  144352. * Gets the left operand input component
  144353. */
  144354. get left(): NodeMaterialConnectionPoint;
  144355. /**
  144356. * Gets the right operand input component
  144357. */
  144358. get right(): NodeMaterialConnectionPoint;
  144359. /**
  144360. * Gets the output component
  144361. */
  144362. get output(): NodeMaterialConnectionPoint;
  144363. protected _buildBlock(state: NodeMaterialBuildState): this;
  144364. }
  144365. }
  144366. declare module BABYLON {
  144367. /**
  144368. * Block used to normalize a vector
  144369. */
  144370. export class NormalizeBlock extends NodeMaterialBlock {
  144371. /**
  144372. * Creates a new NormalizeBlock
  144373. * @param name defines the block name
  144374. */
  144375. constructor(name: string);
  144376. /**
  144377. * Gets the current class name
  144378. * @returns the class name
  144379. */
  144380. getClassName(): string;
  144381. /**
  144382. * Gets the input component
  144383. */
  144384. get input(): NodeMaterialConnectionPoint;
  144385. /**
  144386. * Gets the output component
  144387. */
  144388. get output(): NodeMaterialConnectionPoint;
  144389. protected _buildBlock(state: NodeMaterialBuildState): this;
  144390. }
  144391. }
  144392. declare module BABYLON {
  144393. /**
  144394. * Block used to create a Color3/4 out of individual inputs (one for each component)
  144395. */
  144396. export class ColorMergerBlock extends NodeMaterialBlock {
  144397. /**
  144398. * Create a new ColorMergerBlock
  144399. * @param name defines the block name
  144400. */
  144401. constructor(name: string);
  144402. /**
  144403. * Gets the current class name
  144404. * @returns the class name
  144405. */
  144406. getClassName(): string;
  144407. /**
  144408. * Gets the rgb component (input)
  144409. */
  144410. get rgbIn(): NodeMaterialConnectionPoint;
  144411. /**
  144412. * Gets the r component (input)
  144413. */
  144414. get r(): NodeMaterialConnectionPoint;
  144415. /**
  144416. * Gets the g component (input)
  144417. */
  144418. get g(): NodeMaterialConnectionPoint;
  144419. /**
  144420. * Gets the b component (input)
  144421. */
  144422. get b(): NodeMaterialConnectionPoint;
  144423. /**
  144424. * Gets the a component (input)
  144425. */
  144426. get a(): NodeMaterialConnectionPoint;
  144427. /**
  144428. * Gets the rgba component (output)
  144429. */
  144430. get rgba(): NodeMaterialConnectionPoint;
  144431. /**
  144432. * Gets the rgb component (output)
  144433. */
  144434. get rgbOut(): NodeMaterialConnectionPoint;
  144435. /**
  144436. * Gets the rgb component (output)
  144437. * @deprecated Please use rgbOut instead.
  144438. */
  144439. get rgb(): NodeMaterialConnectionPoint;
  144440. protected _buildBlock(state: NodeMaterialBuildState): this;
  144441. }
  144442. }
  144443. declare module BABYLON {
  144444. /**
  144445. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  144446. */
  144447. export class VectorSplitterBlock extends NodeMaterialBlock {
  144448. /**
  144449. * Create a new VectorSplitterBlock
  144450. * @param name defines the block name
  144451. */
  144452. constructor(name: string);
  144453. /**
  144454. * Gets the current class name
  144455. * @returns the class name
  144456. */
  144457. getClassName(): string;
  144458. /**
  144459. * Gets the xyzw component (input)
  144460. */
  144461. get xyzw(): NodeMaterialConnectionPoint;
  144462. /**
  144463. * Gets the xyz component (input)
  144464. */
  144465. get xyzIn(): NodeMaterialConnectionPoint;
  144466. /**
  144467. * Gets the xy component (input)
  144468. */
  144469. get xyIn(): NodeMaterialConnectionPoint;
  144470. /**
  144471. * Gets the xyz component (output)
  144472. */
  144473. get xyzOut(): NodeMaterialConnectionPoint;
  144474. /**
  144475. * Gets the xy component (output)
  144476. */
  144477. get xyOut(): NodeMaterialConnectionPoint;
  144478. /**
  144479. * Gets the x component (output)
  144480. */
  144481. get x(): NodeMaterialConnectionPoint;
  144482. /**
  144483. * Gets the y component (output)
  144484. */
  144485. get y(): NodeMaterialConnectionPoint;
  144486. /**
  144487. * Gets the z component (output)
  144488. */
  144489. get z(): NodeMaterialConnectionPoint;
  144490. /**
  144491. * Gets the w component (output)
  144492. */
  144493. get w(): NodeMaterialConnectionPoint;
  144494. protected _inputRename(name: string): string;
  144495. protected _outputRename(name: string): string;
  144496. protected _buildBlock(state: NodeMaterialBuildState): this;
  144497. }
  144498. }
  144499. declare module BABYLON {
  144500. /**
  144501. * Block used to lerp between 2 values
  144502. */
  144503. export class LerpBlock extends NodeMaterialBlock {
  144504. /**
  144505. * Creates a new LerpBlock
  144506. * @param name defines the block name
  144507. */
  144508. constructor(name: string);
  144509. /**
  144510. * Gets the current class name
  144511. * @returns the class name
  144512. */
  144513. getClassName(): string;
  144514. /**
  144515. * Gets the left operand input component
  144516. */
  144517. get left(): NodeMaterialConnectionPoint;
  144518. /**
  144519. * Gets the right operand input component
  144520. */
  144521. get right(): NodeMaterialConnectionPoint;
  144522. /**
  144523. * Gets the gradient operand input component
  144524. */
  144525. get gradient(): NodeMaterialConnectionPoint;
  144526. /**
  144527. * Gets the output component
  144528. */
  144529. get output(): NodeMaterialConnectionPoint;
  144530. protected _buildBlock(state: NodeMaterialBuildState): this;
  144531. }
  144532. }
  144533. declare module BABYLON {
  144534. /**
  144535. * Block used to divide 2 vectors
  144536. */
  144537. export class DivideBlock extends NodeMaterialBlock {
  144538. /**
  144539. * Creates a new DivideBlock
  144540. * @param name defines the block name
  144541. */
  144542. constructor(name: string);
  144543. /**
  144544. * Gets the current class name
  144545. * @returns the class name
  144546. */
  144547. getClassName(): string;
  144548. /**
  144549. * Gets the left operand input component
  144550. */
  144551. get left(): NodeMaterialConnectionPoint;
  144552. /**
  144553. * Gets the right operand input component
  144554. */
  144555. get right(): NodeMaterialConnectionPoint;
  144556. /**
  144557. * Gets the output component
  144558. */
  144559. get output(): NodeMaterialConnectionPoint;
  144560. protected _buildBlock(state: NodeMaterialBuildState): this;
  144561. }
  144562. }
  144563. declare module BABYLON {
  144564. /**
  144565. * Block used to subtract 2 vectors
  144566. */
  144567. export class SubtractBlock extends NodeMaterialBlock {
  144568. /**
  144569. * Creates a new SubtractBlock
  144570. * @param name defines the block name
  144571. */
  144572. constructor(name: string);
  144573. /**
  144574. * Gets the current class name
  144575. * @returns the class name
  144576. */
  144577. getClassName(): string;
  144578. /**
  144579. * Gets the left operand input component
  144580. */
  144581. get left(): NodeMaterialConnectionPoint;
  144582. /**
  144583. * Gets the right operand input component
  144584. */
  144585. get right(): NodeMaterialConnectionPoint;
  144586. /**
  144587. * Gets the output component
  144588. */
  144589. get output(): NodeMaterialConnectionPoint;
  144590. protected _buildBlock(state: NodeMaterialBuildState): this;
  144591. }
  144592. }
  144593. declare module BABYLON {
  144594. /**
  144595. * Block used to step a value
  144596. */
  144597. export class StepBlock extends NodeMaterialBlock {
  144598. /**
  144599. * Creates a new StepBlock
  144600. * @param name defines the block name
  144601. */
  144602. constructor(name: string);
  144603. /**
  144604. * Gets the current class name
  144605. * @returns the class name
  144606. */
  144607. getClassName(): string;
  144608. /**
  144609. * Gets the value operand input component
  144610. */
  144611. get value(): NodeMaterialConnectionPoint;
  144612. /**
  144613. * Gets the edge operand input component
  144614. */
  144615. get edge(): NodeMaterialConnectionPoint;
  144616. /**
  144617. * Gets the output component
  144618. */
  144619. get output(): NodeMaterialConnectionPoint;
  144620. protected _buildBlock(state: NodeMaterialBuildState): this;
  144621. }
  144622. }
  144623. declare module BABYLON {
  144624. /**
  144625. * Block used to get the opposite (1 - x) of a value
  144626. */
  144627. export class OneMinusBlock extends NodeMaterialBlock {
  144628. /**
  144629. * Creates a new OneMinusBlock
  144630. * @param name defines the block name
  144631. */
  144632. constructor(name: string);
  144633. /**
  144634. * Gets the current class name
  144635. * @returns the class name
  144636. */
  144637. getClassName(): string;
  144638. /**
  144639. * Gets the input component
  144640. */
  144641. get input(): NodeMaterialConnectionPoint;
  144642. /**
  144643. * Gets the output component
  144644. */
  144645. get output(): NodeMaterialConnectionPoint;
  144646. protected _buildBlock(state: NodeMaterialBuildState): this;
  144647. }
  144648. }
  144649. declare module BABYLON {
  144650. /**
  144651. * Block used to get the view direction
  144652. */
  144653. export class ViewDirectionBlock extends NodeMaterialBlock {
  144654. /**
  144655. * Creates a new ViewDirectionBlock
  144656. * @param name defines the block name
  144657. */
  144658. constructor(name: string);
  144659. /**
  144660. * Gets the current class name
  144661. * @returns the class name
  144662. */
  144663. getClassName(): string;
  144664. /**
  144665. * Gets the world position component
  144666. */
  144667. get worldPosition(): NodeMaterialConnectionPoint;
  144668. /**
  144669. * Gets the camera position component
  144670. */
  144671. get cameraPosition(): NodeMaterialConnectionPoint;
  144672. /**
  144673. * Gets the output component
  144674. */
  144675. get output(): NodeMaterialConnectionPoint;
  144676. autoConfigure(material: NodeMaterial): void;
  144677. protected _buildBlock(state: NodeMaterialBuildState): this;
  144678. }
  144679. }
  144680. declare module BABYLON {
  144681. /**
  144682. * Block used to compute fresnel value
  144683. */
  144684. export class FresnelBlock extends NodeMaterialBlock {
  144685. /**
  144686. * Create a new FresnelBlock
  144687. * @param name defines the block name
  144688. */
  144689. constructor(name: string);
  144690. /**
  144691. * Gets the current class name
  144692. * @returns the class name
  144693. */
  144694. getClassName(): string;
  144695. /**
  144696. * Gets the world normal input component
  144697. */
  144698. get worldNormal(): NodeMaterialConnectionPoint;
  144699. /**
  144700. * Gets the view direction input component
  144701. */
  144702. get viewDirection(): NodeMaterialConnectionPoint;
  144703. /**
  144704. * Gets the bias input component
  144705. */
  144706. get bias(): NodeMaterialConnectionPoint;
  144707. /**
  144708. * Gets the camera (or eye) position component
  144709. */
  144710. get power(): NodeMaterialConnectionPoint;
  144711. /**
  144712. * Gets the fresnel output component
  144713. */
  144714. get fresnel(): NodeMaterialConnectionPoint;
  144715. autoConfigure(material: NodeMaterial): void;
  144716. protected _buildBlock(state: NodeMaterialBuildState): this;
  144717. }
  144718. }
  144719. declare module BABYLON {
  144720. /**
  144721. * Block used to get the max of 2 values
  144722. */
  144723. export class MaxBlock extends NodeMaterialBlock {
  144724. /**
  144725. * Creates a new MaxBlock
  144726. * @param name defines the block name
  144727. */
  144728. constructor(name: string);
  144729. /**
  144730. * Gets the current class name
  144731. * @returns the class name
  144732. */
  144733. getClassName(): string;
  144734. /**
  144735. * Gets the left operand input component
  144736. */
  144737. get left(): NodeMaterialConnectionPoint;
  144738. /**
  144739. * Gets the right operand input component
  144740. */
  144741. get right(): NodeMaterialConnectionPoint;
  144742. /**
  144743. * Gets the output component
  144744. */
  144745. get output(): NodeMaterialConnectionPoint;
  144746. protected _buildBlock(state: NodeMaterialBuildState): this;
  144747. }
  144748. }
  144749. declare module BABYLON {
  144750. /**
  144751. * Block used to get the min of 2 values
  144752. */
  144753. export class MinBlock extends NodeMaterialBlock {
  144754. /**
  144755. * Creates a new MinBlock
  144756. * @param name defines the block name
  144757. */
  144758. constructor(name: string);
  144759. /**
  144760. * Gets the current class name
  144761. * @returns the class name
  144762. */
  144763. getClassName(): string;
  144764. /**
  144765. * Gets the left operand input component
  144766. */
  144767. get left(): NodeMaterialConnectionPoint;
  144768. /**
  144769. * Gets the right operand input component
  144770. */
  144771. get right(): NodeMaterialConnectionPoint;
  144772. /**
  144773. * Gets the output component
  144774. */
  144775. get output(): NodeMaterialConnectionPoint;
  144776. protected _buildBlock(state: NodeMaterialBuildState): this;
  144777. }
  144778. }
  144779. declare module BABYLON {
  144780. /**
  144781. * Block used to get the distance between 2 values
  144782. */
  144783. export class DistanceBlock extends NodeMaterialBlock {
  144784. /**
  144785. * Creates a new DistanceBlock
  144786. * @param name defines the block name
  144787. */
  144788. constructor(name: string);
  144789. /**
  144790. * Gets the current class name
  144791. * @returns the class name
  144792. */
  144793. getClassName(): string;
  144794. /**
  144795. * Gets the left operand input component
  144796. */
  144797. get left(): NodeMaterialConnectionPoint;
  144798. /**
  144799. * Gets the right operand input component
  144800. */
  144801. get right(): NodeMaterialConnectionPoint;
  144802. /**
  144803. * Gets the output component
  144804. */
  144805. get output(): NodeMaterialConnectionPoint;
  144806. protected _buildBlock(state: NodeMaterialBuildState): this;
  144807. }
  144808. }
  144809. declare module BABYLON {
  144810. /**
  144811. * Block used to get the length of a vector
  144812. */
  144813. export class LengthBlock extends NodeMaterialBlock {
  144814. /**
  144815. * Creates a new LengthBlock
  144816. * @param name defines the block name
  144817. */
  144818. constructor(name: string);
  144819. /**
  144820. * Gets the current class name
  144821. * @returns the class name
  144822. */
  144823. getClassName(): string;
  144824. /**
  144825. * Gets the value input component
  144826. */
  144827. get value(): NodeMaterialConnectionPoint;
  144828. /**
  144829. * Gets the output component
  144830. */
  144831. get output(): NodeMaterialConnectionPoint;
  144832. protected _buildBlock(state: NodeMaterialBuildState): this;
  144833. }
  144834. }
  144835. declare module BABYLON {
  144836. /**
  144837. * Block used to get negative version of a value (i.e. x * -1)
  144838. */
  144839. export class NegateBlock extends NodeMaterialBlock {
  144840. /**
  144841. * Creates a new NegateBlock
  144842. * @param name defines the block name
  144843. */
  144844. constructor(name: string);
  144845. /**
  144846. * Gets the current class name
  144847. * @returns the class name
  144848. */
  144849. getClassName(): string;
  144850. /**
  144851. * Gets the value input component
  144852. */
  144853. get value(): NodeMaterialConnectionPoint;
  144854. /**
  144855. * Gets the output component
  144856. */
  144857. get output(): NodeMaterialConnectionPoint;
  144858. protected _buildBlock(state: NodeMaterialBuildState): this;
  144859. }
  144860. }
  144861. declare module BABYLON {
  144862. /**
  144863. * Block used to get the value of the first parameter raised to the power of the second
  144864. */
  144865. export class PowBlock extends NodeMaterialBlock {
  144866. /**
  144867. * Creates a new PowBlock
  144868. * @param name defines the block name
  144869. */
  144870. constructor(name: string);
  144871. /**
  144872. * Gets the current class name
  144873. * @returns the class name
  144874. */
  144875. getClassName(): string;
  144876. /**
  144877. * Gets the value operand input component
  144878. */
  144879. get value(): NodeMaterialConnectionPoint;
  144880. /**
  144881. * Gets the power operand input component
  144882. */
  144883. get power(): NodeMaterialConnectionPoint;
  144884. /**
  144885. * Gets the output component
  144886. */
  144887. get output(): NodeMaterialConnectionPoint;
  144888. protected _buildBlock(state: NodeMaterialBuildState): this;
  144889. }
  144890. }
  144891. declare module BABYLON {
  144892. /**
  144893. * Block used to get a random number
  144894. */
  144895. export class RandomNumberBlock extends NodeMaterialBlock {
  144896. /**
  144897. * Creates a new RandomNumberBlock
  144898. * @param name defines the block name
  144899. */
  144900. constructor(name: string);
  144901. /**
  144902. * Gets the current class name
  144903. * @returns the class name
  144904. */
  144905. getClassName(): string;
  144906. /**
  144907. * Gets the seed input component
  144908. */
  144909. get seed(): NodeMaterialConnectionPoint;
  144910. /**
  144911. * Gets the output component
  144912. */
  144913. get output(): NodeMaterialConnectionPoint;
  144914. protected _buildBlock(state: NodeMaterialBuildState): this;
  144915. }
  144916. }
  144917. declare module BABYLON {
  144918. /**
  144919. * Block used to compute arc tangent of 2 values
  144920. */
  144921. export class ArcTan2Block extends NodeMaterialBlock {
  144922. /**
  144923. * Creates a new ArcTan2Block
  144924. * @param name defines the block name
  144925. */
  144926. constructor(name: string);
  144927. /**
  144928. * Gets the current class name
  144929. * @returns the class name
  144930. */
  144931. getClassName(): string;
  144932. /**
  144933. * Gets the x operand input component
  144934. */
  144935. get x(): NodeMaterialConnectionPoint;
  144936. /**
  144937. * Gets the y operand input component
  144938. */
  144939. get y(): NodeMaterialConnectionPoint;
  144940. /**
  144941. * Gets the output component
  144942. */
  144943. get output(): NodeMaterialConnectionPoint;
  144944. protected _buildBlock(state: NodeMaterialBuildState): this;
  144945. }
  144946. }
  144947. declare module BABYLON {
  144948. /**
  144949. * Block used to smooth step a value
  144950. */
  144951. export class SmoothStepBlock extends NodeMaterialBlock {
  144952. /**
  144953. * Creates a new SmoothStepBlock
  144954. * @param name defines the block name
  144955. */
  144956. constructor(name: string);
  144957. /**
  144958. * Gets the current class name
  144959. * @returns the class name
  144960. */
  144961. getClassName(): string;
  144962. /**
  144963. * Gets the value operand input component
  144964. */
  144965. get value(): NodeMaterialConnectionPoint;
  144966. /**
  144967. * Gets the first edge operand input component
  144968. */
  144969. get edge0(): NodeMaterialConnectionPoint;
  144970. /**
  144971. * Gets the second edge operand input component
  144972. */
  144973. get edge1(): NodeMaterialConnectionPoint;
  144974. /**
  144975. * Gets the output component
  144976. */
  144977. get output(): NodeMaterialConnectionPoint;
  144978. protected _buildBlock(state: NodeMaterialBuildState): this;
  144979. }
  144980. }
  144981. declare module BABYLON {
  144982. /**
  144983. * Block used to get the reciprocal (1 / x) of a value
  144984. */
  144985. export class ReciprocalBlock extends NodeMaterialBlock {
  144986. /**
  144987. * Creates a new ReciprocalBlock
  144988. * @param name defines the block name
  144989. */
  144990. constructor(name: string);
  144991. /**
  144992. * Gets the current class name
  144993. * @returns the class name
  144994. */
  144995. getClassName(): string;
  144996. /**
  144997. * Gets the input component
  144998. */
  144999. get input(): NodeMaterialConnectionPoint;
  145000. /**
  145001. * Gets the output component
  145002. */
  145003. get output(): NodeMaterialConnectionPoint;
  145004. protected _buildBlock(state: NodeMaterialBuildState): this;
  145005. }
  145006. }
  145007. declare module BABYLON {
  145008. /**
  145009. * Block used to replace a color by another one
  145010. */
  145011. export class ReplaceColorBlock extends NodeMaterialBlock {
  145012. /**
  145013. * Creates a new ReplaceColorBlock
  145014. * @param name defines the block name
  145015. */
  145016. constructor(name: string);
  145017. /**
  145018. * Gets the current class name
  145019. * @returns the class name
  145020. */
  145021. getClassName(): string;
  145022. /**
  145023. * Gets the value input component
  145024. */
  145025. get value(): NodeMaterialConnectionPoint;
  145026. /**
  145027. * Gets the reference input component
  145028. */
  145029. get reference(): NodeMaterialConnectionPoint;
  145030. /**
  145031. * Gets the distance input component
  145032. */
  145033. get distance(): NodeMaterialConnectionPoint;
  145034. /**
  145035. * Gets the replacement input component
  145036. */
  145037. get replacement(): NodeMaterialConnectionPoint;
  145038. /**
  145039. * Gets the output component
  145040. */
  145041. get output(): NodeMaterialConnectionPoint;
  145042. protected _buildBlock(state: NodeMaterialBuildState): this;
  145043. }
  145044. }
  145045. declare module BABYLON {
  145046. /**
  145047. * Block used to posterize a value
  145048. * @see https://en.wikipedia.org/wiki/Posterization
  145049. */
  145050. export class PosterizeBlock extends NodeMaterialBlock {
  145051. /**
  145052. * Creates a new PosterizeBlock
  145053. * @param name defines the block name
  145054. */
  145055. constructor(name: string);
  145056. /**
  145057. * Gets the current class name
  145058. * @returns the class name
  145059. */
  145060. getClassName(): string;
  145061. /**
  145062. * Gets the value input component
  145063. */
  145064. get value(): NodeMaterialConnectionPoint;
  145065. /**
  145066. * Gets the steps input component
  145067. */
  145068. get steps(): NodeMaterialConnectionPoint;
  145069. /**
  145070. * Gets the output component
  145071. */
  145072. get output(): NodeMaterialConnectionPoint;
  145073. protected _buildBlock(state: NodeMaterialBuildState): this;
  145074. }
  145075. }
  145076. declare module BABYLON {
  145077. /**
  145078. * Operations supported by the Wave block
  145079. */
  145080. export enum WaveBlockKind {
  145081. /** SawTooth */
  145082. SawTooth = 0,
  145083. /** Square */
  145084. Square = 1,
  145085. /** Triangle */
  145086. Triangle = 2
  145087. }
  145088. /**
  145089. * Block used to apply wave operation to floats
  145090. */
  145091. export class WaveBlock extends NodeMaterialBlock {
  145092. /**
  145093. * Gets or sets the kibnd of wave to be applied by the block
  145094. */
  145095. kind: WaveBlockKind;
  145096. /**
  145097. * Creates a new WaveBlock
  145098. * @param name defines the block name
  145099. */
  145100. constructor(name: string);
  145101. /**
  145102. * Gets the current class name
  145103. * @returns the class name
  145104. */
  145105. getClassName(): string;
  145106. /**
  145107. * Gets the input component
  145108. */
  145109. get input(): NodeMaterialConnectionPoint;
  145110. /**
  145111. * Gets the output component
  145112. */
  145113. get output(): NodeMaterialConnectionPoint;
  145114. protected _buildBlock(state: NodeMaterialBuildState): this;
  145115. serialize(): any;
  145116. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145117. }
  145118. }
  145119. declare module BABYLON {
  145120. /**
  145121. * Class used to store a color step for the GradientBlock
  145122. */
  145123. export class GradientBlockColorStep {
  145124. private _step;
  145125. /**
  145126. * Gets value indicating which step this color is associated with (between 0 and 1)
  145127. */
  145128. get step(): number;
  145129. /**
  145130. * Sets a value indicating which step this color is associated with (between 0 and 1)
  145131. */
  145132. set step(val: number);
  145133. private _color;
  145134. /**
  145135. * Gets the color associated with this step
  145136. */
  145137. get color(): Color3;
  145138. /**
  145139. * Sets the color associated with this step
  145140. */
  145141. set color(val: Color3);
  145142. /**
  145143. * Creates a new GradientBlockColorStep
  145144. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  145145. * @param color defines the color associated with this step
  145146. */
  145147. constructor(step: number, color: Color3);
  145148. }
  145149. /**
  145150. * Block used to return a color from a gradient based on an input value between 0 and 1
  145151. */
  145152. export class GradientBlock extends NodeMaterialBlock {
  145153. /**
  145154. * Gets or sets the list of color steps
  145155. */
  145156. colorSteps: GradientBlockColorStep[];
  145157. /** Gets an observable raised when the value is changed */
  145158. onValueChangedObservable: Observable<GradientBlock>;
  145159. /** calls observable when the value is changed*/
  145160. colorStepsUpdated(): void;
  145161. /**
  145162. * Creates a new GradientBlock
  145163. * @param name defines the block name
  145164. */
  145165. constructor(name: string);
  145166. /**
  145167. * Gets the current class name
  145168. * @returns the class name
  145169. */
  145170. getClassName(): string;
  145171. /**
  145172. * Gets the gradient input component
  145173. */
  145174. get gradient(): NodeMaterialConnectionPoint;
  145175. /**
  145176. * Gets the output component
  145177. */
  145178. get output(): NodeMaterialConnectionPoint;
  145179. private _writeColorConstant;
  145180. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145181. serialize(): any;
  145182. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145183. protected _dumpPropertiesCode(): string;
  145184. }
  145185. }
  145186. declare module BABYLON {
  145187. /**
  145188. * Block used to normalize lerp between 2 values
  145189. */
  145190. export class NLerpBlock extends NodeMaterialBlock {
  145191. /**
  145192. * Creates a new NLerpBlock
  145193. * @param name defines the block name
  145194. */
  145195. constructor(name: string);
  145196. /**
  145197. * Gets the current class name
  145198. * @returns the class name
  145199. */
  145200. getClassName(): string;
  145201. /**
  145202. * Gets the left operand input component
  145203. */
  145204. get left(): NodeMaterialConnectionPoint;
  145205. /**
  145206. * Gets the right operand input component
  145207. */
  145208. get right(): NodeMaterialConnectionPoint;
  145209. /**
  145210. * Gets the gradient operand input component
  145211. */
  145212. get gradient(): NodeMaterialConnectionPoint;
  145213. /**
  145214. * Gets the output component
  145215. */
  145216. get output(): NodeMaterialConnectionPoint;
  145217. protected _buildBlock(state: NodeMaterialBuildState): this;
  145218. }
  145219. }
  145220. declare module BABYLON {
  145221. /**
  145222. * block used to Generate a Worley Noise 3D Noise Pattern
  145223. */
  145224. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  145225. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  145226. manhattanDistance: boolean;
  145227. /**
  145228. * Creates a new WorleyNoise3DBlock
  145229. * @param name defines the block name
  145230. */
  145231. constructor(name: string);
  145232. /**
  145233. * Gets the current class name
  145234. * @returns the class name
  145235. */
  145236. getClassName(): string;
  145237. /**
  145238. * Gets the seed input component
  145239. */
  145240. get seed(): NodeMaterialConnectionPoint;
  145241. /**
  145242. * Gets the jitter input component
  145243. */
  145244. get jitter(): NodeMaterialConnectionPoint;
  145245. /**
  145246. * Gets the output component
  145247. */
  145248. get output(): NodeMaterialConnectionPoint;
  145249. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145250. /**
  145251. * Exposes the properties to the UI?
  145252. */
  145253. protected _dumpPropertiesCode(): string;
  145254. /**
  145255. * Exposes the properties to the Seralize?
  145256. */
  145257. serialize(): any;
  145258. /**
  145259. * Exposes the properties to the deseralize?
  145260. */
  145261. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145262. }
  145263. }
  145264. declare module BABYLON {
  145265. /**
  145266. * block used to Generate a Simplex Perlin 3d Noise Pattern
  145267. */
  145268. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  145269. /**
  145270. * Creates a new SimplexPerlin3DBlock
  145271. * @param name defines the block name
  145272. */
  145273. constructor(name: string);
  145274. /**
  145275. * Gets the current class name
  145276. * @returns the class name
  145277. */
  145278. getClassName(): string;
  145279. /**
  145280. * Gets the seed operand input component
  145281. */
  145282. get seed(): NodeMaterialConnectionPoint;
  145283. /**
  145284. * Gets the output component
  145285. */
  145286. get output(): NodeMaterialConnectionPoint;
  145287. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145288. }
  145289. }
  145290. declare module BABYLON {
  145291. /**
  145292. * Block used to blend normals
  145293. */
  145294. export class NormalBlendBlock extends NodeMaterialBlock {
  145295. /**
  145296. * Creates a new NormalBlendBlock
  145297. * @param name defines the block name
  145298. */
  145299. constructor(name: string);
  145300. /**
  145301. * Gets the current class name
  145302. * @returns the class name
  145303. */
  145304. getClassName(): string;
  145305. /**
  145306. * Gets the first input component
  145307. */
  145308. get normalMap0(): NodeMaterialConnectionPoint;
  145309. /**
  145310. * Gets the second input component
  145311. */
  145312. get normalMap1(): NodeMaterialConnectionPoint;
  145313. /**
  145314. * Gets the output component
  145315. */
  145316. get output(): NodeMaterialConnectionPoint;
  145317. protected _buildBlock(state: NodeMaterialBuildState): this;
  145318. }
  145319. }
  145320. declare module BABYLON {
  145321. /**
  145322. * Block used to rotate a 2d vector by a given angle
  145323. */
  145324. export class Rotate2dBlock extends NodeMaterialBlock {
  145325. /**
  145326. * Creates a new Rotate2dBlock
  145327. * @param name defines the block name
  145328. */
  145329. constructor(name: string);
  145330. /**
  145331. * Gets the current class name
  145332. * @returns the class name
  145333. */
  145334. getClassName(): string;
  145335. /**
  145336. * Gets the input vector
  145337. */
  145338. get input(): NodeMaterialConnectionPoint;
  145339. /**
  145340. * Gets the input angle
  145341. */
  145342. get angle(): NodeMaterialConnectionPoint;
  145343. /**
  145344. * Gets the output component
  145345. */
  145346. get output(): NodeMaterialConnectionPoint;
  145347. autoConfigure(material: NodeMaterial): void;
  145348. protected _buildBlock(state: NodeMaterialBuildState): this;
  145349. }
  145350. }
  145351. declare module BABYLON {
  145352. /**
  145353. * Block used to get the reflected vector from a direction and a normal
  145354. */
  145355. export class ReflectBlock extends NodeMaterialBlock {
  145356. /**
  145357. * Creates a new ReflectBlock
  145358. * @param name defines the block name
  145359. */
  145360. constructor(name: string);
  145361. /**
  145362. * Gets the current class name
  145363. * @returns the class name
  145364. */
  145365. getClassName(): string;
  145366. /**
  145367. * Gets the incident component
  145368. */
  145369. get incident(): NodeMaterialConnectionPoint;
  145370. /**
  145371. * Gets the normal component
  145372. */
  145373. get normal(): NodeMaterialConnectionPoint;
  145374. /**
  145375. * Gets the output component
  145376. */
  145377. get output(): NodeMaterialConnectionPoint;
  145378. protected _buildBlock(state: NodeMaterialBuildState): this;
  145379. }
  145380. }
  145381. declare module BABYLON {
  145382. /**
  145383. * Block used to get the refracted vector from a direction and a normal
  145384. */
  145385. export class RefractBlock extends NodeMaterialBlock {
  145386. /**
  145387. * Creates a new RefractBlock
  145388. * @param name defines the block name
  145389. */
  145390. constructor(name: string);
  145391. /**
  145392. * Gets the current class name
  145393. * @returns the class name
  145394. */
  145395. getClassName(): string;
  145396. /**
  145397. * Gets the incident component
  145398. */
  145399. get incident(): NodeMaterialConnectionPoint;
  145400. /**
  145401. * Gets the normal component
  145402. */
  145403. get normal(): NodeMaterialConnectionPoint;
  145404. /**
  145405. * Gets the index of refraction component
  145406. */
  145407. get ior(): NodeMaterialConnectionPoint;
  145408. /**
  145409. * Gets the output component
  145410. */
  145411. get output(): NodeMaterialConnectionPoint;
  145412. protected _buildBlock(state: NodeMaterialBuildState): this;
  145413. }
  145414. }
  145415. declare module BABYLON {
  145416. /**
  145417. * Block used to desaturate a color
  145418. */
  145419. export class DesaturateBlock extends NodeMaterialBlock {
  145420. /**
  145421. * Creates a new DesaturateBlock
  145422. * @param name defines the block name
  145423. */
  145424. constructor(name: string);
  145425. /**
  145426. * Gets the current class name
  145427. * @returns the class name
  145428. */
  145429. getClassName(): string;
  145430. /**
  145431. * Gets the color operand input component
  145432. */
  145433. get color(): NodeMaterialConnectionPoint;
  145434. /**
  145435. * Gets the level operand input component
  145436. */
  145437. get level(): NodeMaterialConnectionPoint;
  145438. /**
  145439. * Gets the output component
  145440. */
  145441. get output(): NodeMaterialConnectionPoint;
  145442. protected _buildBlock(state: NodeMaterialBuildState): this;
  145443. }
  145444. }
  145445. declare module BABYLON {
  145446. /**
  145447. * Block used to implement the ambient occlusion module of the PBR material
  145448. */
  145449. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  145450. /**
  145451. * Create a new AmbientOcclusionBlock
  145452. * @param name defines the block name
  145453. */
  145454. constructor(name: string);
  145455. /**
  145456. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  145457. */
  145458. useAmbientInGrayScale: boolean;
  145459. /**
  145460. * Initialize the block and prepare the context for build
  145461. * @param state defines the state that will be used for the build
  145462. */
  145463. initialize(state: NodeMaterialBuildState): void;
  145464. /**
  145465. * Gets the current class name
  145466. * @returns the class name
  145467. */
  145468. getClassName(): string;
  145469. /**
  145470. * Gets the texture input component
  145471. */
  145472. get texture(): NodeMaterialConnectionPoint;
  145473. /**
  145474. * Gets the texture intensity component
  145475. */
  145476. get intensity(): NodeMaterialConnectionPoint;
  145477. /**
  145478. * Gets the direct light intensity input component
  145479. */
  145480. get directLightIntensity(): NodeMaterialConnectionPoint;
  145481. /**
  145482. * Gets the ambient occlusion object output component
  145483. */
  145484. get ambientOcc(): NodeMaterialConnectionPoint;
  145485. /**
  145486. * Gets the main code of the block (fragment side)
  145487. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  145488. * @returns the shader code
  145489. */
  145490. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  145491. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145492. protected _buildBlock(state: NodeMaterialBuildState): this;
  145493. protected _dumpPropertiesCode(): string;
  145494. serialize(): any;
  145495. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145496. }
  145497. }
  145498. declare module BABYLON {
  145499. /**
  145500. * Block used to implement the reflection module of the PBR material
  145501. */
  145502. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  145503. /** @hidden */
  145504. _defineLODReflectionAlpha: string;
  145505. /** @hidden */
  145506. _defineLinearSpecularReflection: string;
  145507. private _vEnvironmentIrradianceName;
  145508. /** @hidden */
  145509. _vReflectionMicrosurfaceInfosName: string;
  145510. /** @hidden */
  145511. _vReflectionInfosName: string;
  145512. /** @hidden */
  145513. _vReflectionFilteringInfoName: string;
  145514. private _scene;
  145515. /**
  145516. * The three properties below are set by the main PBR block prior to calling methods of this class.
  145517. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145518. * It's less burden on the user side in the editor part.
  145519. */
  145520. /** @hidden */
  145521. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145522. /** @hidden */
  145523. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145524. /** @hidden */
  145525. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  145526. /**
  145527. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  145528. * diffuse part of the IBL.
  145529. */
  145530. useSphericalHarmonics: boolean;
  145531. /**
  145532. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  145533. */
  145534. forceIrradianceInFragment: boolean;
  145535. /**
  145536. * Create a new ReflectionBlock
  145537. * @param name defines the block name
  145538. */
  145539. constructor(name: string);
  145540. /**
  145541. * Gets the current class name
  145542. * @returns the class name
  145543. */
  145544. getClassName(): string;
  145545. /**
  145546. * Gets the position input component
  145547. */
  145548. get position(): NodeMaterialConnectionPoint;
  145549. /**
  145550. * Gets the world position input component
  145551. */
  145552. get worldPosition(): NodeMaterialConnectionPoint;
  145553. /**
  145554. * Gets the world normal input component
  145555. */
  145556. get worldNormal(): NodeMaterialConnectionPoint;
  145557. /**
  145558. * Gets the world input component
  145559. */
  145560. get world(): NodeMaterialConnectionPoint;
  145561. /**
  145562. * Gets the camera (or eye) position component
  145563. */
  145564. get cameraPosition(): NodeMaterialConnectionPoint;
  145565. /**
  145566. * Gets the view input component
  145567. */
  145568. get view(): NodeMaterialConnectionPoint;
  145569. /**
  145570. * Gets the color input component
  145571. */
  145572. get color(): NodeMaterialConnectionPoint;
  145573. /**
  145574. * Gets the reflection object output component
  145575. */
  145576. get reflection(): NodeMaterialConnectionPoint;
  145577. /**
  145578. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  145579. */
  145580. get hasTexture(): boolean;
  145581. /**
  145582. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  145583. */
  145584. get reflectionColor(): string;
  145585. protected _getTexture(): Nullable<BaseTexture>;
  145586. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145587. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145588. /**
  145589. * Gets the code to inject in the vertex shader
  145590. * @param state current state of the node material building
  145591. * @returns the shader code
  145592. */
  145593. handleVertexSide(state: NodeMaterialBuildState): string;
  145594. /**
  145595. * Gets the main code of the block (fragment side)
  145596. * @param state current state of the node material building
  145597. * @param normalVarName name of the existing variable corresponding to the normal
  145598. * @returns the shader code
  145599. */
  145600. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  145601. protected _buildBlock(state: NodeMaterialBuildState): this;
  145602. protected _dumpPropertiesCode(): string;
  145603. serialize(): any;
  145604. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145605. }
  145606. }
  145607. declare module BABYLON {
  145608. /**
  145609. * Block used to implement the sheen module of the PBR material
  145610. */
  145611. export class SheenBlock extends NodeMaterialBlock {
  145612. /**
  145613. * Create a new SheenBlock
  145614. * @param name defines the block name
  145615. */
  145616. constructor(name: string);
  145617. /**
  145618. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  145619. * It allows the strength of the sheen effect to not depend on the base color of the material,
  145620. * making it easier to setup and tweak the effect
  145621. */
  145622. albedoScaling: boolean;
  145623. /**
  145624. * Defines if the sheen is linked to the sheen color.
  145625. */
  145626. linkSheenWithAlbedo: boolean;
  145627. /**
  145628. * Initialize the block and prepare the context for build
  145629. * @param state defines the state that will be used for the build
  145630. */
  145631. initialize(state: NodeMaterialBuildState): void;
  145632. /**
  145633. * Gets the current class name
  145634. * @returns the class name
  145635. */
  145636. getClassName(): string;
  145637. /**
  145638. * Gets the intensity input component
  145639. */
  145640. get intensity(): NodeMaterialConnectionPoint;
  145641. /**
  145642. * Gets the color input component
  145643. */
  145644. get color(): NodeMaterialConnectionPoint;
  145645. /**
  145646. * Gets the roughness input component
  145647. */
  145648. get roughness(): NodeMaterialConnectionPoint;
  145649. /**
  145650. * Gets the sheen object output component
  145651. */
  145652. get sheen(): NodeMaterialConnectionPoint;
  145653. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145654. /**
  145655. * Gets the main code of the block (fragment side)
  145656. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145657. * @returns the shader code
  145658. */
  145659. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  145660. protected _buildBlock(state: NodeMaterialBuildState): this;
  145661. protected _dumpPropertiesCode(): string;
  145662. serialize(): any;
  145663. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145664. }
  145665. }
  145666. declare module BABYLON {
  145667. /**
  145668. * Block used to implement the reflectivity module of the PBR material
  145669. */
  145670. export class ReflectivityBlock extends NodeMaterialBlock {
  145671. private _metallicReflectanceColor;
  145672. private _metallicF0Factor;
  145673. /** @hidden */
  145674. _vMetallicReflectanceFactorsName: string;
  145675. /**
  145676. * The property below is set by the main PBR block prior to calling methods of this class.
  145677. */
  145678. /** @hidden */
  145679. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  145680. /**
  145681. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  145682. */
  145683. useAmbientOcclusionFromMetallicTextureRed: boolean;
  145684. /**
  145685. * Specifies if the metallic texture contains the metallness information in its blue channel.
  145686. */
  145687. useMetallnessFromMetallicTextureBlue: boolean;
  145688. /**
  145689. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  145690. */
  145691. useRoughnessFromMetallicTextureAlpha: boolean;
  145692. /**
  145693. * Specifies if the metallic texture contains the roughness information in its green channel.
  145694. */
  145695. useRoughnessFromMetallicTextureGreen: boolean;
  145696. /**
  145697. * Create a new ReflectivityBlock
  145698. * @param name defines the block name
  145699. */
  145700. constructor(name: string);
  145701. /**
  145702. * Initialize the block and prepare the context for build
  145703. * @param state defines the state that will be used for the build
  145704. */
  145705. initialize(state: NodeMaterialBuildState): void;
  145706. /**
  145707. * Gets the current class name
  145708. * @returns the class name
  145709. */
  145710. getClassName(): string;
  145711. /**
  145712. * Gets the metallic input component
  145713. */
  145714. get metallic(): NodeMaterialConnectionPoint;
  145715. /**
  145716. * Gets the roughness input component
  145717. */
  145718. get roughness(): NodeMaterialConnectionPoint;
  145719. /**
  145720. * Gets the texture input component
  145721. */
  145722. get texture(): NodeMaterialConnectionPoint;
  145723. /**
  145724. * Gets the reflectivity object output component
  145725. */
  145726. get reflectivity(): NodeMaterialConnectionPoint;
  145727. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145728. /**
  145729. * Gets the main code of the block (fragment side)
  145730. * @param state current state of the node material building
  145731. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  145732. * @returns the shader code
  145733. */
  145734. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  145735. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145736. protected _buildBlock(state: NodeMaterialBuildState): this;
  145737. protected _dumpPropertiesCode(): string;
  145738. serialize(): any;
  145739. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145740. }
  145741. }
  145742. declare module BABYLON {
  145743. /**
  145744. * Block used to implement the anisotropy module of the PBR material
  145745. */
  145746. export class AnisotropyBlock extends NodeMaterialBlock {
  145747. /**
  145748. * The two properties below are set by the main PBR block prior to calling methods of this class.
  145749. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145750. * It's less burden on the user side in the editor part.
  145751. */
  145752. /** @hidden */
  145753. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145754. /** @hidden */
  145755. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145756. /**
  145757. * Create a new AnisotropyBlock
  145758. * @param name defines the block name
  145759. */
  145760. constructor(name: string);
  145761. /**
  145762. * Initialize the block and prepare the context for build
  145763. * @param state defines the state that will be used for the build
  145764. */
  145765. initialize(state: NodeMaterialBuildState): void;
  145766. /**
  145767. * Gets the current class name
  145768. * @returns the class name
  145769. */
  145770. getClassName(): string;
  145771. /**
  145772. * Gets the intensity input component
  145773. */
  145774. get intensity(): NodeMaterialConnectionPoint;
  145775. /**
  145776. * Gets the direction input component
  145777. */
  145778. get direction(): NodeMaterialConnectionPoint;
  145779. /**
  145780. * Gets the texture input component
  145781. */
  145782. get texture(): NodeMaterialConnectionPoint;
  145783. /**
  145784. * Gets the uv input component
  145785. */
  145786. get uv(): NodeMaterialConnectionPoint;
  145787. /**
  145788. * Gets the worldTangent input component
  145789. */
  145790. get worldTangent(): NodeMaterialConnectionPoint;
  145791. /**
  145792. * Gets the anisotropy object output component
  145793. */
  145794. get anisotropy(): NodeMaterialConnectionPoint;
  145795. private _generateTBNSpace;
  145796. /**
  145797. * Gets the main code of the block (fragment side)
  145798. * @param state current state of the node material building
  145799. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145800. * @returns the shader code
  145801. */
  145802. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  145803. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145804. protected _buildBlock(state: NodeMaterialBuildState): this;
  145805. }
  145806. }
  145807. declare module BABYLON {
  145808. /**
  145809. * Block used to implement the clear coat module of the PBR material
  145810. */
  145811. export class ClearCoatBlock extends NodeMaterialBlock {
  145812. private _scene;
  145813. /**
  145814. * Create a new ClearCoatBlock
  145815. * @param name defines the block name
  145816. */
  145817. constructor(name: string);
  145818. /**
  145819. * Initialize the block and prepare the context for build
  145820. * @param state defines the state that will be used for the build
  145821. */
  145822. initialize(state: NodeMaterialBuildState): void;
  145823. /**
  145824. * Gets the current class name
  145825. * @returns the class name
  145826. */
  145827. getClassName(): string;
  145828. /**
  145829. * Gets the intensity input component
  145830. */
  145831. get intensity(): NodeMaterialConnectionPoint;
  145832. /**
  145833. * Gets the roughness input component
  145834. */
  145835. get roughness(): NodeMaterialConnectionPoint;
  145836. /**
  145837. * Gets the ior input component
  145838. */
  145839. get ior(): NodeMaterialConnectionPoint;
  145840. /**
  145841. * Gets the texture input component
  145842. */
  145843. get texture(): NodeMaterialConnectionPoint;
  145844. /**
  145845. * Gets the bump texture input component
  145846. */
  145847. get bumpTexture(): NodeMaterialConnectionPoint;
  145848. /**
  145849. * Gets the uv input component
  145850. */
  145851. get uv(): NodeMaterialConnectionPoint;
  145852. /**
  145853. * Gets the tint color input component
  145854. */
  145855. get tintColor(): NodeMaterialConnectionPoint;
  145856. /**
  145857. * Gets the tint "at distance" input component
  145858. */
  145859. get tintAtDistance(): NodeMaterialConnectionPoint;
  145860. /**
  145861. * Gets the tint thickness input component
  145862. */
  145863. get tintThickness(): NodeMaterialConnectionPoint;
  145864. /**
  145865. * Gets the world tangent input component
  145866. */
  145867. get worldTangent(): NodeMaterialConnectionPoint;
  145868. /**
  145869. * Gets the clear coat object output component
  145870. */
  145871. get clearcoat(): NodeMaterialConnectionPoint;
  145872. autoConfigure(material: NodeMaterial): void;
  145873. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145874. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145875. private _generateTBNSpace;
  145876. /**
  145877. * Gets the main code of the block (fragment side)
  145878. * @param state current state of the node material building
  145879. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  145880. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145881. * @param worldPosVarName name of the variable holding the world position
  145882. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145883. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  145884. * @param worldNormalVarName name of the variable holding the world normal
  145885. * @returns the shader code
  145886. */
  145887. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  145888. protected _buildBlock(state: NodeMaterialBuildState): this;
  145889. }
  145890. }
  145891. declare module BABYLON {
  145892. /**
  145893. * Block used to implement the sub surface module of the PBR material
  145894. */
  145895. export class SubSurfaceBlock extends NodeMaterialBlock {
  145896. /**
  145897. * Create a new SubSurfaceBlock
  145898. * @param name defines the block name
  145899. */
  145900. constructor(name: string);
  145901. /**
  145902. * Stores the intensity of the different subsurface effects in the thickness texture.
  145903. * * the green channel is the translucency intensity.
  145904. * * the blue channel is the scattering intensity.
  145905. * * the alpha channel is the refraction intensity.
  145906. */
  145907. useMaskFromThicknessTexture: boolean;
  145908. /**
  145909. * Initialize the block and prepare the context for build
  145910. * @param state defines the state that will be used for the build
  145911. */
  145912. initialize(state: NodeMaterialBuildState): void;
  145913. /**
  145914. * Gets the current class name
  145915. * @returns the class name
  145916. */
  145917. getClassName(): string;
  145918. /**
  145919. * Gets the min thickness input component
  145920. */
  145921. get minThickness(): NodeMaterialConnectionPoint;
  145922. /**
  145923. * Gets the max thickness input component
  145924. */
  145925. get maxThickness(): NodeMaterialConnectionPoint;
  145926. /**
  145927. * Gets the thickness texture component
  145928. */
  145929. get thicknessTexture(): NodeMaterialConnectionPoint;
  145930. /**
  145931. * Gets the tint color input component
  145932. */
  145933. get tintColor(): NodeMaterialConnectionPoint;
  145934. /**
  145935. * Gets the translucency intensity input component
  145936. */
  145937. get translucencyIntensity(): NodeMaterialConnectionPoint;
  145938. /**
  145939. * Gets the translucency diffusion distance input component
  145940. */
  145941. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  145942. /**
  145943. * Gets the refraction object parameters
  145944. */
  145945. get refraction(): NodeMaterialConnectionPoint;
  145946. /**
  145947. * Gets the sub surface object output component
  145948. */
  145949. get subsurface(): NodeMaterialConnectionPoint;
  145950. autoConfigure(material: NodeMaterial): void;
  145951. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145952. /**
  145953. * Gets the main code of the block (fragment side)
  145954. * @param state current state of the node material building
  145955. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  145956. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145957. * @param worldPosVarName name of the variable holding the world position
  145958. * @returns the shader code
  145959. */
  145960. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  145961. protected _buildBlock(state: NodeMaterialBuildState): this;
  145962. }
  145963. }
  145964. declare module BABYLON {
  145965. /**
  145966. * Block used to implement the PBR metallic/roughness model
  145967. */
  145968. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  145969. /**
  145970. * Gets or sets the light associated with this block
  145971. */
  145972. light: Nullable<Light>;
  145973. private _lightId;
  145974. private _scene;
  145975. private _environmentBRDFTexture;
  145976. private _environmentBrdfSamplerName;
  145977. private _vNormalWName;
  145978. private _invertNormalName;
  145979. /**
  145980. * Create a new ReflectionBlock
  145981. * @param name defines the block name
  145982. */
  145983. constructor(name: string);
  145984. /**
  145985. * Intensity of the direct lights e.g. the four lights available in your scene.
  145986. * This impacts both the direct diffuse and specular highlights.
  145987. */
  145988. directIntensity: number;
  145989. /**
  145990. * Intensity of the environment e.g. how much the environment will light the object
  145991. * either through harmonics for rough material or through the refelction for shiny ones.
  145992. */
  145993. environmentIntensity: number;
  145994. /**
  145995. * This is a special control allowing the reduction of the specular highlights coming from the
  145996. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  145997. */
  145998. specularIntensity: number;
  145999. /**
  146000. * Defines the falloff type used in this material.
  146001. * It by default is Physical.
  146002. */
  146003. lightFalloff: number;
  146004. /**
  146005. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  146006. */
  146007. useAlphaFromAlbedoTexture: boolean;
  146008. /**
  146009. * Specifies that alpha test should be used
  146010. */
  146011. useAlphaTest: boolean;
  146012. /**
  146013. * Defines the alpha limits in alpha test mode.
  146014. */
  146015. alphaTestCutoff: number;
  146016. /**
  146017. * Specifies that alpha blending should be used
  146018. */
  146019. useAlphaBlending: boolean;
  146020. /**
  146021. * Defines if the alpha value should be determined via the rgb values.
  146022. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  146023. */
  146024. opacityRGB: boolean;
  146025. /**
  146026. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  146027. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  146028. */
  146029. useRadianceOverAlpha: boolean;
  146030. /**
  146031. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  146032. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  146033. */
  146034. useSpecularOverAlpha: boolean;
  146035. /**
  146036. * Enables specular anti aliasing in the PBR shader.
  146037. * It will both interacts on the Geometry for analytical and IBL lighting.
  146038. * It also prefilter the roughness map based on the bump values.
  146039. */
  146040. enableSpecularAntiAliasing: boolean;
  146041. /**
  146042. * Enables realtime filtering on the texture.
  146043. */
  146044. realTimeFiltering: boolean;
  146045. /**
  146046. * Quality switch for realtime filtering
  146047. */
  146048. realTimeFilteringQuality: number;
  146049. /**
  146050. * Defines if the material uses energy conservation.
  146051. */
  146052. useEnergyConservation: boolean;
  146053. /**
  146054. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  146055. * too much the area relying on ambient texture to define their ambient occlusion.
  146056. */
  146057. useRadianceOcclusion: boolean;
  146058. /**
  146059. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  146060. * makes the reflect vector face the model (under horizon).
  146061. */
  146062. useHorizonOcclusion: boolean;
  146063. /**
  146064. * If set to true, no lighting calculations will be applied.
  146065. */
  146066. unlit: boolean;
  146067. /**
  146068. * Force normal to face away from face.
  146069. */
  146070. forceNormalForward: boolean;
  146071. /**
  146072. * Defines the material debug mode.
  146073. * It helps seeing only some components of the material while troubleshooting.
  146074. */
  146075. debugMode: number;
  146076. /**
  146077. * Specify from where on screen the debug mode should start.
  146078. * The value goes from -1 (full screen) to 1 (not visible)
  146079. * It helps with side by side comparison against the final render
  146080. * This defaults to 0
  146081. */
  146082. debugLimit: number;
  146083. /**
  146084. * As the default viewing range might not be enough (if the ambient is really small for instance)
  146085. * You can use the factor to better multiply the final value.
  146086. */
  146087. debugFactor: number;
  146088. /**
  146089. * Initialize the block and prepare the context for build
  146090. * @param state defines the state that will be used for the build
  146091. */
  146092. initialize(state: NodeMaterialBuildState): void;
  146093. /**
  146094. * Gets the current class name
  146095. * @returns the class name
  146096. */
  146097. getClassName(): string;
  146098. /**
  146099. * Gets the world position input component
  146100. */
  146101. get worldPosition(): NodeMaterialConnectionPoint;
  146102. /**
  146103. * Gets the world normal input component
  146104. */
  146105. get worldNormal(): NodeMaterialConnectionPoint;
  146106. /**
  146107. * Gets the perturbed normal input component
  146108. */
  146109. get perturbedNormal(): NodeMaterialConnectionPoint;
  146110. /**
  146111. * Gets the camera position input component
  146112. */
  146113. get cameraPosition(): NodeMaterialConnectionPoint;
  146114. /**
  146115. * Gets the base color input component
  146116. */
  146117. get baseColor(): NodeMaterialConnectionPoint;
  146118. /**
  146119. * Gets the opacity texture input component
  146120. */
  146121. get opacityTexture(): NodeMaterialConnectionPoint;
  146122. /**
  146123. * Gets the ambient color input component
  146124. */
  146125. get ambientColor(): NodeMaterialConnectionPoint;
  146126. /**
  146127. * Gets the reflectivity object parameters
  146128. */
  146129. get reflectivity(): NodeMaterialConnectionPoint;
  146130. /**
  146131. * Gets the ambient occlusion object parameters
  146132. */
  146133. get ambientOcc(): NodeMaterialConnectionPoint;
  146134. /**
  146135. * Gets the reflection object parameters
  146136. */
  146137. get reflection(): NodeMaterialConnectionPoint;
  146138. /**
  146139. * Gets the sheen object parameters
  146140. */
  146141. get sheen(): NodeMaterialConnectionPoint;
  146142. /**
  146143. * Gets the clear coat object parameters
  146144. */
  146145. get clearcoat(): NodeMaterialConnectionPoint;
  146146. /**
  146147. * Gets the sub surface object parameters
  146148. */
  146149. get subsurface(): NodeMaterialConnectionPoint;
  146150. /**
  146151. * Gets the anisotropy object parameters
  146152. */
  146153. get anisotropy(): NodeMaterialConnectionPoint;
  146154. /**
  146155. * Gets the ambient output component
  146156. */
  146157. get ambient(): NodeMaterialConnectionPoint;
  146158. /**
  146159. * Gets the diffuse output component
  146160. */
  146161. get diffuse(): NodeMaterialConnectionPoint;
  146162. /**
  146163. * Gets the specular output component
  146164. */
  146165. get specular(): NodeMaterialConnectionPoint;
  146166. /**
  146167. * Gets the sheen output component
  146168. */
  146169. get sheenDir(): NodeMaterialConnectionPoint;
  146170. /**
  146171. * Gets the clear coat output component
  146172. */
  146173. get clearcoatDir(): NodeMaterialConnectionPoint;
  146174. /**
  146175. * Gets the indirect diffuse output component
  146176. */
  146177. get diffuseIndirect(): NodeMaterialConnectionPoint;
  146178. /**
  146179. * Gets the indirect specular output component
  146180. */
  146181. get specularIndirect(): NodeMaterialConnectionPoint;
  146182. /**
  146183. * Gets the indirect sheen output component
  146184. */
  146185. get sheenIndirect(): NodeMaterialConnectionPoint;
  146186. /**
  146187. * Gets the indirect clear coat output component
  146188. */
  146189. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  146190. /**
  146191. * Gets the refraction output component
  146192. */
  146193. get refraction(): NodeMaterialConnectionPoint;
  146194. /**
  146195. * Gets the global lighting output component
  146196. */
  146197. get lighting(): NodeMaterialConnectionPoint;
  146198. /**
  146199. * Gets the shadow output component
  146200. */
  146201. get shadow(): NodeMaterialConnectionPoint;
  146202. /**
  146203. * Gets the alpha output component
  146204. */
  146205. get alpha(): NodeMaterialConnectionPoint;
  146206. autoConfigure(material: NodeMaterial): void;
  146207. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146208. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  146209. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  146210. private _injectVertexCode;
  146211. /**
  146212. * Gets the code corresponding to the albedo/opacity module
  146213. * @returns the shader code
  146214. */
  146215. getAlbedoOpacityCode(): string;
  146216. protected _buildBlock(state: NodeMaterialBuildState): this;
  146217. protected _dumpPropertiesCode(): string;
  146218. serialize(): any;
  146219. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146220. }
  146221. }
  146222. declare module BABYLON {
  146223. /**
  146224. * Block used to compute value of one parameter modulo another
  146225. */
  146226. export class ModBlock extends NodeMaterialBlock {
  146227. /**
  146228. * Creates a new ModBlock
  146229. * @param name defines the block name
  146230. */
  146231. constructor(name: string);
  146232. /**
  146233. * Gets the current class name
  146234. * @returns the class name
  146235. */
  146236. getClassName(): string;
  146237. /**
  146238. * Gets the left operand input component
  146239. */
  146240. get left(): NodeMaterialConnectionPoint;
  146241. /**
  146242. * Gets the right operand input component
  146243. */
  146244. get right(): NodeMaterialConnectionPoint;
  146245. /**
  146246. * Gets the output component
  146247. */
  146248. get output(): NodeMaterialConnectionPoint;
  146249. protected _buildBlock(state: NodeMaterialBuildState): this;
  146250. }
  146251. }
  146252. declare module BABYLON {
  146253. /**
  146254. * Configuration for Draco compression
  146255. */
  146256. export interface IDracoCompressionConfiguration {
  146257. /**
  146258. * Configuration for the decoder.
  146259. */
  146260. decoder: {
  146261. /**
  146262. * The url to the WebAssembly module.
  146263. */
  146264. wasmUrl?: string;
  146265. /**
  146266. * The url to the WebAssembly binary.
  146267. */
  146268. wasmBinaryUrl?: string;
  146269. /**
  146270. * The url to the fallback JavaScript module.
  146271. */
  146272. fallbackUrl?: string;
  146273. };
  146274. }
  146275. /**
  146276. * Draco compression (https://google.github.io/draco/)
  146277. *
  146278. * This class wraps the Draco module.
  146279. *
  146280. * **Encoder**
  146281. *
  146282. * The encoder is not currently implemented.
  146283. *
  146284. * **Decoder**
  146285. *
  146286. * 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.
  146287. *
  146288. * To update the configuration, use the following code:
  146289. * ```javascript
  146290. * DracoCompression.Configuration = {
  146291. * decoder: {
  146292. * wasmUrl: "<url to the WebAssembly library>",
  146293. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  146294. * fallbackUrl: "<url to the fallback JavaScript library>",
  146295. * }
  146296. * };
  146297. * ```
  146298. *
  146299. * 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.
  146300. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  146301. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  146302. *
  146303. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  146304. * ```javascript
  146305. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  146306. * ```
  146307. *
  146308. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  146309. */
  146310. export class DracoCompression implements IDisposable {
  146311. private _workerPoolPromise?;
  146312. private _decoderModulePromise?;
  146313. /**
  146314. * The configuration. Defaults to the following urls:
  146315. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  146316. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  146317. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  146318. */
  146319. static Configuration: IDracoCompressionConfiguration;
  146320. /**
  146321. * Returns true if the decoder configuration is available.
  146322. */
  146323. static get DecoderAvailable(): boolean;
  146324. /**
  146325. * Default number of workers to create when creating the draco compression object.
  146326. */
  146327. static DefaultNumWorkers: number;
  146328. private static GetDefaultNumWorkers;
  146329. private static _Default;
  146330. /**
  146331. * Default instance for the draco compression object.
  146332. */
  146333. static get Default(): DracoCompression;
  146334. /**
  146335. * Constructor
  146336. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  146337. */
  146338. constructor(numWorkers?: number);
  146339. /**
  146340. * Stop all async operations and release resources.
  146341. */
  146342. dispose(): void;
  146343. /**
  146344. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  146345. * @returns a promise that resolves when ready
  146346. */
  146347. whenReadyAsync(): Promise<void>;
  146348. /**
  146349. * Decode Draco compressed mesh data to vertex data.
  146350. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  146351. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  146352. * @returns A promise that resolves with the decoded vertex data
  146353. */
  146354. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  146355. [kind: string]: number;
  146356. }): Promise<VertexData>;
  146357. }
  146358. }
  146359. declare module BABYLON {
  146360. /**
  146361. * Class for building Constructive Solid Geometry
  146362. */
  146363. export class CSG {
  146364. private polygons;
  146365. /**
  146366. * The world matrix
  146367. */
  146368. matrix: Matrix;
  146369. /**
  146370. * Stores the position
  146371. */
  146372. position: Vector3;
  146373. /**
  146374. * Stores the rotation
  146375. */
  146376. rotation: Vector3;
  146377. /**
  146378. * Stores the rotation quaternion
  146379. */
  146380. rotationQuaternion: Nullable<Quaternion>;
  146381. /**
  146382. * Stores the scaling vector
  146383. */
  146384. scaling: Vector3;
  146385. /**
  146386. * Convert the Mesh to CSG
  146387. * @param mesh The Mesh to convert to CSG
  146388. * @returns A new CSG from the Mesh
  146389. */
  146390. static FromMesh(mesh: Mesh): CSG;
  146391. /**
  146392. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  146393. * @param polygons Polygons used to construct a CSG solid
  146394. */
  146395. private static FromPolygons;
  146396. /**
  146397. * Clones, or makes a deep copy, of the CSG
  146398. * @returns A new CSG
  146399. */
  146400. clone(): CSG;
  146401. /**
  146402. * Unions this CSG with another CSG
  146403. * @param csg The CSG to union against this CSG
  146404. * @returns The unioned CSG
  146405. */
  146406. union(csg: CSG): CSG;
  146407. /**
  146408. * Unions this CSG with another CSG in place
  146409. * @param csg The CSG to union against this CSG
  146410. */
  146411. unionInPlace(csg: CSG): void;
  146412. /**
  146413. * Subtracts this CSG with another CSG
  146414. * @param csg The CSG to subtract against this CSG
  146415. * @returns A new CSG
  146416. */
  146417. subtract(csg: CSG): CSG;
  146418. /**
  146419. * Subtracts this CSG with another CSG in place
  146420. * @param csg The CSG to subtact against this CSG
  146421. */
  146422. subtractInPlace(csg: CSG): void;
  146423. /**
  146424. * Intersect this CSG with another CSG
  146425. * @param csg The CSG to intersect against this CSG
  146426. * @returns A new CSG
  146427. */
  146428. intersect(csg: CSG): CSG;
  146429. /**
  146430. * Intersects this CSG with another CSG in place
  146431. * @param csg The CSG to intersect against this CSG
  146432. */
  146433. intersectInPlace(csg: CSG): void;
  146434. /**
  146435. * Return a new CSG solid with solid and empty space switched. This solid is
  146436. * not modified.
  146437. * @returns A new CSG solid with solid and empty space switched
  146438. */
  146439. inverse(): CSG;
  146440. /**
  146441. * Inverses the CSG in place
  146442. */
  146443. inverseInPlace(): void;
  146444. /**
  146445. * This is used to keep meshes transformations so they can be restored
  146446. * when we build back a Babylon Mesh
  146447. * NB : All CSG operations are performed in world coordinates
  146448. * @param csg The CSG to copy the transform attributes from
  146449. * @returns This CSG
  146450. */
  146451. copyTransformAttributes(csg: CSG): CSG;
  146452. /**
  146453. * Build Raw mesh from CSG
  146454. * Coordinates here are in world space
  146455. * @param name The name of the mesh geometry
  146456. * @param scene The Scene
  146457. * @param keepSubMeshes Specifies if the submeshes should be kept
  146458. * @returns A new Mesh
  146459. */
  146460. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146461. /**
  146462. * Build Mesh from CSG taking material and transforms into account
  146463. * @param name The name of the Mesh
  146464. * @param material The material of the Mesh
  146465. * @param scene The Scene
  146466. * @param keepSubMeshes Specifies if submeshes should be kept
  146467. * @returns The new Mesh
  146468. */
  146469. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146470. }
  146471. }
  146472. declare module BABYLON {
  146473. /**
  146474. * Class used to create a trail following a mesh
  146475. */
  146476. export class TrailMesh extends Mesh {
  146477. private _generator;
  146478. private _autoStart;
  146479. private _running;
  146480. private _diameter;
  146481. private _length;
  146482. private _sectionPolygonPointsCount;
  146483. private _sectionVectors;
  146484. private _sectionNormalVectors;
  146485. private _beforeRenderObserver;
  146486. /**
  146487. * @constructor
  146488. * @param name The value used by scene.getMeshByName() to do a lookup.
  146489. * @param generator The mesh or transform node to generate a trail.
  146490. * @param scene The scene to add this mesh to.
  146491. * @param diameter Diameter of trailing mesh. Default is 1.
  146492. * @param length Length of trailing mesh. Default is 60.
  146493. * @param autoStart Automatically start trailing mesh. Default true.
  146494. */
  146495. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  146496. /**
  146497. * "TrailMesh"
  146498. * @returns "TrailMesh"
  146499. */
  146500. getClassName(): string;
  146501. private _createMesh;
  146502. /**
  146503. * Start trailing mesh.
  146504. */
  146505. start(): void;
  146506. /**
  146507. * Stop trailing mesh.
  146508. */
  146509. stop(): void;
  146510. /**
  146511. * Update trailing mesh geometry.
  146512. */
  146513. update(): void;
  146514. /**
  146515. * Returns a new TrailMesh object.
  146516. * @param name is a string, the name given to the new mesh
  146517. * @param newGenerator use new generator object for cloned trail mesh
  146518. * @returns a new mesh
  146519. */
  146520. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  146521. /**
  146522. * Serializes this trail mesh
  146523. * @param serializationObject object to write serialization to
  146524. */
  146525. serialize(serializationObject: any): void;
  146526. /**
  146527. * Parses a serialized trail mesh
  146528. * @param parsedMesh the serialized mesh
  146529. * @param scene the scene to create the trail mesh in
  146530. * @returns the created trail mesh
  146531. */
  146532. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  146533. }
  146534. }
  146535. declare module BABYLON {
  146536. /**
  146537. * Class containing static functions to help procedurally build meshes
  146538. */
  146539. export class TiledBoxBuilder {
  146540. /**
  146541. * Creates a box mesh
  146542. * 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)
  146543. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146545. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146547. * @param name defines the name of the mesh
  146548. * @param options defines the options used to create the mesh
  146549. * @param scene defines the hosting scene
  146550. * @returns the box mesh
  146551. */
  146552. static CreateTiledBox(name: string, options: {
  146553. pattern?: number;
  146554. width?: number;
  146555. height?: number;
  146556. depth?: number;
  146557. tileSize?: number;
  146558. tileWidth?: number;
  146559. tileHeight?: number;
  146560. alignHorizontal?: number;
  146561. alignVertical?: number;
  146562. faceUV?: Vector4[];
  146563. faceColors?: Color4[];
  146564. sideOrientation?: number;
  146565. updatable?: boolean;
  146566. }, scene?: Nullable<Scene>): Mesh;
  146567. }
  146568. }
  146569. declare module BABYLON {
  146570. /**
  146571. * Class containing static functions to help procedurally build meshes
  146572. */
  146573. export class TorusKnotBuilder {
  146574. /**
  146575. * Creates a torus knot mesh
  146576. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146577. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146578. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146579. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146581. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146583. * @param name defines the name of the mesh
  146584. * @param options defines the options used to create the mesh
  146585. * @param scene defines the hosting scene
  146586. * @returns the torus knot mesh
  146587. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146588. */
  146589. static CreateTorusKnot(name: string, options: {
  146590. radius?: number;
  146591. tube?: number;
  146592. radialSegments?: number;
  146593. tubularSegments?: number;
  146594. p?: number;
  146595. q?: number;
  146596. updatable?: boolean;
  146597. sideOrientation?: number;
  146598. frontUVs?: Vector4;
  146599. backUVs?: Vector4;
  146600. }, scene: any): Mesh;
  146601. }
  146602. }
  146603. declare module BABYLON {
  146604. /**
  146605. * Polygon
  146606. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  146607. */
  146608. export class Polygon {
  146609. /**
  146610. * Creates a rectangle
  146611. * @param xmin bottom X coord
  146612. * @param ymin bottom Y coord
  146613. * @param xmax top X coord
  146614. * @param ymax top Y coord
  146615. * @returns points that make the resulting rectation
  146616. */
  146617. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  146618. /**
  146619. * Creates a circle
  146620. * @param radius radius of circle
  146621. * @param cx scale in x
  146622. * @param cy scale in y
  146623. * @param numberOfSides number of sides that make up the circle
  146624. * @returns points that make the resulting circle
  146625. */
  146626. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  146627. /**
  146628. * Creates a polygon from input string
  146629. * @param input Input polygon data
  146630. * @returns the parsed points
  146631. */
  146632. static Parse(input: string): Vector2[];
  146633. /**
  146634. * Starts building a polygon from x and y coordinates
  146635. * @param x x coordinate
  146636. * @param y y coordinate
  146637. * @returns the started path2
  146638. */
  146639. static StartingAt(x: number, y: number): Path2;
  146640. }
  146641. /**
  146642. * Builds a polygon
  146643. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  146644. */
  146645. export class PolygonMeshBuilder {
  146646. private _points;
  146647. private _outlinepoints;
  146648. private _holes;
  146649. private _name;
  146650. private _scene;
  146651. private _epoints;
  146652. private _eholes;
  146653. private _addToepoint;
  146654. /**
  146655. * Babylon reference to the earcut plugin.
  146656. */
  146657. bjsEarcut: any;
  146658. /**
  146659. * Creates a PolygonMeshBuilder
  146660. * @param name name of the builder
  146661. * @param contours Path of the polygon
  146662. * @param scene scene to add to when creating the mesh
  146663. * @param earcutInjection can be used to inject your own earcut reference
  146664. */
  146665. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  146666. /**
  146667. * Adds a whole within the polygon
  146668. * @param hole Array of points defining the hole
  146669. * @returns this
  146670. */
  146671. addHole(hole: Vector2[]): PolygonMeshBuilder;
  146672. /**
  146673. * Creates the polygon
  146674. * @param updatable If the mesh should be updatable
  146675. * @param depth The depth of the mesh created
  146676. * @returns the created mesh
  146677. */
  146678. build(updatable?: boolean, depth?: number): Mesh;
  146679. /**
  146680. * Creates the polygon
  146681. * @param depth The depth of the mesh created
  146682. * @returns the created VertexData
  146683. */
  146684. buildVertexData(depth?: number): VertexData;
  146685. /**
  146686. * Adds a side to the polygon
  146687. * @param positions points that make the polygon
  146688. * @param normals normals of the polygon
  146689. * @param uvs uvs of the polygon
  146690. * @param indices indices of the polygon
  146691. * @param bounds bounds of the polygon
  146692. * @param points points of the polygon
  146693. * @param depth depth of the polygon
  146694. * @param flip flip of the polygon
  146695. */
  146696. private addSide;
  146697. }
  146698. }
  146699. declare module BABYLON {
  146700. /**
  146701. * Class containing static functions to help procedurally build meshes
  146702. */
  146703. export class PolygonBuilder {
  146704. /**
  146705. * Creates a polygon mesh
  146706. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146707. * * 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
  146708. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146710. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146711. * * Remember you can only change the shape positions, not their number when updating a polygon
  146712. * @param name defines the name of the mesh
  146713. * @param options defines the options used to create the mesh
  146714. * @param scene defines the hosting scene
  146715. * @param earcutInjection can be used to inject your own earcut reference
  146716. * @returns the polygon mesh
  146717. */
  146718. static CreatePolygon(name: string, options: {
  146719. shape: Vector3[];
  146720. holes?: Vector3[][];
  146721. depth?: number;
  146722. faceUV?: Vector4[];
  146723. faceColors?: Color4[];
  146724. updatable?: boolean;
  146725. sideOrientation?: number;
  146726. frontUVs?: Vector4;
  146727. backUVs?: Vector4;
  146728. wrap?: boolean;
  146729. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146730. /**
  146731. * Creates an extruded polygon mesh, with depth in the Y direction.
  146732. * * 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)
  146733. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146734. * @param name defines the name of the mesh
  146735. * @param options defines the options used to create the mesh
  146736. * @param scene defines the hosting scene
  146737. * @param earcutInjection can be used to inject your own earcut reference
  146738. * @returns the polygon mesh
  146739. */
  146740. static ExtrudePolygon(name: string, options: {
  146741. shape: Vector3[];
  146742. holes?: Vector3[][];
  146743. depth?: number;
  146744. faceUV?: Vector4[];
  146745. faceColors?: Color4[];
  146746. updatable?: boolean;
  146747. sideOrientation?: number;
  146748. frontUVs?: Vector4;
  146749. backUVs?: Vector4;
  146750. wrap?: boolean;
  146751. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146752. }
  146753. }
  146754. declare module BABYLON {
  146755. /**
  146756. * Class containing static functions to help procedurally build meshes
  146757. */
  146758. export class LatheBuilder {
  146759. /**
  146760. * Creates lathe mesh.
  146761. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146762. * * 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
  146763. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146764. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146765. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146766. * * 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
  146767. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146768. * * 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
  146769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146771. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146773. * @param name defines the name of the mesh
  146774. * @param options defines the options used to create the mesh
  146775. * @param scene defines the hosting scene
  146776. * @returns the lathe mesh
  146777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146778. */
  146779. static CreateLathe(name: string, options: {
  146780. shape: Vector3[];
  146781. radius?: number;
  146782. tessellation?: number;
  146783. clip?: number;
  146784. arc?: number;
  146785. closed?: boolean;
  146786. updatable?: boolean;
  146787. sideOrientation?: number;
  146788. frontUVs?: Vector4;
  146789. backUVs?: Vector4;
  146790. cap?: number;
  146791. invertUV?: boolean;
  146792. }, scene?: Nullable<Scene>): Mesh;
  146793. }
  146794. }
  146795. declare module BABYLON {
  146796. /**
  146797. * Class containing static functions to help procedurally build meshes
  146798. */
  146799. export class TiledPlaneBuilder {
  146800. /**
  146801. * Creates a tiled plane mesh
  146802. * * The parameter `pattern` will, depending on value, do nothing or
  146803. * * * flip (reflect about central vertical) alternate tiles across and up
  146804. * * * flip every tile on alternate rows
  146805. * * * rotate (180 degs) alternate tiles across and up
  146806. * * * rotate every tile on alternate rows
  146807. * * * flip and rotate alternate tiles across and up
  146808. * * * flip and rotate every tile on alternate rows
  146809. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  146810. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  146811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146812. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146813. * * 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)
  146814. * * 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)
  146815. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146816. * @param name defines the name of the mesh
  146817. * @param options defines the options used to create the mesh
  146818. * @param scene defines the hosting scene
  146819. * @returns the box mesh
  146820. */
  146821. static CreateTiledPlane(name: string, options: {
  146822. pattern?: number;
  146823. tileSize?: number;
  146824. tileWidth?: number;
  146825. tileHeight?: number;
  146826. size?: number;
  146827. width?: number;
  146828. height?: number;
  146829. alignHorizontal?: number;
  146830. alignVertical?: number;
  146831. sideOrientation?: number;
  146832. frontUVs?: Vector4;
  146833. backUVs?: Vector4;
  146834. updatable?: boolean;
  146835. }, scene?: Nullable<Scene>): Mesh;
  146836. }
  146837. }
  146838. declare module BABYLON {
  146839. /**
  146840. * Class containing static functions to help procedurally build meshes
  146841. */
  146842. export class TubeBuilder {
  146843. /**
  146844. * Creates a tube mesh.
  146845. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146846. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146847. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146848. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146849. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146850. * * 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)
  146851. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146852. * * 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
  146853. * * 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
  146854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146856. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146858. * @param name defines the name of the mesh
  146859. * @param options defines the options used to create the mesh
  146860. * @param scene defines the hosting scene
  146861. * @returns the tube mesh
  146862. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146863. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146864. */
  146865. static CreateTube(name: string, options: {
  146866. path: Vector3[];
  146867. radius?: number;
  146868. tessellation?: number;
  146869. radiusFunction?: {
  146870. (i: number, distance: number): number;
  146871. };
  146872. cap?: number;
  146873. arc?: number;
  146874. updatable?: boolean;
  146875. sideOrientation?: number;
  146876. frontUVs?: Vector4;
  146877. backUVs?: Vector4;
  146878. instance?: Mesh;
  146879. invertUV?: boolean;
  146880. }, scene?: Nullable<Scene>): Mesh;
  146881. }
  146882. }
  146883. declare module BABYLON {
  146884. /**
  146885. * Class containing static functions to help procedurally build meshes
  146886. */
  146887. export class IcoSphereBuilder {
  146888. /**
  146889. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146890. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146891. * * 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`)
  146892. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146893. * * 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
  146894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146895. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146897. * @param name defines the name of the mesh
  146898. * @param options defines the options used to create the mesh
  146899. * @param scene defines the hosting scene
  146900. * @returns the icosahedron mesh
  146901. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146902. */
  146903. static CreateIcoSphere(name: string, options: {
  146904. radius?: number;
  146905. radiusX?: number;
  146906. radiusY?: number;
  146907. radiusZ?: number;
  146908. flat?: boolean;
  146909. subdivisions?: number;
  146910. sideOrientation?: number;
  146911. frontUVs?: Vector4;
  146912. backUVs?: Vector4;
  146913. updatable?: boolean;
  146914. }, scene?: Nullable<Scene>): Mesh;
  146915. }
  146916. }
  146917. declare module BABYLON {
  146918. /**
  146919. * Class containing static functions to help procedurally build meshes
  146920. */
  146921. export class DecalBuilder {
  146922. /**
  146923. * Creates a decal mesh.
  146924. * 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
  146925. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146926. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146927. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146928. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146929. * @param name defines the name of the mesh
  146930. * @param sourceMesh defines the mesh where the decal must be applied
  146931. * @param options defines the options used to create the mesh
  146932. * @param scene defines the hosting scene
  146933. * @returns the decal mesh
  146934. * @see https://doc.babylonjs.com/how_to/decals
  146935. */
  146936. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146937. position?: Vector3;
  146938. normal?: Vector3;
  146939. size?: Vector3;
  146940. angle?: number;
  146941. }): Mesh;
  146942. }
  146943. }
  146944. declare module BABYLON {
  146945. /**
  146946. * Class containing static functions to help procedurally build meshes
  146947. */
  146948. export class MeshBuilder {
  146949. /**
  146950. * Creates a box mesh
  146951. * * The parameter `size` sets the size (float) of each box side (default 1)
  146952. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  146953. * * 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)
  146954. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146958. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146959. * @param name defines the name of the mesh
  146960. * @param options defines the options used to create the mesh
  146961. * @param scene defines the hosting scene
  146962. * @returns the box mesh
  146963. */
  146964. static CreateBox(name: string, options: {
  146965. size?: number;
  146966. width?: number;
  146967. height?: number;
  146968. depth?: number;
  146969. faceUV?: Vector4[];
  146970. faceColors?: Color4[];
  146971. sideOrientation?: number;
  146972. frontUVs?: Vector4;
  146973. backUVs?: Vector4;
  146974. wrap?: boolean;
  146975. topBaseAt?: number;
  146976. bottomBaseAt?: number;
  146977. updatable?: boolean;
  146978. }, scene?: Nullable<Scene>): Mesh;
  146979. /**
  146980. * Creates a tiled box mesh
  146981. * * faceTiles sets the pattern, tile size and number of tiles for a face
  146982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146983. * @param name defines the name of the mesh
  146984. * @param options defines the options used to create the mesh
  146985. * @param scene defines the hosting scene
  146986. * @returns the tiled box mesh
  146987. */
  146988. static CreateTiledBox(name: string, options: {
  146989. pattern?: number;
  146990. size?: number;
  146991. width?: number;
  146992. height?: number;
  146993. depth: number;
  146994. tileSize?: number;
  146995. tileWidth?: number;
  146996. tileHeight?: number;
  146997. faceUV?: Vector4[];
  146998. faceColors?: Color4[];
  146999. alignHorizontal?: number;
  147000. alignVertical?: number;
  147001. sideOrientation?: number;
  147002. updatable?: boolean;
  147003. }, scene?: Nullable<Scene>): Mesh;
  147004. /**
  147005. * Creates a sphere mesh
  147006. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  147007. * * 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`)
  147008. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  147009. * * 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
  147010. * * 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)
  147011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147014. * @param name defines the name of the mesh
  147015. * @param options defines the options used to create the mesh
  147016. * @param scene defines the hosting scene
  147017. * @returns the sphere mesh
  147018. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  147019. */
  147020. static CreateSphere(name: string, options: {
  147021. segments?: number;
  147022. diameter?: number;
  147023. diameterX?: number;
  147024. diameterY?: number;
  147025. diameterZ?: number;
  147026. arc?: number;
  147027. slice?: number;
  147028. sideOrientation?: number;
  147029. frontUVs?: Vector4;
  147030. backUVs?: Vector4;
  147031. updatable?: boolean;
  147032. }, scene?: Nullable<Scene>): Mesh;
  147033. /**
  147034. * Creates a plane polygonal mesh. By default, this is a disc
  147035. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  147036. * * 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
  147037. * * 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
  147038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147039. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147041. * @param name defines the name of the mesh
  147042. * @param options defines the options used to create the mesh
  147043. * @param scene defines the hosting scene
  147044. * @returns the plane polygonal mesh
  147045. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  147046. */
  147047. static CreateDisc(name: string, options: {
  147048. radius?: number;
  147049. tessellation?: number;
  147050. arc?: number;
  147051. updatable?: boolean;
  147052. sideOrientation?: number;
  147053. frontUVs?: Vector4;
  147054. backUVs?: Vector4;
  147055. }, scene?: Nullable<Scene>): Mesh;
  147056. /**
  147057. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147058. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147059. * * 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`)
  147060. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147061. * * 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
  147062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147063. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147065. * @param name defines the name of the mesh
  147066. * @param options defines the options used to create the mesh
  147067. * @param scene defines the hosting scene
  147068. * @returns the icosahedron mesh
  147069. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  147070. */
  147071. static CreateIcoSphere(name: string, options: {
  147072. radius?: number;
  147073. radiusX?: number;
  147074. radiusY?: number;
  147075. radiusZ?: number;
  147076. flat?: boolean;
  147077. subdivisions?: number;
  147078. sideOrientation?: number;
  147079. frontUVs?: Vector4;
  147080. backUVs?: Vector4;
  147081. updatable?: boolean;
  147082. }, scene?: Nullable<Scene>): Mesh;
  147083. /**
  147084. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147085. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  147086. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  147087. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  147088. * * 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
  147089. * * 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
  147090. * * 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
  147091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147092. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147093. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147094. * * 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
  147095. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  147096. * * 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
  147097. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  147098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147099. * @param name defines the name of the mesh
  147100. * @param options defines the options used to create the mesh
  147101. * @param scene defines the hosting scene
  147102. * @returns the ribbon mesh
  147103. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  147104. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147105. */
  147106. static CreateRibbon(name: string, options: {
  147107. pathArray: Vector3[][];
  147108. closeArray?: boolean;
  147109. closePath?: boolean;
  147110. offset?: number;
  147111. updatable?: boolean;
  147112. sideOrientation?: number;
  147113. frontUVs?: Vector4;
  147114. backUVs?: Vector4;
  147115. instance?: Mesh;
  147116. invertUV?: boolean;
  147117. uvs?: Vector2[];
  147118. colors?: Color4[];
  147119. }, scene?: Nullable<Scene>): Mesh;
  147120. /**
  147121. * Creates a cylinder or a cone mesh
  147122. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  147123. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  147124. * * 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.
  147125. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  147126. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  147127. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  147128. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  147129. * * 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).
  147130. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  147131. * * 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).
  147132. * * 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
  147133. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  147134. * * 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
  147135. * * 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.
  147136. * * If `enclose` is false, a ring surface is one element.
  147137. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  147138. * * 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
  147139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147140. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147142. * @param name defines the name of the mesh
  147143. * @param options defines the options used to create the mesh
  147144. * @param scene defines the hosting scene
  147145. * @returns the cylinder mesh
  147146. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  147147. */
  147148. static CreateCylinder(name: string, options: {
  147149. height?: number;
  147150. diameterTop?: number;
  147151. diameterBottom?: number;
  147152. diameter?: number;
  147153. tessellation?: number;
  147154. subdivisions?: number;
  147155. arc?: number;
  147156. faceColors?: Color4[];
  147157. faceUV?: Vector4[];
  147158. updatable?: boolean;
  147159. hasRings?: boolean;
  147160. enclose?: boolean;
  147161. cap?: number;
  147162. sideOrientation?: number;
  147163. frontUVs?: Vector4;
  147164. backUVs?: Vector4;
  147165. }, scene?: Nullable<Scene>): Mesh;
  147166. /**
  147167. * Creates a torus mesh
  147168. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  147169. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  147170. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  147171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147172. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147174. * @param name defines the name of the mesh
  147175. * @param options defines the options used to create the mesh
  147176. * @param scene defines the hosting scene
  147177. * @returns the torus mesh
  147178. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  147179. */
  147180. static CreateTorus(name: string, options: {
  147181. diameter?: number;
  147182. thickness?: number;
  147183. tessellation?: number;
  147184. updatable?: boolean;
  147185. sideOrientation?: number;
  147186. frontUVs?: Vector4;
  147187. backUVs?: Vector4;
  147188. }, scene?: Nullable<Scene>): Mesh;
  147189. /**
  147190. * Creates a torus knot mesh
  147191. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  147192. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  147193. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  147194. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  147195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147198. * @param name defines the name of the mesh
  147199. * @param options defines the options used to create the mesh
  147200. * @param scene defines the hosting scene
  147201. * @returns the torus knot mesh
  147202. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  147203. */
  147204. static CreateTorusKnot(name: string, options: {
  147205. radius?: number;
  147206. tube?: number;
  147207. radialSegments?: number;
  147208. tubularSegments?: number;
  147209. p?: number;
  147210. q?: number;
  147211. updatable?: boolean;
  147212. sideOrientation?: number;
  147213. frontUVs?: Vector4;
  147214. backUVs?: Vector4;
  147215. }, scene?: Nullable<Scene>): Mesh;
  147216. /**
  147217. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  147218. * * 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
  147219. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  147220. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  147221. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  147222. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  147223. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  147224. * * 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
  147225. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  147226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147227. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  147228. * @param name defines the name of the new line system
  147229. * @param options defines the options used to create the line system
  147230. * @param scene defines the hosting scene
  147231. * @returns a new line system mesh
  147232. */
  147233. static CreateLineSystem(name: string, options: {
  147234. lines: Vector3[][];
  147235. updatable?: boolean;
  147236. instance?: Nullable<LinesMesh>;
  147237. colors?: Nullable<Color4[][]>;
  147238. useVertexAlpha?: boolean;
  147239. }, scene: Nullable<Scene>): LinesMesh;
  147240. /**
  147241. * Creates a line mesh
  147242. * 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
  147243. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147244. * * The parameter `points` is an array successive Vector3
  147245. * * 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
  147246. * * The optional parameter `colors` is an array of successive Color4, one per line point
  147247. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  147248. * * When updating an instance, remember that only point positions can change, not the number of points
  147249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147250. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  147251. * @param name defines the name of the new line system
  147252. * @param options defines the options used to create the line system
  147253. * @param scene defines the hosting scene
  147254. * @returns a new line mesh
  147255. */
  147256. static CreateLines(name: string, options: {
  147257. points: Vector3[];
  147258. updatable?: boolean;
  147259. instance?: Nullable<LinesMesh>;
  147260. colors?: Color4[];
  147261. useVertexAlpha?: boolean;
  147262. }, scene?: Nullable<Scene>): LinesMesh;
  147263. /**
  147264. * Creates a dashed line mesh
  147265. * * 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
  147266. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147267. * * The parameter `points` is an array successive Vector3
  147268. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  147269. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  147270. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  147271. * * 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
  147272. * * When updating an instance, remember that only point positions can change, not the number of points
  147273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147274. * @param name defines the name of the mesh
  147275. * @param options defines the options used to create the mesh
  147276. * @param scene defines the hosting scene
  147277. * @returns the dashed line mesh
  147278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  147279. */
  147280. static CreateDashedLines(name: string, options: {
  147281. points: Vector3[];
  147282. dashSize?: number;
  147283. gapSize?: number;
  147284. dashNb?: number;
  147285. updatable?: boolean;
  147286. instance?: LinesMesh;
  147287. }, scene?: Nullable<Scene>): LinesMesh;
  147288. /**
  147289. * 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.
  147290. * * 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.
  147291. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147292. * * 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.
  147293. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  147294. * * 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
  147295. * * 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
  147296. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  147297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147298. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147299. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  147300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147301. * @param name defines the name of the mesh
  147302. * @param options defines the options used to create the mesh
  147303. * @param scene defines the hosting scene
  147304. * @returns the extruded shape mesh
  147305. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147306. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147307. */
  147308. static ExtrudeShape(name: string, options: {
  147309. shape: Vector3[];
  147310. path: Vector3[];
  147311. scale?: number;
  147312. rotation?: number;
  147313. cap?: number;
  147314. updatable?: boolean;
  147315. sideOrientation?: number;
  147316. frontUVs?: Vector4;
  147317. backUVs?: Vector4;
  147318. instance?: Mesh;
  147319. invertUV?: boolean;
  147320. }, scene?: Nullable<Scene>): Mesh;
  147321. /**
  147322. * Creates an custom extruded shape mesh.
  147323. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  147324. * * 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.
  147325. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147326. * * 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
  147327. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  147328. * * 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
  147329. * * It must returns a float value that will be the scale value applied to the shape on each path point
  147330. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  147331. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  147332. * * 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
  147333. * * 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
  147334. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  147335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147336. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147337. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147339. * @param name defines the name of the mesh
  147340. * @param options defines the options used to create the mesh
  147341. * @param scene defines the hosting scene
  147342. * @returns the custom extruded shape mesh
  147343. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  147344. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147345. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147346. */
  147347. static ExtrudeShapeCustom(name: string, options: {
  147348. shape: Vector3[];
  147349. path: Vector3[];
  147350. scaleFunction?: any;
  147351. rotationFunction?: any;
  147352. ribbonCloseArray?: boolean;
  147353. ribbonClosePath?: boolean;
  147354. cap?: number;
  147355. updatable?: boolean;
  147356. sideOrientation?: number;
  147357. frontUVs?: Vector4;
  147358. backUVs?: Vector4;
  147359. instance?: Mesh;
  147360. invertUV?: boolean;
  147361. }, scene?: Nullable<Scene>): Mesh;
  147362. /**
  147363. * Creates lathe mesh.
  147364. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  147365. * * 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
  147366. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  147367. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  147368. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  147369. * * 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
  147370. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  147371. * * 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
  147372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147374. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147376. * @param name defines the name of the mesh
  147377. * @param options defines the options used to create the mesh
  147378. * @param scene defines the hosting scene
  147379. * @returns the lathe mesh
  147380. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  147381. */
  147382. static CreateLathe(name: string, options: {
  147383. shape: Vector3[];
  147384. radius?: number;
  147385. tessellation?: number;
  147386. clip?: number;
  147387. arc?: number;
  147388. closed?: boolean;
  147389. updatable?: boolean;
  147390. sideOrientation?: number;
  147391. frontUVs?: Vector4;
  147392. backUVs?: Vector4;
  147393. cap?: number;
  147394. invertUV?: boolean;
  147395. }, scene?: Nullable<Scene>): Mesh;
  147396. /**
  147397. * Creates a tiled plane mesh
  147398. * * You can set a limited pattern arrangement with the tiles
  147399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147402. * @param name defines the name of the mesh
  147403. * @param options defines the options used to create the mesh
  147404. * @param scene defines the hosting scene
  147405. * @returns the plane mesh
  147406. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147407. */
  147408. static CreateTiledPlane(name: string, options: {
  147409. pattern?: number;
  147410. tileSize?: number;
  147411. tileWidth?: number;
  147412. tileHeight?: number;
  147413. size?: number;
  147414. width?: number;
  147415. height?: number;
  147416. alignHorizontal?: number;
  147417. alignVertical?: number;
  147418. sideOrientation?: number;
  147419. frontUVs?: Vector4;
  147420. backUVs?: Vector4;
  147421. updatable?: boolean;
  147422. }, scene?: Nullable<Scene>): Mesh;
  147423. /**
  147424. * Creates a plane mesh
  147425. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  147426. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  147427. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  147428. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147429. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147431. * @param name defines the name of the mesh
  147432. * @param options defines the options used to create the mesh
  147433. * @param scene defines the hosting scene
  147434. * @returns the plane mesh
  147435. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147436. */
  147437. static CreatePlane(name: string, options: {
  147438. size?: number;
  147439. width?: number;
  147440. height?: number;
  147441. sideOrientation?: number;
  147442. frontUVs?: Vector4;
  147443. backUVs?: Vector4;
  147444. updatable?: boolean;
  147445. sourcePlane?: Plane;
  147446. }, scene?: Nullable<Scene>): Mesh;
  147447. /**
  147448. * Creates a ground mesh
  147449. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  147450. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  147451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147452. * @param name defines the name of the mesh
  147453. * @param options defines the options used to create the mesh
  147454. * @param scene defines the hosting scene
  147455. * @returns the ground mesh
  147456. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  147457. */
  147458. static CreateGround(name: string, options: {
  147459. width?: number;
  147460. height?: number;
  147461. subdivisions?: number;
  147462. subdivisionsX?: number;
  147463. subdivisionsY?: number;
  147464. updatable?: boolean;
  147465. }, scene?: Nullable<Scene>): Mesh;
  147466. /**
  147467. * Creates a tiled ground mesh
  147468. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  147469. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  147470. * * 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
  147471. * * 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
  147472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147473. * @param name defines the name of the mesh
  147474. * @param options defines the options used to create the mesh
  147475. * @param scene defines the hosting scene
  147476. * @returns the tiled ground mesh
  147477. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  147478. */
  147479. static CreateTiledGround(name: string, options: {
  147480. xmin: number;
  147481. zmin: number;
  147482. xmax: number;
  147483. zmax: number;
  147484. subdivisions?: {
  147485. w: number;
  147486. h: number;
  147487. };
  147488. precision?: {
  147489. w: number;
  147490. h: number;
  147491. };
  147492. updatable?: boolean;
  147493. }, scene?: Nullable<Scene>): Mesh;
  147494. /**
  147495. * Creates a ground mesh from a height map
  147496. * * The parameter `url` sets the URL of the height map image resource.
  147497. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  147498. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  147499. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  147500. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  147501. * * 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.
  147502. * * 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).
  147503. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  147504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147505. * @param name defines the name of the mesh
  147506. * @param url defines the url to the height map
  147507. * @param options defines the options used to create the mesh
  147508. * @param scene defines the hosting scene
  147509. * @returns the ground mesh
  147510. * @see https://doc.babylonjs.com/babylon101/height_map
  147511. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  147512. */
  147513. static CreateGroundFromHeightMap(name: string, url: string, options: {
  147514. width?: number;
  147515. height?: number;
  147516. subdivisions?: number;
  147517. minHeight?: number;
  147518. maxHeight?: number;
  147519. colorFilter?: Color3;
  147520. alphaFilter?: number;
  147521. updatable?: boolean;
  147522. onReady?: (mesh: GroundMesh) => void;
  147523. }, scene?: Nullable<Scene>): GroundMesh;
  147524. /**
  147525. * Creates a polygon mesh
  147526. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147527. * * 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
  147528. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147530. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147531. * * Remember you can only change the shape positions, not their number when updating a polygon
  147532. * @param name defines the name of the mesh
  147533. * @param options defines the options used to create the mesh
  147534. * @param scene defines the hosting scene
  147535. * @param earcutInjection can be used to inject your own earcut reference
  147536. * @returns the polygon mesh
  147537. */
  147538. static CreatePolygon(name: string, options: {
  147539. shape: Vector3[];
  147540. holes?: Vector3[][];
  147541. depth?: number;
  147542. faceUV?: Vector4[];
  147543. faceColors?: Color4[];
  147544. updatable?: boolean;
  147545. sideOrientation?: number;
  147546. frontUVs?: Vector4;
  147547. backUVs?: Vector4;
  147548. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147549. /**
  147550. * Creates an extruded polygon mesh, with depth in the Y direction.
  147551. * * 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)
  147552. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147553. * @param name defines the name of the mesh
  147554. * @param options defines the options used to create the mesh
  147555. * @param scene defines the hosting scene
  147556. * @param earcutInjection can be used to inject your own earcut reference
  147557. * @returns the polygon mesh
  147558. */
  147559. static ExtrudePolygon(name: string, options: {
  147560. shape: Vector3[];
  147561. holes?: Vector3[][];
  147562. depth?: number;
  147563. faceUV?: Vector4[];
  147564. faceColors?: Color4[];
  147565. updatable?: boolean;
  147566. sideOrientation?: number;
  147567. frontUVs?: Vector4;
  147568. backUVs?: Vector4;
  147569. wrap?: boolean;
  147570. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147571. /**
  147572. * Creates a tube mesh.
  147573. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147574. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147575. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147576. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147577. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147578. * * 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)
  147579. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147580. * * 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
  147581. * * 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
  147582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147584. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147586. * @param name defines the name of the mesh
  147587. * @param options defines the options used to create the mesh
  147588. * @param scene defines the hosting scene
  147589. * @returns the tube mesh
  147590. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147591. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147592. */
  147593. static CreateTube(name: string, options: {
  147594. path: Vector3[];
  147595. radius?: number;
  147596. tessellation?: number;
  147597. radiusFunction?: {
  147598. (i: number, distance: number): number;
  147599. };
  147600. cap?: number;
  147601. arc?: number;
  147602. updatable?: boolean;
  147603. sideOrientation?: number;
  147604. frontUVs?: Vector4;
  147605. backUVs?: Vector4;
  147606. instance?: Mesh;
  147607. invertUV?: boolean;
  147608. }, scene?: Nullable<Scene>): Mesh;
  147609. /**
  147610. * Creates a polyhedron mesh
  147611. * * 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
  147612. * * The parameter `size` (positive float, default 1) sets the polygon size
  147613. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  147614. * * 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`
  147615. * * 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
  147616. * * 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)`)
  147617. * * 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
  147618. * * 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
  147619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147622. * @param name defines the name of the mesh
  147623. * @param options defines the options used to create the mesh
  147624. * @param scene defines the hosting scene
  147625. * @returns the polyhedron mesh
  147626. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  147627. */
  147628. static CreatePolyhedron(name: string, options: {
  147629. type?: number;
  147630. size?: number;
  147631. sizeX?: number;
  147632. sizeY?: number;
  147633. sizeZ?: number;
  147634. custom?: any;
  147635. faceUV?: Vector4[];
  147636. faceColors?: Color4[];
  147637. flat?: boolean;
  147638. updatable?: boolean;
  147639. sideOrientation?: number;
  147640. frontUVs?: Vector4;
  147641. backUVs?: Vector4;
  147642. }, scene?: Nullable<Scene>): Mesh;
  147643. /**
  147644. * Creates a decal mesh.
  147645. * 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
  147646. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147647. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147648. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147649. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147650. * @param name defines the name of the mesh
  147651. * @param sourceMesh defines the mesh where the decal must be applied
  147652. * @param options defines the options used to create the mesh
  147653. * @param scene defines the hosting scene
  147654. * @returns the decal mesh
  147655. * @see https://doc.babylonjs.com/how_to/decals
  147656. */
  147657. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147658. position?: Vector3;
  147659. normal?: Vector3;
  147660. size?: Vector3;
  147661. angle?: number;
  147662. }): Mesh;
  147663. /**
  147664. * Creates a Capsule Mesh
  147665. * @param name defines the name of the mesh.
  147666. * @param options the constructors options used to shape the mesh.
  147667. * @param scene defines the scene the mesh is scoped to.
  147668. * @returns the capsule mesh
  147669. * @see https://doc.babylonjs.com/how_to/capsule_shape
  147670. */
  147671. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  147672. }
  147673. }
  147674. declare module BABYLON {
  147675. /**
  147676. * A simplifier interface for future simplification implementations
  147677. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147678. */
  147679. export interface ISimplifier {
  147680. /**
  147681. * Simplification of a given mesh according to the given settings.
  147682. * Since this requires computation, it is assumed that the function runs async.
  147683. * @param settings The settings of the simplification, including quality and distance
  147684. * @param successCallback A callback that will be called after the mesh was simplified.
  147685. * @param errorCallback in case of an error, this callback will be called. optional.
  147686. */
  147687. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  147688. }
  147689. /**
  147690. * Expected simplification settings.
  147691. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  147692. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147693. */
  147694. export interface ISimplificationSettings {
  147695. /**
  147696. * Gets or sets the expected quality
  147697. */
  147698. quality: number;
  147699. /**
  147700. * Gets or sets the distance when this optimized version should be used
  147701. */
  147702. distance: number;
  147703. /**
  147704. * Gets an already optimized mesh
  147705. */
  147706. optimizeMesh?: boolean;
  147707. }
  147708. /**
  147709. * Class used to specify simplification options
  147710. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147711. */
  147712. export class SimplificationSettings implements ISimplificationSettings {
  147713. /** expected quality */
  147714. quality: number;
  147715. /** distance when this optimized version should be used */
  147716. distance: number;
  147717. /** already optimized mesh */
  147718. optimizeMesh?: boolean | undefined;
  147719. /**
  147720. * Creates a SimplificationSettings
  147721. * @param quality expected quality
  147722. * @param distance distance when this optimized version should be used
  147723. * @param optimizeMesh already optimized mesh
  147724. */
  147725. constructor(
  147726. /** expected quality */
  147727. quality: number,
  147728. /** distance when this optimized version should be used */
  147729. distance: number,
  147730. /** already optimized mesh */
  147731. optimizeMesh?: boolean | undefined);
  147732. }
  147733. /**
  147734. * Interface used to define a simplification task
  147735. */
  147736. export interface ISimplificationTask {
  147737. /**
  147738. * Array of settings
  147739. */
  147740. settings: Array<ISimplificationSettings>;
  147741. /**
  147742. * Simplification type
  147743. */
  147744. simplificationType: SimplificationType;
  147745. /**
  147746. * Mesh to simplify
  147747. */
  147748. mesh: Mesh;
  147749. /**
  147750. * Callback called on success
  147751. */
  147752. successCallback?: () => void;
  147753. /**
  147754. * Defines if parallel processing can be used
  147755. */
  147756. parallelProcessing: boolean;
  147757. }
  147758. /**
  147759. * Queue used to order the simplification tasks
  147760. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147761. */
  147762. export class SimplificationQueue {
  147763. private _simplificationArray;
  147764. /**
  147765. * Gets a boolean indicating that the process is still running
  147766. */
  147767. running: boolean;
  147768. /**
  147769. * Creates a new queue
  147770. */
  147771. constructor();
  147772. /**
  147773. * Adds a new simplification task
  147774. * @param task defines a task to add
  147775. */
  147776. addTask(task: ISimplificationTask): void;
  147777. /**
  147778. * Execute next task
  147779. */
  147780. executeNext(): void;
  147781. /**
  147782. * Execute a simplification task
  147783. * @param task defines the task to run
  147784. */
  147785. runSimplification(task: ISimplificationTask): void;
  147786. private getSimplifier;
  147787. }
  147788. /**
  147789. * The implemented types of simplification
  147790. * At the moment only Quadratic Error Decimation is implemented
  147791. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147792. */
  147793. export enum SimplificationType {
  147794. /** Quadratic error decimation */
  147795. QUADRATIC = 0
  147796. }
  147797. /**
  147798. * An implementation of the Quadratic Error simplification algorithm.
  147799. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  147800. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  147801. * @author RaananW
  147802. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147803. */
  147804. export class QuadraticErrorSimplification implements ISimplifier {
  147805. private _mesh;
  147806. private triangles;
  147807. private vertices;
  147808. private references;
  147809. private _reconstructedMesh;
  147810. /** Gets or sets the number pf sync interations */
  147811. syncIterations: number;
  147812. /** Gets or sets the aggressiveness of the simplifier */
  147813. aggressiveness: number;
  147814. /** Gets or sets the number of allowed iterations for decimation */
  147815. decimationIterations: number;
  147816. /** Gets or sets the espilon to use for bounding box computation */
  147817. boundingBoxEpsilon: number;
  147818. /**
  147819. * Creates a new QuadraticErrorSimplification
  147820. * @param _mesh defines the target mesh
  147821. */
  147822. constructor(_mesh: Mesh);
  147823. /**
  147824. * Simplification of a given mesh according to the given settings.
  147825. * Since this requires computation, it is assumed that the function runs async.
  147826. * @param settings The settings of the simplification, including quality and distance
  147827. * @param successCallback A callback that will be called after the mesh was simplified.
  147828. */
  147829. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  147830. private runDecimation;
  147831. private initWithMesh;
  147832. private init;
  147833. private reconstructMesh;
  147834. private initDecimatedMesh;
  147835. private isFlipped;
  147836. private updateTriangles;
  147837. private identifyBorder;
  147838. private updateMesh;
  147839. private vertexError;
  147840. private calculateError;
  147841. }
  147842. }
  147843. declare module BABYLON {
  147844. interface Scene {
  147845. /** @hidden (Backing field) */
  147846. _simplificationQueue: SimplificationQueue;
  147847. /**
  147848. * Gets or sets the simplification queue attached to the scene
  147849. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147850. */
  147851. simplificationQueue: SimplificationQueue;
  147852. }
  147853. interface Mesh {
  147854. /**
  147855. * Simplify the mesh according to the given array of settings.
  147856. * Function will return immediately and will simplify async
  147857. * @param settings a collection of simplification settings
  147858. * @param parallelProcessing should all levels calculate parallel or one after the other
  147859. * @param simplificationType the type of simplification to run
  147860. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  147861. * @returns the current mesh
  147862. */
  147863. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  147864. }
  147865. /**
  147866. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  147867. * created in a scene
  147868. */
  147869. export class SimplicationQueueSceneComponent implements ISceneComponent {
  147870. /**
  147871. * The component name helpfull to identify the component in the list of scene components.
  147872. */
  147873. readonly name: string;
  147874. /**
  147875. * The scene the component belongs to.
  147876. */
  147877. scene: Scene;
  147878. /**
  147879. * Creates a new instance of the component for the given scene
  147880. * @param scene Defines the scene to register the component in
  147881. */
  147882. constructor(scene: Scene);
  147883. /**
  147884. * Registers the component in a given scene
  147885. */
  147886. register(): void;
  147887. /**
  147888. * Rebuilds the elements related to this component in case of
  147889. * context lost for instance.
  147890. */
  147891. rebuild(): void;
  147892. /**
  147893. * Disposes the component and the associated ressources
  147894. */
  147895. dispose(): void;
  147896. private _beforeCameraUpdate;
  147897. }
  147898. }
  147899. declare module BABYLON {
  147900. interface Mesh {
  147901. /**
  147902. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  147903. */
  147904. thinInstanceEnablePicking: boolean;
  147905. /**
  147906. * Creates a new thin instance
  147907. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  147908. * @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
  147909. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  147910. */
  147911. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  147912. /**
  147913. * Adds the transformation (matrix) of the current mesh as a thin instance
  147914. * @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
  147915. * @returns the thin instance index number
  147916. */
  147917. thinInstanceAddSelf(refresh: boolean): number;
  147918. /**
  147919. * Registers a custom attribute to be used with thin instances
  147920. * @param kind name of the attribute
  147921. * @param stride size in floats of the attribute
  147922. */
  147923. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  147924. /**
  147925. * Sets the matrix of a thin instance
  147926. * @param index index of the thin instance
  147927. * @param matrix matrix to set
  147928. * @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
  147929. */
  147930. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  147931. /**
  147932. * Sets the value of a custom attribute for a thin instance
  147933. * @param kind name of the attribute
  147934. * @param index index of the thin instance
  147935. * @param value value to set
  147936. * @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
  147937. */
  147938. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  147939. /**
  147940. * 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.
  147941. */
  147942. thinInstanceCount: number;
  147943. /**
  147944. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  147945. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  147946. * @param buffer buffer to set
  147947. * @param stride size in floats of each value of the buffer
  147948. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  147949. */
  147950. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  147951. /**
  147952. * Gets the list of world matrices
  147953. * @return an array containing all the world matrices from the thin instances
  147954. */
  147955. thinInstanceGetWorldMatrices(): Matrix[];
  147956. /**
  147957. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  147958. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147959. */
  147960. thinInstanceBufferUpdated(kind: string): void;
  147961. /**
  147962. * Applies a partial update to a buffer directly on the GPU
  147963. * 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
  147964. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147965. * @param data the data to set in the GPU buffer
  147966. * @param offset the offset in the GPU buffer where to update the data
  147967. */
  147968. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  147969. /**
  147970. * Refreshes the bounding info, taking into account all the thin instances defined
  147971. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  147972. */
  147973. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  147974. /** @hidden */
  147975. _thinInstanceInitializeUserStorage(): void;
  147976. /** @hidden */
  147977. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  147978. /** @hidden */
  147979. _userThinInstanceBuffersStorage: {
  147980. data: {
  147981. [key: string]: Float32Array;
  147982. };
  147983. sizes: {
  147984. [key: string]: number;
  147985. };
  147986. vertexBuffers: {
  147987. [key: string]: Nullable<VertexBuffer>;
  147988. };
  147989. strides: {
  147990. [key: string]: number;
  147991. };
  147992. };
  147993. }
  147994. }
  147995. declare module BABYLON {
  147996. /**
  147997. * Navigation plugin interface to add navigation constrained by a navigation mesh
  147998. */
  147999. export interface INavigationEnginePlugin {
  148000. /**
  148001. * plugin name
  148002. */
  148003. name: string;
  148004. /**
  148005. * Creates a navigation mesh
  148006. * @param meshes array of all the geometry used to compute the navigatio mesh
  148007. * @param parameters bunch of parameters used to filter geometry
  148008. */
  148009. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148010. /**
  148011. * Create a navigation mesh debug mesh
  148012. * @param scene is where the mesh will be added
  148013. * @returns debug display mesh
  148014. */
  148015. createDebugNavMesh(scene: Scene): Mesh;
  148016. /**
  148017. * Get a navigation mesh constrained position, closest to the parameter position
  148018. * @param position world position
  148019. * @returns the closest point to position constrained by the navigation mesh
  148020. */
  148021. getClosestPoint(position: Vector3): Vector3;
  148022. /**
  148023. * Get a navigation mesh constrained position, closest to the parameter position
  148024. * @param position world position
  148025. * @param result output the closest point to position constrained by the navigation mesh
  148026. */
  148027. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148028. /**
  148029. * Get a navigation mesh constrained position, within a particular radius
  148030. * @param position world position
  148031. * @param maxRadius the maximum distance to the constrained world position
  148032. * @returns the closest point to position constrained by the navigation mesh
  148033. */
  148034. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148035. /**
  148036. * Get a navigation mesh constrained position, within a particular radius
  148037. * @param position world position
  148038. * @param maxRadius the maximum distance to the constrained world position
  148039. * @param result output the closest point to position constrained by the navigation mesh
  148040. */
  148041. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148042. /**
  148043. * Compute the final position from a segment made of destination-position
  148044. * @param position world position
  148045. * @param destination world position
  148046. * @returns the resulting point along the navmesh
  148047. */
  148048. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148049. /**
  148050. * Compute the final position from a segment made of destination-position
  148051. * @param position world position
  148052. * @param destination world position
  148053. * @param result output the resulting point along the navmesh
  148054. */
  148055. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148056. /**
  148057. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148058. * @param start world position
  148059. * @param end world position
  148060. * @returns array containing world position composing the path
  148061. */
  148062. computePath(start: Vector3, end: Vector3): Vector3[];
  148063. /**
  148064. * If this plugin is supported
  148065. * @returns true if plugin is supported
  148066. */
  148067. isSupported(): boolean;
  148068. /**
  148069. * Create a new Crowd so you can add agents
  148070. * @param maxAgents the maximum agent count in the crowd
  148071. * @param maxAgentRadius the maximum radius an agent can have
  148072. * @param scene to attach the crowd to
  148073. * @returns the crowd you can add agents to
  148074. */
  148075. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148076. /**
  148077. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148078. * The queries will try to find a solution within those bounds
  148079. * default is (1,1,1)
  148080. * @param extent x,y,z value that define the extent around the queries point of reference
  148081. */
  148082. setDefaultQueryExtent(extent: Vector3): void;
  148083. /**
  148084. * Get the Bounding box extent specified by setDefaultQueryExtent
  148085. * @returns the box extent values
  148086. */
  148087. getDefaultQueryExtent(): Vector3;
  148088. /**
  148089. * build the navmesh from a previously saved state using getNavmeshData
  148090. * @param data the Uint8Array returned by getNavmeshData
  148091. */
  148092. buildFromNavmeshData(data: Uint8Array): void;
  148093. /**
  148094. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148095. * @returns data the Uint8Array that can be saved and reused
  148096. */
  148097. getNavmeshData(): Uint8Array;
  148098. /**
  148099. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148100. * @param result output the box extent values
  148101. */
  148102. getDefaultQueryExtentToRef(result: Vector3): void;
  148103. /**
  148104. * Release all resources
  148105. */
  148106. dispose(): void;
  148107. }
  148108. /**
  148109. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  148110. */
  148111. export interface ICrowd {
  148112. /**
  148113. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148114. * You can attach anything to that node. The node position is updated in the scene update tick.
  148115. * @param pos world position that will be constrained by the navigation mesh
  148116. * @param parameters agent parameters
  148117. * @param transform hooked to the agent that will be update by the scene
  148118. * @returns agent index
  148119. */
  148120. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148121. /**
  148122. * Returns the agent position in world space
  148123. * @param index agent index returned by addAgent
  148124. * @returns world space position
  148125. */
  148126. getAgentPosition(index: number): Vector3;
  148127. /**
  148128. * Gets the agent position result in world space
  148129. * @param index agent index returned by addAgent
  148130. * @param result output world space position
  148131. */
  148132. getAgentPositionToRef(index: number, result: Vector3): void;
  148133. /**
  148134. * Gets the agent velocity in world space
  148135. * @param index agent index returned by addAgent
  148136. * @returns world space velocity
  148137. */
  148138. getAgentVelocity(index: number): Vector3;
  148139. /**
  148140. * Gets the agent velocity result in world space
  148141. * @param index agent index returned by addAgent
  148142. * @param result output world space velocity
  148143. */
  148144. getAgentVelocityToRef(index: number, result: Vector3): void;
  148145. /**
  148146. * remove a particular agent previously created
  148147. * @param index agent index returned by addAgent
  148148. */
  148149. removeAgent(index: number): void;
  148150. /**
  148151. * get the list of all agents attached to this crowd
  148152. * @returns list of agent indices
  148153. */
  148154. getAgents(): number[];
  148155. /**
  148156. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148157. * @param deltaTime in seconds
  148158. */
  148159. update(deltaTime: number): void;
  148160. /**
  148161. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148162. * @param index agent index returned by addAgent
  148163. * @param destination targeted world position
  148164. */
  148165. agentGoto(index: number, destination: Vector3): void;
  148166. /**
  148167. * Teleport the agent to a new position
  148168. * @param index agent index returned by addAgent
  148169. * @param destination targeted world position
  148170. */
  148171. agentTeleport(index: number, destination: Vector3): void;
  148172. /**
  148173. * Update agent parameters
  148174. * @param index agent index returned by addAgent
  148175. * @param parameters agent parameters
  148176. */
  148177. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148178. /**
  148179. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148180. * The queries will try to find a solution within those bounds
  148181. * default is (1,1,1)
  148182. * @param extent x,y,z value that define the extent around the queries point of reference
  148183. */
  148184. setDefaultQueryExtent(extent: Vector3): void;
  148185. /**
  148186. * Get the Bounding box extent specified by setDefaultQueryExtent
  148187. * @returns the box extent values
  148188. */
  148189. getDefaultQueryExtent(): Vector3;
  148190. /**
  148191. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148192. * @param result output the box extent values
  148193. */
  148194. getDefaultQueryExtentToRef(result: Vector3): void;
  148195. /**
  148196. * Release all resources
  148197. */
  148198. dispose(): void;
  148199. }
  148200. /**
  148201. * Configures an agent
  148202. */
  148203. export interface IAgentParameters {
  148204. /**
  148205. * Agent radius. [Limit: >= 0]
  148206. */
  148207. radius: number;
  148208. /**
  148209. * Agent height. [Limit: > 0]
  148210. */
  148211. height: number;
  148212. /**
  148213. * Maximum allowed acceleration. [Limit: >= 0]
  148214. */
  148215. maxAcceleration: number;
  148216. /**
  148217. * Maximum allowed speed. [Limit: >= 0]
  148218. */
  148219. maxSpeed: number;
  148220. /**
  148221. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  148222. */
  148223. collisionQueryRange: number;
  148224. /**
  148225. * The path visibility optimization range. [Limit: > 0]
  148226. */
  148227. pathOptimizationRange: number;
  148228. /**
  148229. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  148230. */
  148231. separationWeight: number;
  148232. }
  148233. /**
  148234. * Configures the navigation mesh creation
  148235. */
  148236. export interface INavMeshParameters {
  148237. /**
  148238. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  148239. */
  148240. cs: number;
  148241. /**
  148242. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  148243. */
  148244. ch: number;
  148245. /**
  148246. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  148247. */
  148248. walkableSlopeAngle: number;
  148249. /**
  148250. * Minimum floor to 'ceiling' height that will still allow the floor area to
  148251. * be considered walkable. [Limit: >= 3] [Units: vx]
  148252. */
  148253. walkableHeight: number;
  148254. /**
  148255. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  148256. */
  148257. walkableClimb: number;
  148258. /**
  148259. * The distance to erode/shrink the walkable area of the heightfield away from
  148260. * obstructions. [Limit: >=0] [Units: vx]
  148261. */
  148262. walkableRadius: number;
  148263. /**
  148264. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  148265. */
  148266. maxEdgeLen: number;
  148267. /**
  148268. * The maximum distance a simplfied contour's border edges should deviate
  148269. * the original raw contour. [Limit: >=0] [Units: vx]
  148270. */
  148271. maxSimplificationError: number;
  148272. /**
  148273. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  148274. */
  148275. minRegionArea: number;
  148276. /**
  148277. * Any regions with a span count smaller than this value will, if possible,
  148278. * be merged with larger regions. [Limit: >=0] [Units: vx]
  148279. */
  148280. mergeRegionArea: number;
  148281. /**
  148282. * The maximum number of vertices allowed for polygons generated during the
  148283. * contour to polygon conversion process. [Limit: >= 3]
  148284. */
  148285. maxVertsPerPoly: number;
  148286. /**
  148287. * Sets the sampling distance to use when generating the detail mesh.
  148288. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  148289. */
  148290. detailSampleDist: number;
  148291. /**
  148292. * The maximum distance the detail mesh surface should deviate from heightfield
  148293. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  148294. */
  148295. detailSampleMaxError: number;
  148296. }
  148297. }
  148298. declare module BABYLON {
  148299. /**
  148300. * RecastJS navigation plugin
  148301. */
  148302. export class RecastJSPlugin implements INavigationEnginePlugin {
  148303. /**
  148304. * Reference to the Recast library
  148305. */
  148306. bjsRECAST: any;
  148307. /**
  148308. * plugin name
  148309. */
  148310. name: string;
  148311. /**
  148312. * the first navmesh created. We might extend this to support multiple navmeshes
  148313. */
  148314. navMesh: any;
  148315. /**
  148316. * Initializes the recastJS plugin
  148317. * @param recastInjection can be used to inject your own recast reference
  148318. */
  148319. constructor(recastInjection?: any);
  148320. /**
  148321. * Creates a navigation mesh
  148322. * @param meshes array of all the geometry used to compute the navigatio mesh
  148323. * @param parameters bunch of parameters used to filter geometry
  148324. */
  148325. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148326. /**
  148327. * Create a navigation mesh debug mesh
  148328. * @param scene is where the mesh will be added
  148329. * @returns debug display mesh
  148330. */
  148331. createDebugNavMesh(scene: Scene): Mesh;
  148332. /**
  148333. * Get a navigation mesh constrained position, closest to the parameter position
  148334. * @param position world position
  148335. * @returns the closest point to position constrained by the navigation mesh
  148336. */
  148337. getClosestPoint(position: Vector3): Vector3;
  148338. /**
  148339. * Get a navigation mesh constrained position, closest to the parameter position
  148340. * @param position world position
  148341. * @param result output the closest point to position constrained by the navigation mesh
  148342. */
  148343. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148344. /**
  148345. * Get a navigation mesh constrained position, within a particular radius
  148346. * @param position world position
  148347. * @param maxRadius the maximum distance to the constrained world position
  148348. * @returns the closest point to position constrained by the navigation mesh
  148349. */
  148350. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148351. /**
  148352. * Get a navigation mesh constrained position, within a particular radius
  148353. * @param position world position
  148354. * @param maxRadius the maximum distance to the constrained world position
  148355. * @param result output the closest point to position constrained by the navigation mesh
  148356. */
  148357. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148358. /**
  148359. * Compute the final position from a segment made of destination-position
  148360. * @param position world position
  148361. * @param destination world position
  148362. * @returns the resulting point along the navmesh
  148363. */
  148364. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148365. /**
  148366. * Compute the final position from a segment made of destination-position
  148367. * @param position world position
  148368. * @param destination world position
  148369. * @param result output the resulting point along the navmesh
  148370. */
  148371. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148372. /**
  148373. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148374. * @param start world position
  148375. * @param end world position
  148376. * @returns array containing world position composing the path
  148377. */
  148378. computePath(start: Vector3, end: Vector3): Vector3[];
  148379. /**
  148380. * Create a new Crowd so you can add agents
  148381. * @param maxAgents the maximum agent count in the crowd
  148382. * @param maxAgentRadius the maximum radius an agent can have
  148383. * @param scene to attach the crowd to
  148384. * @returns the crowd you can add agents to
  148385. */
  148386. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148387. /**
  148388. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148389. * The queries will try to find a solution within those bounds
  148390. * default is (1,1,1)
  148391. * @param extent x,y,z value that define the extent around the queries point of reference
  148392. */
  148393. setDefaultQueryExtent(extent: Vector3): void;
  148394. /**
  148395. * Get the Bounding box extent specified by setDefaultQueryExtent
  148396. * @returns the box extent values
  148397. */
  148398. getDefaultQueryExtent(): Vector3;
  148399. /**
  148400. * build the navmesh from a previously saved state using getNavmeshData
  148401. * @param data the Uint8Array returned by getNavmeshData
  148402. */
  148403. buildFromNavmeshData(data: Uint8Array): void;
  148404. /**
  148405. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148406. * @returns data the Uint8Array that can be saved and reused
  148407. */
  148408. getNavmeshData(): Uint8Array;
  148409. /**
  148410. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148411. * @param result output the box extent values
  148412. */
  148413. getDefaultQueryExtentToRef(result: Vector3): void;
  148414. /**
  148415. * Disposes
  148416. */
  148417. dispose(): void;
  148418. /**
  148419. * If this plugin is supported
  148420. * @returns true if plugin is supported
  148421. */
  148422. isSupported(): boolean;
  148423. }
  148424. /**
  148425. * Recast detour crowd implementation
  148426. */
  148427. export class RecastJSCrowd implements ICrowd {
  148428. /**
  148429. * Recast/detour plugin
  148430. */
  148431. bjsRECASTPlugin: RecastJSPlugin;
  148432. /**
  148433. * Link to the detour crowd
  148434. */
  148435. recastCrowd: any;
  148436. /**
  148437. * One transform per agent
  148438. */
  148439. transforms: TransformNode[];
  148440. /**
  148441. * All agents created
  148442. */
  148443. agents: number[];
  148444. /**
  148445. * Link to the scene is kept to unregister the crowd from the scene
  148446. */
  148447. private _scene;
  148448. /**
  148449. * Observer for crowd updates
  148450. */
  148451. private _onBeforeAnimationsObserver;
  148452. /**
  148453. * Constructor
  148454. * @param plugin recastJS plugin
  148455. * @param maxAgents the maximum agent count in the crowd
  148456. * @param maxAgentRadius the maximum radius an agent can have
  148457. * @param scene to attach the crowd to
  148458. * @returns the crowd you can add agents to
  148459. */
  148460. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  148461. /**
  148462. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148463. * You can attach anything to that node. The node position is updated in the scene update tick.
  148464. * @param pos world position that will be constrained by the navigation mesh
  148465. * @param parameters agent parameters
  148466. * @param transform hooked to the agent that will be update by the scene
  148467. * @returns agent index
  148468. */
  148469. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148470. /**
  148471. * Returns the agent position in world space
  148472. * @param index agent index returned by addAgent
  148473. * @returns world space position
  148474. */
  148475. getAgentPosition(index: number): Vector3;
  148476. /**
  148477. * Returns the agent position result in world space
  148478. * @param index agent index returned by addAgent
  148479. * @param result output world space position
  148480. */
  148481. getAgentPositionToRef(index: number, result: Vector3): void;
  148482. /**
  148483. * Returns the agent velocity in world space
  148484. * @param index agent index returned by addAgent
  148485. * @returns world space velocity
  148486. */
  148487. getAgentVelocity(index: number): Vector3;
  148488. /**
  148489. * Returns the agent velocity result in world space
  148490. * @param index agent index returned by addAgent
  148491. * @param result output world space velocity
  148492. */
  148493. getAgentVelocityToRef(index: number, result: Vector3): void;
  148494. /**
  148495. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148496. * @param index agent index returned by addAgent
  148497. * @param destination targeted world position
  148498. */
  148499. agentGoto(index: number, destination: Vector3): void;
  148500. /**
  148501. * Teleport the agent to a new position
  148502. * @param index agent index returned by addAgent
  148503. * @param destination targeted world position
  148504. */
  148505. agentTeleport(index: number, destination: Vector3): void;
  148506. /**
  148507. * Update agent parameters
  148508. * @param index agent index returned by addAgent
  148509. * @param parameters agent parameters
  148510. */
  148511. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148512. /**
  148513. * remove a particular agent previously created
  148514. * @param index agent index returned by addAgent
  148515. */
  148516. removeAgent(index: number): void;
  148517. /**
  148518. * get the list of all agents attached to this crowd
  148519. * @returns list of agent indices
  148520. */
  148521. getAgents(): number[];
  148522. /**
  148523. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148524. * @param deltaTime in seconds
  148525. */
  148526. update(deltaTime: number): void;
  148527. /**
  148528. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148529. * The queries will try to find a solution within those bounds
  148530. * default is (1,1,1)
  148531. * @param extent x,y,z value that define the extent around the queries point of reference
  148532. */
  148533. setDefaultQueryExtent(extent: Vector3): void;
  148534. /**
  148535. * Get the Bounding box extent specified by setDefaultQueryExtent
  148536. * @returns the box extent values
  148537. */
  148538. getDefaultQueryExtent(): Vector3;
  148539. /**
  148540. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148541. * @param result output the box extent values
  148542. */
  148543. getDefaultQueryExtentToRef(result: Vector3): void;
  148544. /**
  148545. * Release all resources
  148546. */
  148547. dispose(): void;
  148548. }
  148549. }
  148550. declare module BABYLON {
  148551. /**
  148552. * Class used to enable access to IndexedDB
  148553. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  148554. */
  148555. export class Database implements IOfflineProvider {
  148556. private _callbackManifestChecked;
  148557. private _currentSceneUrl;
  148558. private _db;
  148559. private _enableSceneOffline;
  148560. private _enableTexturesOffline;
  148561. private _manifestVersionFound;
  148562. private _mustUpdateRessources;
  148563. private _hasReachedQuota;
  148564. private _isSupported;
  148565. private _idbFactory;
  148566. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  148567. private static IsUASupportingBlobStorage;
  148568. /**
  148569. * Gets a boolean indicating if Database storate is enabled (off by default)
  148570. */
  148571. static IDBStorageEnabled: boolean;
  148572. /**
  148573. * Gets a boolean indicating if scene must be saved in the database
  148574. */
  148575. get enableSceneOffline(): boolean;
  148576. /**
  148577. * Gets a boolean indicating if textures must be saved in the database
  148578. */
  148579. get enableTexturesOffline(): boolean;
  148580. /**
  148581. * Creates a new Database
  148582. * @param urlToScene defines the url to load the scene
  148583. * @param callbackManifestChecked defines the callback to use when manifest is checked
  148584. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  148585. */
  148586. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  148587. private static _ParseURL;
  148588. private static _ReturnFullUrlLocation;
  148589. private _checkManifestFile;
  148590. /**
  148591. * Open the database and make it available
  148592. * @param successCallback defines the callback to call on success
  148593. * @param errorCallback defines the callback to call on error
  148594. */
  148595. open(successCallback: () => void, errorCallback: () => void): void;
  148596. /**
  148597. * Loads an image from the database
  148598. * @param url defines the url to load from
  148599. * @param image defines the target DOM image
  148600. */
  148601. loadImage(url: string, image: HTMLImageElement): void;
  148602. private _loadImageFromDBAsync;
  148603. private _saveImageIntoDBAsync;
  148604. private _checkVersionFromDB;
  148605. private _loadVersionFromDBAsync;
  148606. private _saveVersionIntoDBAsync;
  148607. /**
  148608. * Loads a file from database
  148609. * @param url defines the URL to load from
  148610. * @param sceneLoaded defines a callback to call on success
  148611. * @param progressCallBack defines a callback to call when progress changed
  148612. * @param errorCallback defines a callback to call on error
  148613. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  148614. */
  148615. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  148616. private _loadFileAsync;
  148617. private _saveFileAsync;
  148618. /**
  148619. * Validates if xhr data is correct
  148620. * @param xhr defines the request to validate
  148621. * @param dataType defines the expected data type
  148622. * @returns true if data is correct
  148623. */
  148624. private static _ValidateXHRData;
  148625. }
  148626. }
  148627. declare module BABYLON {
  148628. /** @hidden */
  148629. export var gpuUpdateParticlesPixelShader: {
  148630. name: string;
  148631. shader: string;
  148632. };
  148633. }
  148634. declare module BABYLON {
  148635. /** @hidden */
  148636. export var gpuUpdateParticlesVertexShader: {
  148637. name: string;
  148638. shader: string;
  148639. };
  148640. }
  148641. declare module BABYLON {
  148642. /** @hidden */
  148643. export var clipPlaneFragmentDeclaration2: {
  148644. name: string;
  148645. shader: string;
  148646. };
  148647. }
  148648. declare module BABYLON {
  148649. /** @hidden */
  148650. export var gpuRenderParticlesPixelShader: {
  148651. name: string;
  148652. shader: string;
  148653. };
  148654. }
  148655. declare module BABYLON {
  148656. /** @hidden */
  148657. export var clipPlaneVertexDeclaration2: {
  148658. name: string;
  148659. shader: string;
  148660. };
  148661. }
  148662. declare module BABYLON {
  148663. /** @hidden */
  148664. export var gpuRenderParticlesVertexShader: {
  148665. name: string;
  148666. shader: string;
  148667. };
  148668. }
  148669. declare module BABYLON {
  148670. /**
  148671. * This represents a GPU particle system in Babylon
  148672. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  148673. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  148674. */
  148675. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  148676. /**
  148677. * The layer mask we are rendering the particles through.
  148678. */
  148679. layerMask: number;
  148680. private _capacity;
  148681. private _activeCount;
  148682. private _currentActiveCount;
  148683. private _accumulatedCount;
  148684. private _renderEffect;
  148685. private _updateEffect;
  148686. private _buffer0;
  148687. private _buffer1;
  148688. private _spriteBuffer;
  148689. private _updateVAO;
  148690. private _renderVAO;
  148691. private _targetIndex;
  148692. private _sourceBuffer;
  148693. private _targetBuffer;
  148694. private _currentRenderId;
  148695. private _started;
  148696. private _stopped;
  148697. private _timeDelta;
  148698. private _randomTexture;
  148699. private _randomTexture2;
  148700. private _attributesStrideSize;
  148701. private _updateEffectOptions;
  148702. private _randomTextureSize;
  148703. private _actualFrame;
  148704. private _customEffect;
  148705. private readonly _rawTextureWidth;
  148706. /**
  148707. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  148708. */
  148709. static get IsSupported(): boolean;
  148710. /**
  148711. * An event triggered when the system is disposed.
  148712. */
  148713. onDisposeObservable: Observable<IParticleSystem>;
  148714. /**
  148715. * An event triggered when the system is stopped
  148716. */
  148717. onStoppedObservable: Observable<IParticleSystem>;
  148718. /**
  148719. * Gets the maximum number of particles active at the same time.
  148720. * @returns The max number of active particles.
  148721. */
  148722. getCapacity(): number;
  148723. /**
  148724. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  148725. * to override the particles.
  148726. */
  148727. forceDepthWrite: boolean;
  148728. /**
  148729. * Gets or set the number of active particles
  148730. */
  148731. get activeParticleCount(): number;
  148732. set activeParticleCount(value: number);
  148733. private _preWarmDone;
  148734. /**
  148735. * Specifies if the particles are updated in emitter local space or world space.
  148736. */
  148737. isLocal: boolean;
  148738. /** Gets or sets a matrix to use to compute projection */
  148739. defaultProjectionMatrix: Matrix;
  148740. /**
  148741. * Is this system ready to be used/rendered
  148742. * @return true if the system is ready
  148743. */
  148744. isReady(): boolean;
  148745. /**
  148746. * Gets if the system has been started. (Note: this will still be true after stop is called)
  148747. * @returns True if it has been started, otherwise false.
  148748. */
  148749. isStarted(): boolean;
  148750. /**
  148751. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  148752. * @returns True if it has been stopped, otherwise false.
  148753. */
  148754. isStopped(): boolean;
  148755. /**
  148756. * Gets a boolean indicating that the system is stopping
  148757. * @returns true if the system is currently stopping
  148758. */
  148759. isStopping(): boolean;
  148760. /**
  148761. * Gets the number of particles active at the same time.
  148762. * @returns The number of active particles.
  148763. */
  148764. getActiveCount(): number;
  148765. /**
  148766. * Starts the particle system and begins to emit
  148767. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  148768. */
  148769. start(delay?: number): void;
  148770. /**
  148771. * Stops the particle system.
  148772. */
  148773. stop(): void;
  148774. /**
  148775. * Remove all active particles
  148776. */
  148777. reset(): void;
  148778. /**
  148779. * Returns the string "GPUParticleSystem"
  148780. * @returns a string containing the class name
  148781. */
  148782. getClassName(): string;
  148783. /**
  148784. * Gets the custom effect used to render the particles
  148785. * @param blendMode Blend mode for which the effect should be retrieved
  148786. * @returns The effect
  148787. */
  148788. getCustomEffect(blendMode?: number): Nullable<Effect>;
  148789. /**
  148790. * Sets the custom effect used to render the particles
  148791. * @param effect The effect to set
  148792. * @param blendMode Blend mode for which the effect should be set
  148793. */
  148794. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  148795. /** @hidden */
  148796. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  148797. /**
  148798. * Observable that will be called just before the particles are drawn
  148799. */
  148800. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  148801. /**
  148802. * Gets the name of the particle vertex shader
  148803. */
  148804. get vertexShaderName(): string;
  148805. private _colorGradientsTexture;
  148806. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  148807. /**
  148808. * Adds a new color gradient
  148809. * @param gradient defines the gradient to use (between 0 and 1)
  148810. * @param color1 defines the color to affect to the specified gradient
  148811. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  148812. * @returns the current particle system
  148813. */
  148814. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  148815. private _refreshColorGradient;
  148816. /** Force the system to rebuild all gradients that need to be resync */
  148817. forceRefreshGradients(): void;
  148818. /**
  148819. * Remove a specific color gradient
  148820. * @param gradient defines the gradient to remove
  148821. * @returns the current particle system
  148822. */
  148823. removeColorGradient(gradient: number): GPUParticleSystem;
  148824. private _angularSpeedGradientsTexture;
  148825. private _sizeGradientsTexture;
  148826. private _velocityGradientsTexture;
  148827. private _limitVelocityGradientsTexture;
  148828. private _dragGradientsTexture;
  148829. private _addFactorGradient;
  148830. /**
  148831. * Adds a new size gradient
  148832. * @param gradient defines the gradient to use (between 0 and 1)
  148833. * @param factor defines the size factor to affect to the specified gradient
  148834. * @returns the current particle system
  148835. */
  148836. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  148837. /**
  148838. * Remove a specific size gradient
  148839. * @param gradient defines the gradient to remove
  148840. * @returns the current particle system
  148841. */
  148842. removeSizeGradient(gradient: number): GPUParticleSystem;
  148843. private _refreshFactorGradient;
  148844. /**
  148845. * Adds a new angular speed gradient
  148846. * @param gradient defines the gradient to use (between 0 and 1)
  148847. * @param factor defines the angular speed to affect to the specified gradient
  148848. * @returns the current particle system
  148849. */
  148850. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  148851. /**
  148852. * Remove a specific angular speed gradient
  148853. * @param gradient defines the gradient to remove
  148854. * @returns the current particle system
  148855. */
  148856. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  148857. /**
  148858. * Adds a new velocity gradient
  148859. * @param gradient defines the gradient to use (between 0 and 1)
  148860. * @param factor defines the velocity to affect to the specified gradient
  148861. * @returns the current particle system
  148862. */
  148863. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148864. /**
  148865. * Remove a specific velocity gradient
  148866. * @param gradient defines the gradient to remove
  148867. * @returns the current particle system
  148868. */
  148869. removeVelocityGradient(gradient: number): GPUParticleSystem;
  148870. /**
  148871. * Adds a new limit velocity gradient
  148872. * @param gradient defines the gradient to use (between 0 and 1)
  148873. * @param factor defines the limit velocity value to affect to the specified gradient
  148874. * @returns the current particle system
  148875. */
  148876. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148877. /**
  148878. * Remove a specific limit velocity gradient
  148879. * @param gradient defines the gradient to remove
  148880. * @returns the current particle system
  148881. */
  148882. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  148883. /**
  148884. * Adds a new drag gradient
  148885. * @param gradient defines the gradient to use (between 0 and 1)
  148886. * @param factor defines the drag value to affect to the specified gradient
  148887. * @returns the current particle system
  148888. */
  148889. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  148890. /**
  148891. * Remove a specific drag gradient
  148892. * @param gradient defines the gradient to remove
  148893. * @returns the current particle system
  148894. */
  148895. removeDragGradient(gradient: number): GPUParticleSystem;
  148896. /**
  148897. * Not supported by GPUParticleSystem
  148898. * @param gradient defines the gradient to use (between 0 and 1)
  148899. * @param factor defines the emit rate value to affect to the specified gradient
  148900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148901. * @returns the current particle system
  148902. */
  148903. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148904. /**
  148905. * Not supported by GPUParticleSystem
  148906. * @param gradient defines the gradient to remove
  148907. * @returns the current particle system
  148908. */
  148909. removeEmitRateGradient(gradient: number): IParticleSystem;
  148910. /**
  148911. * Not supported by GPUParticleSystem
  148912. * @param gradient defines the gradient to use (between 0 and 1)
  148913. * @param factor defines the start size value to affect to the specified gradient
  148914. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148915. * @returns the current particle system
  148916. */
  148917. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148918. /**
  148919. * Not supported by GPUParticleSystem
  148920. * @param gradient defines the gradient to remove
  148921. * @returns the current particle system
  148922. */
  148923. removeStartSizeGradient(gradient: number): IParticleSystem;
  148924. /**
  148925. * Not supported by GPUParticleSystem
  148926. * @param gradient defines the gradient to use (between 0 and 1)
  148927. * @param min defines the color remap minimal range
  148928. * @param max defines the color remap maximal range
  148929. * @returns the current particle system
  148930. */
  148931. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148932. /**
  148933. * Not supported by GPUParticleSystem
  148934. * @param gradient defines the gradient to remove
  148935. * @returns the current particle system
  148936. */
  148937. removeColorRemapGradient(): IParticleSystem;
  148938. /**
  148939. * Not supported by GPUParticleSystem
  148940. * @param gradient defines the gradient to use (between 0 and 1)
  148941. * @param min defines the alpha remap minimal range
  148942. * @param max defines the alpha remap maximal range
  148943. * @returns the current particle system
  148944. */
  148945. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148946. /**
  148947. * Not supported by GPUParticleSystem
  148948. * @param gradient defines the gradient to remove
  148949. * @returns the current particle system
  148950. */
  148951. removeAlphaRemapGradient(): IParticleSystem;
  148952. /**
  148953. * Not supported by GPUParticleSystem
  148954. * @param gradient defines the gradient to use (between 0 and 1)
  148955. * @param color defines the color to affect to the specified gradient
  148956. * @returns the current particle system
  148957. */
  148958. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  148959. /**
  148960. * Not supported by GPUParticleSystem
  148961. * @param gradient defines the gradient to remove
  148962. * @returns the current particle system
  148963. */
  148964. removeRampGradient(): IParticleSystem;
  148965. /**
  148966. * Not supported by GPUParticleSystem
  148967. * @returns the list of ramp gradients
  148968. */
  148969. getRampGradients(): Nullable<Array<Color3Gradient>>;
  148970. /**
  148971. * Not supported by GPUParticleSystem
  148972. * Gets or sets a boolean indicating that ramp gradients must be used
  148973. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  148974. */
  148975. get useRampGradients(): boolean;
  148976. set useRampGradients(value: boolean);
  148977. /**
  148978. * Not supported by GPUParticleSystem
  148979. * @param gradient defines the gradient to use (between 0 and 1)
  148980. * @param factor defines the life time factor to affect to the specified gradient
  148981. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148982. * @returns the current particle system
  148983. */
  148984. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148985. /**
  148986. * Not supported by GPUParticleSystem
  148987. * @param gradient defines the gradient to remove
  148988. * @returns the current particle system
  148989. */
  148990. removeLifeTimeGradient(gradient: number): IParticleSystem;
  148991. /**
  148992. * Instantiates a GPU particle system.
  148993. * 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.
  148994. * @param name The name of the particle system
  148995. * @param options The options used to create the system
  148996. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  148997. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  148998. * @param customEffect a custom effect used to change the way particles are rendered by default
  148999. */
  149000. constructor(name: string, options: Partial<{
  149001. capacity: number;
  149002. randomTextureSize: number;
  149003. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  149004. protected _reset(): void;
  149005. private _createUpdateVAO;
  149006. private _createRenderVAO;
  149007. private _initialize;
  149008. /** @hidden */
  149009. _recreateUpdateEffect(): void;
  149010. private _getEffect;
  149011. /**
  149012. * Fill the defines array according to the current settings of the particle system
  149013. * @param defines Array to be updated
  149014. * @param blendMode blend mode to take into account when updating the array
  149015. */
  149016. fillDefines(defines: Array<string>, blendMode?: number): void;
  149017. /**
  149018. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  149019. * @param uniforms Uniforms array to fill
  149020. * @param attributes Attributes array to fill
  149021. * @param samplers Samplers array to fill
  149022. */
  149023. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  149024. /** @hidden */
  149025. _recreateRenderEffect(): Effect;
  149026. /**
  149027. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  149028. * @param preWarm defines if we are in the pre-warmimg phase
  149029. */
  149030. animate(preWarm?: boolean): void;
  149031. private _createFactorGradientTexture;
  149032. private _createSizeGradientTexture;
  149033. private _createAngularSpeedGradientTexture;
  149034. private _createVelocityGradientTexture;
  149035. private _createLimitVelocityGradientTexture;
  149036. private _createDragGradientTexture;
  149037. private _createColorGradientTexture;
  149038. /**
  149039. * Renders the particle system in its current state
  149040. * @param preWarm defines if the system should only update the particles but not render them
  149041. * @returns the current number of particles
  149042. */
  149043. render(preWarm?: boolean): number;
  149044. /**
  149045. * Rebuilds the particle system
  149046. */
  149047. rebuild(): void;
  149048. private _releaseBuffers;
  149049. private _releaseVAOs;
  149050. /**
  149051. * Disposes the particle system and free the associated resources
  149052. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  149053. */
  149054. dispose(disposeTexture?: boolean): void;
  149055. /**
  149056. * Clones the particle system.
  149057. * @param name The name of the cloned object
  149058. * @param newEmitter The new emitter to use
  149059. * @returns the cloned particle system
  149060. */
  149061. clone(name: string, newEmitter: any): GPUParticleSystem;
  149062. /**
  149063. * Serializes the particle system to a JSON object
  149064. * @param serializeTexture defines if the texture must be serialized as well
  149065. * @returns the JSON object
  149066. */
  149067. serialize(serializeTexture?: boolean): any;
  149068. /**
  149069. * Parses a JSON object to create a GPU particle system.
  149070. * @param parsedParticleSystem The JSON object to parse
  149071. * @param sceneOrEngine The scene or the engine to create the particle system in
  149072. * @param rootUrl The root url to use to load external dependencies like texture
  149073. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  149074. * @returns the parsed GPU particle system
  149075. */
  149076. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  149077. }
  149078. }
  149079. declare module BABYLON {
  149080. /**
  149081. * Represents a set of particle systems working together to create a specific effect
  149082. */
  149083. export class ParticleSystemSet implements IDisposable {
  149084. /**
  149085. * Gets or sets base Assets URL
  149086. */
  149087. static BaseAssetsUrl: string;
  149088. private _emitterCreationOptions;
  149089. private _emitterNode;
  149090. /**
  149091. * Gets the particle system list
  149092. */
  149093. systems: IParticleSystem[];
  149094. /**
  149095. * Gets the emitter node used with this set
  149096. */
  149097. get emitterNode(): Nullable<TransformNode>;
  149098. /**
  149099. * Creates a new emitter mesh as a sphere
  149100. * @param options defines the options used to create the sphere
  149101. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  149102. * @param scene defines the hosting scene
  149103. */
  149104. setEmitterAsSphere(options: {
  149105. diameter: number;
  149106. segments: number;
  149107. color: Color3;
  149108. }, renderingGroupId: number, scene: Scene): void;
  149109. /**
  149110. * Starts all particle systems of the set
  149111. * @param emitter defines an optional mesh to use as emitter for the particle systems
  149112. */
  149113. start(emitter?: AbstractMesh): void;
  149114. /**
  149115. * Release all associated resources
  149116. */
  149117. dispose(): void;
  149118. /**
  149119. * Serialize the set into a JSON compatible object
  149120. * @param serializeTexture defines if the texture must be serialized as well
  149121. * @returns a JSON compatible representation of the set
  149122. */
  149123. serialize(serializeTexture?: boolean): any;
  149124. /**
  149125. * Parse a new ParticleSystemSet from a serialized source
  149126. * @param data defines a JSON compatible representation of the set
  149127. * @param scene defines the hosting scene
  149128. * @param gpu defines if we want GPU particles or CPU particles
  149129. * @returns a new ParticleSystemSet
  149130. */
  149131. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  149132. }
  149133. }
  149134. declare module BABYLON {
  149135. /**
  149136. * This class is made for on one-liner static method to help creating particle system set.
  149137. */
  149138. export class ParticleHelper {
  149139. /**
  149140. * Gets or sets base Assets URL
  149141. */
  149142. static BaseAssetsUrl: string;
  149143. /** Define the Url to load snippets */
  149144. static SnippetUrl: string;
  149145. /**
  149146. * Create a default particle system that you can tweak
  149147. * @param emitter defines the emitter to use
  149148. * @param capacity defines the system capacity (default is 500 particles)
  149149. * @param scene defines the hosting scene
  149150. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  149151. * @returns the new Particle system
  149152. */
  149153. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  149154. /**
  149155. * This is the main static method (one-liner) of this helper to create different particle systems
  149156. * @param type This string represents the type to the particle system to create
  149157. * @param scene The scene where the particle system should live
  149158. * @param gpu If the system will use gpu
  149159. * @returns the ParticleSystemSet created
  149160. */
  149161. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  149162. /**
  149163. * Static function used to export a particle system to a ParticleSystemSet variable.
  149164. * Please note that the emitter shape is not exported
  149165. * @param systems defines the particle systems to export
  149166. * @returns the created particle system set
  149167. */
  149168. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  149169. /**
  149170. * Creates a particle system from a snippet saved in a remote file
  149171. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  149172. * @param url defines the url to load from
  149173. * @param scene defines the hosting scene
  149174. * @param gpu If the system will use gpu
  149175. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149176. * @returns a promise that will resolve to the new particle system
  149177. */
  149178. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149179. /**
  149180. * Creates a particle system from a snippet saved by the particle system editor
  149181. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  149182. * @param scene defines the hosting scene
  149183. * @param gpu If the system will use gpu
  149184. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149185. * @returns a promise that will resolve to the new particle system
  149186. */
  149187. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149188. }
  149189. }
  149190. declare module BABYLON {
  149191. interface Engine {
  149192. /**
  149193. * Create an effect to use with particle systems.
  149194. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  149195. * the particle system for which you want to create a custom effect in the last parameter
  149196. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  149197. * @param uniformsNames defines a list of attribute names
  149198. * @param samplers defines an array of string used to represent textures
  149199. * @param defines defines the string containing the defines to use to compile the shaders
  149200. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  149201. * @param onCompiled defines a function to call when the effect creation is successful
  149202. * @param onError defines a function to call when the effect creation has failed
  149203. * @param particleSystem the particle system you want to create the effect for
  149204. * @returns the new Effect
  149205. */
  149206. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  149207. }
  149208. interface Mesh {
  149209. /**
  149210. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  149211. * @returns an array of IParticleSystem
  149212. */
  149213. getEmittedParticleSystems(): IParticleSystem[];
  149214. /**
  149215. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  149216. * @returns an array of IParticleSystem
  149217. */
  149218. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  149219. }
  149220. }
  149221. declare module BABYLON {
  149222. /** Defines the 4 color options */
  149223. export enum PointColor {
  149224. /** color value */
  149225. Color = 2,
  149226. /** uv value */
  149227. UV = 1,
  149228. /** random value */
  149229. Random = 0,
  149230. /** stated value */
  149231. Stated = 3
  149232. }
  149233. /**
  149234. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  149235. * 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.
  149236. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  149237. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  149238. *
  149239. * Full documentation here : TO BE ENTERED
  149240. */
  149241. export class PointsCloudSystem implements IDisposable {
  149242. /**
  149243. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  149244. * Example : var p = SPS.particles[i];
  149245. */
  149246. particles: CloudPoint[];
  149247. /**
  149248. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  149249. */
  149250. nbParticles: number;
  149251. /**
  149252. * This a counter for your own usage. It's not set by any SPS functions.
  149253. */
  149254. counter: number;
  149255. /**
  149256. * The PCS name. This name is also given to the underlying mesh.
  149257. */
  149258. name: string;
  149259. /**
  149260. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  149261. */
  149262. mesh: Mesh;
  149263. /**
  149264. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  149265. * Please read :
  149266. */
  149267. vars: any;
  149268. /**
  149269. * @hidden
  149270. */
  149271. _size: number;
  149272. private _scene;
  149273. private _promises;
  149274. private _positions;
  149275. private _indices;
  149276. private _normals;
  149277. private _colors;
  149278. private _uvs;
  149279. private _indices32;
  149280. private _positions32;
  149281. private _colors32;
  149282. private _uvs32;
  149283. private _updatable;
  149284. private _isVisibilityBoxLocked;
  149285. private _alwaysVisible;
  149286. private _groups;
  149287. private _groupCounter;
  149288. private _computeParticleColor;
  149289. private _computeParticleTexture;
  149290. private _computeParticleRotation;
  149291. private _computeBoundingBox;
  149292. private _isReady;
  149293. /**
  149294. * Creates a PCS (Points Cloud System) object
  149295. * @param name (String) is the PCS name, this will be the underlying mesh name
  149296. * @param pointSize (number) is the size for each point
  149297. * @param scene (Scene) is the scene in which the PCS is added
  149298. * @param options defines the options of the PCS e.g.
  149299. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  149300. */
  149301. constructor(name: string, pointSize: number, scene: Scene, options?: {
  149302. updatable?: boolean;
  149303. });
  149304. /**
  149305. * Builds the PCS underlying mesh. Returns a standard Mesh.
  149306. * If no points were added to the PCS, the returned mesh is just a single point.
  149307. * @returns a promise for the created mesh
  149308. */
  149309. buildMeshAsync(): Promise<Mesh>;
  149310. /**
  149311. * @hidden
  149312. */
  149313. private _buildMesh;
  149314. private _addParticle;
  149315. private _randomUnitVector;
  149316. private _getColorIndicesForCoord;
  149317. private _setPointsColorOrUV;
  149318. private _colorFromTexture;
  149319. private _calculateDensity;
  149320. /**
  149321. * Adds points to the PCS in random positions within a unit sphere
  149322. * @param nb (positive integer) the number of particles to be created from this model
  149323. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  149324. * @returns the number of groups in the system
  149325. */
  149326. addPoints(nb: number, pointFunction?: any): number;
  149327. /**
  149328. * Adds points to the PCS from the surface of 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. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149337. /**
  149338. * Adds points to the PCS inside the model shape
  149339. * @param mesh is any Mesh object that will be used as a surface model for the points
  149340. * @param nb (positive integer) the number of particles to be created from this model
  149341. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  149342. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  149343. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  149344. * @returns the number of groups in the system
  149345. */
  149346. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149347. /**
  149348. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  149349. * This method calls `updateParticle()` for each particle of the SPS.
  149350. * For an animated SPS, it is usually called within the render loop.
  149351. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  149352. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  149353. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  149354. * @returns the PCS.
  149355. */
  149356. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  149357. /**
  149358. * Disposes the PCS.
  149359. */
  149360. dispose(): void;
  149361. /**
  149362. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  149363. * doc :
  149364. * @returns the PCS.
  149365. */
  149366. refreshVisibleSize(): PointsCloudSystem;
  149367. /**
  149368. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  149369. * @param size the size (float) of the visibility box
  149370. * note : this doesn't lock the PCS mesh bounding box.
  149371. * doc :
  149372. */
  149373. setVisibilityBox(size: number): void;
  149374. /**
  149375. * Gets whether the PCS is always visible or not
  149376. * doc :
  149377. */
  149378. get isAlwaysVisible(): boolean;
  149379. /**
  149380. * Sets the PCS as always visible or not
  149381. * doc :
  149382. */
  149383. set isAlwaysVisible(val: boolean);
  149384. /**
  149385. * Tells to `setParticles()` to compute the particle rotations or not
  149386. * Default value : false. The PCS is faster when it's set to false
  149387. * Note : particle rotations are only applied to parent particles
  149388. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  149389. */
  149390. set computeParticleRotation(val: boolean);
  149391. /**
  149392. * Tells to `setParticles()` to compute the particle colors or not.
  149393. * Default value : true. The PCS is faster when it's set to false.
  149394. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149395. */
  149396. set computeParticleColor(val: boolean);
  149397. set computeParticleTexture(val: boolean);
  149398. /**
  149399. * Gets if `setParticles()` computes the particle colors or not.
  149400. * Default value : false. The PCS is faster when it's set to false.
  149401. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149402. */
  149403. get computeParticleColor(): boolean;
  149404. /**
  149405. * Gets if `setParticles()` computes the particle textures or not.
  149406. * Default value : false. The PCS is faster when it's set to false.
  149407. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  149408. */
  149409. get computeParticleTexture(): boolean;
  149410. /**
  149411. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  149412. */
  149413. set computeBoundingBox(val: boolean);
  149414. /**
  149415. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  149416. */
  149417. get computeBoundingBox(): boolean;
  149418. /**
  149419. * This function does nothing. It may be overwritten to set all the particle first values.
  149420. * The PCS doesn't call this function, you may have to call it by your own.
  149421. * doc :
  149422. */
  149423. initParticles(): void;
  149424. /**
  149425. * This function does nothing. It may be overwritten to recycle a particle
  149426. * The PCS doesn't call this function, you can to call it
  149427. * doc :
  149428. * @param particle The particle to recycle
  149429. * @returns the recycled particle
  149430. */
  149431. recycleParticle(particle: CloudPoint): CloudPoint;
  149432. /**
  149433. * Updates a particle : this function should be overwritten by the user.
  149434. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  149435. * doc :
  149436. * @example : just set a particle position or velocity and recycle conditions
  149437. * @param particle The particle to update
  149438. * @returns the updated particle
  149439. */
  149440. updateParticle(particle: CloudPoint): CloudPoint;
  149441. /**
  149442. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  149443. * This does nothing and may be overwritten by the user.
  149444. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149445. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149446. * @param update the boolean update value actually passed to setParticles()
  149447. */
  149448. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149449. /**
  149450. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  149451. * This will be passed three parameters.
  149452. * This does nothing and may be overwritten by the user.
  149453. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149454. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149455. * @param update the boolean update value actually passed to setParticles()
  149456. */
  149457. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149458. }
  149459. }
  149460. declare module BABYLON {
  149461. /**
  149462. * Represents one particle of a points cloud system.
  149463. */
  149464. export class CloudPoint {
  149465. /**
  149466. * particle global index
  149467. */
  149468. idx: number;
  149469. /**
  149470. * The color of the particle
  149471. */
  149472. color: Nullable<Color4>;
  149473. /**
  149474. * The world space position of the particle.
  149475. */
  149476. position: Vector3;
  149477. /**
  149478. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  149479. */
  149480. rotation: Vector3;
  149481. /**
  149482. * The world space rotation quaternion of the particle.
  149483. */
  149484. rotationQuaternion: Nullable<Quaternion>;
  149485. /**
  149486. * The uv of the particle.
  149487. */
  149488. uv: Nullable<Vector2>;
  149489. /**
  149490. * The current speed of the particle.
  149491. */
  149492. velocity: Vector3;
  149493. /**
  149494. * The pivot point in the particle local space.
  149495. */
  149496. pivot: Vector3;
  149497. /**
  149498. * Must the particle be translated from its pivot point in its local space ?
  149499. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  149500. * Default : false
  149501. */
  149502. translateFromPivot: boolean;
  149503. /**
  149504. * Index of this particle in the global "positions" array (Internal use)
  149505. * @hidden
  149506. */
  149507. _pos: number;
  149508. /**
  149509. * @hidden Index of this particle in the global "indices" array (Internal use)
  149510. */
  149511. _ind: number;
  149512. /**
  149513. * Group this particle belongs to
  149514. */
  149515. _group: PointsGroup;
  149516. /**
  149517. * Group id of this particle
  149518. */
  149519. groupId: number;
  149520. /**
  149521. * Index of the particle in its group id (Internal use)
  149522. */
  149523. idxInGroup: number;
  149524. /**
  149525. * @hidden Particle BoundingInfo object (Internal use)
  149526. */
  149527. _boundingInfo: BoundingInfo;
  149528. /**
  149529. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  149530. */
  149531. _pcs: PointsCloudSystem;
  149532. /**
  149533. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  149534. */
  149535. _stillInvisible: boolean;
  149536. /**
  149537. * @hidden Last computed particle rotation matrix
  149538. */
  149539. _rotationMatrix: number[];
  149540. /**
  149541. * Parent particle Id, if any.
  149542. * Default null.
  149543. */
  149544. parentId: Nullable<number>;
  149545. /**
  149546. * @hidden Internal global position in the PCS.
  149547. */
  149548. _globalPosition: Vector3;
  149549. /**
  149550. * Creates a Point Cloud object.
  149551. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  149552. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  149553. * @param group (PointsGroup) is the group the particle belongs to
  149554. * @param groupId (integer) is the group identifier in the PCS.
  149555. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  149556. * @param pcs defines the PCS it is associated to
  149557. */
  149558. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  149559. /**
  149560. * get point size
  149561. */
  149562. get size(): Vector3;
  149563. /**
  149564. * Set point size
  149565. */
  149566. set size(scale: Vector3);
  149567. /**
  149568. * Legacy support, changed quaternion to rotationQuaternion
  149569. */
  149570. get quaternion(): Nullable<Quaternion>;
  149571. /**
  149572. * Legacy support, changed quaternion to rotationQuaternion
  149573. */
  149574. set quaternion(q: Nullable<Quaternion>);
  149575. /**
  149576. * Returns a boolean. True if the particle intersects a mesh, else false
  149577. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  149578. * @param target is the object (point or mesh) what the intersection is computed against
  149579. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  149580. * @returns true if it intersects
  149581. */
  149582. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  149583. /**
  149584. * get the rotation matrix of the particle
  149585. * @hidden
  149586. */
  149587. getRotationMatrix(m: Matrix): void;
  149588. }
  149589. /**
  149590. * Represents a group of points in a points cloud system
  149591. * * PCS internal tool, don't use it manually.
  149592. */
  149593. export class PointsGroup {
  149594. /**
  149595. * The group id
  149596. * @hidden
  149597. */
  149598. groupID: number;
  149599. /**
  149600. * image data for group (internal use)
  149601. * @hidden
  149602. */
  149603. _groupImageData: Nullable<ArrayBufferView>;
  149604. /**
  149605. * Image Width (internal use)
  149606. * @hidden
  149607. */
  149608. _groupImgWidth: number;
  149609. /**
  149610. * Image Height (internal use)
  149611. * @hidden
  149612. */
  149613. _groupImgHeight: number;
  149614. /**
  149615. * Custom position function (internal use)
  149616. * @hidden
  149617. */
  149618. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  149619. /**
  149620. * density per facet for surface points
  149621. * @hidden
  149622. */
  149623. _groupDensity: number[];
  149624. /**
  149625. * Only when points are colored by texture carries pointer to texture list array
  149626. * @hidden
  149627. */
  149628. _textureNb: number;
  149629. /**
  149630. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  149631. * PCS internal tool, don't use it manually.
  149632. * @hidden
  149633. */
  149634. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  149635. }
  149636. }
  149637. declare module BABYLON {
  149638. interface Scene {
  149639. /** @hidden (Backing field) */
  149640. _physicsEngine: Nullable<IPhysicsEngine>;
  149641. /** @hidden */
  149642. _physicsTimeAccumulator: number;
  149643. /**
  149644. * Gets the current physics engine
  149645. * @returns a IPhysicsEngine or null if none attached
  149646. */
  149647. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  149648. /**
  149649. * Enables physics to the current scene
  149650. * @param gravity defines the scene's gravity for the physics engine
  149651. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  149652. * @return a boolean indicating if the physics engine was initialized
  149653. */
  149654. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  149655. /**
  149656. * Disables and disposes the physics engine associated with the scene
  149657. */
  149658. disablePhysicsEngine(): void;
  149659. /**
  149660. * Gets a boolean indicating if there is an active physics engine
  149661. * @returns a boolean indicating if there is an active physics engine
  149662. */
  149663. isPhysicsEnabled(): boolean;
  149664. /**
  149665. * Deletes a physics compound impostor
  149666. * @param compound defines the compound to delete
  149667. */
  149668. deleteCompoundImpostor(compound: any): void;
  149669. /**
  149670. * An event triggered when physic simulation is about to be run
  149671. */
  149672. onBeforePhysicsObservable: Observable<Scene>;
  149673. /**
  149674. * An event triggered when physic simulation has been done
  149675. */
  149676. onAfterPhysicsObservable: Observable<Scene>;
  149677. }
  149678. interface AbstractMesh {
  149679. /** @hidden */
  149680. _physicsImpostor: Nullable<PhysicsImpostor>;
  149681. /**
  149682. * Gets or sets impostor used for physic simulation
  149683. * @see https://doc.babylonjs.com/features/physics_engine
  149684. */
  149685. physicsImpostor: Nullable<PhysicsImpostor>;
  149686. /**
  149687. * Gets the current physics impostor
  149688. * @see https://doc.babylonjs.com/features/physics_engine
  149689. * @returns a physics impostor or null
  149690. */
  149691. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  149692. /** Apply a physic impulse to the mesh
  149693. * @param force defines the force to apply
  149694. * @param contactPoint defines where to apply the force
  149695. * @returns the current mesh
  149696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  149697. */
  149698. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  149699. /**
  149700. * Creates a physic joint between two meshes
  149701. * @param otherMesh defines the other mesh to use
  149702. * @param pivot1 defines the pivot to use on this mesh
  149703. * @param pivot2 defines the pivot to use on the other mesh
  149704. * @param options defines additional options (can be plugin dependent)
  149705. * @returns the current mesh
  149706. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  149707. */
  149708. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  149709. /** @hidden */
  149710. _disposePhysicsObserver: Nullable<Observer<Node>>;
  149711. }
  149712. /**
  149713. * Defines the physics engine scene component responsible to manage a physics engine
  149714. */
  149715. export class PhysicsEngineSceneComponent implements ISceneComponent {
  149716. /**
  149717. * The component name helpful to identify the component in the list of scene components.
  149718. */
  149719. readonly name: string;
  149720. /**
  149721. * The scene the component belongs to.
  149722. */
  149723. scene: Scene;
  149724. /**
  149725. * Creates a new instance of the component for the given scene
  149726. * @param scene Defines the scene to register the component in
  149727. */
  149728. constructor(scene: Scene);
  149729. /**
  149730. * Registers the component in a given scene
  149731. */
  149732. register(): void;
  149733. /**
  149734. * Rebuilds the elements related to this component in case of
  149735. * context lost for instance.
  149736. */
  149737. rebuild(): void;
  149738. /**
  149739. * Disposes the component and the associated ressources
  149740. */
  149741. dispose(): void;
  149742. }
  149743. }
  149744. declare module BABYLON {
  149745. /**
  149746. * A helper for physics simulations
  149747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149748. */
  149749. export class PhysicsHelper {
  149750. private _scene;
  149751. private _physicsEngine;
  149752. /**
  149753. * Initializes the Physics helper
  149754. * @param scene Babylon.js scene
  149755. */
  149756. constructor(scene: Scene);
  149757. /**
  149758. * Applies a radial explosion impulse
  149759. * @param origin the origin of the explosion
  149760. * @param radiusOrEventOptions the radius or the options of radial explosion
  149761. * @param strength the explosion strength
  149762. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149763. * @returns A physics radial explosion event, or null
  149764. */
  149765. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149766. /**
  149767. * Applies a radial explosion force
  149768. * @param origin the origin of the explosion
  149769. * @param radiusOrEventOptions the radius or the options of radial explosion
  149770. * @param strength the explosion strength
  149771. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149772. * @returns A physics radial explosion event, or null
  149773. */
  149774. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149775. /**
  149776. * Creates a gravitational field
  149777. * @param origin the origin of the explosion
  149778. * @param radiusOrEventOptions the radius or the options of radial explosion
  149779. * @param strength the explosion strength
  149780. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149781. * @returns A physics gravitational field event, or null
  149782. */
  149783. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  149784. /**
  149785. * Creates a physics updraft event
  149786. * @param origin the origin of the updraft
  149787. * @param radiusOrEventOptions the radius or the options of the updraft
  149788. * @param strength the strength of the updraft
  149789. * @param height the height of the updraft
  149790. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  149791. * @returns A physics updraft event, or null
  149792. */
  149793. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  149794. /**
  149795. * Creates a physics vortex event
  149796. * @param origin the of the vortex
  149797. * @param radiusOrEventOptions the radius or the options of the vortex
  149798. * @param strength the strength of the vortex
  149799. * @param height the height of the vortex
  149800. * @returns a Physics vortex event, or null
  149801. * A physics vortex event or null
  149802. */
  149803. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  149804. }
  149805. /**
  149806. * Represents a physics radial explosion event
  149807. */
  149808. class PhysicsRadialExplosionEvent {
  149809. private _scene;
  149810. private _options;
  149811. private _sphere;
  149812. private _dataFetched;
  149813. /**
  149814. * Initializes a radial explosioin event
  149815. * @param _scene BabylonJS scene
  149816. * @param _options The options for the vortex event
  149817. */
  149818. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  149819. /**
  149820. * Returns the data related to the radial explosion event (sphere).
  149821. * @returns The radial explosion event data
  149822. */
  149823. getData(): PhysicsRadialExplosionEventData;
  149824. /**
  149825. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  149826. * @param impostor A physics imposter
  149827. * @param origin the origin of the explosion
  149828. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  149829. */
  149830. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  149831. /**
  149832. * Triggers affecterd impostors callbacks
  149833. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  149834. */
  149835. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  149836. /**
  149837. * Disposes the sphere.
  149838. * @param force Specifies if the sphere should be disposed by force
  149839. */
  149840. dispose(force?: boolean): void;
  149841. /*** Helpers ***/
  149842. private _prepareSphere;
  149843. private _intersectsWithSphere;
  149844. }
  149845. /**
  149846. * Represents a gravitational field event
  149847. */
  149848. class PhysicsGravitationalFieldEvent {
  149849. private _physicsHelper;
  149850. private _scene;
  149851. private _origin;
  149852. private _options;
  149853. private _tickCallback;
  149854. private _sphere;
  149855. private _dataFetched;
  149856. /**
  149857. * Initializes the physics gravitational field event
  149858. * @param _physicsHelper A physics helper
  149859. * @param _scene BabylonJS scene
  149860. * @param _origin The origin position of the gravitational field event
  149861. * @param _options The options for the vortex event
  149862. */
  149863. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  149864. /**
  149865. * Returns the data related to the gravitational field event (sphere).
  149866. * @returns A gravitational field event
  149867. */
  149868. getData(): PhysicsGravitationalFieldEventData;
  149869. /**
  149870. * Enables the gravitational field.
  149871. */
  149872. enable(): void;
  149873. /**
  149874. * Disables the gravitational field.
  149875. */
  149876. disable(): void;
  149877. /**
  149878. * Disposes the sphere.
  149879. * @param force The force to dispose from the gravitational field event
  149880. */
  149881. dispose(force?: boolean): void;
  149882. private _tick;
  149883. }
  149884. /**
  149885. * Represents a physics updraft event
  149886. */
  149887. class PhysicsUpdraftEvent {
  149888. private _scene;
  149889. private _origin;
  149890. private _options;
  149891. private _physicsEngine;
  149892. private _originTop;
  149893. private _originDirection;
  149894. private _tickCallback;
  149895. private _cylinder;
  149896. private _cylinderPosition;
  149897. private _dataFetched;
  149898. /**
  149899. * Initializes the physics updraft event
  149900. * @param _scene BabylonJS scene
  149901. * @param _origin The origin position of the updraft
  149902. * @param _options The options for the updraft event
  149903. */
  149904. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  149905. /**
  149906. * Returns the data related to the updraft event (cylinder).
  149907. * @returns A physics updraft event
  149908. */
  149909. getData(): PhysicsUpdraftEventData;
  149910. /**
  149911. * Enables the updraft.
  149912. */
  149913. enable(): void;
  149914. /**
  149915. * Disables the updraft.
  149916. */
  149917. disable(): void;
  149918. /**
  149919. * Disposes the cylinder.
  149920. * @param force Specifies if the updraft should be disposed by force
  149921. */
  149922. dispose(force?: boolean): void;
  149923. private getImpostorHitData;
  149924. private _tick;
  149925. /*** Helpers ***/
  149926. private _prepareCylinder;
  149927. private _intersectsWithCylinder;
  149928. }
  149929. /**
  149930. * Represents a physics vortex event
  149931. */
  149932. class PhysicsVortexEvent {
  149933. private _scene;
  149934. private _origin;
  149935. private _options;
  149936. private _physicsEngine;
  149937. private _originTop;
  149938. private _tickCallback;
  149939. private _cylinder;
  149940. private _cylinderPosition;
  149941. private _dataFetched;
  149942. /**
  149943. * Initializes the physics vortex event
  149944. * @param _scene The BabylonJS scene
  149945. * @param _origin The origin position of the vortex
  149946. * @param _options The options for the vortex event
  149947. */
  149948. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  149949. /**
  149950. * Returns the data related to the vortex event (cylinder).
  149951. * @returns The physics vortex event data
  149952. */
  149953. getData(): PhysicsVortexEventData;
  149954. /**
  149955. * Enables the vortex.
  149956. */
  149957. enable(): void;
  149958. /**
  149959. * Disables the cortex.
  149960. */
  149961. disable(): void;
  149962. /**
  149963. * Disposes the sphere.
  149964. * @param force
  149965. */
  149966. dispose(force?: boolean): void;
  149967. private getImpostorHitData;
  149968. private _tick;
  149969. /*** Helpers ***/
  149970. private _prepareCylinder;
  149971. private _intersectsWithCylinder;
  149972. }
  149973. /**
  149974. * Options fot the radial explosion event
  149975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149976. */
  149977. export class PhysicsRadialExplosionEventOptions {
  149978. /**
  149979. * The radius of the sphere for the radial explosion.
  149980. */
  149981. radius: number;
  149982. /**
  149983. * The strenth of the explosion.
  149984. */
  149985. strength: number;
  149986. /**
  149987. * The strenght of the force in correspondence to the distance of the affected object
  149988. */
  149989. falloff: PhysicsRadialImpulseFalloff;
  149990. /**
  149991. * Sphere options for the radial explosion.
  149992. */
  149993. sphere: {
  149994. segments: number;
  149995. diameter: number;
  149996. };
  149997. /**
  149998. * Sphere options for the radial explosion.
  149999. */
  150000. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  150001. }
  150002. /**
  150003. * Options fot the updraft event
  150004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150005. */
  150006. export class PhysicsUpdraftEventOptions {
  150007. /**
  150008. * The radius of the cylinder for the vortex
  150009. */
  150010. radius: number;
  150011. /**
  150012. * The strenth of the updraft.
  150013. */
  150014. strength: number;
  150015. /**
  150016. * The height of the cylinder for the updraft.
  150017. */
  150018. height: number;
  150019. /**
  150020. * The mode for the the updraft.
  150021. */
  150022. updraftMode: PhysicsUpdraftMode;
  150023. }
  150024. /**
  150025. * Options fot the vortex event
  150026. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150027. */
  150028. export class PhysicsVortexEventOptions {
  150029. /**
  150030. * The radius of the cylinder for the vortex
  150031. */
  150032. radius: number;
  150033. /**
  150034. * The strenth of the vortex.
  150035. */
  150036. strength: number;
  150037. /**
  150038. * The height of the cylinder for the vortex.
  150039. */
  150040. height: number;
  150041. /**
  150042. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  150043. */
  150044. centripetalForceThreshold: number;
  150045. /**
  150046. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  150047. */
  150048. centripetalForceMultiplier: number;
  150049. /**
  150050. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  150051. */
  150052. centrifugalForceMultiplier: number;
  150053. /**
  150054. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  150055. */
  150056. updraftForceMultiplier: number;
  150057. }
  150058. /**
  150059. * The strenght 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 PhysicsRadialImpulseFalloff {
  150063. /** Defines that impulse is constant in strength across it's whole radius */
  150064. Constant = 0,
  150065. /** Defines that impulse gets weaker if it's further from the origin */
  150066. Linear = 1
  150067. }
  150068. /**
  150069. * The strength of the force in correspondence to the distance of the affected object
  150070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150071. */
  150072. export enum PhysicsUpdraftMode {
  150073. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  150074. Center = 0,
  150075. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  150076. Perpendicular = 1
  150077. }
  150078. /**
  150079. * Interface for a physics hit data
  150080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150081. */
  150082. export interface PhysicsHitData {
  150083. /**
  150084. * The force applied at the contact point
  150085. */
  150086. force: Vector3;
  150087. /**
  150088. * The contact point
  150089. */
  150090. contactPoint: Vector3;
  150091. /**
  150092. * The distance from the origin to the contact point
  150093. */
  150094. distanceFromOrigin: number;
  150095. }
  150096. /**
  150097. * Interface for radial explosion event data
  150098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150099. */
  150100. export interface PhysicsRadialExplosionEventData {
  150101. /**
  150102. * A sphere used for the radial explosion event
  150103. */
  150104. sphere: Mesh;
  150105. }
  150106. /**
  150107. * Interface for gravitational field event data
  150108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150109. */
  150110. export interface PhysicsGravitationalFieldEventData {
  150111. /**
  150112. * A sphere mesh used for the gravitational field event
  150113. */
  150114. sphere: Mesh;
  150115. }
  150116. /**
  150117. * Interface for updraft event data
  150118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150119. */
  150120. export interface PhysicsUpdraftEventData {
  150121. /**
  150122. * A cylinder used for the updraft event
  150123. */
  150124. cylinder: Mesh;
  150125. }
  150126. /**
  150127. * Interface for vortex event data
  150128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150129. */
  150130. export interface PhysicsVortexEventData {
  150131. /**
  150132. * A cylinder used for the vortex event
  150133. */
  150134. cylinder: Mesh;
  150135. }
  150136. /**
  150137. * Interface for an affected physics impostor
  150138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150139. */
  150140. export interface PhysicsAffectedImpostorWithData {
  150141. /**
  150142. * The impostor affected by the effect
  150143. */
  150144. impostor: PhysicsImpostor;
  150145. /**
  150146. * The data about the hit/horce from the explosion
  150147. */
  150148. hitData: PhysicsHitData;
  150149. }
  150150. }
  150151. declare module BABYLON {
  150152. /** @hidden */
  150153. export var blackAndWhitePixelShader: {
  150154. name: string;
  150155. shader: string;
  150156. };
  150157. }
  150158. declare module BABYLON {
  150159. /**
  150160. * Post process used to render in black and white
  150161. */
  150162. export class BlackAndWhitePostProcess extends PostProcess {
  150163. /**
  150164. * Linear about to convert he result to black and white (default: 1)
  150165. */
  150166. degree: number;
  150167. /**
  150168. * Gets a string identifying the name of the class
  150169. * @returns "BlackAndWhitePostProcess" string
  150170. */
  150171. getClassName(): string;
  150172. /**
  150173. * Creates a black and white post process
  150174. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  150175. * @param name The name of the effect.
  150176. * @param options The required width/height ratio to downsize to before computing the render pass.
  150177. * @param camera The camera to apply the render pass to.
  150178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150179. * @param engine The engine which the post process will be applied. (default: current engine)
  150180. * @param reusable If the post process can be reused on the same frame. (default: false)
  150181. */
  150182. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150183. /** @hidden */
  150184. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  150185. }
  150186. }
  150187. declare module BABYLON {
  150188. /**
  150189. * This represents a set of one or more post processes in Babylon.
  150190. * A post process can be used to apply a shader to a texture after it is rendered.
  150191. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150192. */
  150193. export class PostProcessRenderEffect {
  150194. private _postProcesses;
  150195. private _getPostProcesses;
  150196. private _singleInstance;
  150197. private _cameras;
  150198. private _indicesForCamera;
  150199. /**
  150200. * Name of the effect
  150201. * @hidden
  150202. */
  150203. _name: string;
  150204. /**
  150205. * Instantiates a post process render effect.
  150206. * A post process can be used to apply a shader to a texture after it is rendered.
  150207. * @param engine The engine the effect is tied to
  150208. * @param name The name of the effect
  150209. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  150210. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  150211. */
  150212. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  150213. /**
  150214. * Checks if all the post processes in the effect are supported.
  150215. */
  150216. get isSupported(): boolean;
  150217. /**
  150218. * Updates the current state of the effect
  150219. * @hidden
  150220. */
  150221. _update(): void;
  150222. /**
  150223. * Attaches the effect on cameras
  150224. * @param cameras The camera to attach to.
  150225. * @hidden
  150226. */
  150227. _attachCameras(cameras: Camera): void;
  150228. /**
  150229. * Attaches the effect on cameras
  150230. * @param cameras The camera to attach to.
  150231. * @hidden
  150232. */
  150233. _attachCameras(cameras: Camera[]): void;
  150234. /**
  150235. * Detaches the effect on cameras
  150236. * @param cameras The camera to detatch from.
  150237. * @hidden
  150238. */
  150239. _detachCameras(cameras: Camera): void;
  150240. /**
  150241. * Detatches the effect on cameras
  150242. * @param cameras The camera to detatch from.
  150243. * @hidden
  150244. */
  150245. _detachCameras(cameras: Camera[]): void;
  150246. /**
  150247. * Enables the effect on given cameras
  150248. * @param cameras The camera to enable.
  150249. * @hidden
  150250. */
  150251. _enable(cameras: Camera): void;
  150252. /**
  150253. * Enables the effect on given cameras
  150254. * @param cameras The camera to enable.
  150255. * @hidden
  150256. */
  150257. _enable(cameras: Nullable<Camera[]>): void;
  150258. /**
  150259. * Disables the effect on the given cameras
  150260. * @param cameras The camera to disable.
  150261. * @hidden
  150262. */
  150263. _disable(cameras: Camera): void;
  150264. /**
  150265. * Disables the effect on the given cameras
  150266. * @param cameras The camera to disable.
  150267. * @hidden
  150268. */
  150269. _disable(cameras: Nullable<Camera[]>): void;
  150270. /**
  150271. * Gets a list of the post processes contained in the effect.
  150272. * @param camera The camera to get the post processes on.
  150273. * @returns The list of the post processes in the effect.
  150274. */
  150275. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  150276. }
  150277. }
  150278. declare module BABYLON {
  150279. /** @hidden */
  150280. export var extractHighlightsPixelShader: {
  150281. name: string;
  150282. shader: string;
  150283. };
  150284. }
  150285. declare module BABYLON {
  150286. /**
  150287. * 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.
  150288. */
  150289. export class ExtractHighlightsPostProcess extends PostProcess {
  150290. /**
  150291. * The luminance threshold, pixels below this value will be set to black.
  150292. */
  150293. threshold: number;
  150294. /** @hidden */
  150295. _exposure: number;
  150296. /**
  150297. * Post process which has the input texture to be used when performing highlight extraction
  150298. * @hidden
  150299. */
  150300. _inputPostProcess: Nullable<PostProcess>;
  150301. /**
  150302. * Gets a string identifying the name of the class
  150303. * @returns "ExtractHighlightsPostProcess" string
  150304. */
  150305. getClassName(): string;
  150306. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150307. }
  150308. }
  150309. declare module BABYLON {
  150310. /** @hidden */
  150311. export var bloomMergePixelShader: {
  150312. name: string;
  150313. shader: string;
  150314. };
  150315. }
  150316. declare module BABYLON {
  150317. /**
  150318. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150319. */
  150320. export class BloomMergePostProcess extends PostProcess {
  150321. /** Weight of the bloom to be added to the original input. */
  150322. weight: number;
  150323. /**
  150324. * Gets a string identifying the name of the class
  150325. * @returns "BloomMergePostProcess" string
  150326. */
  150327. getClassName(): string;
  150328. /**
  150329. * Creates a new instance of @see BloomMergePostProcess
  150330. * @param name The name of the effect.
  150331. * @param originalFromInput Post process which's input will be used for the merge.
  150332. * @param blurred Blurred highlights post process which's output will be used.
  150333. * @param weight Weight of the bloom to be added to the original input.
  150334. * @param options The required width/height ratio to downsize to before computing the render pass.
  150335. * @param camera The camera to apply the render pass to.
  150336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150337. * @param engine The engine which the post process will be applied. (default: current engine)
  150338. * @param reusable If the post process can be reused on the same frame. (default: false)
  150339. * @param textureType Type of textures used when performing the post process. (default: 0)
  150340. * @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)
  150341. */
  150342. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  150343. /** Weight of the bloom to be added to the original input. */
  150344. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150345. }
  150346. }
  150347. declare module BABYLON {
  150348. /**
  150349. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  150350. */
  150351. export class BloomEffect extends PostProcessRenderEffect {
  150352. private bloomScale;
  150353. /**
  150354. * @hidden Internal
  150355. */
  150356. _effects: Array<PostProcess>;
  150357. /**
  150358. * @hidden Internal
  150359. */
  150360. _downscale: ExtractHighlightsPostProcess;
  150361. private _blurX;
  150362. private _blurY;
  150363. private _merge;
  150364. /**
  150365. * The luminance threshold to find bright areas of the image to bloom.
  150366. */
  150367. get threshold(): number;
  150368. set threshold(value: number);
  150369. /**
  150370. * The strength of the bloom.
  150371. */
  150372. get weight(): number;
  150373. set weight(value: number);
  150374. /**
  150375. * Specifies the size of the bloom blur kernel, relative to the final output size
  150376. */
  150377. get kernel(): number;
  150378. set kernel(value: number);
  150379. /**
  150380. * Creates a new instance of @see BloomEffect
  150381. * @param scene The scene the effect belongs to.
  150382. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  150383. * @param bloomKernel The size of the kernel to be used when applying the blur.
  150384. * @param bloomWeight The the strength of bloom.
  150385. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150386. * @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)
  150387. */
  150388. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  150389. /**
  150390. * Disposes each of the internal effects for a given camera.
  150391. * @param camera The camera to dispose the effect on.
  150392. */
  150393. disposeEffects(camera: Camera): void;
  150394. /**
  150395. * @hidden Internal
  150396. */
  150397. _updateEffects(): void;
  150398. /**
  150399. * Internal
  150400. * @returns if all the contained post processes are ready.
  150401. * @hidden
  150402. */
  150403. _isReady(): boolean;
  150404. }
  150405. }
  150406. declare module BABYLON {
  150407. /** @hidden */
  150408. export var chromaticAberrationPixelShader: {
  150409. name: string;
  150410. shader: string;
  150411. };
  150412. }
  150413. declare module BABYLON {
  150414. /**
  150415. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  150416. */
  150417. export class ChromaticAberrationPostProcess extends PostProcess {
  150418. /**
  150419. * The amount of seperation of rgb channels (default: 30)
  150420. */
  150421. aberrationAmount: number;
  150422. /**
  150423. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  150424. */
  150425. radialIntensity: number;
  150426. /**
  150427. * 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))
  150428. */
  150429. direction: Vector2;
  150430. /**
  150431. * 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))
  150432. */
  150433. centerPosition: Vector2;
  150434. /** The width of the screen to apply the effect on */
  150435. screenWidth: number;
  150436. /** The height of the screen to apply the effect on */
  150437. screenHeight: number;
  150438. /**
  150439. * Gets a string identifying the name of the class
  150440. * @returns "ChromaticAberrationPostProcess" string
  150441. */
  150442. getClassName(): string;
  150443. /**
  150444. * Creates a new instance ChromaticAberrationPostProcess
  150445. * @param name The name of the effect.
  150446. * @param screenWidth The width of the screen to apply the effect on.
  150447. * @param screenHeight The height of the screen to apply the effect on.
  150448. * @param options The required width/height ratio to downsize to before computing the render pass.
  150449. * @param camera The camera to apply the render pass to.
  150450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150451. * @param engine The engine which the post process will be applied. (default: current engine)
  150452. * @param reusable If the post process can be reused on the same frame. (default: false)
  150453. * @param textureType Type of textures used when performing the post process. (default: 0)
  150454. * @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)
  150455. */
  150456. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150457. /** @hidden */
  150458. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  150459. }
  150460. }
  150461. declare module BABYLON {
  150462. /** @hidden */
  150463. export var circleOfConfusionPixelShader: {
  150464. name: string;
  150465. shader: string;
  150466. };
  150467. }
  150468. declare module BABYLON {
  150469. /**
  150470. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  150471. */
  150472. export class CircleOfConfusionPostProcess extends PostProcess {
  150473. /**
  150474. * 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.
  150475. */
  150476. lensSize: number;
  150477. /**
  150478. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150479. */
  150480. fStop: number;
  150481. /**
  150482. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150483. */
  150484. focusDistance: number;
  150485. /**
  150486. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  150487. */
  150488. focalLength: number;
  150489. /**
  150490. * Gets a string identifying the name of the class
  150491. * @returns "CircleOfConfusionPostProcess" string
  150492. */
  150493. getClassName(): string;
  150494. private _depthTexture;
  150495. /**
  150496. * Creates a new instance CircleOfConfusionPostProcess
  150497. * @param name The name of the effect.
  150498. * @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.
  150499. * @param options The required width/height ratio to downsize to before computing the render pass.
  150500. * @param camera The camera to apply the render pass to.
  150501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150502. * @param engine The engine which the post process will be applied. (default: current engine)
  150503. * @param reusable If the post process can be reused on the same frame. (default: false)
  150504. * @param textureType Type of textures used when performing the post process. (default: 0)
  150505. * @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)
  150506. */
  150507. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150508. /**
  150509. * 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.
  150510. */
  150511. set depthTexture(value: RenderTargetTexture);
  150512. }
  150513. }
  150514. declare module BABYLON {
  150515. /** @hidden */
  150516. export var colorCorrectionPixelShader: {
  150517. name: string;
  150518. shader: string;
  150519. };
  150520. }
  150521. declare module BABYLON {
  150522. /**
  150523. *
  150524. * This post-process allows the modification of rendered colors by using
  150525. * a 'look-up table' (LUT). This effect is also called Color Grading.
  150526. *
  150527. * The object needs to be provided an url to a texture containing the color
  150528. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  150529. * Use an image editing software to tweak the LUT to match your needs.
  150530. *
  150531. * For an example of a color LUT, see here:
  150532. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  150533. * For explanations on color grading, see here:
  150534. * @see http://udn.epicgames.com/Three/ColorGrading.html
  150535. *
  150536. */
  150537. export class ColorCorrectionPostProcess extends PostProcess {
  150538. private _colorTableTexture;
  150539. /**
  150540. * Gets the color table url used to create the LUT texture
  150541. */
  150542. colorTableUrl: string;
  150543. /**
  150544. * Gets a string identifying the name of the class
  150545. * @returns "ColorCorrectionPostProcess" string
  150546. */
  150547. getClassName(): string;
  150548. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150549. /** @hidden */
  150550. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  150551. }
  150552. }
  150553. declare module BABYLON {
  150554. /** @hidden */
  150555. export var convolutionPixelShader: {
  150556. name: string;
  150557. shader: string;
  150558. };
  150559. }
  150560. declare module BABYLON {
  150561. /**
  150562. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  150563. * input texture to perform effects such as edge detection or sharpening
  150564. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150565. */
  150566. export class ConvolutionPostProcess extends PostProcess {
  150567. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  150568. kernel: number[];
  150569. /**
  150570. * Gets a string identifying the name of the class
  150571. * @returns "ConvolutionPostProcess" string
  150572. */
  150573. getClassName(): string;
  150574. /**
  150575. * Creates a new instance ConvolutionPostProcess
  150576. * @param name The name of the effect.
  150577. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  150578. * @param options The required width/height ratio to downsize to before computing the render pass.
  150579. * @param camera The camera to apply the render pass to.
  150580. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150581. * @param engine The engine which the post process will be applied. (default: current engine)
  150582. * @param reusable If the post process can be reused on the same frame. (default: false)
  150583. * @param textureType Type of textures used when performing the post process. (default: 0)
  150584. */
  150585. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150586. /** @hidden */
  150587. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  150588. /**
  150589. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150590. */
  150591. static EdgeDetect0Kernel: number[];
  150592. /**
  150593. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150594. */
  150595. static EdgeDetect1Kernel: number[];
  150596. /**
  150597. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150598. */
  150599. static EdgeDetect2Kernel: number[];
  150600. /**
  150601. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150602. */
  150603. static SharpenKernel: number[];
  150604. /**
  150605. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150606. */
  150607. static EmbossKernel: number[];
  150608. /**
  150609. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150610. */
  150611. static GaussianKernel: number[];
  150612. }
  150613. }
  150614. declare module BABYLON {
  150615. /**
  150616. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  150617. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  150618. * based on samples that have a large difference in distance than the center pixel.
  150619. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  150620. */
  150621. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  150622. /**
  150623. * The direction the blur should be applied
  150624. */
  150625. direction: Vector2;
  150626. /**
  150627. * Gets a string identifying the name of the class
  150628. * @returns "DepthOfFieldBlurPostProcess" string
  150629. */
  150630. getClassName(): string;
  150631. /**
  150632. * Creates a new instance CircleOfConfusionPostProcess
  150633. * @param name The name of the effect.
  150634. * @param scene The scene the effect belongs to.
  150635. * @param direction The direction the blur should be applied.
  150636. * @param kernel The size of the kernel used to blur.
  150637. * @param options The required width/height ratio to downsize to before computing the render pass.
  150638. * @param camera The camera to apply the render pass to.
  150639. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  150640. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  150641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150642. * @param engine The engine which the post process will be applied. (default: current engine)
  150643. * @param reusable If the post process can be reused on the same frame. (default: false)
  150644. * @param textureType Type of textures used when performing the post process. (default: 0)
  150645. * @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)
  150646. */
  150647. 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);
  150648. }
  150649. }
  150650. declare module BABYLON {
  150651. /** @hidden */
  150652. export var depthOfFieldMergePixelShader: {
  150653. name: string;
  150654. shader: string;
  150655. };
  150656. }
  150657. declare module BABYLON {
  150658. /**
  150659. * Options to be set when merging outputs from the default pipeline.
  150660. */
  150661. export class DepthOfFieldMergePostProcessOptions {
  150662. /**
  150663. * The original image to merge on top of
  150664. */
  150665. originalFromInput: PostProcess;
  150666. /**
  150667. * Parameters to perform the merge of the depth of field effect
  150668. */
  150669. depthOfField?: {
  150670. circleOfConfusion: PostProcess;
  150671. blurSteps: Array<PostProcess>;
  150672. };
  150673. /**
  150674. * Parameters to perform the merge of bloom effect
  150675. */
  150676. bloom?: {
  150677. blurred: PostProcess;
  150678. weight: number;
  150679. };
  150680. }
  150681. /**
  150682. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150683. */
  150684. export class DepthOfFieldMergePostProcess extends PostProcess {
  150685. private blurSteps;
  150686. /**
  150687. * Gets a string identifying the name of the class
  150688. * @returns "DepthOfFieldMergePostProcess" string
  150689. */
  150690. getClassName(): string;
  150691. /**
  150692. * Creates a new instance of DepthOfFieldMergePostProcess
  150693. * @param name The name of the effect.
  150694. * @param originalFromInput Post process which's input will be used for the merge.
  150695. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  150696. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  150697. * @param options The required width/height ratio to downsize to before computing the render pass.
  150698. * @param camera The camera to apply the render pass to.
  150699. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150700. * @param engine The engine which the post process will be applied. (default: current engine)
  150701. * @param reusable If the post process can be reused on the same frame. (default: false)
  150702. * @param textureType Type of textures used when performing the post process. (default: 0)
  150703. * @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)
  150704. */
  150705. 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);
  150706. /**
  150707. * Updates the effect with the current post process compile time values and recompiles the shader.
  150708. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  150709. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  150710. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  150711. * @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
  150712. * @param onCompiled Called when the shader has been compiled.
  150713. * @param onError Called if there is an error when compiling a shader.
  150714. */
  150715. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  150716. }
  150717. }
  150718. declare module BABYLON {
  150719. /**
  150720. * Specifies the level of max blur that should be applied when using the depth of field effect
  150721. */
  150722. export enum DepthOfFieldEffectBlurLevel {
  150723. /**
  150724. * Subtle blur
  150725. */
  150726. Low = 0,
  150727. /**
  150728. * Medium blur
  150729. */
  150730. Medium = 1,
  150731. /**
  150732. * Large blur
  150733. */
  150734. High = 2
  150735. }
  150736. /**
  150737. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  150738. */
  150739. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  150740. private _circleOfConfusion;
  150741. /**
  150742. * @hidden Internal, blurs from high to low
  150743. */
  150744. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  150745. private _depthOfFieldBlurY;
  150746. private _dofMerge;
  150747. /**
  150748. * @hidden Internal post processes in depth of field effect
  150749. */
  150750. _effects: Array<PostProcess>;
  150751. /**
  150752. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  150753. */
  150754. set focalLength(value: number);
  150755. get focalLength(): number;
  150756. /**
  150757. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150758. */
  150759. set fStop(value: number);
  150760. get fStop(): number;
  150761. /**
  150762. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150763. */
  150764. set focusDistance(value: number);
  150765. get focusDistance(): number;
  150766. /**
  150767. * 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.
  150768. */
  150769. set lensSize(value: number);
  150770. get lensSize(): number;
  150771. /**
  150772. * Creates a new instance DepthOfFieldEffect
  150773. * @param scene The scene the effect belongs to.
  150774. * @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.
  150775. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150776. * @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)
  150777. */
  150778. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  150779. /**
  150780. * Get the current class name of the current effet
  150781. * @returns "DepthOfFieldEffect"
  150782. */
  150783. getClassName(): string;
  150784. /**
  150785. * 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.
  150786. */
  150787. set depthTexture(value: RenderTargetTexture);
  150788. /**
  150789. * Disposes each of the internal effects for a given camera.
  150790. * @param camera The camera to dispose the effect on.
  150791. */
  150792. disposeEffects(camera: Camera): void;
  150793. /**
  150794. * @hidden Internal
  150795. */
  150796. _updateEffects(): void;
  150797. /**
  150798. * Internal
  150799. * @returns if all the contained post processes are ready.
  150800. * @hidden
  150801. */
  150802. _isReady(): boolean;
  150803. }
  150804. }
  150805. declare module BABYLON {
  150806. /** @hidden */
  150807. export var displayPassPixelShader: {
  150808. name: string;
  150809. shader: string;
  150810. };
  150811. }
  150812. declare module BABYLON {
  150813. /**
  150814. * DisplayPassPostProcess which produces an output the same as it's input
  150815. */
  150816. export class DisplayPassPostProcess extends PostProcess {
  150817. /**
  150818. * Gets a string identifying the name of the class
  150819. * @returns "DisplayPassPostProcess" string
  150820. */
  150821. getClassName(): string;
  150822. /**
  150823. * Creates the DisplayPassPostProcess
  150824. * @param name The name of the effect.
  150825. * @param options The required width/height ratio to downsize to before computing the render pass.
  150826. * @param camera The camera to apply the render pass to.
  150827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150828. * @param engine The engine which the post process will be applied. (default: current engine)
  150829. * @param reusable If the post process can be reused on the same frame. (default: false)
  150830. */
  150831. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150832. /** @hidden */
  150833. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  150834. }
  150835. }
  150836. declare module BABYLON {
  150837. /** @hidden */
  150838. export var filterPixelShader: {
  150839. name: string;
  150840. shader: string;
  150841. };
  150842. }
  150843. declare module BABYLON {
  150844. /**
  150845. * Applies a kernel filter to the image
  150846. */
  150847. export class FilterPostProcess extends PostProcess {
  150848. /** The matrix to be applied to the image */
  150849. kernelMatrix: Matrix;
  150850. /**
  150851. * Gets a string identifying the name of the class
  150852. * @returns "FilterPostProcess" string
  150853. */
  150854. getClassName(): string;
  150855. /**
  150856. *
  150857. * @param name The name of the effect.
  150858. * @param kernelMatrix The matrix to be applied to the image
  150859. * @param options The required width/height ratio to downsize to before computing the render pass.
  150860. * @param camera The camera to apply the render pass to.
  150861. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150862. * @param engine The engine which the post process will be applied. (default: current engine)
  150863. * @param reusable If the post process can be reused on the same frame. (default: false)
  150864. */
  150865. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150866. /** @hidden */
  150867. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  150868. }
  150869. }
  150870. declare module BABYLON {
  150871. /** @hidden */
  150872. export var fxaaPixelShader: {
  150873. name: string;
  150874. shader: string;
  150875. };
  150876. }
  150877. declare module BABYLON {
  150878. /** @hidden */
  150879. export var fxaaVertexShader: {
  150880. name: string;
  150881. shader: string;
  150882. };
  150883. }
  150884. declare module BABYLON {
  150885. /**
  150886. * Fxaa post process
  150887. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  150888. */
  150889. export class FxaaPostProcess extends PostProcess {
  150890. /**
  150891. * Gets a string identifying the name of the class
  150892. * @returns "FxaaPostProcess" string
  150893. */
  150894. getClassName(): string;
  150895. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150896. private _getDefines;
  150897. /** @hidden */
  150898. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  150899. }
  150900. }
  150901. declare module BABYLON {
  150902. /** @hidden */
  150903. export var grainPixelShader: {
  150904. name: string;
  150905. shader: string;
  150906. };
  150907. }
  150908. declare module BABYLON {
  150909. /**
  150910. * The GrainPostProcess adds noise to the image at mid luminance levels
  150911. */
  150912. export class GrainPostProcess extends PostProcess {
  150913. /**
  150914. * The intensity of the grain added (default: 30)
  150915. */
  150916. intensity: number;
  150917. /**
  150918. * If the grain should be randomized on every frame
  150919. */
  150920. animated: boolean;
  150921. /**
  150922. * Gets a string identifying the name of the class
  150923. * @returns "GrainPostProcess" string
  150924. */
  150925. getClassName(): string;
  150926. /**
  150927. * Creates a new instance of @see GrainPostProcess
  150928. * @param name The name of the effect.
  150929. * @param options The required width/height ratio to downsize to before computing the render pass.
  150930. * @param camera The camera to apply the render pass to.
  150931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150932. * @param engine The engine which the post process will be applied. (default: current engine)
  150933. * @param reusable If the post process can be reused on the same frame. (default: false)
  150934. * @param textureType Type of textures used when performing the post process. (default: 0)
  150935. * @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)
  150936. */
  150937. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150938. /** @hidden */
  150939. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  150940. }
  150941. }
  150942. declare module BABYLON {
  150943. /** @hidden */
  150944. export var highlightsPixelShader: {
  150945. name: string;
  150946. shader: string;
  150947. };
  150948. }
  150949. declare module BABYLON {
  150950. /**
  150951. * Extracts highlights from the image
  150952. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150953. */
  150954. export class HighlightsPostProcess extends PostProcess {
  150955. /**
  150956. * Gets a string identifying the name of the class
  150957. * @returns "HighlightsPostProcess" string
  150958. */
  150959. getClassName(): string;
  150960. /**
  150961. * Extracts highlights from the image
  150962. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150963. * @param name The name of the effect.
  150964. * @param options The required width/height ratio to downsize to before computing the render pass.
  150965. * @param camera The camera to apply the render pass to.
  150966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150967. * @param engine The engine which the post process will be applied. (default: current engine)
  150968. * @param reusable If the post process can be reused on the same frame. (default: false)
  150969. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  150970. */
  150971. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150972. }
  150973. }
  150974. declare module BABYLON {
  150975. /**
  150976. * Contains all parameters needed for the prepass to perform
  150977. * motion blur
  150978. */
  150979. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  150980. /**
  150981. * Is motion blur enabled
  150982. */
  150983. enabled: boolean;
  150984. /**
  150985. * Name of the configuration
  150986. */
  150987. name: string;
  150988. /**
  150989. * Textures that should be present in the MRT for this effect to work
  150990. */
  150991. readonly texturesRequired: number[];
  150992. }
  150993. }
  150994. declare module BABYLON {
  150995. interface Scene {
  150996. /** @hidden (Backing field) */
  150997. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150998. /**
  150999. * Gets or Sets the current geometry buffer associated to the scene.
  151000. */
  151001. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  151002. /**
  151003. * Enables a GeometryBufferRender and associates it with the scene
  151004. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  151005. * @returns the GeometryBufferRenderer
  151006. */
  151007. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  151008. /**
  151009. * Disables the GeometryBufferRender associated with the scene
  151010. */
  151011. disableGeometryBufferRenderer(): void;
  151012. }
  151013. /**
  151014. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151015. * in several rendering techniques.
  151016. */
  151017. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  151018. /**
  151019. * The component name helpful to identify the component in the list of scene components.
  151020. */
  151021. readonly name: string;
  151022. /**
  151023. * The scene the component belongs to.
  151024. */
  151025. scene: Scene;
  151026. /**
  151027. * Creates a new instance of the component for the given scene
  151028. * @param scene Defines the scene to register the component in
  151029. */
  151030. constructor(scene: Scene);
  151031. /**
  151032. * Registers the component in a given scene
  151033. */
  151034. register(): void;
  151035. /**
  151036. * Rebuilds the elements related to this component in case of
  151037. * context lost for instance.
  151038. */
  151039. rebuild(): void;
  151040. /**
  151041. * Disposes the component and the associated ressources
  151042. */
  151043. dispose(): void;
  151044. private _gatherRenderTargets;
  151045. }
  151046. }
  151047. declare module BABYLON {
  151048. /** @hidden */
  151049. export var motionBlurPixelShader: {
  151050. name: string;
  151051. shader: string;
  151052. };
  151053. }
  151054. declare module BABYLON {
  151055. /**
  151056. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  151057. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  151058. * As an example, all you have to do is to create the post-process:
  151059. * var mb = new BABYLON.MotionBlurPostProcess(
  151060. * 'mb', // The name of the effect.
  151061. * scene, // The scene containing the objects to blur according to their velocity.
  151062. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  151063. * camera // The camera to apply the render pass to.
  151064. * );
  151065. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  151066. */
  151067. export class MotionBlurPostProcess extends PostProcess {
  151068. /**
  151069. * Defines how much the image is blurred by the movement. Default value is equal to 1
  151070. */
  151071. motionStrength: number;
  151072. /**
  151073. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  151074. */
  151075. get motionBlurSamples(): number;
  151076. /**
  151077. * Sets the number of iterations to be used for motion blur quality
  151078. */
  151079. set motionBlurSamples(samples: number);
  151080. private _motionBlurSamples;
  151081. private _forceGeometryBuffer;
  151082. private _geometryBufferRenderer;
  151083. private _prePassRenderer;
  151084. /**
  151085. * Gets a string identifying the name of the class
  151086. * @returns "MotionBlurPostProcess" string
  151087. */
  151088. getClassName(): string;
  151089. /**
  151090. * Creates a new instance MotionBlurPostProcess
  151091. * @param name The name of the effect.
  151092. * @param scene The scene containing the objects to blur according to their velocity.
  151093. * @param options The required width/height ratio to downsize to before computing the render pass.
  151094. * @param camera The camera to apply the render pass to.
  151095. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151096. * @param engine The engine which the post process will be applied. (default: current engine)
  151097. * @param reusable If the post process can be reused on the same frame. (default: false)
  151098. * @param textureType Type of textures used when performing the post process. (default: 0)
  151099. * @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)
  151100. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  151101. */
  151102. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  151103. /**
  151104. * Excludes the given skinned mesh from computing bones velocities.
  151105. * 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.
  151106. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  151107. */
  151108. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151109. /**
  151110. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  151111. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  151112. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  151113. */
  151114. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151115. /**
  151116. * Disposes the post process.
  151117. * @param camera The camera to dispose the post process on.
  151118. */
  151119. dispose(camera?: Camera): void;
  151120. /** @hidden */
  151121. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  151122. }
  151123. }
  151124. declare module BABYLON {
  151125. /** @hidden */
  151126. export var refractionPixelShader: {
  151127. name: string;
  151128. shader: string;
  151129. };
  151130. }
  151131. declare module BABYLON {
  151132. /**
  151133. * Post process which applies a refractin texture
  151134. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151135. */
  151136. export class RefractionPostProcess extends PostProcess {
  151137. private _refTexture;
  151138. private _ownRefractionTexture;
  151139. /** the base color of the refraction (used to taint the rendering) */
  151140. color: Color3;
  151141. /** simulated refraction depth */
  151142. depth: number;
  151143. /** the coefficient of the base color (0 to remove base color tainting) */
  151144. colorLevel: number;
  151145. /** Gets the url used to load the refraction texture */
  151146. refractionTextureUrl: string;
  151147. /**
  151148. * Gets or sets the refraction texture
  151149. * Please note that you are responsible for disposing the texture if you set it manually
  151150. */
  151151. get refractionTexture(): Texture;
  151152. set refractionTexture(value: Texture);
  151153. /**
  151154. * Gets a string identifying the name of the class
  151155. * @returns "RefractionPostProcess" string
  151156. */
  151157. getClassName(): string;
  151158. /**
  151159. * Initializes the RefractionPostProcess
  151160. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151161. * @param name The name of the effect.
  151162. * @param refractionTextureUrl Url of the refraction texture to use
  151163. * @param color the base color of the refraction (used to taint the rendering)
  151164. * @param depth simulated refraction depth
  151165. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  151166. * @param camera The camera to apply the render pass to.
  151167. * @param options The required width/height ratio to downsize to before computing the render pass.
  151168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151169. * @param engine The engine which the post process will be applied. (default: current engine)
  151170. * @param reusable If the post process can be reused on the same frame. (default: false)
  151171. */
  151172. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151173. /**
  151174. * Disposes of the post process
  151175. * @param camera Camera to dispose post process on
  151176. */
  151177. dispose(camera: Camera): void;
  151178. /** @hidden */
  151179. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  151180. }
  151181. }
  151182. declare module BABYLON {
  151183. /** @hidden */
  151184. export var sharpenPixelShader: {
  151185. name: string;
  151186. shader: string;
  151187. };
  151188. }
  151189. declare module BABYLON {
  151190. /**
  151191. * The SharpenPostProcess applies a sharpen kernel to every pixel
  151192. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  151193. */
  151194. export class SharpenPostProcess extends PostProcess {
  151195. /**
  151196. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  151197. */
  151198. colorAmount: number;
  151199. /**
  151200. * How much sharpness should be applied (default: 0.3)
  151201. */
  151202. edgeAmount: number;
  151203. /**
  151204. * Gets a string identifying the name of the class
  151205. * @returns "SharpenPostProcess" string
  151206. */
  151207. getClassName(): string;
  151208. /**
  151209. * Creates a new instance ConvolutionPostProcess
  151210. * @param name The name of the effect.
  151211. * @param options The required width/height ratio to downsize to before computing the render pass.
  151212. * @param camera The camera to apply the render pass to.
  151213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151214. * @param engine The engine which the post process will be applied. (default: current engine)
  151215. * @param reusable If the post process can be reused on the same frame. (default: false)
  151216. * @param textureType Type of textures used when performing the post process. (default: 0)
  151217. * @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)
  151218. */
  151219. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151220. /** @hidden */
  151221. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  151222. }
  151223. }
  151224. declare module BABYLON {
  151225. /**
  151226. * PostProcessRenderPipeline
  151227. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151228. */
  151229. export class PostProcessRenderPipeline {
  151230. private engine;
  151231. private _renderEffects;
  151232. private _renderEffectsForIsolatedPass;
  151233. /**
  151234. * List of inspectable custom properties (used by the Inspector)
  151235. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  151236. */
  151237. inspectableCustomProperties: IInspectable[];
  151238. /**
  151239. * @hidden
  151240. */
  151241. protected _cameras: Camera[];
  151242. /** @hidden */
  151243. _name: string;
  151244. /**
  151245. * Gets pipeline name
  151246. */
  151247. get name(): string;
  151248. /** Gets the list of attached cameras */
  151249. get cameras(): Camera[];
  151250. /**
  151251. * Initializes a PostProcessRenderPipeline
  151252. * @param engine engine to add the pipeline to
  151253. * @param name name of the pipeline
  151254. */
  151255. constructor(engine: Engine, name: string);
  151256. /**
  151257. * Gets the class name
  151258. * @returns "PostProcessRenderPipeline"
  151259. */
  151260. getClassName(): string;
  151261. /**
  151262. * If all the render effects in the pipeline are supported
  151263. */
  151264. get isSupported(): boolean;
  151265. /**
  151266. * Adds an effect to the pipeline
  151267. * @param renderEffect the effect to add
  151268. */
  151269. addEffect(renderEffect: PostProcessRenderEffect): void;
  151270. /** @hidden */
  151271. _rebuild(): void;
  151272. /** @hidden */
  151273. _enableEffect(renderEffectName: string, cameras: Camera): void;
  151274. /** @hidden */
  151275. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  151276. /** @hidden */
  151277. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151278. /** @hidden */
  151279. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151280. /** @hidden */
  151281. _attachCameras(cameras: Camera, unique: boolean): void;
  151282. /** @hidden */
  151283. _attachCameras(cameras: Camera[], unique: boolean): void;
  151284. /** @hidden */
  151285. _detachCameras(cameras: Camera): void;
  151286. /** @hidden */
  151287. _detachCameras(cameras: Nullable<Camera[]>): void;
  151288. /** @hidden */
  151289. _update(): void;
  151290. /** @hidden */
  151291. _reset(): void;
  151292. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  151293. /**
  151294. * Sets the required values to the prepass renderer.
  151295. * @param prePassRenderer defines the prepass renderer to setup.
  151296. * @returns true if the pre pass is needed.
  151297. */
  151298. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151299. /**
  151300. * Disposes of the pipeline
  151301. */
  151302. dispose(): void;
  151303. }
  151304. }
  151305. declare module BABYLON {
  151306. /**
  151307. * PostProcessRenderPipelineManager class
  151308. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151309. */
  151310. export class PostProcessRenderPipelineManager {
  151311. private _renderPipelines;
  151312. /**
  151313. * Initializes a PostProcessRenderPipelineManager
  151314. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151315. */
  151316. constructor();
  151317. /**
  151318. * Gets the list of supported render pipelines
  151319. */
  151320. get supportedPipelines(): PostProcessRenderPipeline[];
  151321. /**
  151322. * Adds a pipeline to the manager
  151323. * @param renderPipeline The pipeline to add
  151324. */
  151325. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  151326. /**
  151327. * Attaches a camera to the pipeline
  151328. * @param renderPipelineName The name of the pipeline to attach to
  151329. * @param cameras the camera to attach
  151330. * @param unique if the camera can be attached multiple times to the pipeline
  151331. */
  151332. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  151333. /**
  151334. * Detaches a camera from the pipeline
  151335. * @param renderPipelineName The name of the pipeline to detach from
  151336. * @param cameras the camera to detach
  151337. */
  151338. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  151339. /**
  151340. * Enables an effect by name on a pipeline
  151341. * @param renderPipelineName the name of the pipeline to enable the effect in
  151342. * @param renderEffectName the name of the effect to enable
  151343. * @param cameras the cameras that the effect should be enabled on
  151344. */
  151345. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151346. /**
  151347. * Disables an effect by name on a pipeline
  151348. * @param renderPipelineName the name of the pipeline to disable the effect in
  151349. * @param renderEffectName the name of the effect to disable
  151350. * @param cameras the cameras that the effect should be disabled on
  151351. */
  151352. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151353. /**
  151354. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  151355. */
  151356. update(): void;
  151357. /** @hidden */
  151358. _rebuild(): void;
  151359. /**
  151360. * Disposes of the manager and pipelines
  151361. */
  151362. dispose(): void;
  151363. }
  151364. }
  151365. declare module BABYLON {
  151366. interface Scene {
  151367. /** @hidden (Backing field) */
  151368. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151369. /**
  151370. * Gets the postprocess render pipeline manager
  151371. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151372. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151373. */
  151374. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151375. }
  151376. /**
  151377. * Defines the Render Pipeline scene component responsible to rendering pipelines
  151378. */
  151379. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  151380. /**
  151381. * The component name helpfull to identify the component in the list of scene components.
  151382. */
  151383. readonly name: string;
  151384. /**
  151385. * The scene the component belongs to.
  151386. */
  151387. scene: Scene;
  151388. /**
  151389. * Creates a new instance of the component for the given scene
  151390. * @param scene Defines the scene to register the component in
  151391. */
  151392. constructor(scene: Scene);
  151393. /**
  151394. * Registers the component in a given scene
  151395. */
  151396. register(): void;
  151397. /**
  151398. * Rebuilds the elements related to this component in case of
  151399. * context lost for instance.
  151400. */
  151401. rebuild(): void;
  151402. /**
  151403. * Disposes the component and the associated ressources
  151404. */
  151405. dispose(): void;
  151406. private _gatherRenderTargets;
  151407. }
  151408. }
  151409. declare module BABYLON {
  151410. /**
  151411. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  151412. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151413. */
  151414. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151415. private _scene;
  151416. private _camerasToBeAttached;
  151417. /**
  151418. * ID of the sharpen post process,
  151419. */
  151420. private readonly SharpenPostProcessId;
  151421. /**
  151422. * @ignore
  151423. * ID of the image processing post process;
  151424. */
  151425. readonly ImageProcessingPostProcessId: string;
  151426. /**
  151427. * @ignore
  151428. * ID of the Fast Approximate Anti-Aliasing post process;
  151429. */
  151430. readonly FxaaPostProcessId: string;
  151431. /**
  151432. * ID of the chromatic aberration post process,
  151433. */
  151434. private readonly ChromaticAberrationPostProcessId;
  151435. /**
  151436. * ID of the grain post process
  151437. */
  151438. private readonly GrainPostProcessId;
  151439. /**
  151440. * Sharpen post process which will apply a sharpen convolution to enhance edges
  151441. */
  151442. sharpen: SharpenPostProcess;
  151443. private _sharpenEffect;
  151444. private bloom;
  151445. /**
  151446. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  151447. */
  151448. depthOfField: DepthOfFieldEffect;
  151449. /**
  151450. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151451. */
  151452. fxaa: FxaaPostProcess;
  151453. /**
  151454. * Image post processing pass used to perform operations such as tone mapping or color grading.
  151455. */
  151456. imageProcessing: ImageProcessingPostProcess;
  151457. /**
  151458. * Chromatic aberration post process which will shift rgb colors in the image
  151459. */
  151460. chromaticAberration: ChromaticAberrationPostProcess;
  151461. private _chromaticAberrationEffect;
  151462. /**
  151463. * Grain post process which add noise to the image
  151464. */
  151465. grain: GrainPostProcess;
  151466. private _grainEffect;
  151467. /**
  151468. * Glow post process which adds a glow to emissive areas of the image
  151469. */
  151470. private _glowLayer;
  151471. /**
  151472. * Animations which can be used to tweak settings over a period of time
  151473. */
  151474. animations: Animation[];
  151475. private _imageProcessingConfigurationObserver;
  151476. private _sharpenEnabled;
  151477. private _bloomEnabled;
  151478. private _depthOfFieldEnabled;
  151479. private _depthOfFieldBlurLevel;
  151480. private _fxaaEnabled;
  151481. private _imageProcessingEnabled;
  151482. private _defaultPipelineTextureType;
  151483. private _bloomScale;
  151484. private _chromaticAberrationEnabled;
  151485. private _grainEnabled;
  151486. private _buildAllowed;
  151487. /**
  151488. * Gets active scene
  151489. */
  151490. get scene(): Scene;
  151491. /**
  151492. * Enable or disable the sharpen process from the pipeline
  151493. */
  151494. set sharpenEnabled(enabled: boolean);
  151495. get sharpenEnabled(): boolean;
  151496. private _resizeObserver;
  151497. private _hardwareScaleLevel;
  151498. private _bloomKernel;
  151499. /**
  151500. * Specifies the size of the bloom blur kernel, relative to the final output size
  151501. */
  151502. get bloomKernel(): number;
  151503. set bloomKernel(value: number);
  151504. /**
  151505. * Specifies the weight of the bloom in the final rendering
  151506. */
  151507. private _bloomWeight;
  151508. /**
  151509. * Specifies the luma threshold for the area that will be blurred by the bloom
  151510. */
  151511. private _bloomThreshold;
  151512. private _hdr;
  151513. /**
  151514. * The strength of the bloom.
  151515. */
  151516. set bloomWeight(value: number);
  151517. get bloomWeight(): number;
  151518. /**
  151519. * The strength of the bloom.
  151520. */
  151521. set bloomThreshold(value: number);
  151522. get bloomThreshold(): number;
  151523. /**
  151524. * The scale of the bloom, lower value will provide better performance.
  151525. */
  151526. set bloomScale(value: number);
  151527. get bloomScale(): number;
  151528. /**
  151529. * Enable or disable the bloom from the pipeline
  151530. */
  151531. set bloomEnabled(enabled: boolean);
  151532. get bloomEnabled(): boolean;
  151533. private _rebuildBloom;
  151534. /**
  151535. * If the depth of field is enabled.
  151536. */
  151537. get depthOfFieldEnabled(): boolean;
  151538. set depthOfFieldEnabled(enabled: boolean);
  151539. /**
  151540. * Blur level of the depth of field effect. (Higher blur will effect performance)
  151541. */
  151542. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  151543. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  151544. /**
  151545. * If the anti aliasing is enabled.
  151546. */
  151547. set fxaaEnabled(enabled: boolean);
  151548. get fxaaEnabled(): boolean;
  151549. private _samples;
  151550. /**
  151551. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151552. */
  151553. set samples(sampleCount: number);
  151554. get samples(): number;
  151555. /**
  151556. * If image processing is enabled.
  151557. */
  151558. set imageProcessingEnabled(enabled: boolean);
  151559. get imageProcessingEnabled(): boolean;
  151560. /**
  151561. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  151562. */
  151563. set glowLayerEnabled(enabled: boolean);
  151564. get glowLayerEnabled(): boolean;
  151565. /**
  151566. * Gets the glow layer (or null if not defined)
  151567. */
  151568. get glowLayer(): Nullable<GlowLayer>;
  151569. /**
  151570. * Enable or disable the chromaticAberration process from the pipeline
  151571. */
  151572. set chromaticAberrationEnabled(enabled: boolean);
  151573. get chromaticAberrationEnabled(): boolean;
  151574. /**
  151575. * Enable or disable the grain process from the pipeline
  151576. */
  151577. set grainEnabled(enabled: boolean);
  151578. get grainEnabled(): boolean;
  151579. /**
  151580. * @constructor
  151581. * @param name - The rendering pipeline name (default: "")
  151582. * @param hdr - If high dynamic range textures should be used (default: true)
  151583. * @param scene - The scene linked to this pipeline (default: the last created scene)
  151584. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  151585. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  151586. */
  151587. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  151588. /**
  151589. * Get the class name
  151590. * @returns "DefaultRenderingPipeline"
  151591. */
  151592. getClassName(): string;
  151593. /**
  151594. * Force the compilation of the entire pipeline.
  151595. */
  151596. prepare(): void;
  151597. private _hasCleared;
  151598. private _prevPostProcess;
  151599. private _prevPrevPostProcess;
  151600. private _setAutoClearAndTextureSharing;
  151601. private _depthOfFieldSceneObserver;
  151602. private _buildPipeline;
  151603. private _disposePostProcesses;
  151604. /**
  151605. * Adds a camera to the pipeline
  151606. * @param camera the camera to be added
  151607. */
  151608. addCamera(camera: Camera): void;
  151609. /**
  151610. * Removes a camera from the pipeline
  151611. * @param camera the camera to remove
  151612. */
  151613. removeCamera(camera: Camera): void;
  151614. /**
  151615. * Dispose of the pipeline and stop all post processes
  151616. */
  151617. dispose(): void;
  151618. /**
  151619. * Serialize the rendering pipeline (Used when exporting)
  151620. * @returns the serialized object
  151621. */
  151622. serialize(): any;
  151623. /**
  151624. * Parse the serialized pipeline
  151625. * @param source Source pipeline.
  151626. * @param scene The scene to load the pipeline to.
  151627. * @param rootUrl The URL of the serialized pipeline.
  151628. * @returns An instantiated pipeline from the serialized object.
  151629. */
  151630. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  151631. }
  151632. }
  151633. declare module BABYLON {
  151634. /** @hidden */
  151635. export var lensHighlightsPixelShader: {
  151636. name: string;
  151637. shader: string;
  151638. };
  151639. }
  151640. declare module BABYLON {
  151641. /** @hidden */
  151642. export var depthOfFieldPixelShader: {
  151643. name: string;
  151644. shader: string;
  151645. };
  151646. }
  151647. declare module BABYLON {
  151648. /**
  151649. * BABYLON.JS Chromatic Aberration GLSL Shader
  151650. * Author: Olivier Guyot
  151651. * Separates very slightly R, G and B colors on the edges of the screen
  151652. * Inspired by Francois Tarlier & Martins Upitis
  151653. */
  151654. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  151655. /**
  151656. * @ignore
  151657. * The chromatic aberration PostProcess id in the pipeline
  151658. */
  151659. LensChromaticAberrationEffect: string;
  151660. /**
  151661. * @ignore
  151662. * The highlights enhancing PostProcess id in the pipeline
  151663. */
  151664. HighlightsEnhancingEffect: string;
  151665. /**
  151666. * @ignore
  151667. * The depth-of-field PostProcess id in the pipeline
  151668. */
  151669. LensDepthOfFieldEffect: string;
  151670. private _scene;
  151671. private _depthTexture;
  151672. private _grainTexture;
  151673. private _chromaticAberrationPostProcess;
  151674. private _highlightsPostProcess;
  151675. private _depthOfFieldPostProcess;
  151676. private _edgeBlur;
  151677. private _grainAmount;
  151678. private _chromaticAberration;
  151679. private _distortion;
  151680. private _highlightsGain;
  151681. private _highlightsThreshold;
  151682. private _dofDistance;
  151683. private _dofAperture;
  151684. private _dofDarken;
  151685. private _dofPentagon;
  151686. private _blurNoise;
  151687. /**
  151688. * @constructor
  151689. *
  151690. * Effect parameters are as follow:
  151691. * {
  151692. * chromatic_aberration: number; // from 0 to x (1 for realism)
  151693. * edge_blur: number; // from 0 to x (1 for realism)
  151694. * distortion: number; // from 0 to x (1 for realism)
  151695. * grain_amount: number; // from 0 to 1
  151696. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  151697. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  151698. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  151699. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  151700. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  151701. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  151702. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  151703. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  151704. * }
  151705. * Note: if an effect parameter is unset, effect is disabled
  151706. *
  151707. * @param name The rendering pipeline name
  151708. * @param parameters - An object containing all parameters (see above)
  151709. * @param scene The scene linked to this pipeline
  151710. * @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)
  151711. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151712. */
  151713. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  151714. /**
  151715. * Get the class name
  151716. * @returns "LensRenderingPipeline"
  151717. */
  151718. getClassName(): string;
  151719. /**
  151720. * Gets associated scene
  151721. */
  151722. get scene(): Scene;
  151723. /**
  151724. * Gets or sets the edge blur
  151725. */
  151726. get edgeBlur(): number;
  151727. set edgeBlur(value: number);
  151728. /**
  151729. * Gets or sets the grain amount
  151730. */
  151731. get grainAmount(): number;
  151732. set grainAmount(value: number);
  151733. /**
  151734. * Gets or sets the chromatic aberration amount
  151735. */
  151736. get chromaticAberration(): number;
  151737. set chromaticAberration(value: number);
  151738. /**
  151739. * Gets or sets the depth of field aperture
  151740. */
  151741. get dofAperture(): number;
  151742. set dofAperture(value: number);
  151743. /**
  151744. * Gets or sets the edge distortion
  151745. */
  151746. get edgeDistortion(): number;
  151747. set edgeDistortion(value: number);
  151748. /**
  151749. * Gets or sets the depth of field distortion
  151750. */
  151751. get dofDistortion(): number;
  151752. set dofDistortion(value: number);
  151753. /**
  151754. * Gets or sets the darken out of focus amount
  151755. */
  151756. get darkenOutOfFocus(): number;
  151757. set darkenOutOfFocus(value: number);
  151758. /**
  151759. * Gets or sets a boolean indicating if blur noise is enabled
  151760. */
  151761. get blurNoise(): boolean;
  151762. set blurNoise(value: boolean);
  151763. /**
  151764. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  151765. */
  151766. get pentagonBokeh(): boolean;
  151767. set pentagonBokeh(value: boolean);
  151768. /**
  151769. * Gets or sets the highlight grain amount
  151770. */
  151771. get highlightsGain(): number;
  151772. set highlightsGain(value: number);
  151773. /**
  151774. * Gets or sets the highlight threshold
  151775. */
  151776. get highlightsThreshold(): number;
  151777. set highlightsThreshold(value: number);
  151778. /**
  151779. * Sets the amount of blur at the edges
  151780. * @param amount blur amount
  151781. */
  151782. setEdgeBlur(amount: number): void;
  151783. /**
  151784. * Sets edge blur to 0
  151785. */
  151786. disableEdgeBlur(): void;
  151787. /**
  151788. * Sets the amout of grain
  151789. * @param amount Amount of grain
  151790. */
  151791. setGrainAmount(amount: number): void;
  151792. /**
  151793. * Set grain amount to 0
  151794. */
  151795. disableGrain(): void;
  151796. /**
  151797. * Sets the chromatic aberration amount
  151798. * @param amount amount of chromatic aberration
  151799. */
  151800. setChromaticAberration(amount: number): void;
  151801. /**
  151802. * Sets chromatic aberration amount to 0
  151803. */
  151804. disableChromaticAberration(): void;
  151805. /**
  151806. * Sets the EdgeDistortion amount
  151807. * @param amount amount of EdgeDistortion
  151808. */
  151809. setEdgeDistortion(amount: number): void;
  151810. /**
  151811. * Sets edge distortion to 0
  151812. */
  151813. disableEdgeDistortion(): void;
  151814. /**
  151815. * Sets the FocusDistance amount
  151816. * @param amount amount of FocusDistance
  151817. */
  151818. setFocusDistance(amount: number): void;
  151819. /**
  151820. * Disables depth of field
  151821. */
  151822. disableDepthOfField(): void;
  151823. /**
  151824. * Sets the Aperture amount
  151825. * @param amount amount of Aperture
  151826. */
  151827. setAperture(amount: number): void;
  151828. /**
  151829. * Sets the DarkenOutOfFocus amount
  151830. * @param amount amount of DarkenOutOfFocus
  151831. */
  151832. setDarkenOutOfFocus(amount: number): void;
  151833. private _pentagonBokehIsEnabled;
  151834. /**
  151835. * Creates a pentagon bokeh effect
  151836. */
  151837. enablePentagonBokeh(): void;
  151838. /**
  151839. * Disables the pentagon bokeh effect
  151840. */
  151841. disablePentagonBokeh(): void;
  151842. /**
  151843. * Enables noise blur
  151844. */
  151845. enableNoiseBlur(): void;
  151846. /**
  151847. * Disables noise blur
  151848. */
  151849. disableNoiseBlur(): void;
  151850. /**
  151851. * Sets the HighlightsGain amount
  151852. * @param amount amount of HighlightsGain
  151853. */
  151854. setHighlightsGain(amount: number): void;
  151855. /**
  151856. * Sets the HighlightsThreshold amount
  151857. * @param amount amount of HighlightsThreshold
  151858. */
  151859. setHighlightsThreshold(amount: number): void;
  151860. /**
  151861. * Disables highlights
  151862. */
  151863. disableHighlights(): void;
  151864. /**
  151865. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  151866. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  151867. */
  151868. dispose(disableDepthRender?: boolean): void;
  151869. private _createChromaticAberrationPostProcess;
  151870. private _createHighlightsPostProcess;
  151871. private _createDepthOfFieldPostProcess;
  151872. private _createGrainTexture;
  151873. }
  151874. }
  151875. declare module BABYLON {
  151876. /**
  151877. * Contains all parameters needed for the prepass to perform
  151878. * screen space subsurface scattering
  151879. */
  151880. export class SSAO2Configuration implements PrePassEffectConfiguration {
  151881. /**
  151882. * Is subsurface enabled
  151883. */
  151884. enabled: boolean;
  151885. /**
  151886. * Name of the configuration
  151887. */
  151888. name: string;
  151889. /**
  151890. * Textures that should be present in the MRT for this effect to work
  151891. */
  151892. readonly texturesRequired: number[];
  151893. }
  151894. }
  151895. declare module BABYLON {
  151896. /** @hidden */
  151897. export var ssao2PixelShader: {
  151898. name: string;
  151899. shader: string;
  151900. };
  151901. }
  151902. declare module BABYLON {
  151903. /** @hidden */
  151904. export var ssaoCombinePixelShader: {
  151905. name: string;
  151906. shader: string;
  151907. };
  151908. }
  151909. declare module BABYLON {
  151910. /**
  151911. * Render pipeline to produce ssao effect
  151912. */
  151913. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  151914. /**
  151915. * @ignore
  151916. * The PassPostProcess id in the pipeline that contains the original scene color
  151917. */
  151918. SSAOOriginalSceneColorEffect: string;
  151919. /**
  151920. * @ignore
  151921. * The SSAO PostProcess id in the pipeline
  151922. */
  151923. SSAORenderEffect: string;
  151924. /**
  151925. * @ignore
  151926. * The horizontal blur PostProcess id in the pipeline
  151927. */
  151928. SSAOBlurHRenderEffect: string;
  151929. /**
  151930. * @ignore
  151931. * The vertical blur PostProcess id in the pipeline
  151932. */
  151933. SSAOBlurVRenderEffect: string;
  151934. /**
  151935. * @ignore
  151936. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151937. */
  151938. SSAOCombineRenderEffect: string;
  151939. /**
  151940. * The output strength of the SSAO post-process. Default value is 1.0.
  151941. */
  151942. totalStrength: number;
  151943. /**
  151944. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  151945. */
  151946. maxZ: number;
  151947. /**
  151948. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  151949. */
  151950. minZAspect: number;
  151951. private _samples;
  151952. /**
  151953. * Number of samples used for the SSAO calculations. Default value is 8
  151954. */
  151955. set samples(n: number);
  151956. get samples(): number;
  151957. private _textureSamples;
  151958. /**
  151959. * Number of samples to use for antialiasing
  151960. */
  151961. set textureSamples(n: number);
  151962. get textureSamples(): number;
  151963. /**
  151964. * Force rendering the geometry through geometry buffer
  151965. */
  151966. private _forceGeometryBuffer;
  151967. /**
  151968. * Ratio object used for SSAO ratio and blur ratio
  151969. */
  151970. private _ratio;
  151971. /**
  151972. * Dynamically generated sphere sampler.
  151973. */
  151974. private _sampleSphere;
  151975. /**
  151976. * Blur filter offsets
  151977. */
  151978. private _samplerOffsets;
  151979. private _expensiveBlur;
  151980. /**
  151981. * If bilateral blur should be used
  151982. */
  151983. set expensiveBlur(b: boolean);
  151984. get expensiveBlur(): boolean;
  151985. /**
  151986. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  151987. */
  151988. radius: number;
  151989. /**
  151990. * The base color of the SSAO post-process
  151991. * The final result is "base + ssao" between [0, 1]
  151992. */
  151993. base: number;
  151994. /**
  151995. * Support test.
  151996. */
  151997. static get IsSupported(): boolean;
  151998. private _scene;
  151999. private _randomTexture;
  152000. private _originalColorPostProcess;
  152001. private _ssaoPostProcess;
  152002. private _blurHPostProcess;
  152003. private _blurVPostProcess;
  152004. private _ssaoCombinePostProcess;
  152005. private _prePassRenderer;
  152006. /**
  152007. * Gets active scene
  152008. */
  152009. get scene(): Scene;
  152010. /**
  152011. * @constructor
  152012. * @param name The rendering pipeline name
  152013. * @param scene The scene linked to this pipeline
  152014. * @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 }
  152015. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152016. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  152017. */
  152018. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  152019. /**
  152020. * Get the class name
  152021. * @returns "SSAO2RenderingPipeline"
  152022. */
  152023. getClassName(): string;
  152024. /**
  152025. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152026. */
  152027. dispose(disableGeometryBufferRenderer?: boolean): void;
  152028. private _createBlurPostProcess;
  152029. /** @hidden */
  152030. _rebuild(): void;
  152031. private _bits;
  152032. private _radicalInverse_VdC;
  152033. private _hammersley;
  152034. private _hemisphereSample_uniform;
  152035. private _generateHemisphere;
  152036. private _getDefinesForSSAO;
  152037. private _createSSAOPostProcess;
  152038. private _createSSAOCombinePostProcess;
  152039. private _createRandomTexture;
  152040. /**
  152041. * Serialize the rendering pipeline (Used when exporting)
  152042. * @returns the serialized object
  152043. */
  152044. serialize(): any;
  152045. /**
  152046. * Parse the serialized pipeline
  152047. * @param source Source pipeline.
  152048. * @param scene The scene to load the pipeline to.
  152049. * @param rootUrl The URL of the serialized pipeline.
  152050. * @returns An instantiated pipeline from the serialized object.
  152051. */
  152052. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  152053. }
  152054. }
  152055. declare module BABYLON {
  152056. /** @hidden */
  152057. export var ssaoPixelShader: {
  152058. name: string;
  152059. shader: string;
  152060. };
  152061. }
  152062. declare module BABYLON {
  152063. /**
  152064. * Render pipeline to produce ssao effect
  152065. */
  152066. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  152067. /**
  152068. * @ignore
  152069. * The PassPostProcess id in the pipeline that contains the original scene color
  152070. */
  152071. SSAOOriginalSceneColorEffect: string;
  152072. /**
  152073. * @ignore
  152074. * The SSAO PostProcess id in the pipeline
  152075. */
  152076. SSAORenderEffect: string;
  152077. /**
  152078. * @ignore
  152079. * The horizontal blur PostProcess id in the pipeline
  152080. */
  152081. SSAOBlurHRenderEffect: string;
  152082. /**
  152083. * @ignore
  152084. * The vertical blur PostProcess id in the pipeline
  152085. */
  152086. SSAOBlurVRenderEffect: string;
  152087. /**
  152088. * @ignore
  152089. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  152090. */
  152091. SSAOCombineRenderEffect: string;
  152092. /**
  152093. * The output strength of the SSAO post-process. Default value is 1.0.
  152094. */
  152095. totalStrength: number;
  152096. /**
  152097. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  152098. */
  152099. radius: number;
  152100. /**
  152101. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  152102. * Must not be equal to fallOff and superior to fallOff.
  152103. * Default value is 0.0075
  152104. */
  152105. area: number;
  152106. /**
  152107. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  152108. * Must not be equal to area and inferior to area.
  152109. * Default value is 0.000001
  152110. */
  152111. fallOff: number;
  152112. /**
  152113. * The base color of the SSAO post-process
  152114. * The final result is "base + ssao" between [0, 1]
  152115. */
  152116. base: number;
  152117. private _scene;
  152118. private _depthTexture;
  152119. private _randomTexture;
  152120. private _originalColorPostProcess;
  152121. private _ssaoPostProcess;
  152122. private _blurHPostProcess;
  152123. private _blurVPostProcess;
  152124. private _ssaoCombinePostProcess;
  152125. private _firstUpdate;
  152126. /**
  152127. * Gets active scene
  152128. */
  152129. get scene(): Scene;
  152130. /**
  152131. * @constructor
  152132. * @param name - The rendering pipeline name
  152133. * @param scene - The scene linked to this pipeline
  152134. * @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 }
  152135. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  152136. */
  152137. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  152138. /**
  152139. * Get the class name
  152140. * @returns "SSAORenderingPipeline"
  152141. */
  152142. getClassName(): string;
  152143. /**
  152144. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152145. */
  152146. dispose(disableDepthRender?: boolean): void;
  152147. private _createBlurPostProcess;
  152148. /** @hidden */
  152149. _rebuild(): void;
  152150. private _createSSAOPostProcess;
  152151. private _createSSAOCombinePostProcess;
  152152. private _createRandomTexture;
  152153. }
  152154. }
  152155. declare module BABYLON {
  152156. /**
  152157. * Contains all parameters needed for the prepass to perform
  152158. * screen space reflections
  152159. */
  152160. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  152161. /**
  152162. * Is ssr enabled
  152163. */
  152164. enabled: boolean;
  152165. /**
  152166. * Name of the configuration
  152167. */
  152168. name: string;
  152169. /**
  152170. * Textures that should be present in the MRT for this effect to work
  152171. */
  152172. readonly texturesRequired: number[];
  152173. }
  152174. }
  152175. declare module BABYLON {
  152176. /** @hidden */
  152177. export var screenSpaceReflectionPixelShader: {
  152178. name: string;
  152179. shader: string;
  152180. };
  152181. }
  152182. declare module BABYLON {
  152183. /**
  152184. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  152185. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  152186. */
  152187. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  152188. /**
  152189. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  152190. */
  152191. threshold: number;
  152192. /**
  152193. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  152194. */
  152195. strength: number;
  152196. /**
  152197. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  152198. */
  152199. reflectionSpecularFalloffExponent: number;
  152200. /**
  152201. * 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]
  152202. */
  152203. step: number;
  152204. /**
  152205. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  152206. */
  152207. roughnessFactor: number;
  152208. private _forceGeometryBuffer;
  152209. private _geometryBufferRenderer;
  152210. private _prePassRenderer;
  152211. private _enableSmoothReflections;
  152212. private _reflectionSamples;
  152213. private _smoothSteps;
  152214. /**
  152215. * Gets a string identifying the name of the class
  152216. * @returns "ScreenSpaceReflectionPostProcess" string
  152217. */
  152218. getClassName(): string;
  152219. /**
  152220. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  152221. * @param name The name of the effect.
  152222. * @param scene The scene containing the objects to calculate reflections.
  152223. * @param options The required width/height ratio to downsize to before computing the render pass.
  152224. * @param camera The camera to apply the render pass to.
  152225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152226. * @param engine The engine which the post process will be applied. (default: current engine)
  152227. * @param reusable If the post process can be reused on the same frame. (default: false)
  152228. * @param textureType Type of textures used when performing the post process. (default: 0)
  152229. * @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)
  152230. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  152231. */
  152232. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  152233. /**
  152234. * Gets wether or not smoothing reflections is enabled.
  152235. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152236. */
  152237. get enableSmoothReflections(): boolean;
  152238. /**
  152239. * Sets wether or not smoothing reflections is enabled.
  152240. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152241. */
  152242. set enableSmoothReflections(enabled: boolean);
  152243. /**
  152244. * Gets the number of samples taken while computing reflections. More samples count is high,
  152245. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152246. */
  152247. get reflectionSamples(): number;
  152248. /**
  152249. * Sets the number of samples taken while computing reflections. More samples count is high,
  152250. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152251. */
  152252. set reflectionSamples(samples: number);
  152253. /**
  152254. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  152255. * more the post-process will require GPU power and can generate a drop in FPS.
  152256. * Default value (5.0) work pretty well in all cases but can be adjusted.
  152257. */
  152258. get smoothSteps(): number;
  152259. set smoothSteps(steps: number);
  152260. private _updateEffectDefines;
  152261. /** @hidden */
  152262. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  152263. }
  152264. }
  152265. declare module BABYLON {
  152266. /** @hidden */
  152267. export var standardPixelShader: {
  152268. name: string;
  152269. shader: string;
  152270. };
  152271. }
  152272. declare module BABYLON {
  152273. /**
  152274. * Standard rendering pipeline
  152275. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152276. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  152277. */
  152278. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  152279. /**
  152280. * Public members
  152281. */
  152282. /**
  152283. * Post-process which contains the original scene color before the pipeline applies all the effects
  152284. */
  152285. originalPostProcess: Nullable<PostProcess>;
  152286. /**
  152287. * Post-process used to down scale an image x4
  152288. */
  152289. downSampleX4PostProcess: Nullable<PostProcess>;
  152290. /**
  152291. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  152292. */
  152293. brightPassPostProcess: Nullable<PostProcess>;
  152294. /**
  152295. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  152296. */
  152297. blurHPostProcesses: PostProcess[];
  152298. /**
  152299. * Post-process array storing all the vertical blur post-processes used by the pipeline
  152300. */
  152301. blurVPostProcesses: PostProcess[];
  152302. /**
  152303. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  152304. */
  152305. textureAdderPostProcess: Nullable<PostProcess>;
  152306. /**
  152307. * Post-process used to create volumetric lighting effect
  152308. */
  152309. volumetricLightPostProcess: Nullable<PostProcess>;
  152310. /**
  152311. * Post-process used to smooth the previous volumetric light post-process on the X axis
  152312. */
  152313. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  152314. /**
  152315. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  152316. */
  152317. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  152318. /**
  152319. * Post-process used to merge the volumetric light effect and the real scene color
  152320. */
  152321. volumetricLightMergePostProces: Nullable<PostProcess>;
  152322. /**
  152323. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  152324. */
  152325. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  152326. /**
  152327. * Base post-process used to calculate the average luminance of the final image for HDR
  152328. */
  152329. luminancePostProcess: Nullable<PostProcess>;
  152330. /**
  152331. * Post-processes used to create down sample post-processes in order to get
  152332. * the average luminance of the final image for HDR
  152333. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  152334. */
  152335. luminanceDownSamplePostProcesses: PostProcess[];
  152336. /**
  152337. * Post-process used to create a HDR effect (light adaptation)
  152338. */
  152339. hdrPostProcess: Nullable<PostProcess>;
  152340. /**
  152341. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  152342. */
  152343. textureAdderFinalPostProcess: Nullable<PostProcess>;
  152344. /**
  152345. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  152346. */
  152347. lensFlareFinalPostProcess: Nullable<PostProcess>;
  152348. /**
  152349. * Post-process used to merge the final HDR post-process and the real scene color
  152350. */
  152351. hdrFinalPostProcess: Nullable<PostProcess>;
  152352. /**
  152353. * Post-process used to create a lens flare effect
  152354. */
  152355. lensFlarePostProcess: Nullable<PostProcess>;
  152356. /**
  152357. * Post-process that merges the result of the lens flare post-process and the real scene color
  152358. */
  152359. lensFlareComposePostProcess: Nullable<PostProcess>;
  152360. /**
  152361. * Post-process used to create a motion blur effect
  152362. */
  152363. motionBlurPostProcess: Nullable<PostProcess>;
  152364. /**
  152365. * Post-process used to create a depth of field effect
  152366. */
  152367. depthOfFieldPostProcess: Nullable<PostProcess>;
  152368. /**
  152369. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  152370. */
  152371. fxaaPostProcess: Nullable<FxaaPostProcess>;
  152372. /**
  152373. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  152374. */
  152375. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  152376. /**
  152377. * Represents the brightness threshold in order to configure the illuminated surfaces
  152378. */
  152379. brightThreshold: number;
  152380. /**
  152381. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  152382. */
  152383. blurWidth: number;
  152384. /**
  152385. * Sets if the blur for highlighted surfaces must be only horizontal
  152386. */
  152387. horizontalBlur: boolean;
  152388. /**
  152389. * Gets the overall exposure used by the pipeline
  152390. */
  152391. get exposure(): number;
  152392. /**
  152393. * Sets the overall exposure used by the pipeline
  152394. */
  152395. set exposure(value: number);
  152396. /**
  152397. * Texture used typically to simulate "dirty" on camera lens
  152398. */
  152399. lensTexture: Nullable<Texture>;
  152400. /**
  152401. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  152402. */
  152403. volumetricLightCoefficient: number;
  152404. /**
  152405. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  152406. */
  152407. volumetricLightPower: number;
  152408. /**
  152409. * Used the set the blur intensity to smooth the volumetric lights
  152410. */
  152411. volumetricLightBlurScale: number;
  152412. /**
  152413. * Light (spot or directional) used to generate the volumetric lights rays
  152414. * The source light must have a shadow generate so the pipeline can get its
  152415. * depth map
  152416. */
  152417. sourceLight: Nullable<SpotLight | DirectionalLight>;
  152418. /**
  152419. * For eye adaptation, represents the minimum luminance the eye can see
  152420. */
  152421. hdrMinimumLuminance: number;
  152422. /**
  152423. * For eye adaptation, represents the decrease luminance speed
  152424. */
  152425. hdrDecreaseRate: number;
  152426. /**
  152427. * For eye adaptation, represents the increase luminance speed
  152428. */
  152429. hdrIncreaseRate: number;
  152430. /**
  152431. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152432. */
  152433. get hdrAutoExposure(): boolean;
  152434. /**
  152435. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152436. */
  152437. set hdrAutoExposure(value: boolean);
  152438. /**
  152439. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  152440. */
  152441. lensColorTexture: Nullable<Texture>;
  152442. /**
  152443. * The overall strengh for the lens flare effect
  152444. */
  152445. lensFlareStrength: number;
  152446. /**
  152447. * Dispersion coefficient for lens flare ghosts
  152448. */
  152449. lensFlareGhostDispersal: number;
  152450. /**
  152451. * Main lens flare halo width
  152452. */
  152453. lensFlareHaloWidth: number;
  152454. /**
  152455. * Based on the lens distortion effect, defines how much the lens flare result
  152456. * is distorted
  152457. */
  152458. lensFlareDistortionStrength: number;
  152459. /**
  152460. * Configures the blur intensity used for for lens flare (halo)
  152461. */
  152462. lensFlareBlurWidth: number;
  152463. /**
  152464. * Lens star texture must be used to simulate rays on the flares and is available
  152465. * in the documentation
  152466. */
  152467. lensStarTexture: Nullable<Texture>;
  152468. /**
  152469. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  152470. * flare effect by taking account of the dirt texture
  152471. */
  152472. lensFlareDirtTexture: Nullable<Texture>;
  152473. /**
  152474. * Represents the focal length for the depth of field effect
  152475. */
  152476. depthOfFieldDistance: number;
  152477. /**
  152478. * Represents the blur intensity for the blurred part of the depth of field effect
  152479. */
  152480. depthOfFieldBlurWidth: number;
  152481. /**
  152482. * Gets how much the image is blurred by the movement while using the motion blur post-process
  152483. */
  152484. get motionStrength(): number;
  152485. /**
  152486. * Sets how much the image is blurred by the movement while using the motion blur post-process
  152487. */
  152488. set motionStrength(strength: number);
  152489. /**
  152490. * Gets wether or not the motion blur post-process is object based or screen based.
  152491. */
  152492. get objectBasedMotionBlur(): boolean;
  152493. /**
  152494. * Sets wether or not the motion blur post-process should be object based or screen based
  152495. */
  152496. set objectBasedMotionBlur(value: boolean);
  152497. /**
  152498. * List of animations for the pipeline (IAnimatable implementation)
  152499. */
  152500. animations: Animation[];
  152501. /**
  152502. * Private members
  152503. */
  152504. private _scene;
  152505. private _currentDepthOfFieldSource;
  152506. private _basePostProcess;
  152507. private _fixedExposure;
  152508. private _currentExposure;
  152509. private _hdrAutoExposure;
  152510. private _hdrCurrentLuminance;
  152511. private _motionStrength;
  152512. private _isObjectBasedMotionBlur;
  152513. private _floatTextureType;
  152514. private _camerasToBeAttached;
  152515. private _ratio;
  152516. private _bloomEnabled;
  152517. private _depthOfFieldEnabled;
  152518. private _vlsEnabled;
  152519. private _lensFlareEnabled;
  152520. private _hdrEnabled;
  152521. private _motionBlurEnabled;
  152522. private _fxaaEnabled;
  152523. private _screenSpaceReflectionsEnabled;
  152524. private _motionBlurSamples;
  152525. private _volumetricLightStepsCount;
  152526. private _samples;
  152527. /**
  152528. * @ignore
  152529. * Specifies if the bloom pipeline is enabled
  152530. */
  152531. get BloomEnabled(): boolean;
  152532. set BloomEnabled(enabled: boolean);
  152533. /**
  152534. * @ignore
  152535. * Specifies if the depth of field pipeline is enabed
  152536. */
  152537. get DepthOfFieldEnabled(): boolean;
  152538. set DepthOfFieldEnabled(enabled: boolean);
  152539. /**
  152540. * @ignore
  152541. * Specifies if the lens flare pipeline is enabed
  152542. */
  152543. get LensFlareEnabled(): boolean;
  152544. set LensFlareEnabled(enabled: boolean);
  152545. /**
  152546. * @ignore
  152547. * Specifies if the HDR pipeline is enabled
  152548. */
  152549. get HDREnabled(): boolean;
  152550. set HDREnabled(enabled: boolean);
  152551. /**
  152552. * @ignore
  152553. * Specifies if the volumetric lights scattering effect is enabled
  152554. */
  152555. get VLSEnabled(): boolean;
  152556. set VLSEnabled(enabled: boolean);
  152557. /**
  152558. * @ignore
  152559. * Specifies if the motion blur effect is enabled
  152560. */
  152561. get MotionBlurEnabled(): boolean;
  152562. set MotionBlurEnabled(enabled: boolean);
  152563. /**
  152564. * Specifies if anti-aliasing is enabled
  152565. */
  152566. get fxaaEnabled(): boolean;
  152567. set fxaaEnabled(enabled: boolean);
  152568. /**
  152569. * Specifies if screen space reflections are enabled.
  152570. */
  152571. get screenSpaceReflectionsEnabled(): boolean;
  152572. set screenSpaceReflectionsEnabled(enabled: boolean);
  152573. /**
  152574. * Specifies the number of steps used to calculate the volumetric lights
  152575. * Typically in interval [50, 200]
  152576. */
  152577. get volumetricLightStepsCount(): number;
  152578. set volumetricLightStepsCount(count: number);
  152579. /**
  152580. * Specifies the number of samples used for the motion blur effect
  152581. * Typically in interval [16, 64]
  152582. */
  152583. get motionBlurSamples(): number;
  152584. set motionBlurSamples(samples: number);
  152585. /**
  152586. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  152587. */
  152588. get samples(): number;
  152589. set samples(sampleCount: number);
  152590. /**
  152591. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152592. * @constructor
  152593. * @param name The rendering pipeline name
  152594. * @param scene The scene linked to this pipeline
  152595. * @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)
  152596. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  152597. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152598. */
  152599. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  152600. private _buildPipeline;
  152601. private _createDownSampleX4PostProcess;
  152602. private _createBrightPassPostProcess;
  152603. private _createBlurPostProcesses;
  152604. private _createTextureAdderPostProcess;
  152605. private _createVolumetricLightPostProcess;
  152606. private _createLuminancePostProcesses;
  152607. private _createHdrPostProcess;
  152608. private _createLensFlarePostProcess;
  152609. private _createDepthOfFieldPostProcess;
  152610. private _createMotionBlurPostProcess;
  152611. private _getDepthTexture;
  152612. private _disposePostProcesses;
  152613. /**
  152614. * Dispose of the pipeline and stop all post processes
  152615. */
  152616. dispose(): void;
  152617. /**
  152618. * Serialize the rendering pipeline (Used when exporting)
  152619. * @returns the serialized object
  152620. */
  152621. serialize(): any;
  152622. /**
  152623. * Parse the serialized pipeline
  152624. * @param source Source pipeline.
  152625. * @param scene The scene to load the pipeline to.
  152626. * @param rootUrl The URL of the serialized pipeline.
  152627. * @returns An instantiated pipeline from the serialized object.
  152628. */
  152629. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  152630. /**
  152631. * Luminance steps
  152632. */
  152633. static LuminanceSteps: number;
  152634. }
  152635. }
  152636. declare module BABYLON {
  152637. /** @hidden */
  152638. export var stereoscopicInterlacePixelShader: {
  152639. name: string;
  152640. shader: string;
  152641. };
  152642. }
  152643. declare module BABYLON {
  152644. /**
  152645. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  152646. */
  152647. export class StereoscopicInterlacePostProcessI extends PostProcess {
  152648. private _stepSize;
  152649. private _passedProcess;
  152650. /**
  152651. * Gets a string identifying the name of the class
  152652. * @returns "StereoscopicInterlacePostProcessI" string
  152653. */
  152654. getClassName(): string;
  152655. /**
  152656. * Initializes a StereoscopicInterlacePostProcessI
  152657. * @param name The name of the effect.
  152658. * @param rigCameras The rig cameras to be appled to the post process
  152659. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  152660. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  152661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152662. * @param engine The engine which the post process will be applied. (default: current engine)
  152663. * @param reusable If the post process can be reused on the same frame. (default: false)
  152664. */
  152665. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152666. }
  152667. /**
  152668. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  152669. */
  152670. export class StereoscopicInterlacePostProcess extends PostProcess {
  152671. private _stepSize;
  152672. private _passedProcess;
  152673. /**
  152674. * Gets a string identifying the name of the class
  152675. * @returns "StereoscopicInterlacePostProcess" string
  152676. */
  152677. getClassName(): string;
  152678. /**
  152679. * Initializes a StereoscopicInterlacePostProcess
  152680. * @param name The name of the effect.
  152681. * @param rigCameras The rig cameras to be appled to the post process
  152682. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  152683. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152684. * @param engine The engine which the post process will be applied. (default: current engine)
  152685. * @param reusable If the post process can be reused on the same frame. (default: false)
  152686. */
  152687. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152688. }
  152689. }
  152690. declare module BABYLON {
  152691. /** @hidden */
  152692. export var tonemapPixelShader: {
  152693. name: string;
  152694. shader: string;
  152695. };
  152696. }
  152697. declare module BABYLON {
  152698. /** Defines operator used for tonemapping */
  152699. export enum TonemappingOperator {
  152700. /** Hable */
  152701. Hable = 0,
  152702. /** Reinhard */
  152703. Reinhard = 1,
  152704. /** HejiDawson */
  152705. HejiDawson = 2,
  152706. /** Photographic */
  152707. Photographic = 3
  152708. }
  152709. /**
  152710. * Defines a post process to apply tone mapping
  152711. */
  152712. export class TonemapPostProcess extends PostProcess {
  152713. private _operator;
  152714. /** Defines the required exposure adjustement */
  152715. exposureAdjustment: number;
  152716. /**
  152717. * Gets a string identifying the name of the class
  152718. * @returns "TonemapPostProcess" string
  152719. */
  152720. getClassName(): string;
  152721. /**
  152722. * Creates a new TonemapPostProcess
  152723. * @param name defines the name of the postprocess
  152724. * @param _operator defines the operator to use
  152725. * @param exposureAdjustment defines the required exposure adjustement
  152726. * @param camera defines the camera to use (can be null)
  152727. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  152728. * @param engine defines the hosting engine (can be ignore if camera is set)
  152729. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  152730. */
  152731. constructor(name: string, _operator: TonemappingOperator,
  152732. /** Defines the required exposure adjustement */
  152733. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  152734. }
  152735. }
  152736. declare module BABYLON {
  152737. /** @hidden */
  152738. export var volumetricLightScatteringPixelShader: {
  152739. name: string;
  152740. shader: string;
  152741. };
  152742. }
  152743. declare module BABYLON {
  152744. /** @hidden */
  152745. export var volumetricLightScatteringPassVertexShader: {
  152746. name: string;
  152747. shader: string;
  152748. };
  152749. }
  152750. declare module BABYLON {
  152751. /** @hidden */
  152752. export var volumetricLightScatteringPassPixelShader: {
  152753. name: string;
  152754. shader: string;
  152755. };
  152756. }
  152757. declare module BABYLON {
  152758. /**
  152759. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  152760. */
  152761. export class VolumetricLightScatteringPostProcess extends PostProcess {
  152762. private _volumetricLightScatteringPass;
  152763. private _volumetricLightScatteringRTT;
  152764. private _viewPort;
  152765. private _screenCoordinates;
  152766. private _cachedDefines;
  152767. /**
  152768. * If not undefined, the mesh position is computed from the attached node position
  152769. */
  152770. attachedNode: {
  152771. position: Vector3;
  152772. };
  152773. /**
  152774. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  152775. */
  152776. customMeshPosition: Vector3;
  152777. /**
  152778. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  152779. */
  152780. useCustomMeshPosition: boolean;
  152781. /**
  152782. * If the post-process should inverse the light scattering direction
  152783. */
  152784. invert: boolean;
  152785. /**
  152786. * The internal mesh used by the post-process
  152787. */
  152788. mesh: Mesh;
  152789. /**
  152790. * @hidden
  152791. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  152792. */
  152793. get useDiffuseColor(): boolean;
  152794. set useDiffuseColor(useDiffuseColor: boolean);
  152795. /**
  152796. * Array containing the excluded meshes not rendered in the internal pass
  152797. */
  152798. excludedMeshes: AbstractMesh[];
  152799. /**
  152800. * Controls the overall intensity of the post-process
  152801. */
  152802. exposure: number;
  152803. /**
  152804. * Dissipates each sample's contribution in range [0, 1]
  152805. */
  152806. decay: number;
  152807. /**
  152808. * Controls the overall intensity of each sample
  152809. */
  152810. weight: number;
  152811. /**
  152812. * Controls the density of each sample
  152813. */
  152814. density: number;
  152815. /**
  152816. * @constructor
  152817. * @param name The post-process name
  152818. * @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)
  152819. * @param camera The camera that the post-process will be attached to
  152820. * @param mesh The mesh used to create the light scattering
  152821. * @param samples The post-process quality, default 100
  152822. * @param samplingModeThe post-process filtering mode
  152823. * @param engine The babylon engine
  152824. * @param reusable If the post-process is reusable
  152825. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  152826. */
  152827. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  152828. /**
  152829. * Returns the string "VolumetricLightScatteringPostProcess"
  152830. * @returns "VolumetricLightScatteringPostProcess"
  152831. */
  152832. getClassName(): string;
  152833. private _isReady;
  152834. /**
  152835. * Sets the new light position for light scattering effect
  152836. * @param position The new custom light position
  152837. */
  152838. setCustomMeshPosition(position: Vector3): void;
  152839. /**
  152840. * Returns the light position for light scattering effect
  152841. * @return Vector3 The custom light position
  152842. */
  152843. getCustomMeshPosition(): Vector3;
  152844. /**
  152845. * Disposes the internal assets and detaches the post-process from the camera
  152846. */
  152847. dispose(camera: Camera): void;
  152848. /**
  152849. * Returns the render target texture used by the post-process
  152850. * @return the render target texture used by the post-process
  152851. */
  152852. getPass(): RenderTargetTexture;
  152853. private _meshExcluded;
  152854. private _createPass;
  152855. private _updateMeshScreenCoordinates;
  152856. /**
  152857. * Creates a default mesh for the Volumeric Light Scattering post-process
  152858. * @param name The mesh name
  152859. * @param scene The scene where to create the mesh
  152860. * @return the default mesh
  152861. */
  152862. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  152863. }
  152864. }
  152865. declare module BABYLON {
  152866. /** @hidden */
  152867. export var screenSpaceCurvaturePixelShader: {
  152868. name: string;
  152869. shader: string;
  152870. };
  152871. }
  152872. declare module BABYLON {
  152873. /**
  152874. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  152875. */
  152876. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  152877. /**
  152878. * Defines how much ridge the curvature effect displays.
  152879. */
  152880. ridge: number;
  152881. /**
  152882. * Defines how much valley the curvature effect displays.
  152883. */
  152884. valley: number;
  152885. private _geometryBufferRenderer;
  152886. /**
  152887. * Gets a string identifying the name of the class
  152888. * @returns "ScreenSpaceCurvaturePostProcess" string
  152889. */
  152890. getClassName(): string;
  152891. /**
  152892. * Creates a new instance ScreenSpaceCurvaturePostProcess
  152893. * @param name The name of the effect.
  152894. * @param scene The scene containing the objects to blur according to their velocity.
  152895. * @param options The required width/height ratio to downsize to before computing the render pass.
  152896. * @param camera The camera to apply the render pass to.
  152897. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152898. * @param engine The engine which the post process will be applied. (default: current engine)
  152899. * @param reusable If the post process can be reused on the same frame. (default: false)
  152900. * @param textureType Type of textures used when performing the post process. (default: 0)
  152901. * @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)
  152902. */
  152903. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152904. /**
  152905. * Support test.
  152906. */
  152907. static get IsSupported(): boolean;
  152908. /** @hidden */
  152909. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  152910. }
  152911. }
  152912. declare module BABYLON {
  152913. interface Scene {
  152914. /** @hidden (Backing field) */
  152915. _boundingBoxRenderer: BoundingBoxRenderer;
  152916. /** @hidden (Backing field) */
  152917. _forceShowBoundingBoxes: boolean;
  152918. /**
  152919. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  152920. */
  152921. forceShowBoundingBoxes: boolean;
  152922. /**
  152923. * Gets the bounding box renderer associated with the scene
  152924. * @returns a BoundingBoxRenderer
  152925. */
  152926. getBoundingBoxRenderer(): BoundingBoxRenderer;
  152927. }
  152928. interface AbstractMesh {
  152929. /** @hidden (Backing field) */
  152930. _showBoundingBox: boolean;
  152931. /**
  152932. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  152933. */
  152934. showBoundingBox: boolean;
  152935. }
  152936. /**
  152937. * Component responsible of rendering the bounding box of the meshes in a scene.
  152938. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  152939. */
  152940. export class BoundingBoxRenderer implements ISceneComponent {
  152941. /**
  152942. * The component name helpfull to identify the component in the list of scene components.
  152943. */
  152944. readonly name: string;
  152945. /**
  152946. * The scene the component belongs to.
  152947. */
  152948. scene: Scene;
  152949. /**
  152950. * Color of the bounding box lines placed in front of an object
  152951. */
  152952. frontColor: Color3;
  152953. /**
  152954. * Color of the bounding box lines placed behind an object
  152955. */
  152956. backColor: Color3;
  152957. /**
  152958. * Defines if the renderer should show the back lines or not
  152959. */
  152960. showBackLines: boolean;
  152961. /**
  152962. * Observable raised before rendering a bounding box
  152963. */
  152964. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  152965. /**
  152966. * Observable raised after rendering a bounding box
  152967. */
  152968. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  152969. /**
  152970. * @hidden
  152971. */
  152972. renderList: SmartArray<BoundingBox>;
  152973. private _colorShader;
  152974. private _vertexBuffers;
  152975. private _indexBuffer;
  152976. private _fillIndexBuffer;
  152977. private _fillIndexData;
  152978. /**
  152979. * Instantiates a new bounding box renderer in a scene.
  152980. * @param scene the scene the renderer renders in
  152981. */
  152982. constructor(scene: Scene);
  152983. /**
  152984. * Registers the component in a given scene
  152985. */
  152986. register(): void;
  152987. private _evaluateSubMesh;
  152988. private _activeMesh;
  152989. private _prepareRessources;
  152990. private _createIndexBuffer;
  152991. /**
  152992. * Rebuilds the elements related to this component in case of
  152993. * context lost for instance.
  152994. */
  152995. rebuild(): void;
  152996. /**
  152997. * @hidden
  152998. */
  152999. reset(): void;
  153000. /**
  153001. * Render the bounding boxes of a specific rendering group
  153002. * @param renderingGroupId defines the rendering group to render
  153003. */
  153004. render(renderingGroupId: number): void;
  153005. /**
  153006. * In case of occlusion queries, we can render the occlusion bounding box through this method
  153007. * @param mesh Define the mesh to render the occlusion bounding box for
  153008. */
  153009. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  153010. /**
  153011. * Dispose and release the resources attached to this renderer.
  153012. */
  153013. dispose(): void;
  153014. }
  153015. }
  153016. declare module BABYLON {
  153017. interface Scene {
  153018. /** @hidden (Backing field) */
  153019. _depthRenderer: {
  153020. [id: string]: DepthRenderer;
  153021. };
  153022. /**
  153023. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  153024. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  153025. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  153026. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  153027. * @returns the created depth renderer
  153028. */
  153029. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  153030. /**
  153031. * Disables a depth renderer for a given camera
  153032. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  153033. */
  153034. disableDepthRenderer(camera?: Nullable<Camera>): void;
  153035. }
  153036. /**
  153037. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  153038. * in several rendering techniques.
  153039. */
  153040. export class DepthRendererSceneComponent implements ISceneComponent {
  153041. /**
  153042. * The component name helpfull to identify the component in the list of scene components.
  153043. */
  153044. readonly name: string;
  153045. /**
  153046. * The scene the component belongs to.
  153047. */
  153048. scene: Scene;
  153049. /**
  153050. * Creates a new instance of the component for the given scene
  153051. * @param scene Defines the scene to register the component in
  153052. */
  153053. constructor(scene: Scene);
  153054. /**
  153055. * Registers the component in a given scene
  153056. */
  153057. register(): void;
  153058. /**
  153059. * Rebuilds the elements related to this component in case of
  153060. * context lost for instance.
  153061. */
  153062. rebuild(): void;
  153063. /**
  153064. * Disposes the component and the associated ressources
  153065. */
  153066. dispose(): void;
  153067. private _gatherRenderTargets;
  153068. private _gatherActiveCameraRenderTargets;
  153069. }
  153070. }
  153071. declare module BABYLON {
  153072. interface AbstractScene {
  153073. /** @hidden (Backing field) */
  153074. _prePassRenderer: Nullable<PrePassRenderer>;
  153075. /**
  153076. * Gets or Sets the current prepass renderer associated to the scene.
  153077. */
  153078. prePassRenderer: Nullable<PrePassRenderer>;
  153079. /**
  153080. * Enables the prepass and associates it with the scene
  153081. * @returns the PrePassRenderer
  153082. */
  153083. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  153084. /**
  153085. * Disables the prepass associated with the scene
  153086. */
  153087. disablePrePassRenderer(): void;
  153088. }
  153089. /**
  153090. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153091. * in several rendering techniques.
  153092. */
  153093. export class PrePassRendererSceneComponent implements ISceneComponent {
  153094. /**
  153095. * The component name helpful to identify the component in the list of scene components.
  153096. */
  153097. readonly name: string;
  153098. /**
  153099. * The scene the component belongs to.
  153100. */
  153101. scene: Scene;
  153102. /**
  153103. * Creates a new instance of the component for the given scene
  153104. * @param scene Defines the scene to register the component in
  153105. */
  153106. constructor(scene: Scene);
  153107. /**
  153108. * Registers the component in a given scene
  153109. */
  153110. register(): void;
  153111. private _beforeCameraDraw;
  153112. private _afterCameraDraw;
  153113. private _beforeClearStage;
  153114. /**
  153115. * Rebuilds the elements related to this component in case of
  153116. * context lost for instance.
  153117. */
  153118. rebuild(): void;
  153119. /**
  153120. * Disposes the component and the associated ressources
  153121. */
  153122. dispose(): void;
  153123. }
  153124. }
  153125. declare module BABYLON {
  153126. /** @hidden */
  153127. export var fibonacci: {
  153128. name: string;
  153129. shader: string;
  153130. };
  153131. }
  153132. declare module BABYLON {
  153133. /** @hidden */
  153134. export var diffusionProfile: {
  153135. name: string;
  153136. shader: string;
  153137. };
  153138. }
  153139. declare module BABYLON {
  153140. /** @hidden */
  153141. export var subSurfaceScatteringPixelShader: {
  153142. name: string;
  153143. shader: string;
  153144. };
  153145. }
  153146. declare module BABYLON {
  153147. /**
  153148. * Sub surface scattering post process
  153149. */
  153150. export class SubSurfaceScatteringPostProcess extends PostProcess {
  153151. /**
  153152. * Gets a string identifying the name of the class
  153153. * @returns "SubSurfaceScatteringPostProcess" string
  153154. */
  153155. getClassName(): string;
  153156. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  153157. }
  153158. }
  153159. declare module BABYLON {
  153160. /**
  153161. * Contains all parameters needed for the prepass to perform
  153162. * screen space subsurface scattering
  153163. */
  153164. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  153165. /** @hidden */
  153166. static _SceneComponentInitialization: (scene: Scene) => void;
  153167. private _ssDiffusionS;
  153168. private _ssFilterRadii;
  153169. private _ssDiffusionD;
  153170. /**
  153171. * Post process to attach for screen space subsurface scattering
  153172. */
  153173. postProcess: SubSurfaceScatteringPostProcess;
  153174. /**
  153175. * Diffusion profile color for subsurface scattering
  153176. */
  153177. get ssDiffusionS(): number[];
  153178. /**
  153179. * Diffusion profile max color channel value for subsurface scattering
  153180. */
  153181. get ssDiffusionD(): number[];
  153182. /**
  153183. * Diffusion profile filter radius for subsurface scattering
  153184. */
  153185. get ssFilterRadii(): number[];
  153186. /**
  153187. * Is subsurface enabled
  153188. */
  153189. enabled: boolean;
  153190. /**
  153191. * Name of the configuration
  153192. */
  153193. name: string;
  153194. /**
  153195. * Diffusion profile colors for subsurface scattering
  153196. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  153197. * See ...
  153198. * Note that you can only store up to 5 of them
  153199. */
  153200. ssDiffusionProfileColors: Color3[];
  153201. /**
  153202. * Defines the ratio real world => scene units.
  153203. * Used for subsurface scattering
  153204. */
  153205. metersPerUnit: number;
  153206. /**
  153207. * Textures that should be present in the MRT for this effect to work
  153208. */
  153209. readonly texturesRequired: number[];
  153210. private _scene;
  153211. /**
  153212. * Builds a subsurface configuration object
  153213. * @param scene The scene
  153214. */
  153215. constructor(scene: Scene);
  153216. /**
  153217. * Adds a new diffusion profile.
  153218. * Useful for more realistic subsurface scattering on diverse materials.
  153219. * @param color The color of the diffusion profile. Should be the average color of the material.
  153220. * @return The index of the diffusion profile for the material subsurface configuration
  153221. */
  153222. addDiffusionProfile(color: Color3): number;
  153223. /**
  153224. * Creates the sss post process
  153225. * @return The created post process
  153226. */
  153227. createPostProcess(): SubSurfaceScatteringPostProcess;
  153228. /**
  153229. * Deletes all diffusion profiles.
  153230. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  153231. */
  153232. clearAllDiffusionProfiles(): void;
  153233. /**
  153234. * Disposes this object
  153235. */
  153236. dispose(): void;
  153237. /**
  153238. * @hidden
  153239. * https://zero-radiance.github.io/post/sampling-diffusion/
  153240. *
  153241. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  153242. * ------------------------------------------------------------------------------------
  153243. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  153244. * PDF[r, phi, s] = r * R[r, phi, s]
  153245. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  153246. * ------------------------------------------------------------------------------------
  153247. * We importance sample the color channel with the widest scattering distance.
  153248. */
  153249. getDiffusionProfileParameters(color: Color3): number;
  153250. /**
  153251. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  153252. * 'u' is the random number (the value of the CDF): [0, 1).
  153253. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  153254. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  153255. */
  153256. private _sampleBurleyDiffusionProfile;
  153257. }
  153258. }
  153259. declare module BABYLON {
  153260. interface AbstractScene {
  153261. /** @hidden (Backing field) */
  153262. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153263. /**
  153264. * Gets or Sets the current prepass renderer associated to the scene.
  153265. */
  153266. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153267. /**
  153268. * Enables the subsurface effect for prepass
  153269. * @returns the SubSurfaceConfiguration
  153270. */
  153271. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  153272. /**
  153273. * Disables the subsurface effect for prepass
  153274. */
  153275. disableSubSurfaceForPrePass(): void;
  153276. }
  153277. /**
  153278. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153279. * in several rendering techniques.
  153280. */
  153281. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  153282. /**
  153283. * The component name helpful to identify the component in the list of scene components.
  153284. */
  153285. readonly name: string;
  153286. /**
  153287. * The scene the component belongs to.
  153288. */
  153289. scene: Scene;
  153290. /**
  153291. * Creates a new instance of the component for the given scene
  153292. * @param scene Defines the scene to register the component in
  153293. */
  153294. constructor(scene: Scene);
  153295. /**
  153296. * Registers the component in a given scene
  153297. */
  153298. register(): void;
  153299. /**
  153300. * Serializes the component data to the specified json object
  153301. * @param serializationObject The object to serialize to
  153302. */
  153303. serialize(serializationObject: any): void;
  153304. /**
  153305. * Adds all the elements from the container to the scene
  153306. * @param container the container holding the elements
  153307. */
  153308. addFromContainer(container: AbstractScene): void;
  153309. /**
  153310. * Removes all the elements in the container from the scene
  153311. * @param container contains the elements to remove
  153312. * @param dispose if the removed element should be disposed (default: false)
  153313. */
  153314. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  153315. /**
  153316. * Rebuilds the elements related to this component in case of
  153317. * context lost for instance.
  153318. */
  153319. rebuild(): void;
  153320. /**
  153321. * Disposes the component and the associated ressources
  153322. */
  153323. dispose(): void;
  153324. }
  153325. }
  153326. declare module BABYLON {
  153327. /** @hidden */
  153328. export var outlinePixelShader: {
  153329. name: string;
  153330. shader: string;
  153331. };
  153332. }
  153333. declare module BABYLON {
  153334. /** @hidden */
  153335. export var outlineVertexShader: {
  153336. name: string;
  153337. shader: string;
  153338. };
  153339. }
  153340. declare module BABYLON {
  153341. interface Scene {
  153342. /** @hidden */
  153343. _outlineRenderer: OutlineRenderer;
  153344. /**
  153345. * Gets the outline renderer associated with the scene
  153346. * @returns a OutlineRenderer
  153347. */
  153348. getOutlineRenderer(): OutlineRenderer;
  153349. }
  153350. interface AbstractMesh {
  153351. /** @hidden (Backing field) */
  153352. _renderOutline: boolean;
  153353. /**
  153354. * Gets or sets a boolean indicating if the outline must be rendered as well
  153355. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  153356. */
  153357. renderOutline: boolean;
  153358. /** @hidden (Backing field) */
  153359. _renderOverlay: boolean;
  153360. /**
  153361. * Gets or sets a boolean indicating if the overlay must be rendered as well
  153362. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  153363. */
  153364. renderOverlay: boolean;
  153365. }
  153366. /**
  153367. * This class is responsible to draw bothe outline/overlay of meshes.
  153368. * It should not be used directly but through the available method on mesh.
  153369. */
  153370. export class OutlineRenderer implements ISceneComponent {
  153371. /**
  153372. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  153373. */
  153374. private static _StencilReference;
  153375. /**
  153376. * The name of the component. Each component must have a unique name.
  153377. */
  153378. name: string;
  153379. /**
  153380. * The scene the component belongs to.
  153381. */
  153382. scene: Scene;
  153383. /**
  153384. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  153385. */
  153386. zOffset: number;
  153387. private _engine;
  153388. private _effect;
  153389. private _cachedDefines;
  153390. private _savedDepthWrite;
  153391. /**
  153392. * Instantiates a new outline renderer. (There could be only one per scene).
  153393. * @param scene Defines the scene it belongs to
  153394. */
  153395. constructor(scene: Scene);
  153396. /**
  153397. * Register the component to one instance of a scene.
  153398. */
  153399. register(): void;
  153400. /**
  153401. * Rebuilds the elements related to this component in case of
  153402. * context lost for instance.
  153403. */
  153404. rebuild(): void;
  153405. /**
  153406. * Disposes the component and the associated ressources.
  153407. */
  153408. dispose(): void;
  153409. /**
  153410. * Renders the outline in the canvas.
  153411. * @param subMesh Defines the sumesh to render
  153412. * @param batch Defines the batch of meshes in case of instances
  153413. * @param useOverlay Defines if the rendering is for the overlay or the outline
  153414. */
  153415. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  153416. /**
  153417. * Returns whether or not the outline renderer is ready for a given submesh.
  153418. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  153419. * @param subMesh Defines the submesh to check readyness for
  153420. * @param useInstances Defines wheter wee are trying to render instances or not
  153421. * @returns true if ready otherwise false
  153422. */
  153423. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  153424. private _beforeRenderingMesh;
  153425. private _afterRenderingMesh;
  153426. }
  153427. }
  153428. declare module BABYLON {
  153429. /**
  153430. * Defines the basic options interface of a Sprite Frame Source Size.
  153431. */
  153432. export interface ISpriteJSONSpriteSourceSize {
  153433. /**
  153434. * number of the original width of the Frame
  153435. */
  153436. w: number;
  153437. /**
  153438. * number of the original height of the Frame
  153439. */
  153440. h: number;
  153441. }
  153442. /**
  153443. * Defines the basic options interface of a Sprite Frame Data.
  153444. */
  153445. export interface ISpriteJSONSpriteFrameData {
  153446. /**
  153447. * number of the x offset of the Frame
  153448. */
  153449. x: number;
  153450. /**
  153451. * number of the y offset of the Frame
  153452. */
  153453. y: number;
  153454. /**
  153455. * number of the width of the Frame
  153456. */
  153457. w: number;
  153458. /**
  153459. * number of the height of the Frame
  153460. */
  153461. h: number;
  153462. }
  153463. /**
  153464. * Defines the basic options interface of a JSON Sprite.
  153465. */
  153466. export interface ISpriteJSONSprite {
  153467. /**
  153468. * string name of the Frame
  153469. */
  153470. filename: string;
  153471. /**
  153472. * ISpriteJSONSpriteFrame basic object of the frame data
  153473. */
  153474. frame: ISpriteJSONSpriteFrameData;
  153475. /**
  153476. * boolean to flag is the frame was rotated.
  153477. */
  153478. rotated: boolean;
  153479. /**
  153480. * boolean to flag is the frame was trimmed.
  153481. */
  153482. trimmed: boolean;
  153483. /**
  153484. * ISpriteJSONSpriteFrame basic object of the source data
  153485. */
  153486. spriteSourceSize: ISpriteJSONSpriteFrameData;
  153487. /**
  153488. * ISpriteJSONSpriteFrame basic object of the source data
  153489. */
  153490. sourceSize: ISpriteJSONSpriteSourceSize;
  153491. }
  153492. /**
  153493. * Defines the basic options interface of a JSON atlas.
  153494. */
  153495. export interface ISpriteJSONAtlas {
  153496. /**
  153497. * Array of objects that contain the frame data.
  153498. */
  153499. frames: Array<ISpriteJSONSprite>;
  153500. /**
  153501. * object basic object containing the sprite meta data.
  153502. */
  153503. meta?: object;
  153504. }
  153505. }
  153506. declare module BABYLON {
  153507. /** @hidden */
  153508. export var spriteMapPixelShader: {
  153509. name: string;
  153510. shader: string;
  153511. };
  153512. }
  153513. declare module BABYLON {
  153514. /** @hidden */
  153515. export var spriteMapVertexShader: {
  153516. name: string;
  153517. shader: string;
  153518. };
  153519. }
  153520. declare module BABYLON {
  153521. /**
  153522. * Defines the basic options interface of a SpriteMap
  153523. */
  153524. export interface ISpriteMapOptions {
  153525. /**
  153526. * Vector2 of the number of cells in the grid.
  153527. */
  153528. stageSize?: Vector2;
  153529. /**
  153530. * Vector2 of the size of the output plane in World Units.
  153531. */
  153532. outputSize?: Vector2;
  153533. /**
  153534. * Vector3 of the position of the output plane in World Units.
  153535. */
  153536. outputPosition?: Vector3;
  153537. /**
  153538. * Vector3 of the rotation of the output plane.
  153539. */
  153540. outputRotation?: Vector3;
  153541. /**
  153542. * number of layers that the system will reserve in resources.
  153543. */
  153544. layerCount?: number;
  153545. /**
  153546. * number of max animation frames a single cell will reserve in resources.
  153547. */
  153548. maxAnimationFrames?: number;
  153549. /**
  153550. * number cell index of the base tile when the system compiles.
  153551. */
  153552. baseTile?: number;
  153553. /**
  153554. * boolean flip the sprite after its been repositioned by the framing data.
  153555. */
  153556. flipU?: boolean;
  153557. /**
  153558. * Vector3 scalar of the global RGB values of the SpriteMap.
  153559. */
  153560. colorMultiply?: Vector3;
  153561. }
  153562. /**
  153563. * Defines the IDisposable interface in order to be cleanable from resources.
  153564. */
  153565. export interface ISpriteMap extends IDisposable {
  153566. /**
  153567. * String name of the SpriteMap.
  153568. */
  153569. name: string;
  153570. /**
  153571. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  153572. */
  153573. atlasJSON: ISpriteJSONAtlas;
  153574. /**
  153575. * Texture of the SpriteMap.
  153576. */
  153577. spriteSheet: Texture;
  153578. /**
  153579. * The parameters to initialize the SpriteMap with.
  153580. */
  153581. options: ISpriteMapOptions;
  153582. }
  153583. /**
  153584. * Class used to manage a grid restricted sprite deployment on an Output plane.
  153585. */
  153586. export class SpriteMap implements ISpriteMap {
  153587. /** The Name of the spriteMap */
  153588. name: string;
  153589. /** The JSON file with the frame and meta data */
  153590. atlasJSON: ISpriteJSONAtlas;
  153591. /** The systems Sprite Sheet Texture */
  153592. spriteSheet: Texture;
  153593. /** Arguments passed with the Constructor */
  153594. options: ISpriteMapOptions;
  153595. /** Public Sprite Storage array, parsed from atlasJSON */
  153596. sprites: Array<ISpriteJSONSprite>;
  153597. /** Returns the Number of Sprites in the System */
  153598. get spriteCount(): number;
  153599. /** Returns the Position of Output Plane*/
  153600. get position(): Vector3;
  153601. /** Returns the Position of Output Plane*/
  153602. set position(v: Vector3);
  153603. /** Returns the Rotation of Output Plane*/
  153604. get rotation(): Vector3;
  153605. /** Returns the Rotation of Output Plane*/
  153606. set rotation(v: Vector3);
  153607. /** Sets the AnimationMap*/
  153608. get animationMap(): RawTexture;
  153609. /** Sets the AnimationMap*/
  153610. set animationMap(v: RawTexture);
  153611. /** Scene that the SpriteMap was created in */
  153612. private _scene;
  153613. /** Texture Buffer of Float32 that holds tile frame data*/
  153614. private _frameMap;
  153615. /** Texture Buffers of Float32 that holds tileMap data*/
  153616. private _tileMaps;
  153617. /** Texture Buffer of Float32 that holds Animation Data*/
  153618. private _animationMap;
  153619. /** Custom ShaderMaterial Central to the System*/
  153620. private _material;
  153621. /** Custom ShaderMaterial Central to the System*/
  153622. private _output;
  153623. /** Systems Time Ticker*/
  153624. private _time;
  153625. /**
  153626. * Creates a new SpriteMap
  153627. * @param name defines the SpriteMaps Name
  153628. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  153629. * @param spriteSheet is the Texture that the Sprites are on.
  153630. * @param options a basic deployment configuration
  153631. * @param scene The Scene that the map is deployed on
  153632. */
  153633. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  153634. /**
  153635. * Returns tileID location
  153636. * @returns Vector2 the cell position ID
  153637. */
  153638. getTileID(): Vector2;
  153639. /**
  153640. * Gets the UV location of the mouse over the SpriteMap.
  153641. * @returns Vector2 the UV position of the mouse interaction
  153642. */
  153643. getMousePosition(): Vector2;
  153644. /**
  153645. * Creates the "frame" texture Buffer
  153646. * -------------------------------------
  153647. * Structure of frames
  153648. * "filename": "Falling-Water-2.png",
  153649. * "frame": {"x":69,"y":103,"w":24,"h":32},
  153650. * "rotated": true,
  153651. * "trimmed": true,
  153652. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  153653. * "sourceSize": {"w":32,"h":32}
  153654. * @returns RawTexture of the frameMap
  153655. */
  153656. private _createFrameBuffer;
  153657. /**
  153658. * Creates the tileMap texture Buffer
  153659. * @param buffer normally and array of numbers, or a false to generate from scratch
  153660. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  153661. * @returns RawTexture of the tileMap
  153662. */
  153663. private _createTileBuffer;
  153664. /**
  153665. * Modifies the data of the tileMaps
  153666. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  153667. * @param pos is the iVector2 Coordinates of the Tile
  153668. * @param tile The SpriteIndex of the new Tile
  153669. */
  153670. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  153671. /**
  153672. * Creates the animationMap texture Buffer
  153673. * @param buffer normally and array of numbers, or a false to generate from scratch
  153674. * @returns RawTexture of the animationMap
  153675. */
  153676. private _createTileAnimationBuffer;
  153677. /**
  153678. * Modifies the data of the animationMap
  153679. * @param cellID is the Index of the Sprite
  153680. * @param _frame is the target Animation frame
  153681. * @param toCell is the Target Index of the next frame of the animation
  153682. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  153683. * @param speed is a global scalar of the time variable on the map.
  153684. */
  153685. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  153686. /**
  153687. * Exports the .tilemaps file
  153688. */
  153689. saveTileMaps(): void;
  153690. /**
  153691. * Imports the .tilemaps file
  153692. * @param url of the .tilemaps file
  153693. */
  153694. loadTileMaps(url: string): void;
  153695. /**
  153696. * Release associated resources
  153697. */
  153698. dispose(): void;
  153699. }
  153700. }
  153701. declare module BABYLON {
  153702. /**
  153703. * Class used to manage multiple sprites of different sizes on the same spritesheet
  153704. * @see https://doc.babylonjs.com/babylon101/sprites
  153705. */
  153706. export class SpritePackedManager extends SpriteManager {
  153707. /** defines the packed manager's name */
  153708. name: string;
  153709. /**
  153710. * Creates a new sprite manager from a packed sprite sheet
  153711. * @param name defines the manager's name
  153712. * @param imgUrl defines the sprite sheet url
  153713. * @param capacity defines the maximum allowed number of sprites
  153714. * @param scene defines the hosting scene
  153715. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  153716. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  153717. * @param samplingMode defines the smapling mode to use with spritesheet
  153718. * @param fromPacked set to true; do not alter
  153719. */
  153720. constructor(
  153721. /** defines the packed manager's name */
  153722. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  153723. }
  153724. }
  153725. declare module BABYLON {
  153726. /**
  153727. * Defines the list of states available for a task inside a AssetsManager
  153728. */
  153729. export enum AssetTaskState {
  153730. /**
  153731. * Initialization
  153732. */
  153733. INIT = 0,
  153734. /**
  153735. * Running
  153736. */
  153737. RUNNING = 1,
  153738. /**
  153739. * Done
  153740. */
  153741. DONE = 2,
  153742. /**
  153743. * Error
  153744. */
  153745. ERROR = 3
  153746. }
  153747. /**
  153748. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  153749. */
  153750. export abstract class AbstractAssetTask {
  153751. /**
  153752. * Task name
  153753. */ name: string;
  153754. /**
  153755. * Callback called when the task is successful
  153756. */
  153757. onSuccess: (task: any) => void;
  153758. /**
  153759. * Callback called when the task is not successful
  153760. */
  153761. onError: (task: any, message?: string, exception?: any) => void;
  153762. /**
  153763. * Creates a new AssetsManager
  153764. * @param name defines the name of the task
  153765. */
  153766. constructor(
  153767. /**
  153768. * Task name
  153769. */ name: string);
  153770. private _isCompleted;
  153771. private _taskState;
  153772. private _errorObject;
  153773. /**
  153774. * Get if the task is completed
  153775. */
  153776. get isCompleted(): boolean;
  153777. /**
  153778. * Gets the current state of the task
  153779. */
  153780. get taskState(): AssetTaskState;
  153781. /**
  153782. * Gets the current error object (if task is in error)
  153783. */
  153784. get errorObject(): {
  153785. message?: string;
  153786. exception?: any;
  153787. };
  153788. /**
  153789. * Internal only
  153790. * @hidden
  153791. */
  153792. _setErrorObject(message?: string, exception?: any): void;
  153793. /**
  153794. * Execute the current task
  153795. * @param scene defines the scene where you want your assets to be loaded
  153796. * @param onSuccess is a callback called when the task is successfully executed
  153797. * @param onError is a callback called if an error occurs
  153798. */
  153799. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153800. /**
  153801. * Execute the current task
  153802. * @param scene defines the scene where you want your assets to be loaded
  153803. * @param onSuccess is a callback called when the task is successfully executed
  153804. * @param onError is a callback called if an error occurs
  153805. */
  153806. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153807. /**
  153808. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  153809. * This can be used with failed tasks that have the reason for failure fixed.
  153810. */
  153811. reset(): void;
  153812. private onErrorCallback;
  153813. private onDoneCallback;
  153814. }
  153815. /**
  153816. * Define the interface used by progress events raised during assets loading
  153817. */
  153818. export interface IAssetsProgressEvent {
  153819. /**
  153820. * Defines the number of remaining tasks to process
  153821. */
  153822. remainingCount: number;
  153823. /**
  153824. * Defines the total number of tasks
  153825. */
  153826. totalCount: number;
  153827. /**
  153828. * Defines the task that was just processed
  153829. */
  153830. task: AbstractAssetTask;
  153831. }
  153832. /**
  153833. * Class used to share progress information about assets loading
  153834. */
  153835. export class AssetsProgressEvent implements IAssetsProgressEvent {
  153836. /**
  153837. * Defines the number of remaining tasks to process
  153838. */
  153839. remainingCount: number;
  153840. /**
  153841. * Defines the total number of tasks
  153842. */
  153843. totalCount: number;
  153844. /**
  153845. * Defines the task that was just processed
  153846. */
  153847. task: AbstractAssetTask;
  153848. /**
  153849. * Creates a AssetsProgressEvent
  153850. * @param remainingCount defines the number of remaining tasks to process
  153851. * @param totalCount defines the total number of tasks
  153852. * @param task defines the task that was just processed
  153853. */
  153854. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  153855. }
  153856. /**
  153857. * Define a task used by AssetsManager to load assets into a container
  153858. */
  153859. export class ContainerAssetTask extends AbstractAssetTask {
  153860. /**
  153861. * Defines the name of the task
  153862. */
  153863. name: string;
  153864. /**
  153865. * Defines the list of mesh's names you want to load
  153866. */
  153867. meshesNames: any;
  153868. /**
  153869. * Defines the root url to use as a base to load your meshes and associated resources
  153870. */
  153871. rootUrl: string;
  153872. /**
  153873. * Defines the filename or File of the scene to load from
  153874. */
  153875. sceneFilename: string | File;
  153876. /**
  153877. * Get the loaded asset container
  153878. */
  153879. loadedContainer: AssetContainer;
  153880. /**
  153881. * Gets the list of loaded meshes
  153882. */
  153883. loadedMeshes: Array<AbstractMesh>;
  153884. /**
  153885. * Gets the list of loaded particle systems
  153886. */
  153887. loadedParticleSystems: Array<IParticleSystem>;
  153888. /**
  153889. * Gets the list of loaded skeletons
  153890. */
  153891. loadedSkeletons: Array<Skeleton>;
  153892. /**
  153893. * Gets the list of loaded animation groups
  153894. */
  153895. loadedAnimationGroups: Array<AnimationGroup>;
  153896. /**
  153897. * Callback called when the task is successful
  153898. */
  153899. onSuccess: (task: ContainerAssetTask) => void;
  153900. /**
  153901. * Callback called when the task is successful
  153902. */
  153903. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  153904. /**
  153905. * Creates a new ContainerAssetTask
  153906. * @param name defines the name of the task
  153907. * @param meshesNames defines the list of mesh's names you want to load
  153908. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153909. * @param sceneFilename defines the filename or File of the scene to load from
  153910. */
  153911. constructor(
  153912. /**
  153913. * Defines the name of the task
  153914. */
  153915. name: string,
  153916. /**
  153917. * Defines the list of mesh's names you want to load
  153918. */
  153919. meshesNames: any,
  153920. /**
  153921. * Defines the root url to use as a base to load your meshes and associated resources
  153922. */
  153923. rootUrl: string,
  153924. /**
  153925. * Defines the filename or File of the scene to load from
  153926. */
  153927. sceneFilename: string | File);
  153928. /**
  153929. * Execute the current task
  153930. * @param scene defines the scene where you want your assets to be loaded
  153931. * @param onSuccess is a callback called when the task is successfully executed
  153932. * @param onError is a callback called if an error occurs
  153933. */
  153934. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153935. }
  153936. /**
  153937. * Define a task used by AssetsManager to load meshes
  153938. */
  153939. export class MeshAssetTask extends AbstractAssetTask {
  153940. /**
  153941. * Defines the name of the task
  153942. */
  153943. name: string;
  153944. /**
  153945. * Defines the list of mesh's names you want to load
  153946. */
  153947. meshesNames: any;
  153948. /**
  153949. * Defines the root url to use as a base to load your meshes and associated resources
  153950. */
  153951. rootUrl: string;
  153952. /**
  153953. * Defines the filename or File of the scene to load from
  153954. */
  153955. sceneFilename: string | File;
  153956. /**
  153957. * Gets the list of loaded meshes
  153958. */
  153959. loadedMeshes: Array<AbstractMesh>;
  153960. /**
  153961. * Gets the list of loaded particle systems
  153962. */
  153963. loadedParticleSystems: Array<IParticleSystem>;
  153964. /**
  153965. * Gets the list of loaded skeletons
  153966. */
  153967. loadedSkeletons: Array<Skeleton>;
  153968. /**
  153969. * Gets the list of loaded animation groups
  153970. */
  153971. loadedAnimationGroups: Array<AnimationGroup>;
  153972. /**
  153973. * Callback called when the task is successful
  153974. */
  153975. onSuccess: (task: MeshAssetTask) => void;
  153976. /**
  153977. * Callback called when the task is successful
  153978. */
  153979. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  153980. /**
  153981. * Creates a new MeshAssetTask
  153982. * @param name defines the name of the task
  153983. * @param meshesNames defines the list of mesh's names you want to load
  153984. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153985. * @param sceneFilename defines the filename or File of the scene to load from
  153986. */
  153987. constructor(
  153988. /**
  153989. * Defines the name of the task
  153990. */
  153991. name: string,
  153992. /**
  153993. * Defines the list of mesh's names you want to load
  153994. */
  153995. meshesNames: any,
  153996. /**
  153997. * Defines the root url to use as a base to load your meshes and associated resources
  153998. */
  153999. rootUrl: string,
  154000. /**
  154001. * Defines the filename or File of the scene to load from
  154002. */
  154003. sceneFilename: string | File);
  154004. /**
  154005. * Execute the current task
  154006. * @param scene defines the scene where you want your assets to be loaded
  154007. * @param onSuccess is a callback called when the task is successfully executed
  154008. * @param onError is a callback called if an error occurs
  154009. */
  154010. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154011. }
  154012. /**
  154013. * Define a task used by AssetsManager to load text content
  154014. */
  154015. export class TextFileAssetTask extends AbstractAssetTask {
  154016. /**
  154017. * Defines the name of the task
  154018. */
  154019. name: string;
  154020. /**
  154021. * Defines the location of the file to load
  154022. */
  154023. url: string;
  154024. /**
  154025. * Gets the loaded text string
  154026. */
  154027. text: string;
  154028. /**
  154029. * Callback called when the task is successful
  154030. */
  154031. onSuccess: (task: TextFileAssetTask) => void;
  154032. /**
  154033. * Callback called when the task is successful
  154034. */
  154035. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  154036. /**
  154037. * Creates a new TextFileAssetTask object
  154038. * @param name defines the name of the task
  154039. * @param url defines the location of the file to load
  154040. */
  154041. constructor(
  154042. /**
  154043. * Defines the name of the task
  154044. */
  154045. name: string,
  154046. /**
  154047. * Defines the location of the file to load
  154048. */
  154049. url: string);
  154050. /**
  154051. * Execute the current task
  154052. * @param scene defines the scene where you want your assets to be loaded
  154053. * @param onSuccess is a callback called when the task is successfully executed
  154054. * @param onError is a callback called if an error occurs
  154055. */
  154056. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154057. }
  154058. /**
  154059. * Define a task used by AssetsManager to load binary data
  154060. */
  154061. export class BinaryFileAssetTask extends AbstractAssetTask {
  154062. /**
  154063. * Defines the name of the task
  154064. */
  154065. name: string;
  154066. /**
  154067. * Defines the location of the file to load
  154068. */
  154069. url: string;
  154070. /**
  154071. * Gets the lodaded data (as an array buffer)
  154072. */
  154073. data: ArrayBuffer;
  154074. /**
  154075. * Callback called when the task is successful
  154076. */
  154077. onSuccess: (task: BinaryFileAssetTask) => void;
  154078. /**
  154079. * Callback called when the task is successful
  154080. */
  154081. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  154082. /**
  154083. * Creates a new BinaryFileAssetTask object
  154084. * @param name defines the name of the new task
  154085. * @param url defines the location of the file to load
  154086. */
  154087. constructor(
  154088. /**
  154089. * Defines the name of the task
  154090. */
  154091. name: string,
  154092. /**
  154093. * Defines the location of the file to load
  154094. */
  154095. url: string);
  154096. /**
  154097. * Execute the current task
  154098. * @param scene defines the scene where you want your assets to be loaded
  154099. * @param onSuccess is a callback called when the task is successfully executed
  154100. * @param onError is a callback called if an error occurs
  154101. */
  154102. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154103. }
  154104. /**
  154105. * Define a task used by AssetsManager to load images
  154106. */
  154107. export class ImageAssetTask extends AbstractAssetTask {
  154108. /**
  154109. * Defines the name of the task
  154110. */
  154111. name: string;
  154112. /**
  154113. * Defines the location of the image to load
  154114. */
  154115. url: string;
  154116. /**
  154117. * Gets the loaded images
  154118. */
  154119. image: HTMLImageElement;
  154120. /**
  154121. * Callback called when the task is successful
  154122. */
  154123. onSuccess: (task: ImageAssetTask) => void;
  154124. /**
  154125. * Callback called when the task is successful
  154126. */
  154127. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  154128. /**
  154129. * Creates a new ImageAssetTask
  154130. * @param name defines the name of the task
  154131. * @param url defines the location of the image to load
  154132. */
  154133. constructor(
  154134. /**
  154135. * Defines the name of the task
  154136. */
  154137. name: string,
  154138. /**
  154139. * Defines the location of the image to load
  154140. */
  154141. url: string);
  154142. /**
  154143. * Execute the current task
  154144. * @param scene defines the scene where you want your assets to be loaded
  154145. * @param onSuccess is a callback called when the task is successfully executed
  154146. * @param onError is a callback called if an error occurs
  154147. */
  154148. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154149. }
  154150. /**
  154151. * Defines the interface used by texture loading tasks
  154152. */
  154153. export interface ITextureAssetTask<TEX extends BaseTexture> {
  154154. /**
  154155. * Gets the loaded texture
  154156. */
  154157. texture: TEX;
  154158. }
  154159. /**
  154160. * Define a task used by AssetsManager to load 2D textures
  154161. */
  154162. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  154163. /**
  154164. * Defines the name of the task
  154165. */
  154166. name: string;
  154167. /**
  154168. * Defines the location of the file to load
  154169. */
  154170. url: string;
  154171. /**
  154172. * Defines if mipmap should not be generated (default is false)
  154173. */
  154174. noMipmap?: boolean | undefined;
  154175. /**
  154176. * Defines if texture must be inverted on Y axis (default is true)
  154177. */
  154178. invertY: boolean;
  154179. /**
  154180. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154181. */
  154182. samplingMode: number;
  154183. /**
  154184. * Gets the loaded texture
  154185. */
  154186. texture: Texture;
  154187. /**
  154188. * Callback called when the task is successful
  154189. */
  154190. onSuccess: (task: TextureAssetTask) => void;
  154191. /**
  154192. * Callback called when the task is successful
  154193. */
  154194. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  154195. /**
  154196. * Creates a new TextureAssetTask object
  154197. * @param name defines the name of the task
  154198. * @param url defines the location of the file to load
  154199. * @param noMipmap defines if mipmap should not be generated (default is false)
  154200. * @param invertY defines if texture must be inverted on Y axis (default is true)
  154201. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154202. */
  154203. constructor(
  154204. /**
  154205. * Defines the name of the task
  154206. */
  154207. name: string,
  154208. /**
  154209. * Defines the location of the file to load
  154210. */
  154211. url: string,
  154212. /**
  154213. * Defines if mipmap should not be generated (default is false)
  154214. */
  154215. noMipmap?: boolean | undefined,
  154216. /**
  154217. * Defines if texture must be inverted on Y axis (default is true)
  154218. */
  154219. invertY?: boolean,
  154220. /**
  154221. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154222. */
  154223. samplingMode?: number);
  154224. /**
  154225. * Execute the current task
  154226. * @param scene defines the scene where you want your assets to be loaded
  154227. * @param onSuccess is a callback called when the task is successfully executed
  154228. * @param onError is a callback called if an error occurs
  154229. */
  154230. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154231. }
  154232. /**
  154233. * Define a task used by AssetsManager to load cube textures
  154234. */
  154235. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  154236. /**
  154237. * Defines the name of the task
  154238. */
  154239. name: string;
  154240. /**
  154241. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154242. */
  154243. url: string;
  154244. /**
  154245. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154246. */
  154247. extensions?: string[] | undefined;
  154248. /**
  154249. * Defines if mipmaps should not be generated (default is false)
  154250. */
  154251. noMipmap?: boolean | undefined;
  154252. /**
  154253. * Defines the explicit list of files (undefined by default)
  154254. */
  154255. files?: string[] | undefined;
  154256. /**
  154257. * Gets the loaded texture
  154258. */
  154259. texture: CubeTexture;
  154260. /**
  154261. * Callback called when the task is successful
  154262. */
  154263. onSuccess: (task: CubeTextureAssetTask) => void;
  154264. /**
  154265. * Callback called when the task is successful
  154266. */
  154267. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  154268. /**
  154269. * Creates a new CubeTextureAssetTask
  154270. * @param name defines the name of the task
  154271. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154272. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154273. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154274. * @param files defines the explicit list of files (undefined by default)
  154275. */
  154276. constructor(
  154277. /**
  154278. * Defines the name of the task
  154279. */
  154280. name: string,
  154281. /**
  154282. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154283. */
  154284. url: string,
  154285. /**
  154286. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154287. */
  154288. extensions?: string[] | undefined,
  154289. /**
  154290. * Defines if mipmaps should not be generated (default is false)
  154291. */
  154292. noMipmap?: boolean | undefined,
  154293. /**
  154294. * Defines the explicit list of files (undefined by default)
  154295. */
  154296. files?: string[] | undefined);
  154297. /**
  154298. * Execute the current task
  154299. * @param scene defines the scene where you want your assets to be loaded
  154300. * @param onSuccess is a callback called when the task is successfully executed
  154301. * @param onError is a callback called if an error occurs
  154302. */
  154303. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154304. }
  154305. /**
  154306. * Define a task used by AssetsManager to load HDR cube textures
  154307. */
  154308. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  154309. /**
  154310. * Defines the name of the task
  154311. */
  154312. name: string;
  154313. /**
  154314. * Defines the location of the file to load
  154315. */
  154316. url: string;
  154317. /**
  154318. * Defines the desired size (the more it increases the longer the generation will be)
  154319. */
  154320. size: number;
  154321. /**
  154322. * Defines if mipmaps should not be generated (default is false)
  154323. */
  154324. noMipmap: boolean;
  154325. /**
  154326. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154327. */
  154328. generateHarmonics: boolean;
  154329. /**
  154330. * 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)
  154331. */
  154332. gammaSpace: boolean;
  154333. /**
  154334. * Internal Use Only
  154335. */
  154336. reserved: boolean;
  154337. /**
  154338. * Gets the loaded texture
  154339. */
  154340. texture: HDRCubeTexture;
  154341. /**
  154342. * Callback called when the task is successful
  154343. */
  154344. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  154345. /**
  154346. * Callback called when the task is successful
  154347. */
  154348. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  154349. /**
  154350. * Creates a new HDRCubeTextureAssetTask object
  154351. * @param name defines the name of the task
  154352. * @param url defines the location of the file to load
  154353. * @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.
  154354. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154355. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154356. * @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)
  154357. * @param reserved Internal use only
  154358. */
  154359. constructor(
  154360. /**
  154361. * Defines the name of the task
  154362. */
  154363. name: string,
  154364. /**
  154365. * Defines the location of the file to load
  154366. */
  154367. url: string,
  154368. /**
  154369. * Defines the desired size (the more it increases the longer the generation will be)
  154370. */
  154371. size: number,
  154372. /**
  154373. * Defines if mipmaps should not be generated (default is false)
  154374. */
  154375. noMipmap?: boolean,
  154376. /**
  154377. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154378. */
  154379. generateHarmonics?: boolean,
  154380. /**
  154381. * 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)
  154382. */
  154383. gammaSpace?: boolean,
  154384. /**
  154385. * Internal Use Only
  154386. */
  154387. reserved?: boolean);
  154388. /**
  154389. * Execute the current task
  154390. * @param scene defines the scene where you want your assets to be loaded
  154391. * @param onSuccess is a callback called when the task is successfully executed
  154392. * @param onError is a callback called if an error occurs
  154393. */
  154394. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154395. }
  154396. /**
  154397. * Define a task used by AssetsManager to load Equirectangular cube textures
  154398. */
  154399. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  154400. /**
  154401. * Defines the name of the task
  154402. */
  154403. name: string;
  154404. /**
  154405. * Defines the location of the file to load
  154406. */
  154407. url: string;
  154408. /**
  154409. * Defines the desired size (the more it increases the longer the generation will be)
  154410. */
  154411. size: number;
  154412. /**
  154413. * Defines if mipmaps should not be generated (default is false)
  154414. */
  154415. noMipmap: boolean;
  154416. /**
  154417. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154418. * but the standard material would require them in Gamma space) (default is true)
  154419. */
  154420. gammaSpace: boolean;
  154421. /**
  154422. * Gets the loaded texture
  154423. */
  154424. texture: EquiRectangularCubeTexture;
  154425. /**
  154426. * Callback called when the task is successful
  154427. */
  154428. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  154429. /**
  154430. * Callback called when the task is successful
  154431. */
  154432. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  154433. /**
  154434. * Creates a new EquiRectangularCubeTextureAssetTask object
  154435. * @param name defines the name of the task
  154436. * @param url defines the location of the file to load
  154437. * @param size defines the desired size (the more it increases the longer the generation will be)
  154438. * If the size is omitted this implies you are using a preprocessed cubemap.
  154439. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154440. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  154441. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  154442. * (default is true)
  154443. */
  154444. constructor(
  154445. /**
  154446. * Defines the name of the task
  154447. */
  154448. name: string,
  154449. /**
  154450. * Defines the location of the file to load
  154451. */
  154452. url: string,
  154453. /**
  154454. * Defines the desired size (the more it increases the longer the generation will be)
  154455. */
  154456. size: number,
  154457. /**
  154458. * Defines if mipmaps should not be generated (default is false)
  154459. */
  154460. noMipmap?: boolean,
  154461. /**
  154462. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154463. * but the standard material would require them in Gamma space) (default is true)
  154464. */
  154465. gammaSpace?: boolean);
  154466. /**
  154467. * Execute the current task
  154468. * @param scene defines the scene where you want your assets to be loaded
  154469. * @param onSuccess is a callback called when the task is successfully executed
  154470. * @param onError is a callback called if an error occurs
  154471. */
  154472. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154473. }
  154474. /**
  154475. * This class can be used to easily import assets into a scene
  154476. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  154477. */
  154478. export class AssetsManager {
  154479. private _scene;
  154480. private _isLoading;
  154481. protected _tasks: AbstractAssetTask[];
  154482. protected _waitingTasksCount: number;
  154483. protected _totalTasksCount: number;
  154484. /**
  154485. * Callback called when all tasks are processed
  154486. */
  154487. onFinish: (tasks: AbstractAssetTask[]) => void;
  154488. /**
  154489. * Callback called when a task is successful
  154490. */
  154491. onTaskSuccess: (task: AbstractAssetTask) => void;
  154492. /**
  154493. * Callback called when a task had an error
  154494. */
  154495. onTaskError: (task: AbstractAssetTask) => void;
  154496. /**
  154497. * Callback called when a task is done (whatever the result is)
  154498. */
  154499. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  154500. /**
  154501. * Observable called when all tasks are processed
  154502. */
  154503. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  154504. /**
  154505. * Observable called when a task had an error
  154506. */
  154507. onTaskErrorObservable: Observable<AbstractAssetTask>;
  154508. /**
  154509. * Observable called when all tasks were executed
  154510. */
  154511. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  154512. /**
  154513. * Observable called when a task is done (whatever the result is)
  154514. */
  154515. onProgressObservable: Observable<IAssetsProgressEvent>;
  154516. /**
  154517. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  154518. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  154519. */
  154520. useDefaultLoadingScreen: boolean;
  154521. /**
  154522. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  154523. * when all assets have been downloaded.
  154524. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  154525. */
  154526. autoHideLoadingUI: boolean;
  154527. /**
  154528. * Creates a new AssetsManager
  154529. * @param scene defines the scene to work on
  154530. */
  154531. constructor(scene: Scene);
  154532. /**
  154533. * Add a ContainerAssetTask to the list of active tasks
  154534. * @param taskName defines the name of the new task
  154535. * @param meshesNames defines the name of meshes to load
  154536. * @param rootUrl defines the root url to use to locate files
  154537. * @param sceneFilename defines the filename of the scene file
  154538. * @returns a new ContainerAssetTask object
  154539. */
  154540. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  154541. /**
  154542. * Add a MeshAssetTask to the list of active tasks
  154543. * @param taskName defines the name of the new task
  154544. * @param meshesNames defines the name of meshes to load
  154545. * @param rootUrl defines the root url to use to locate files
  154546. * @param sceneFilename defines the filename of the scene file
  154547. * @returns a new MeshAssetTask object
  154548. */
  154549. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  154550. /**
  154551. * Add a TextFileAssetTask to the list of active tasks
  154552. * @param taskName defines the name of the new task
  154553. * @param url defines the url of the file to load
  154554. * @returns a new TextFileAssetTask object
  154555. */
  154556. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  154557. /**
  154558. * Add a BinaryFileAssetTask to the list of active tasks
  154559. * @param taskName defines the name of the new task
  154560. * @param url defines the url of the file to load
  154561. * @returns a new BinaryFileAssetTask object
  154562. */
  154563. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  154564. /**
  154565. * Add a ImageAssetTask to the list of active tasks
  154566. * @param taskName defines the name of the new task
  154567. * @param url defines the url of the file to load
  154568. * @returns a new ImageAssetTask object
  154569. */
  154570. addImageTask(taskName: string, url: string): ImageAssetTask;
  154571. /**
  154572. * Add a TextureAssetTask 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 noMipmap defines if the texture must not receive mipmaps (false by default)
  154576. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  154577. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  154578. * @returns a new TextureAssetTask object
  154579. */
  154580. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  154581. /**
  154582. * Add a CubeTextureAssetTask to the list of active tasks
  154583. * @param taskName defines the name of the new task
  154584. * @param url defines the url of the file to load
  154585. * @param extensions defines the extension to use to load the cube map (can be null)
  154586. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154587. * @param files defines the list of files to load (can be null)
  154588. * @returns a new CubeTextureAssetTask object
  154589. */
  154590. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  154591. /**
  154592. *
  154593. * Add a HDRCubeTextureAssetTask to the list of active tasks
  154594. * @param taskName defines the name of the new task
  154595. * @param url defines the url of the file to load
  154596. * @param size defines the size you want for the cubemap (can be null)
  154597. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154598. * @param generateHarmonics defines if you want to automatically generate (true by default)
  154599. * @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)
  154600. * @param reserved Internal use only
  154601. * @returns a new HDRCubeTextureAssetTask object
  154602. */
  154603. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  154604. /**
  154605. *
  154606. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  154607. * @param taskName defines the name of the new task
  154608. * @param url defines the url of the file to load
  154609. * @param size defines the size you want for the cubemap (can be null)
  154610. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154611. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  154612. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  154613. * @returns a new EquiRectangularCubeTextureAssetTask object
  154614. */
  154615. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  154616. /**
  154617. * Remove a task from the assets manager.
  154618. * @param task the task to remove
  154619. */
  154620. removeTask(task: AbstractAssetTask): void;
  154621. private _decreaseWaitingTasksCount;
  154622. private _runTask;
  154623. /**
  154624. * Reset the AssetsManager and remove all tasks
  154625. * @return the current instance of the AssetsManager
  154626. */
  154627. reset(): AssetsManager;
  154628. /**
  154629. * Start the loading process
  154630. * @return the current instance of the AssetsManager
  154631. */
  154632. load(): AssetsManager;
  154633. /**
  154634. * Start the loading process as an async operation
  154635. * @return a promise returning the list of failed tasks
  154636. */
  154637. loadAsync(): Promise<void>;
  154638. }
  154639. }
  154640. declare module BABYLON {
  154641. /**
  154642. * Wrapper class for promise with external resolve and reject.
  154643. */
  154644. export class Deferred<T> {
  154645. /**
  154646. * The promise associated with this deferred object.
  154647. */
  154648. readonly promise: Promise<T>;
  154649. private _resolve;
  154650. private _reject;
  154651. /**
  154652. * The resolve method of the promise associated with this deferred object.
  154653. */
  154654. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  154655. /**
  154656. * The reject method of the promise associated with this deferred object.
  154657. */
  154658. get reject(): (reason?: any) => void;
  154659. /**
  154660. * Constructor for this deferred object.
  154661. */
  154662. constructor();
  154663. }
  154664. }
  154665. declare module BABYLON {
  154666. /**
  154667. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  154668. */
  154669. export class MeshExploder {
  154670. private _centerMesh;
  154671. private _meshes;
  154672. private _meshesOrigins;
  154673. private _toCenterVectors;
  154674. private _scaledDirection;
  154675. private _newPosition;
  154676. private _centerPosition;
  154677. /**
  154678. * Explodes meshes from a center mesh.
  154679. * @param meshes The meshes to explode.
  154680. * @param centerMesh The mesh to be center of explosion.
  154681. */
  154682. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  154683. private _setCenterMesh;
  154684. /**
  154685. * Get class name
  154686. * @returns "MeshExploder"
  154687. */
  154688. getClassName(): string;
  154689. /**
  154690. * "Exploded meshes"
  154691. * @returns Array of meshes with the centerMesh at index 0.
  154692. */
  154693. getMeshes(): Array<Mesh>;
  154694. /**
  154695. * Explodes meshes giving a specific direction
  154696. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  154697. */
  154698. explode(direction?: number): void;
  154699. }
  154700. }
  154701. declare module BABYLON {
  154702. /**
  154703. * Class used to help managing file picking and drag'n'drop
  154704. */
  154705. export class FilesInput {
  154706. /**
  154707. * List of files ready to be loaded
  154708. */
  154709. static get FilesToLoad(): {
  154710. [key: string]: File;
  154711. };
  154712. /**
  154713. * Callback called when a file is processed
  154714. */
  154715. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  154716. private _engine;
  154717. private _currentScene;
  154718. private _sceneLoadedCallback;
  154719. private _progressCallback;
  154720. private _additionalRenderLoopLogicCallback;
  154721. private _textureLoadingCallback;
  154722. private _startingProcessingFilesCallback;
  154723. private _onReloadCallback;
  154724. private _errorCallback;
  154725. private _elementToMonitor;
  154726. private _sceneFileToLoad;
  154727. private _filesToLoad;
  154728. /**
  154729. * Creates a new FilesInput
  154730. * @param engine defines the rendering engine
  154731. * @param scene defines the hosting scene
  154732. * @param sceneLoadedCallback callback called when scene is loaded
  154733. * @param progressCallback callback called to track progress
  154734. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  154735. * @param textureLoadingCallback callback called when a texture is loading
  154736. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  154737. * @param onReloadCallback callback called when a reload is requested
  154738. * @param errorCallback callback call if an error occurs
  154739. */
  154740. 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>);
  154741. private _dragEnterHandler;
  154742. private _dragOverHandler;
  154743. private _dropHandler;
  154744. /**
  154745. * Calls this function to listen to drag'n'drop events on a specific DOM element
  154746. * @param elementToMonitor defines the DOM element to track
  154747. */
  154748. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  154749. /** Gets the current list of files to load */
  154750. get filesToLoad(): File[];
  154751. /**
  154752. * Release all associated resources
  154753. */
  154754. dispose(): void;
  154755. private renderFunction;
  154756. private drag;
  154757. private drop;
  154758. private _traverseFolder;
  154759. private _processFiles;
  154760. /**
  154761. * Load files from a drop event
  154762. * @param event defines the drop event to use as source
  154763. */
  154764. loadFiles(event: any): void;
  154765. private _processReload;
  154766. /**
  154767. * Reload the current scene from the loaded files
  154768. */
  154769. reload(): void;
  154770. }
  154771. }
  154772. declare module BABYLON {
  154773. /**
  154774. * Defines the root class used to create scene optimization to use with SceneOptimizer
  154775. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154776. */
  154777. export class SceneOptimization {
  154778. /**
  154779. * Defines the priority of this optimization (0 by default which means first in the list)
  154780. */
  154781. priority: number;
  154782. /**
  154783. * Gets a string describing the action executed by the current optimization
  154784. * @returns description string
  154785. */
  154786. getDescription(): string;
  154787. /**
  154788. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154789. * @param scene defines the current scene where to apply this optimization
  154790. * @param optimizer defines the current optimizer
  154791. * @returns true if everything that can be done was applied
  154792. */
  154793. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154794. /**
  154795. * Creates the SceneOptimization object
  154796. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154797. * @param desc defines the description associated with the optimization
  154798. */
  154799. constructor(
  154800. /**
  154801. * Defines the priority of this optimization (0 by default which means first in the list)
  154802. */
  154803. priority?: number);
  154804. }
  154805. /**
  154806. * Defines an optimization used to reduce the size of render target textures
  154807. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154808. */
  154809. export class TextureOptimization extends SceneOptimization {
  154810. /**
  154811. * Defines the priority of this optimization (0 by default which means first in the list)
  154812. */
  154813. priority: number;
  154814. /**
  154815. * 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
  154816. */
  154817. maximumSize: number;
  154818. /**
  154819. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154820. */
  154821. step: number;
  154822. /**
  154823. * Gets a string describing the action executed by the current optimization
  154824. * @returns description string
  154825. */
  154826. getDescription(): string;
  154827. /**
  154828. * Creates the TextureOptimization object
  154829. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154830. * @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
  154831. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154832. */
  154833. constructor(
  154834. /**
  154835. * Defines the priority of this optimization (0 by default which means first in the list)
  154836. */
  154837. priority?: number,
  154838. /**
  154839. * 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
  154840. */
  154841. maximumSize?: number,
  154842. /**
  154843. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154844. */
  154845. step?: number);
  154846. /**
  154847. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154848. * @param scene defines the current scene where to apply this optimization
  154849. * @param optimizer defines the current optimizer
  154850. * @returns true if everything that can be done was applied
  154851. */
  154852. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154853. }
  154854. /**
  154855. * Defines an optimization used to increase or decrease the rendering resolution
  154856. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154857. */
  154858. export class HardwareScalingOptimization extends SceneOptimization {
  154859. /**
  154860. * Defines the priority of this optimization (0 by default which means first in the list)
  154861. */
  154862. priority: number;
  154863. /**
  154864. * Defines the maximum scale to use (2 by default)
  154865. */
  154866. maximumScale: number;
  154867. /**
  154868. * Defines the step to use between two passes (0.5 by default)
  154869. */
  154870. step: number;
  154871. private _currentScale;
  154872. private _directionOffset;
  154873. /**
  154874. * Gets a string describing the action executed by the current optimization
  154875. * @return description string
  154876. */
  154877. getDescription(): string;
  154878. /**
  154879. * Creates the HardwareScalingOptimization object
  154880. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154881. * @param maximumScale defines the maximum scale to use (2 by default)
  154882. * @param step defines the step to use between two passes (0.5 by default)
  154883. */
  154884. constructor(
  154885. /**
  154886. * Defines the priority of this optimization (0 by default which means first in the list)
  154887. */
  154888. priority?: number,
  154889. /**
  154890. * Defines the maximum scale to use (2 by default)
  154891. */
  154892. maximumScale?: number,
  154893. /**
  154894. * Defines the step to use between two passes (0.5 by default)
  154895. */
  154896. step?: number);
  154897. /**
  154898. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154899. * @param scene defines the current scene where to apply this optimization
  154900. * @param optimizer defines the current optimizer
  154901. * @returns true if everything that can be done was applied
  154902. */
  154903. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154904. }
  154905. /**
  154906. * Defines an optimization used to remove shadows
  154907. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154908. */
  154909. export class ShadowsOptimization extends SceneOptimization {
  154910. /**
  154911. * Gets a string describing the action executed by the current optimization
  154912. * @return description string
  154913. */
  154914. getDescription(): string;
  154915. /**
  154916. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154917. * @param scene defines the current scene where to apply this optimization
  154918. * @param optimizer defines the current optimizer
  154919. * @returns true if everything that can be done was applied
  154920. */
  154921. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154922. }
  154923. /**
  154924. * Defines an optimization used to turn post-processes off
  154925. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154926. */
  154927. export class PostProcessesOptimization extends SceneOptimization {
  154928. /**
  154929. * Gets a string describing the action executed by the current optimization
  154930. * @return description string
  154931. */
  154932. getDescription(): string;
  154933. /**
  154934. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154935. * @param scene defines the current scene where to apply this optimization
  154936. * @param optimizer defines the current optimizer
  154937. * @returns true if everything that can be done was applied
  154938. */
  154939. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154940. }
  154941. /**
  154942. * Defines an optimization used to turn lens flares off
  154943. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154944. */
  154945. export class LensFlaresOptimization extends SceneOptimization {
  154946. /**
  154947. * Gets a string describing the action executed by the current optimization
  154948. * @return description string
  154949. */
  154950. getDescription(): string;
  154951. /**
  154952. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154953. * @param scene defines the current scene where to apply this optimization
  154954. * @param optimizer defines the current optimizer
  154955. * @returns true if everything that can be done was applied
  154956. */
  154957. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154958. }
  154959. /**
  154960. * Defines an optimization based on user defined callback.
  154961. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154962. */
  154963. export class CustomOptimization extends SceneOptimization {
  154964. /**
  154965. * Callback called to apply the custom optimization.
  154966. */
  154967. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  154968. /**
  154969. * Callback called to get custom description
  154970. */
  154971. onGetDescription: () => string;
  154972. /**
  154973. * Gets a string describing the action executed by the current optimization
  154974. * @returns description string
  154975. */
  154976. getDescription(): string;
  154977. /**
  154978. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154979. * @param scene defines the current scene where to apply this optimization
  154980. * @param optimizer defines the current optimizer
  154981. * @returns true if everything that can be done was applied
  154982. */
  154983. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154984. }
  154985. /**
  154986. * Defines an optimization used to turn particles off
  154987. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154988. */
  154989. export class ParticlesOptimization extends SceneOptimization {
  154990. /**
  154991. * Gets a string describing the action executed by the current optimization
  154992. * @return description string
  154993. */
  154994. getDescription(): string;
  154995. /**
  154996. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154997. * @param scene defines the current scene where to apply this optimization
  154998. * @param optimizer defines the current optimizer
  154999. * @returns true if everything that can be done was applied
  155000. */
  155001. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155002. }
  155003. /**
  155004. * Defines an optimization used to turn render targets off
  155005. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155006. */
  155007. export class RenderTargetsOptimization extends SceneOptimization {
  155008. /**
  155009. * Gets a string describing the action executed by the current optimization
  155010. * @return description string
  155011. */
  155012. getDescription(): string;
  155013. /**
  155014. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155015. * @param scene defines the current scene where to apply this optimization
  155016. * @param optimizer defines the current optimizer
  155017. * @returns true if everything that can be done was applied
  155018. */
  155019. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155020. }
  155021. /**
  155022. * Defines an optimization used to merge meshes with compatible materials
  155023. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155024. */
  155025. export class MergeMeshesOptimization extends SceneOptimization {
  155026. private static _UpdateSelectionTree;
  155027. /**
  155028. * Gets or sets a boolean which defines if optimization octree has to be updated
  155029. */
  155030. static get UpdateSelectionTree(): boolean;
  155031. /**
  155032. * Gets or sets a boolean which defines if optimization octree has to be updated
  155033. */
  155034. static set UpdateSelectionTree(value: boolean);
  155035. /**
  155036. * Gets a string describing the action executed by the current optimization
  155037. * @return description string
  155038. */
  155039. getDescription(): string;
  155040. private _canBeMerged;
  155041. /**
  155042. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155043. * @param scene defines the current scene where to apply this optimization
  155044. * @param optimizer defines the current optimizer
  155045. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  155046. * @returns true if everything that can be done was applied
  155047. */
  155048. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  155049. }
  155050. /**
  155051. * Defines a list of options used by SceneOptimizer
  155052. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155053. */
  155054. export class SceneOptimizerOptions {
  155055. /**
  155056. * Defines the target frame rate to reach (60 by default)
  155057. */
  155058. targetFrameRate: number;
  155059. /**
  155060. * Defines the interval between two checkes (2000ms by default)
  155061. */
  155062. trackerDuration: number;
  155063. /**
  155064. * Gets the list of optimizations to apply
  155065. */
  155066. optimizations: SceneOptimization[];
  155067. /**
  155068. * Creates a new list of options used by SceneOptimizer
  155069. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  155070. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  155071. */
  155072. constructor(
  155073. /**
  155074. * Defines the target frame rate to reach (60 by default)
  155075. */
  155076. targetFrameRate?: number,
  155077. /**
  155078. * Defines the interval between two checkes (2000ms by default)
  155079. */
  155080. trackerDuration?: number);
  155081. /**
  155082. * Add a new optimization
  155083. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  155084. * @returns the current SceneOptimizerOptions
  155085. */
  155086. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  155087. /**
  155088. * Add a new custom optimization
  155089. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  155090. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  155091. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155092. * @returns the current SceneOptimizerOptions
  155093. */
  155094. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  155095. /**
  155096. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  155097. * @param targetFrameRate defines the target frame rate (60 by default)
  155098. * @returns a SceneOptimizerOptions object
  155099. */
  155100. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155101. /**
  155102. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  155103. * @param targetFrameRate defines the target frame rate (60 by default)
  155104. * @returns a SceneOptimizerOptions object
  155105. */
  155106. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155107. /**
  155108. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  155109. * @param targetFrameRate defines the target frame rate (60 by default)
  155110. * @returns a SceneOptimizerOptions object
  155111. */
  155112. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155113. }
  155114. /**
  155115. * Class used to run optimizations in order to reach a target frame rate
  155116. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155117. */
  155118. export class SceneOptimizer implements IDisposable {
  155119. private _isRunning;
  155120. private _options;
  155121. private _scene;
  155122. private _currentPriorityLevel;
  155123. private _targetFrameRate;
  155124. private _trackerDuration;
  155125. private _currentFrameRate;
  155126. private _sceneDisposeObserver;
  155127. private _improvementMode;
  155128. /**
  155129. * Defines an observable called when the optimizer reaches the target frame rate
  155130. */
  155131. onSuccessObservable: Observable<SceneOptimizer>;
  155132. /**
  155133. * Defines an observable called when the optimizer enables an optimization
  155134. */
  155135. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  155136. /**
  155137. * Defines an observable called when the optimizer is not able to reach the target frame rate
  155138. */
  155139. onFailureObservable: Observable<SceneOptimizer>;
  155140. /**
  155141. * Gets a boolean indicating if the optimizer is in improvement mode
  155142. */
  155143. get isInImprovementMode(): boolean;
  155144. /**
  155145. * Gets the current priority level (0 at start)
  155146. */
  155147. get currentPriorityLevel(): number;
  155148. /**
  155149. * Gets the current frame rate checked by the SceneOptimizer
  155150. */
  155151. get currentFrameRate(): number;
  155152. /**
  155153. * Gets or sets the current target frame rate (60 by default)
  155154. */
  155155. get targetFrameRate(): number;
  155156. /**
  155157. * Gets or sets the current target frame rate (60 by default)
  155158. */
  155159. set targetFrameRate(value: number);
  155160. /**
  155161. * Gets or sets the current interval between two checks (every 2000ms by default)
  155162. */
  155163. get trackerDuration(): number;
  155164. /**
  155165. * Gets or sets the current interval between two checks (every 2000ms by default)
  155166. */
  155167. set trackerDuration(value: number);
  155168. /**
  155169. * Gets the list of active optimizations
  155170. */
  155171. get optimizations(): SceneOptimization[];
  155172. /**
  155173. * Creates a new SceneOptimizer
  155174. * @param scene defines the scene to work on
  155175. * @param options defines the options to use with the SceneOptimizer
  155176. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  155177. * @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)
  155178. */
  155179. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  155180. /**
  155181. * Stops the current optimizer
  155182. */
  155183. stop(): void;
  155184. /**
  155185. * Reset the optimizer to initial step (current priority level = 0)
  155186. */
  155187. reset(): void;
  155188. /**
  155189. * Start the optimizer. By default it will try to reach a specific framerate
  155190. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  155191. */
  155192. start(): void;
  155193. private _checkCurrentState;
  155194. /**
  155195. * Release all resources
  155196. */
  155197. dispose(): void;
  155198. /**
  155199. * Helper function to create a SceneOptimizer with one single line of code
  155200. * @param scene defines the scene to work on
  155201. * @param options defines the options to use with the SceneOptimizer
  155202. * @param onSuccess defines a callback to call on success
  155203. * @param onFailure defines a callback to call on failure
  155204. * @returns the new SceneOptimizer object
  155205. */
  155206. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  155207. }
  155208. }
  155209. declare module BABYLON {
  155210. /**
  155211. * Class used to serialize a scene into a string
  155212. */
  155213. export class SceneSerializer {
  155214. /**
  155215. * Clear cache used by a previous serialization
  155216. */
  155217. static ClearCache(): void;
  155218. /**
  155219. * Serialize a scene into a JSON compatible object
  155220. * @param scene defines the scene to serialize
  155221. * @returns a JSON compatible object
  155222. */
  155223. static Serialize(scene: Scene): any;
  155224. /**
  155225. * Serialize a mesh into a JSON compatible object
  155226. * @param toSerialize defines the mesh to serialize
  155227. * @param withParents defines if parents must be serialized as well
  155228. * @param withChildren defines if children must be serialized as well
  155229. * @returns a JSON compatible object
  155230. */
  155231. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  155232. }
  155233. }
  155234. declare module BABYLON {
  155235. /**
  155236. * Class used to host texture specific utilities
  155237. */
  155238. export class TextureTools {
  155239. /**
  155240. * Uses the GPU to create a copy texture rescaled at a given size
  155241. * @param texture Texture to copy from
  155242. * @param width defines the desired width
  155243. * @param height defines the desired height
  155244. * @param useBilinearMode defines if bilinear mode has to be used
  155245. * @return the generated texture
  155246. */
  155247. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  155248. }
  155249. }
  155250. declare module BABYLON {
  155251. /**
  155252. * This represents the different options available for the video capture.
  155253. */
  155254. export interface VideoRecorderOptions {
  155255. /** Defines the mime type of the video. */
  155256. mimeType: string;
  155257. /** Defines the FPS the video should be recorded at. */
  155258. fps: number;
  155259. /** Defines the chunk size for the recording data. */
  155260. recordChunckSize: number;
  155261. /** The audio tracks to attach to the recording. */
  155262. audioTracks?: MediaStreamTrack[];
  155263. }
  155264. /**
  155265. * This can help with recording videos from BabylonJS.
  155266. * This is based on the available WebRTC functionalities of the browser.
  155267. *
  155268. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  155269. */
  155270. export class VideoRecorder {
  155271. private static readonly _defaultOptions;
  155272. /**
  155273. * Returns whether or not the VideoRecorder is available in your browser.
  155274. * @param engine Defines the Babylon Engine.
  155275. * @returns true if supported otherwise false.
  155276. */
  155277. static IsSupported(engine: Engine): boolean;
  155278. private readonly _options;
  155279. private _canvas;
  155280. private _mediaRecorder;
  155281. private _recordedChunks;
  155282. private _fileName;
  155283. private _resolve;
  155284. private _reject;
  155285. /**
  155286. * True when a recording is already in progress.
  155287. */
  155288. get isRecording(): boolean;
  155289. /**
  155290. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  155291. * @param engine Defines the BabylonJS Engine you wish to record.
  155292. * @param options Defines options that can be used to customize the capture.
  155293. */
  155294. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  155295. /**
  155296. * Stops the current recording before the default capture timeout passed in the startRecording function.
  155297. */
  155298. stopRecording(): void;
  155299. /**
  155300. * Starts recording the canvas for a max duration specified in parameters.
  155301. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  155302. * If null no automatic download will start and you can rely on the promise to get the data back.
  155303. * @param maxDuration Defines the maximum recording time in seconds.
  155304. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  155305. * @return A promise callback at the end of the recording with the video data in Blob.
  155306. */
  155307. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  155308. /**
  155309. * Releases internal resources used during the recording.
  155310. */
  155311. dispose(): void;
  155312. private _handleDataAvailable;
  155313. private _handleError;
  155314. private _handleStop;
  155315. }
  155316. }
  155317. declare module BABYLON {
  155318. /**
  155319. * Class containing a set of static utilities functions for screenshots
  155320. */
  155321. export class ScreenshotTools {
  155322. /**
  155323. * Captures a screenshot of the current rendering
  155324. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155325. * @param engine defines the rendering engine
  155326. * @param camera defines the source camera
  155327. * @param size This parameter can be set to a single number or to an object with the
  155328. * following (optional) properties: precision, width, height. If a single number is passed,
  155329. * it will be used for both width and height. If an object is passed, the screenshot size
  155330. * will be derived from the parameters. The precision property is a multiplier allowing
  155331. * rendering at a higher or lower resolution
  155332. * @param successCallback defines the callback receives a single parameter which contains the
  155333. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155334. * src parameter of an <img> to display it
  155335. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155336. * Check your browser for supported MIME types
  155337. */
  155338. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  155339. /**
  155340. * Captures a screenshot of the current rendering
  155341. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155342. * @param engine defines the rendering engine
  155343. * @param camera defines the source camera
  155344. * @param size This parameter can be set to a single number or to an object with the
  155345. * following (optional) properties: precision, width, height. If a single number is passed,
  155346. * it will be used for both width and height. If an object is passed, the screenshot size
  155347. * will be derived from the parameters. The precision property is a multiplier allowing
  155348. * rendering at a higher or lower resolution
  155349. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155350. * Check your browser for supported MIME types
  155351. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155352. * to the src parameter of an <img> to display it
  155353. */
  155354. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  155355. /**
  155356. * Generates an image screenshot from the specified camera.
  155357. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155358. * @param engine The engine to use for rendering
  155359. * @param camera The camera to use for rendering
  155360. * @param size This parameter can be set to a single number or to an object with the
  155361. * following (optional) properties: precision, width, height. If a single number is passed,
  155362. * it will be used for both width and height. If an object is passed, the screenshot size
  155363. * will be derived from the parameters. The precision property is a multiplier allowing
  155364. * rendering at a higher or lower resolution
  155365. * @param successCallback The callback receives a single parameter which contains the
  155366. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155367. * src parameter of an <img> to display it
  155368. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155369. * Check your browser for supported MIME types
  155370. * @param samples Texture samples (default: 1)
  155371. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155372. * @param fileName A name for for the downloaded file.
  155373. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155374. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  155375. */
  155376. 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;
  155377. /**
  155378. * Generates an image screenshot from the specified camera.
  155379. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155380. * @param engine The engine to use for rendering
  155381. * @param camera The camera to use for rendering
  155382. * @param size This parameter can be set to a single number or to an object with the
  155383. * following (optional) properties: precision, width, height. If a single number is passed,
  155384. * it will be used for both width and height. If an object is passed, the screenshot size
  155385. * will be derived from the parameters. The precision property is a multiplier allowing
  155386. * rendering at a higher or lower resolution
  155387. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155388. * Check your browser for supported MIME types
  155389. * @param samples Texture samples (default: 1)
  155390. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155391. * @param fileName A name for for the downloaded file.
  155392. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155393. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155394. * to the src parameter of an <img> to display it
  155395. */
  155396. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  155397. /**
  155398. * Gets height and width for screenshot size
  155399. * @private
  155400. */
  155401. private static _getScreenshotSize;
  155402. }
  155403. }
  155404. declare module BABYLON {
  155405. /**
  155406. * Interface for a data buffer
  155407. */
  155408. export interface IDataBuffer {
  155409. /**
  155410. * Reads bytes from the data buffer.
  155411. * @param byteOffset The byte offset to read
  155412. * @param byteLength The byte length to read
  155413. * @returns A promise that resolves when the bytes are read
  155414. */
  155415. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  155416. /**
  155417. * The byte length of the buffer.
  155418. */
  155419. readonly byteLength: number;
  155420. }
  155421. /**
  155422. * Utility class for reading from a data buffer
  155423. */
  155424. export class DataReader {
  155425. /**
  155426. * The data buffer associated with this data reader.
  155427. */
  155428. readonly buffer: IDataBuffer;
  155429. /**
  155430. * The current byte offset from the beginning of the data buffer.
  155431. */
  155432. byteOffset: number;
  155433. private _dataView;
  155434. private _dataByteOffset;
  155435. /**
  155436. * Constructor
  155437. * @param buffer The buffer to read
  155438. */
  155439. constructor(buffer: IDataBuffer);
  155440. /**
  155441. * Loads the given byte length.
  155442. * @param byteLength The byte length to load
  155443. * @returns A promise that resolves when the load is complete
  155444. */
  155445. loadAsync(byteLength: number): Promise<void>;
  155446. /**
  155447. * Read a unsigned 32-bit integer from the currently loaded data range.
  155448. * @returns The 32-bit integer read
  155449. */
  155450. readUint32(): number;
  155451. /**
  155452. * Read a byte array from the currently loaded data range.
  155453. * @param byteLength The byte length to read
  155454. * @returns The byte array read
  155455. */
  155456. readUint8Array(byteLength: number): Uint8Array;
  155457. /**
  155458. * Read a string from the currently loaded data range.
  155459. * @param byteLength The byte length to read
  155460. * @returns The string read
  155461. */
  155462. readString(byteLength: number): string;
  155463. /**
  155464. * Skips the given byte length the currently loaded data range.
  155465. * @param byteLength The byte length to skip
  155466. */
  155467. skipBytes(byteLength: number): void;
  155468. }
  155469. }
  155470. declare module BABYLON {
  155471. /**
  155472. * Class for storing data to local storage if available or in-memory storage otherwise
  155473. */
  155474. export class DataStorage {
  155475. private static _Storage;
  155476. private static _GetStorage;
  155477. /**
  155478. * Reads a string from the data storage
  155479. * @param key The key to read
  155480. * @param defaultValue The value if the key doesn't exist
  155481. * @returns The string value
  155482. */
  155483. static ReadString(key: string, defaultValue: string): string;
  155484. /**
  155485. * Writes a string to the data storage
  155486. * @param key The key to write
  155487. * @param value The value to write
  155488. */
  155489. static WriteString(key: string, value: string): void;
  155490. /**
  155491. * Reads a boolean from the data storage
  155492. * @param key The key to read
  155493. * @param defaultValue The value if the key doesn't exist
  155494. * @returns The boolean value
  155495. */
  155496. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  155497. /**
  155498. * Writes a boolean to the data storage
  155499. * @param key The key to write
  155500. * @param value The value to write
  155501. */
  155502. static WriteBoolean(key: string, value: boolean): void;
  155503. /**
  155504. * Reads a number from the data storage
  155505. * @param key The key to read
  155506. * @param defaultValue The value if the key doesn't exist
  155507. * @returns The number value
  155508. */
  155509. static ReadNumber(key: string, defaultValue: number): number;
  155510. /**
  155511. * Writes a number to the data storage
  155512. * @param key The key to write
  155513. * @param value The value to write
  155514. */
  155515. static WriteNumber(key: string, value: number): void;
  155516. }
  155517. }
  155518. declare module BABYLON {
  155519. /**
  155520. * Class used to record delta files between 2 scene states
  155521. */
  155522. export class SceneRecorder {
  155523. private _trackedScene;
  155524. private _savedJSON;
  155525. /**
  155526. * Track a given scene. This means the current scene state will be considered the original state
  155527. * @param scene defines the scene to track
  155528. */
  155529. track(scene: Scene): void;
  155530. /**
  155531. * Get the delta between current state and original state
  155532. * @returns a string containing the delta
  155533. */
  155534. getDelta(): any;
  155535. private _compareArray;
  155536. private _compareObjects;
  155537. private _compareCollections;
  155538. private static GetShadowGeneratorById;
  155539. /**
  155540. * Apply a given delta to a given scene
  155541. * @param deltaJSON defines the JSON containing the delta
  155542. * @param scene defines the scene to apply the delta to
  155543. */
  155544. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  155545. private static _ApplyPropertiesToEntity;
  155546. private static _ApplyDeltaForEntity;
  155547. }
  155548. }
  155549. declare module BABYLON {
  155550. /**
  155551. * A 3D trajectory consisting of an order list of vectors describing a
  155552. * path of motion through 3D space.
  155553. */
  155554. export class Trajectory {
  155555. private _points;
  155556. private readonly _segmentLength;
  155557. /**
  155558. * Serialize to JSON.
  155559. * @returns serialized JSON string
  155560. */
  155561. serialize(): string;
  155562. /**
  155563. * Deserialize from JSON.
  155564. * @param json serialized JSON string
  155565. * @returns deserialized Trajectory
  155566. */
  155567. static Deserialize(json: string): Trajectory;
  155568. /**
  155569. * Create a new empty Trajectory.
  155570. * @param segmentLength radius of discretization for Trajectory points
  155571. */
  155572. constructor(segmentLength?: number);
  155573. /**
  155574. * Get the length of the Trajectory.
  155575. * @returns length of the Trajectory
  155576. */
  155577. getLength(): number;
  155578. /**
  155579. * Append a new point to the Trajectory.
  155580. * NOTE: This implementation has many allocations.
  155581. * @param point point to append to the Trajectory
  155582. */
  155583. add(point: DeepImmutable<Vector3>): void;
  155584. /**
  155585. * Create a new Trajectory with a segment length chosen to make it
  155586. * probable that the new Trajectory will have a specified number of
  155587. * segments. This operation is imprecise.
  155588. * @param targetResolution number of segments desired
  155589. * @returns new Trajectory with approximately the requested number of segments
  155590. */
  155591. resampleAtTargetResolution(targetResolution: number): Trajectory;
  155592. /**
  155593. * Convert Trajectory segments into tokenized representation. This
  155594. * representation is an array of numbers where each nth number is the
  155595. * index of the token which is most similar to the nth segment of the
  155596. * Trajectory.
  155597. * @param tokens list of vectors which serve as discrete tokens
  155598. * @returns list of indices of most similar token per segment
  155599. */
  155600. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  155601. private static _forwardDir;
  155602. private static _inverseFromVec;
  155603. private static _upDir;
  155604. private static _fromToVec;
  155605. private static _lookMatrix;
  155606. /**
  155607. * Transform the rotation (i.e., direction) of a segment to isolate
  155608. * the relative transformation represented by the segment. This operation
  155609. * may or may not succeed due to singularities in the equations that define
  155610. * motion relativity in this context.
  155611. * @param priorVec the origin of the prior segment
  155612. * @param fromVec the origin of the current segment
  155613. * @param toVec the destination of the current segment
  155614. * @param result reference to output variable
  155615. * @returns whether or not transformation was successful
  155616. */
  155617. private static _transformSegmentDirToRef;
  155618. private static _bestMatch;
  155619. private static _score;
  155620. private static _bestScore;
  155621. /**
  155622. * Determine which token vector is most similar to the
  155623. * segment vector.
  155624. * @param segment segment vector
  155625. * @param tokens token vector list
  155626. * @returns index of the most similar token to the segment
  155627. */
  155628. private static _tokenizeSegment;
  155629. }
  155630. /**
  155631. * Class representing a set of known, named trajectories to which Trajectories can be
  155632. * added and using which Trajectories can be recognized.
  155633. */
  155634. export class TrajectoryClassifier {
  155635. private _maximumAllowableMatchCost;
  155636. private _vector3Alphabet;
  155637. private _levenshteinAlphabet;
  155638. private _nameToDescribedTrajectory;
  155639. /**
  155640. * Serialize to JSON.
  155641. * @returns JSON serialization
  155642. */
  155643. serialize(): string;
  155644. /**
  155645. * Deserialize from JSON.
  155646. * @param json JSON serialization
  155647. * @returns deserialized TrajectorySet
  155648. */
  155649. static Deserialize(json: string): TrajectoryClassifier;
  155650. /**
  155651. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  155652. * VERY naive, need to be generating these things from known
  155653. * sets. Better version later, probably eliminating this one.
  155654. * @returns auto-generated TrajectorySet
  155655. */
  155656. static Generate(): TrajectoryClassifier;
  155657. private constructor();
  155658. /**
  155659. * Add a new Trajectory to the set with a given name.
  155660. * @param trajectory new Trajectory to be added
  155661. * @param classification name to which to add the Trajectory
  155662. */
  155663. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  155664. /**
  155665. * Remove a known named trajectory and all Trajectories associated with it.
  155666. * @param classification name to remove
  155667. * @returns whether anything was removed
  155668. */
  155669. deleteClassification(classification: string): boolean;
  155670. /**
  155671. * Attempt to recognize a Trajectory from among all the classifications
  155672. * already known to the classifier.
  155673. * @param trajectory Trajectory to be recognized
  155674. * @returns classification of Trajectory if recognized, null otherwise
  155675. */
  155676. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  155677. }
  155678. }
  155679. declare module BABYLON {
  155680. /**
  155681. * An interface for all Hit test features
  155682. */
  155683. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  155684. /**
  155685. * Triggered when new babylon (transformed) hit test results are available
  155686. */
  155687. onHitTestResultObservable: Observable<T[]>;
  155688. }
  155689. /**
  155690. * Options used for hit testing
  155691. */
  155692. export interface IWebXRLegacyHitTestOptions {
  155693. /**
  155694. * Only test when user interacted with the scene. Default - hit test every frame
  155695. */
  155696. testOnPointerDownOnly?: boolean;
  155697. /**
  155698. * The node to use to transform the local results to world coordinates
  155699. */
  155700. worldParentNode?: TransformNode;
  155701. }
  155702. /**
  155703. * Interface defining the babylon result of raycasting/hit-test
  155704. */
  155705. export interface IWebXRLegacyHitResult {
  155706. /**
  155707. * Transformation matrix that can be applied to a node that will put it in the hit point location
  155708. */
  155709. transformationMatrix: Matrix;
  155710. /**
  155711. * The native hit test result
  155712. */
  155713. xrHitResult: XRHitResult | XRHitTestResult;
  155714. }
  155715. /**
  155716. * The currently-working hit-test module.
  155717. * Hit test (or Ray-casting) is used to interact with the real world.
  155718. * For further information read here - https://github.com/immersive-web/hit-test
  155719. */
  155720. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  155721. /**
  155722. * options to use when constructing this feature
  155723. */
  155724. readonly options: IWebXRLegacyHitTestOptions;
  155725. private _direction;
  155726. private _mat;
  155727. private _onSelectEnabled;
  155728. private _origin;
  155729. /**
  155730. * The module's name
  155731. */
  155732. static readonly Name: string;
  155733. /**
  155734. * The (Babylon) version of this module.
  155735. * This is an integer representing the implementation version.
  155736. * This number does not correspond to the WebXR specs version
  155737. */
  155738. static readonly Version: number;
  155739. /**
  155740. * Populated with the last native XR Hit Results
  155741. */
  155742. lastNativeXRHitResults: XRHitResult[];
  155743. /**
  155744. * Triggered when new babylon (transformed) hit test results are available
  155745. */
  155746. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  155747. /**
  155748. * Creates a new instance of the (legacy version) hit test feature
  155749. * @param _xrSessionManager an instance of WebXRSessionManager
  155750. * @param options options to use when constructing this feature
  155751. */
  155752. constructor(_xrSessionManager: WebXRSessionManager,
  155753. /**
  155754. * options to use when constructing this feature
  155755. */
  155756. options?: IWebXRLegacyHitTestOptions);
  155757. /**
  155758. * execute a hit test with an XR Ray
  155759. *
  155760. * @param xrSession a native xrSession that will execute this hit test
  155761. * @param xrRay the ray (position and direction) to use for ray-casting
  155762. * @param referenceSpace native XR reference space to use for the hit-test
  155763. * @param filter filter function that will filter the results
  155764. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155765. */
  155766. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  155767. /**
  155768. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  155769. * @param event the (select) event to use to select with
  155770. * @param referenceSpace the reference space to use for this hit test
  155771. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155772. */
  155773. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155774. /**
  155775. * attach this feature
  155776. * Will usually be called by the features manager
  155777. *
  155778. * @returns true if successful.
  155779. */
  155780. attach(): boolean;
  155781. /**
  155782. * detach this feature.
  155783. * Will usually be called by the features manager
  155784. *
  155785. * @returns true if successful.
  155786. */
  155787. detach(): boolean;
  155788. /**
  155789. * Dispose this feature and all of the resources attached
  155790. */
  155791. dispose(): void;
  155792. protected _onXRFrame(frame: XRFrame): void;
  155793. private _onHitTestResults;
  155794. private _onSelect;
  155795. }
  155796. }
  155797. declare module BABYLON {
  155798. /**
  155799. * Options used for hit testing (version 2)
  155800. */
  155801. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  155802. /**
  155803. * Do not create a permanent hit test. Will usually be used when only
  155804. * transient inputs are needed.
  155805. */
  155806. disablePermanentHitTest?: boolean;
  155807. /**
  155808. * Enable transient (for example touch-based) hit test inspections
  155809. */
  155810. enableTransientHitTest?: boolean;
  155811. /**
  155812. * Offset ray for the permanent hit test
  155813. */
  155814. offsetRay?: Vector3;
  155815. /**
  155816. * Offset ray for the transient hit test
  155817. */
  155818. transientOffsetRay?: Vector3;
  155819. /**
  155820. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  155821. */
  155822. useReferenceSpace?: boolean;
  155823. /**
  155824. * Override the default entity type(s) of the hit-test result
  155825. */
  155826. entityTypes?: XRHitTestTrackableType[];
  155827. }
  155828. /**
  155829. * Interface defining the babylon result of hit-test
  155830. */
  155831. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  155832. /**
  155833. * The input source that generated this hit test (if transient)
  155834. */
  155835. inputSource?: XRInputSource;
  155836. /**
  155837. * Is this a transient hit test
  155838. */
  155839. isTransient?: boolean;
  155840. /**
  155841. * Position of the hit test result
  155842. */
  155843. position: Vector3;
  155844. /**
  155845. * Rotation of the hit test result
  155846. */
  155847. rotationQuaternion: Quaternion;
  155848. /**
  155849. * The native hit test result
  155850. */
  155851. xrHitResult: XRHitTestResult;
  155852. }
  155853. /**
  155854. * The currently-working hit-test module.
  155855. * Hit test (or Ray-casting) is used to interact with the real world.
  155856. * For further information read here - https://github.com/immersive-web/hit-test
  155857. *
  155858. * Tested on chrome (mobile) 80.
  155859. */
  155860. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  155861. /**
  155862. * options to use when constructing this feature
  155863. */
  155864. readonly options: IWebXRHitTestOptions;
  155865. private _tmpMat;
  155866. private _tmpPos;
  155867. private _tmpQuat;
  155868. private _transientXrHitTestSource;
  155869. private _xrHitTestSource;
  155870. private initHitTestSource;
  155871. /**
  155872. * The module's name
  155873. */
  155874. static readonly Name: string;
  155875. /**
  155876. * The (Babylon) version of this module.
  155877. * This is an integer representing the implementation version.
  155878. * This number does not correspond to the WebXR specs version
  155879. */
  155880. static readonly Version: number;
  155881. /**
  155882. * When set to true, each hit test will have its own position/rotation objects
  155883. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  155884. * the developers will clone them or copy them as they see fit.
  155885. */
  155886. autoCloneTransformation: boolean;
  155887. /**
  155888. * Triggered when new babylon (transformed) hit test results are available
  155889. * Note - this will be called when results come back from the device. It can be an empty array!!
  155890. */
  155891. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  155892. /**
  155893. * Use this to temporarily pause hit test checks.
  155894. */
  155895. paused: boolean;
  155896. /**
  155897. * Creates a new instance of the hit test feature
  155898. * @param _xrSessionManager an instance of WebXRSessionManager
  155899. * @param options options to use when constructing this feature
  155900. */
  155901. constructor(_xrSessionManager: WebXRSessionManager,
  155902. /**
  155903. * options to use when constructing this feature
  155904. */
  155905. options?: IWebXRHitTestOptions);
  155906. /**
  155907. * attach this feature
  155908. * Will usually be called by the features manager
  155909. *
  155910. * @returns true if successful.
  155911. */
  155912. attach(): boolean;
  155913. /**
  155914. * detach this feature.
  155915. * Will usually be called by the features manager
  155916. *
  155917. * @returns true if successful.
  155918. */
  155919. detach(): boolean;
  155920. /**
  155921. * Dispose this feature and all of the resources attached
  155922. */
  155923. dispose(): void;
  155924. protected _onXRFrame(frame: XRFrame): void;
  155925. private _processWebXRHitTestResult;
  155926. }
  155927. }
  155928. declare module BABYLON {
  155929. /**
  155930. * Configuration options of the anchor system
  155931. */
  155932. export interface IWebXRAnchorSystemOptions {
  155933. /**
  155934. * a node that will be used to convert local to world coordinates
  155935. */
  155936. worldParentNode?: TransformNode;
  155937. /**
  155938. * If set to true a reference of the created anchors will be kept until the next session starts
  155939. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  155940. */
  155941. doNotRemoveAnchorsOnSessionEnded?: boolean;
  155942. }
  155943. /**
  155944. * A babylon container for an XR Anchor
  155945. */
  155946. export interface IWebXRAnchor {
  155947. /**
  155948. * A babylon-assigned ID for this anchor
  155949. */
  155950. id: number;
  155951. /**
  155952. * Transformation matrix to apply to an object attached to this anchor
  155953. */
  155954. transformationMatrix: Matrix;
  155955. /**
  155956. * The native anchor object
  155957. */
  155958. xrAnchor: XRAnchor;
  155959. /**
  155960. * if defined, this object will be constantly updated by the anchor's position and rotation
  155961. */
  155962. attachedNode?: TransformNode;
  155963. }
  155964. /**
  155965. * An implementation of the anchor system for WebXR.
  155966. * For further information see https://github.com/immersive-web/anchors/
  155967. */
  155968. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  155969. private _options;
  155970. private _lastFrameDetected;
  155971. private _trackedAnchors;
  155972. private _referenceSpaceForFrameAnchors;
  155973. private _futureAnchors;
  155974. /**
  155975. * The module's name
  155976. */
  155977. static readonly Name: string;
  155978. /**
  155979. * The (Babylon) version of this module.
  155980. * This is an integer representing the implementation version.
  155981. * This number does not correspond to the WebXR specs version
  155982. */
  155983. static readonly Version: number;
  155984. /**
  155985. * Observers registered here will be executed when a new anchor was added to the session
  155986. */
  155987. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  155988. /**
  155989. * Observers registered here will be executed when an anchor was removed from the session
  155990. */
  155991. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  155992. /**
  155993. * Observers registered here will be executed when an existing anchor updates
  155994. * This can execute N times every frame
  155995. */
  155996. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  155997. /**
  155998. * Set the reference space to use for anchor creation, when not using a hit test.
  155999. * Will default to the session's reference space if not defined
  156000. */
  156001. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  156002. /**
  156003. * constructs a new anchor system
  156004. * @param _xrSessionManager an instance of WebXRSessionManager
  156005. * @param _options configuration object for this feature
  156006. */
  156007. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  156008. private _tmpVector;
  156009. private _tmpQuaternion;
  156010. private _populateTmpTransformation;
  156011. /**
  156012. * Create a new anchor point using a hit test result at a specific point in the scene
  156013. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156014. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156015. *
  156016. * @param hitTestResult The hit test result to use for this anchor creation
  156017. * @param position an optional position offset for this anchor
  156018. * @param rotationQuaternion an optional rotation offset for this anchor
  156019. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156020. */
  156021. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  156022. /**
  156023. * Add a new anchor at a specific position and rotation
  156024. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  156025. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  156026. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156027. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156028. *
  156029. * @param position the position in which to add an anchor
  156030. * @param rotationQuaternion an optional rotation for the anchor transformation
  156031. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  156032. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156033. */
  156034. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  156035. /**
  156036. * detach this feature.
  156037. * Will usually be called by the features manager
  156038. *
  156039. * @returns true if successful.
  156040. */
  156041. detach(): boolean;
  156042. /**
  156043. * Dispose this feature and all of the resources attached
  156044. */
  156045. dispose(): void;
  156046. protected _onXRFrame(frame: XRFrame): void;
  156047. /**
  156048. * avoiding using Array.find for global support.
  156049. * @param xrAnchor the plane to find in the array
  156050. */
  156051. private _findIndexInAnchorArray;
  156052. private _updateAnchorWithXRFrame;
  156053. private _createAnchorAtTransformation;
  156054. }
  156055. }
  156056. declare module BABYLON {
  156057. /**
  156058. * Options used in the plane detector module
  156059. */
  156060. export interface IWebXRPlaneDetectorOptions {
  156061. /**
  156062. * The node to use to transform the local results to world coordinates
  156063. */
  156064. worldParentNode?: TransformNode;
  156065. /**
  156066. * If set to true a reference of the created planes will be kept until the next session starts
  156067. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  156068. */
  156069. doNotRemovePlanesOnSessionEnded?: boolean;
  156070. }
  156071. /**
  156072. * A babylon interface for a WebXR plane.
  156073. * A Plane is actually a polygon, built from N points in space
  156074. *
  156075. * Supported in chrome 79, not supported in canary 81 ATM
  156076. */
  156077. export interface IWebXRPlane {
  156078. /**
  156079. * a babylon-assigned ID for this polygon
  156080. */
  156081. id: number;
  156082. /**
  156083. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  156084. */
  156085. polygonDefinition: Array<Vector3>;
  156086. /**
  156087. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  156088. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  156089. */
  156090. transformationMatrix: Matrix;
  156091. /**
  156092. * the native xr-plane object
  156093. */
  156094. xrPlane: XRPlane;
  156095. }
  156096. /**
  156097. * The plane detector is used to detect planes in the real world when in AR
  156098. * For more information see https://github.com/immersive-web/real-world-geometry/
  156099. */
  156100. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  156101. private _options;
  156102. private _detectedPlanes;
  156103. private _enabled;
  156104. private _lastFrameDetected;
  156105. /**
  156106. * The module's name
  156107. */
  156108. static readonly Name: string;
  156109. /**
  156110. * The (Babylon) version of this module.
  156111. * This is an integer representing the implementation version.
  156112. * This number does not correspond to the WebXR specs version
  156113. */
  156114. static readonly Version: number;
  156115. /**
  156116. * Observers registered here will be executed when a new plane was added to the session
  156117. */
  156118. onPlaneAddedObservable: Observable<IWebXRPlane>;
  156119. /**
  156120. * Observers registered here will be executed when a plane is no longer detected in the session
  156121. */
  156122. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  156123. /**
  156124. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  156125. * This can execute N times every frame
  156126. */
  156127. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  156128. /**
  156129. * construct a new Plane Detector
  156130. * @param _xrSessionManager an instance of xr Session manager
  156131. * @param _options configuration to use when constructing this feature
  156132. */
  156133. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  156134. /**
  156135. * detach this feature.
  156136. * Will usually be called by the features manager
  156137. *
  156138. * @returns true if successful.
  156139. */
  156140. detach(): boolean;
  156141. /**
  156142. * Dispose this feature and all of the resources attached
  156143. */
  156144. dispose(): void;
  156145. protected _onXRFrame(frame: XRFrame): void;
  156146. private _init;
  156147. private _updatePlaneWithXRPlane;
  156148. /**
  156149. * avoiding using Array.find for global support.
  156150. * @param xrPlane the plane to find in the array
  156151. */
  156152. private findIndexInPlaneArray;
  156153. }
  156154. }
  156155. declare module BABYLON {
  156156. /**
  156157. * Options interface for the background remover plugin
  156158. */
  156159. export interface IWebXRBackgroundRemoverOptions {
  156160. /**
  156161. * Further background meshes to disable when entering AR
  156162. */
  156163. backgroundMeshes?: AbstractMesh[];
  156164. /**
  156165. * flags to configure the removal of the environment helper.
  156166. * If not set, the entire background will be removed. If set, flags should be set as well.
  156167. */
  156168. environmentHelperRemovalFlags?: {
  156169. /**
  156170. * Should the skybox be removed (default false)
  156171. */
  156172. skyBox?: boolean;
  156173. /**
  156174. * Should the ground be removed (default false)
  156175. */
  156176. ground?: boolean;
  156177. };
  156178. /**
  156179. * don't disable the environment helper
  156180. */
  156181. ignoreEnvironmentHelper?: boolean;
  156182. }
  156183. /**
  156184. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  156185. */
  156186. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  156187. /**
  156188. * read-only options to be used in this module
  156189. */
  156190. readonly options: IWebXRBackgroundRemoverOptions;
  156191. /**
  156192. * The module's name
  156193. */
  156194. static readonly Name: string;
  156195. /**
  156196. * The (Babylon) version of this module.
  156197. * This is an integer representing the implementation version.
  156198. * This number does not correspond to the WebXR specs version
  156199. */
  156200. static readonly Version: number;
  156201. /**
  156202. * registered observers will be triggered when the background state changes
  156203. */
  156204. onBackgroundStateChangedObservable: Observable<boolean>;
  156205. /**
  156206. * constructs a new background remover module
  156207. * @param _xrSessionManager the session manager for this module
  156208. * @param options read-only options to be used in this module
  156209. */
  156210. constructor(_xrSessionManager: WebXRSessionManager,
  156211. /**
  156212. * read-only options to be used in this module
  156213. */
  156214. options?: IWebXRBackgroundRemoverOptions);
  156215. /**
  156216. * attach this feature
  156217. * Will usually be called by the features manager
  156218. *
  156219. * @returns true if successful.
  156220. */
  156221. attach(): boolean;
  156222. /**
  156223. * detach this feature.
  156224. * Will usually be called by the features manager
  156225. *
  156226. * @returns true if successful.
  156227. */
  156228. detach(): boolean;
  156229. /**
  156230. * Dispose this feature and all of the resources attached
  156231. */
  156232. dispose(): void;
  156233. protected _onXRFrame(_xrFrame: XRFrame): void;
  156234. private _setBackgroundState;
  156235. }
  156236. }
  156237. declare module BABYLON {
  156238. /**
  156239. * Options for the controller physics feature
  156240. */
  156241. export class IWebXRControllerPhysicsOptions {
  156242. /**
  156243. * Should the headset get its own impostor
  156244. */
  156245. enableHeadsetImpostor?: boolean;
  156246. /**
  156247. * Optional parameters for the headset impostor
  156248. */
  156249. headsetImpostorParams?: {
  156250. /**
  156251. * The type of impostor to create. Default is sphere
  156252. */
  156253. impostorType: number;
  156254. /**
  156255. * the size of the impostor. Defaults to 10cm
  156256. */
  156257. impostorSize?: number | {
  156258. width: number;
  156259. height: number;
  156260. depth: number;
  156261. };
  156262. /**
  156263. * Friction definitions
  156264. */
  156265. friction?: number;
  156266. /**
  156267. * Restitution
  156268. */
  156269. restitution?: number;
  156270. };
  156271. /**
  156272. * The physics properties of the future impostors
  156273. */
  156274. physicsProperties?: {
  156275. /**
  156276. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  156277. * Note that this requires a physics engine that supports mesh impostors!
  156278. */
  156279. useControllerMesh?: boolean;
  156280. /**
  156281. * The type of impostor to create. Default is sphere
  156282. */
  156283. impostorType?: number;
  156284. /**
  156285. * the size of the impostor. Defaults to 10cm
  156286. */
  156287. impostorSize?: number | {
  156288. width: number;
  156289. height: number;
  156290. depth: number;
  156291. };
  156292. /**
  156293. * Friction definitions
  156294. */
  156295. friction?: number;
  156296. /**
  156297. * Restitution
  156298. */
  156299. restitution?: number;
  156300. };
  156301. /**
  156302. * the xr input to use with this pointer selection
  156303. */
  156304. xrInput: WebXRInput;
  156305. }
  156306. /**
  156307. * Add physics impostor to your webxr controllers,
  156308. * including naive calculation of their linear and angular velocity
  156309. */
  156310. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  156311. private readonly _options;
  156312. private _attachController;
  156313. private _controllers;
  156314. private _debugMode;
  156315. private _delta;
  156316. private _headsetImpostor?;
  156317. private _headsetMesh?;
  156318. private _lastTimestamp;
  156319. private _tmpQuaternion;
  156320. private _tmpVector;
  156321. /**
  156322. * The module's name
  156323. */
  156324. static readonly Name: string;
  156325. /**
  156326. * The (Babylon) version of this module.
  156327. * This is an integer representing the implementation version.
  156328. * This number does not correspond to the webxr specs version
  156329. */
  156330. static readonly Version: number;
  156331. /**
  156332. * Construct a new Controller Physics Feature
  156333. * @param _xrSessionManager the corresponding xr session manager
  156334. * @param _options options to create this feature with
  156335. */
  156336. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  156337. /**
  156338. * @hidden
  156339. * enable debugging - will show console outputs and the impostor mesh
  156340. */
  156341. _enablePhysicsDebug(): void;
  156342. /**
  156343. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  156344. * @param xrController the controller to add
  156345. */
  156346. addController(xrController: WebXRInputSource): void;
  156347. /**
  156348. * attach this feature
  156349. * Will usually be called by the features manager
  156350. *
  156351. * @returns true if successful.
  156352. */
  156353. attach(): boolean;
  156354. /**
  156355. * detach this feature.
  156356. * Will usually be called by the features manager
  156357. *
  156358. * @returns true if successful.
  156359. */
  156360. detach(): boolean;
  156361. /**
  156362. * Get the headset impostor, if enabled
  156363. * @returns the impostor
  156364. */
  156365. getHeadsetImpostor(): PhysicsImpostor | undefined;
  156366. /**
  156367. * Get the physics impostor of a specific controller.
  156368. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  156369. * @param controller the controller or the controller id of which to get the impostor
  156370. * @returns the impostor or null
  156371. */
  156372. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  156373. /**
  156374. * Update the physics properties provided in the constructor
  156375. * @param newProperties the new properties object
  156376. */
  156377. setPhysicsProperties(newProperties: {
  156378. impostorType?: number;
  156379. impostorSize?: number | {
  156380. width: number;
  156381. height: number;
  156382. depth: number;
  156383. };
  156384. friction?: number;
  156385. restitution?: number;
  156386. }): void;
  156387. protected _onXRFrame(_xrFrame: any): void;
  156388. private _detachController;
  156389. }
  156390. }
  156391. declare module BABYLON {
  156392. /**
  156393. * A babylon interface for a "WebXR" feature point.
  156394. * Represents the position and confidence value of a given feature point.
  156395. */
  156396. export interface IWebXRFeaturePoint {
  156397. /**
  156398. * Represents the position of the feature point in world space.
  156399. */
  156400. position: Vector3;
  156401. /**
  156402. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  156403. */
  156404. confidenceValue: number;
  156405. }
  156406. /**
  156407. * The feature point system is used to detect feature points from real world geometry.
  156408. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  156409. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  156410. */
  156411. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  156412. private _enabled;
  156413. private _featurePointCloud;
  156414. /**
  156415. * The module's name
  156416. */
  156417. static readonly Name: string;
  156418. /**
  156419. * The (Babylon) version of this module.
  156420. * This is an integer representing the implementation version.
  156421. * This number does not correspond to the WebXR specs version
  156422. */
  156423. static readonly Version: number;
  156424. /**
  156425. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  156426. * Will notify the observers about which feature points have been added.
  156427. */
  156428. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  156429. /**
  156430. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  156431. * Will notify the observers about which feature points have been updated.
  156432. */
  156433. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  156434. /**
  156435. * The current feature point cloud maintained across frames.
  156436. */
  156437. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  156438. /**
  156439. * construct the feature point system
  156440. * @param _xrSessionManager an instance of xr Session manager
  156441. */
  156442. constructor(_xrSessionManager: WebXRSessionManager);
  156443. /**
  156444. * Detach this feature.
  156445. * Will usually be called by the features manager
  156446. *
  156447. * @returns true if successful.
  156448. */
  156449. detach(): boolean;
  156450. /**
  156451. * Dispose this feature and all of the resources attached
  156452. */
  156453. dispose(): void;
  156454. /**
  156455. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  156456. */
  156457. protected _onXRFrame(frame: XRFrame): void;
  156458. /**
  156459. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  156460. */
  156461. private _init;
  156462. }
  156463. }
  156464. declare module BABYLON {
  156465. /**
  156466. * Configuration interface for the hand tracking feature
  156467. */
  156468. export interface IWebXRHandTrackingOptions {
  156469. /**
  156470. * The xrInput that will be used as source for new hands
  156471. */
  156472. xrInput: WebXRInput;
  156473. /**
  156474. * Configuration object for the joint meshes
  156475. */
  156476. jointMeshes?: {
  156477. /**
  156478. * Should the meshes created be invisible (defaults to false)
  156479. */
  156480. invisible?: boolean;
  156481. /**
  156482. * A source mesh to be used to create instances. Defaults to a sphere.
  156483. * This mesh will be the source for all other (25) meshes.
  156484. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  156485. */
  156486. sourceMesh?: Mesh;
  156487. /**
  156488. * This function will be called after a mesh was created for a specific joint.
  156489. * Using this function you can either manipulate the instance or return a new mesh.
  156490. * When returning a new mesh the instance created before will be disposed
  156491. */
  156492. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  156493. /**
  156494. * Should the source mesh stay visible. Defaults to false
  156495. */
  156496. keepOriginalVisible?: boolean;
  156497. /**
  156498. * Scale factor for all instances (defaults to 2)
  156499. */
  156500. scaleFactor?: number;
  156501. /**
  156502. * Should each instance have its own physics impostor
  156503. */
  156504. enablePhysics?: boolean;
  156505. /**
  156506. * If enabled, override default physics properties
  156507. */
  156508. physicsProps?: {
  156509. friction?: number;
  156510. restitution?: number;
  156511. impostorType?: number;
  156512. };
  156513. /**
  156514. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  156515. */
  156516. handMesh?: AbstractMesh;
  156517. };
  156518. }
  156519. /**
  156520. * Parts of the hands divided to writs and finger names
  156521. */
  156522. export const enum HandPart {
  156523. /**
  156524. * HandPart - Wrist
  156525. */
  156526. WRIST = "wrist",
  156527. /**
  156528. * HandPart - The THumb
  156529. */
  156530. THUMB = "thumb",
  156531. /**
  156532. * HandPart - Index finger
  156533. */
  156534. INDEX = "index",
  156535. /**
  156536. * HandPart - Middle finger
  156537. */
  156538. MIDDLE = "middle",
  156539. /**
  156540. * HandPart - Ring finger
  156541. */
  156542. RING = "ring",
  156543. /**
  156544. * HandPart - Little finger
  156545. */
  156546. LITTLE = "little"
  156547. }
  156548. /**
  156549. * Representing a single hand (with its corresponding native XRHand object)
  156550. */
  156551. export class WebXRHand implements IDisposable {
  156552. /** the controller to which the hand correlates */
  156553. readonly xrController: WebXRInputSource;
  156554. /** the meshes to be used to track the hand joints */
  156555. readonly trackedMeshes: AbstractMesh[];
  156556. /**
  156557. * Hand-parts definition (key is HandPart)
  156558. */
  156559. handPartsDefinition: {
  156560. [key: string]: number[];
  156561. };
  156562. /**
  156563. * Populate the HandPartsDefinition object.
  156564. * This is called as a side effect since certain browsers don't have XRHand defined.
  156565. */
  156566. private generateHandPartsDefinition;
  156567. /**
  156568. * Construct a new hand object
  156569. * @param xrController the controller to which the hand correlates
  156570. * @param trackedMeshes the meshes to be used to track the hand joints
  156571. */
  156572. constructor(
  156573. /** the controller to which the hand correlates */
  156574. xrController: WebXRInputSource,
  156575. /** the meshes to be used to track the hand joints */
  156576. trackedMeshes: AbstractMesh[]);
  156577. /**
  156578. * Update this hand from the latest xr frame
  156579. * @param xrFrame xrFrame to update from
  156580. * @param referenceSpace The current viewer reference space
  156581. * @param scaleFactor optional scale factor for the meshes
  156582. */
  156583. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  156584. /**
  156585. * Get meshes of part of the hand
  156586. * @param part the part of hand to get
  156587. * @returns An array of meshes that correlate to the hand part requested
  156588. */
  156589. getHandPartMeshes(part: HandPart): AbstractMesh[];
  156590. /**
  156591. * Dispose this Hand object
  156592. */
  156593. dispose(): void;
  156594. }
  156595. /**
  156596. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  156597. */
  156598. export class WebXRHandTracking extends WebXRAbstractFeature {
  156599. /**
  156600. * options to use when constructing this feature
  156601. */
  156602. readonly options: IWebXRHandTrackingOptions;
  156603. private static _idCounter;
  156604. /**
  156605. * The module's name
  156606. */
  156607. static readonly Name: string;
  156608. /**
  156609. * The (Babylon) version of this module.
  156610. * This is an integer representing the implementation version.
  156611. * This number does not correspond to the WebXR specs version
  156612. */
  156613. static readonly Version: number;
  156614. /**
  156615. * This observable will notify registered observers when a new hand object was added and initialized
  156616. */
  156617. onHandAddedObservable: Observable<WebXRHand>;
  156618. /**
  156619. * This observable will notify its observers right before the hand object is disposed
  156620. */
  156621. onHandRemovedObservable: Observable<WebXRHand>;
  156622. private _hands;
  156623. /**
  156624. * Creates a new instance of the hit test feature
  156625. * @param _xrSessionManager an instance of WebXRSessionManager
  156626. * @param options options to use when constructing this feature
  156627. */
  156628. constructor(_xrSessionManager: WebXRSessionManager,
  156629. /**
  156630. * options to use when constructing this feature
  156631. */
  156632. options: IWebXRHandTrackingOptions);
  156633. /**
  156634. * Check if the needed objects are defined.
  156635. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  156636. */
  156637. isCompatible(): boolean;
  156638. /**
  156639. * attach this feature
  156640. * Will usually be called by the features manager
  156641. *
  156642. * @returns true if successful.
  156643. */
  156644. attach(): boolean;
  156645. /**
  156646. * detach this feature.
  156647. * Will usually be called by the features manager
  156648. *
  156649. * @returns true if successful.
  156650. */
  156651. detach(): boolean;
  156652. /**
  156653. * Dispose this feature and all of the resources attached
  156654. */
  156655. dispose(): void;
  156656. /**
  156657. * Get the hand object according to the controller id
  156658. * @param controllerId the controller id to which we want to get the hand
  156659. * @returns null if not found or the WebXRHand object if found
  156660. */
  156661. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  156662. /**
  156663. * Get a hand object according to the requested handedness
  156664. * @param handedness the handedness to request
  156665. * @returns null if not found or the WebXRHand object if found
  156666. */
  156667. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  156668. protected _onXRFrame(_xrFrame: XRFrame): void;
  156669. private _attachHand;
  156670. private _detachHand;
  156671. }
  156672. }
  156673. declare module BABYLON {
  156674. /**
  156675. * The motion controller class for all microsoft mixed reality controllers
  156676. */
  156677. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  156678. protected readonly _mapping: {
  156679. defaultButton: {
  156680. valueNodeName: string;
  156681. unpressedNodeName: string;
  156682. pressedNodeName: string;
  156683. };
  156684. defaultAxis: {
  156685. valueNodeName: string;
  156686. minNodeName: string;
  156687. maxNodeName: string;
  156688. };
  156689. buttons: {
  156690. "xr-standard-trigger": {
  156691. rootNodeName: string;
  156692. componentProperty: string;
  156693. states: string[];
  156694. };
  156695. "xr-standard-squeeze": {
  156696. rootNodeName: string;
  156697. componentProperty: string;
  156698. states: string[];
  156699. };
  156700. "xr-standard-touchpad": {
  156701. rootNodeName: string;
  156702. labelAnchorNodeName: string;
  156703. touchPointNodeName: string;
  156704. };
  156705. "xr-standard-thumbstick": {
  156706. rootNodeName: string;
  156707. componentProperty: string;
  156708. states: string[];
  156709. };
  156710. };
  156711. axes: {
  156712. "xr-standard-touchpad": {
  156713. "x-axis": {
  156714. rootNodeName: string;
  156715. };
  156716. "y-axis": {
  156717. rootNodeName: string;
  156718. };
  156719. };
  156720. "xr-standard-thumbstick": {
  156721. "x-axis": {
  156722. rootNodeName: string;
  156723. };
  156724. "y-axis": {
  156725. rootNodeName: string;
  156726. };
  156727. };
  156728. };
  156729. };
  156730. /**
  156731. * The base url used to load the left and right controller models
  156732. */
  156733. static MODEL_BASE_URL: string;
  156734. /**
  156735. * The name of the left controller model file
  156736. */
  156737. static MODEL_LEFT_FILENAME: string;
  156738. /**
  156739. * The name of the right controller model file
  156740. */
  156741. static MODEL_RIGHT_FILENAME: string;
  156742. profileId: string;
  156743. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156744. protected _getFilenameAndPath(): {
  156745. filename: string;
  156746. path: string;
  156747. };
  156748. protected _getModelLoadingConstraints(): boolean;
  156749. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156750. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156751. protected _updateModel(): void;
  156752. }
  156753. }
  156754. declare module BABYLON {
  156755. /**
  156756. * The motion controller class for oculus touch (quest, rift).
  156757. * This class supports legacy mapping as well the standard xr mapping
  156758. */
  156759. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  156760. private _forceLegacyControllers;
  156761. private _modelRootNode;
  156762. /**
  156763. * The base url used to load the left and right controller models
  156764. */
  156765. static MODEL_BASE_URL: string;
  156766. /**
  156767. * The name of the left controller model file
  156768. */
  156769. static MODEL_LEFT_FILENAME: string;
  156770. /**
  156771. * The name of the right controller model file
  156772. */
  156773. static MODEL_RIGHT_FILENAME: string;
  156774. /**
  156775. * Base Url for the Quest controller model.
  156776. */
  156777. static QUEST_MODEL_BASE_URL: string;
  156778. profileId: string;
  156779. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  156780. protected _getFilenameAndPath(): {
  156781. filename: string;
  156782. path: string;
  156783. };
  156784. protected _getModelLoadingConstraints(): boolean;
  156785. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156786. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156787. protected _updateModel(): void;
  156788. /**
  156789. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  156790. * between the touch and touch 2.
  156791. */
  156792. private _isQuest;
  156793. }
  156794. }
  156795. declare module BABYLON {
  156796. /**
  156797. * The motion controller class for the standard HTC-Vive controllers
  156798. */
  156799. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  156800. private _modelRootNode;
  156801. /**
  156802. * The base url used to load the left and right controller models
  156803. */
  156804. static MODEL_BASE_URL: string;
  156805. /**
  156806. * File name for the controller model.
  156807. */
  156808. static MODEL_FILENAME: string;
  156809. profileId: string;
  156810. /**
  156811. * Create a new Vive motion controller object
  156812. * @param scene the scene to use to create this controller
  156813. * @param gamepadObject the corresponding gamepad object
  156814. * @param handedness the handedness of the controller
  156815. */
  156816. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156817. protected _getFilenameAndPath(): {
  156818. filename: string;
  156819. path: string;
  156820. };
  156821. protected _getModelLoadingConstraints(): boolean;
  156822. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156823. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156824. protected _updateModel(): void;
  156825. }
  156826. }
  156827. declare module BABYLON {
  156828. /**
  156829. * A cursor which tracks a point on a path
  156830. */
  156831. export class PathCursor {
  156832. private path;
  156833. /**
  156834. * Stores path cursor callbacks for when an onchange event is triggered
  156835. */
  156836. private _onchange;
  156837. /**
  156838. * The value of the path cursor
  156839. */
  156840. value: number;
  156841. /**
  156842. * The animation array of the path cursor
  156843. */
  156844. animations: Animation[];
  156845. /**
  156846. * Initializes the path cursor
  156847. * @param path The path to track
  156848. */
  156849. constructor(path: Path2);
  156850. /**
  156851. * Gets the cursor point on the path
  156852. * @returns A point on the path cursor at the cursor location
  156853. */
  156854. getPoint(): Vector3;
  156855. /**
  156856. * Moves the cursor ahead by the step amount
  156857. * @param step The amount to move the cursor forward
  156858. * @returns This path cursor
  156859. */
  156860. moveAhead(step?: number): PathCursor;
  156861. /**
  156862. * Moves the cursor behind by the step amount
  156863. * @param step The amount to move the cursor back
  156864. * @returns This path cursor
  156865. */
  156866. moveBack(step?: number): PathCursor;
  156867. /**
  156868. * Moves the cursor by the step amount
  156869. * If the step amount is greater than one, an exception is thrown
  156870. * @param step The amount to move the cursor
  156871. * @returns This path cursor
  156872. */
  156873. move(step: number): PathCursor;
  156874. /**
  156875. * Ensures that the value is limited between zero and one
  156876. * @returns This path cursor
  156877. */
  156878. private ensureLimits;
  156879. /**
  156880. * Runs onchange callbacks on change (used by the animation engine)
  156881. * @returns This path cursor
  156882. */
  156883. private raiseOnChange;
  156884. /**
  156885. * Executes a function on change
  156886. * @param f A path cursor onchange callback
  156887. * @returns This path cursor
  156888. */
  156889. onchange(f: (cursor: PathCursor) => void): PathCursor;
  156890. }
  156891. }
  156892. declare module BABYLON {
  156893. /** @hidden */
  156894. export var blurPixelShader: {
  156895. name: string;
  156896. shader: string;
  156897. };
  156898. }
  156899. declare module BABYLON {
  156900. /** @hidden */
  156901. export var pointCloudVertexDeclaration: {
  156902. name: string;
  156903. shader: string;
  156904. };
  156905. }
  156906. // Mixins
  156907. interface Window {
  156908. mozIndexedDB: IDBFactory;
  156909. webkitIndexedDB: IDBFactory;
  156910. msIndexedDB: IDBFactory;
  156911. webkitURL: typeof URL;
  156912. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  156913. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  156914. WebGLRenderingContext: WebGLRenderingContext;
  156915. MSGesture: MSGesture;
  156916. CANNON: any;
  156917. AudioContext: AudioContext;
  156918. webkitAudioContext: AudioContext;
  156919. PointerEvent: any;
  156920. Math: Math;
  156921. Uint8Array: Uint8ArrayConstructor;
  156922. Float32Array: Float32ArrayConstructor;
  156923. mozURL: typeof URL;
  156924. msURL: typeof URL;
  156925. VRFrameData: any; // WebVR, from specs 1.1
  156926. DracoDecoderModule: any;
  156927. setImmediate(handler: (...args: any[]) => void): number;
  156928. }
  156929. interface HTMLCanvasElement {
  156930. requestPointerLock(): void;
  156931. msRequestPointerLock?(): void;
  156932. mozRequestPointerLock?(): void;
  156933. webkitRequestPointerLock?(): void;
  156934. /** Track wether a record is in progress */
  156935. isRecording: boolean;
  156936. /** Capture Stream method defined by some browsers */
  156937. captureStream(fps?: number): MediaStream;
  156938. }
  156939. interface CanvasRenderingContext2D {
  156940. msImageSmoothingEnabled: boolean;
  156941. }
  156942. interface MouseEvent {
  156943. mozMovementX: number;
  156944. mozMovementY: number;
  156945. webkitMovementX: number;
  156946. webkitMovementY: number;
  156947. msMovementX: number;
  156948. msMovementY: number;
  156949. }
  156950. interface Navigator {
  156951. mozGetVRDevices: (any: any) => any;
  156952. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156953. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156954. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156955. webkitGetGamepads(): Gamepad[];
  156956. msGetGamepads(): Gamepad[];
  156957. webkitGamepads(): Gamepad[];
  156958. }
  156959. interface HTMLVideoElement {
  156960. mozSrcObject: any;
  156961. }
  156962. interface Math {
  156963. fround(x: number): number;
  156964. imul(a: number, b: number): number;
  156965. }
  156966. interface WebGLRenderingContext {
  156967. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  156968. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  156969. vertexAttribDivisor(index: number, divisor: number): void;
  156970. createVertexArray(): any;
  156971. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  156972. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  156973. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  156974. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  156975. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  156976. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  156977. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  156978. // Queries
  156979. createQuery(): WebGLQuery;
  156980. deleteQuery(query: WebGLQuery): void;
  156981. beginQuery(target: number, query: WebGLQuery): void;
  156982. endQuery(target: number): void;
  156983. getQueryParameter(query: WebGLQuery, pname: number): any;
  156984. getQuery(target: number, pname: number): any;
  156985. MAX_SAMPLES: number;
  156986. RGBA8: number;
  156987. READ_FRAMEBUFFER: number;
  156988. DRAW_FRAMEBUFFER: number;
  156989. UNIFORM_BUFFER: number;
  156990. HALF_FLOAT_OES: number;
  156991. RGBA16F: number;
  156992. RGBA32F: number;
  156993. R32F: number;
  156994. RG32F: number;
  156995. RGB32F: number;
  156996. R16F: number;
  156997. RG16F: number;
  156998. RGB16F: number;
  156999. RED: number;
  157000. RG: number;
  157001. R8: number;
  157002. RG8: number;
  157003. UNSIGNED_INT_24_8: number;
  157004. DEPTH24_STENCIL8: number;
  157005. MIN: number;
  157006. MAX: number;
  157007. /* Multiple Render Targets */
  157008. drawBuffers(buffers: number[]): void;
  157009. readBuffer(src: number): void;
  157010. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  157011. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  157012. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  157013. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  157014. // Occlusion Query
  157015. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  157016. ANY_SAMPLES_PASSED: number;
  157017. QUERY_RESULT_AVAILABLE: number;
  157018. QUERY_RESULT: number;
  157019. }
  157020. interface WebGLProgram {
  157021. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  157022. }
  157023. interface EXT_disjoint_timer_query {
  157024. QUERY_COUNTER_BITS_EXT: number;
  157025. TIME_ELAPSED_EXT: number;
  157026. TIMESTAMP_EXT: number;
  157027. GPU_DISJOINT_EXT: number;
  157028. QUERY_RESULT_EXT: number;
  157029. QUERY_RESULT_AVAILABLE_EXT: number;
  157030. queryCounterEXT(query: WebGLQuery, target: number): void;
  157031. createQueryEXT(): WebGLQuery;
  157032. beginQueryEXT(target: number, query: WebGLQuery): void;
  157033. endQueryEXT(target: number): void;
  157034. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  157035. deleteQueryEXT(query: WebGLQuery): void;
  157036. }
  157037. interface WebGLUniformLocation {
  157038. _currentState: any;
  157039. }
  157040. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  157041. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  157042. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  157043. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157044. interface WebGLRenderingContext {
  157045. readonly RASTERIZER_DISCARD: number;
  157046. readonly DEPTH_COMPONENT24: number;
  157047. readonly TEXTURE_3D: number;
  157048. readonly TEXTURE_2D_ARRAY: number;
  157049. readonly TEXTURE_COMPARE_FUNC: number;
  157050. readonly TEXTURE_COMPARE_MODE: number;
  157051. readonly COMPARE_REF_TO_TEXTURE: number;
  157052. readonly TEXTURE_WRAP_R: number;
  157053. readonly HALF_FLOAT: number;
  157054. readonly RGB8: number;
  157055. readonly RED_INTEGER: number;
  157056. readonly RG_INTEGER: number;
  157057. readonly RGB_INTEGER: number;
  157058. readonly RGBA_INTEGER: number;
  157059. readonly R8_SNORM: number;
  157060. readonly RG8_SNORM: number;
  157061. readonly RGB8_SNORM: number;
  157062. readonly RGBA8_SNORM: number;
  157063. readonly R8I: number;
  157064. readonly RG8I: number;
  157065. readonly RGB8I: number;
  157066. readonly RGBA8I: number;
  157067. readonly R8UI: number;
  157068. readonly RG8UI: number;
  157069. readonly RGB8UI: number;
  157070. readonly RGBA8UI: number;
  157071. readonly R16I: number;
  157072. readonly RG16I: number;
  157073. readonly RGB16I: number;
  157074. readonly RGBA16I: number;
  157075. readonly R16UI: number;
  157076. readonly RG16UI: number;
  157077. readonly RGB16UI: number;
  157078. readonly RGBA16UI: number;
  157079. readonly R32I: number;
  157080. readonly RG32I: number;
  157081. readonly RGB32I: number;
  157082. readonly RGBA32I: number;
  157083. readonly R32UI: number;
  157084. readonly RG32UI: number;
  157085. readonly RGB32UI: number;
  157086. readonly RGBA32UI: number;
  157087. readonly RGB10_A2UI: number;
  157088. readonly R11F_G11F_B10F: number;
  157089. readonly RGB9_E5: number;
  157090. readonly RGB10_A2: number;
  157091. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  157092. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  157093. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  157094. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  157095. readonly DEPTH_COMPONENT32F: number;
  157096. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  157097. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  157098. 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;
  157099. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  157100. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  157101. readonly TRANSFORM_FEEDBACK: number;
  157102. readonly INTERLEAVED_ATTRIBS: number;
  157103. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  157104. createTransformFeedback(): WebGLTransformFeedback;
  157105. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  157106. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  157107. beginTransformFeedback(primitiveMode: number): void;
  157108. endTransformFeedback(): void;
  157109. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  157110. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157111. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157112. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157113. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  157114. }
  157115. interface ImageBitmap {
  157116. readonly width: number;
  157117. readonly height: number;
  157118. close(): void;
  157119. }
  157120. interface WebGLQuery extends WebGLObject {
  157121. }
  157122. declare var WebGLQuery: {
  157123. prototype: WebGLQuery;
  157124. new(): WebGLQuery;
  157125. };
  157126. interface WebGLSampler extends WebGLObject {
  157127. }
  157128. declare var WebGLSampler: {
  157129. prototype: WebGLSampler;
  157130. new(): WebGLSampler;
  157131. };
  157132. interface WebGLSync extends WebGLObject {
  157133. }
  157134. declare var WebGLSync: {
  157135. prototype: WebGLSync;
  157136. new(): WebGLSync;
  157137. };
  157138. interface WebGLTransformFeedback extends WebGLObject {
  157139. }
  157140. declare var WebGLTransformFeedback: {
  157141. prototype: WebGLTransformFeedback;
  157142. new(): WebGLTransformFeedback;
  157143. };
  157144. interface WebGLVertexArrayObject extends WebGLObject {
  157145. }
  157146. declare var WebGLVertexArrayObject: {
  157147. prototype: WebGLVertexArrayObject;
  157148. new(): WebGLVertexArrayObject;
  157149. };
  157150. // Type definitions for WebVR API
  157151. // Project: https://w3c.github.io/webvr/
  157152. // Definitions by: six a <https://github.com/lostfictions>
  157153. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157154. interface VRDisplay extends EventTarget {
  157155. /**
  157156. * Dictionary of capabilities describing the VRDisplay.
  157157. */
  157158. readonly capabilities: VRDisplayCapabilities;
  157159. /**
  157160. * z-depth defining the far plane of the eye view frustum
  157161. * enables mapping of values in the render target depth
  157162. * attachment to scene coordinates. Initially set to 10000.0.
  157163. */
  157164. depthFar: number;
  157165. /**
  157166. * z-depth defining the near plane of the eye view frustum
  157167. * enables mapping of values in the render target depth
  157168. * attachment to scene coordinates. Initially set to 0.01.
  157169. */
  157170. depthNear: number;
  157171. /**
  157172. * An identifier for this distinct VRDisplay. Used as an
  157173. * association point in the Gamepad API.
  157174. */
  157175. readonly displayId: number;
  157176. /**
  157177. * A display name, a user-readable name identifying it.
  157178. */
  157179. readonly displayName: string;
  157180. readonly isConnected: boolean;
  157181. readonly isPresenting: boolean;
  157182. /**
  157183. * If this VRDisplay supports room-scale experiences, the optional
  157184. * stage attribute contains details on the room-scale parameters.
  157185. */
  157186. readonly stageParameters: VRStageParameters | null;
  157187. /**
  157188. * Passing the value returned by `requestAnimationFrame` to
  157189. * `cancelAnimationFrame` will unregister the callback.
  157190. * @param handle Define the hanle of the request to cancel
  157191. */
  157192. cancelAnimationFrame(handle: number): void;
  157193. /**
  157194. * Stops presenting to the VRDisplay.
  157195. * @returns a promise to know when it stopped
  157196. */
  157197. exitPresent(): Promise<void>;
  157198. /**
  157199. * Return the current VREyeParameters for the given eye.
  157200. * @param whichEye Define the eye we want the parameter for
  157201. * @returns the eye parameters
  157202. */
  157203. getEyeParameters(whichEye: string): VREyeParameters;
  157204. /**
  157205. * Populates the passed VRFrameData with the information required to render
  157206. * the current frame.
  157207. * @param frameData Define the data structure to populate
  157208. * @returns true if ok otherwise false
  157209. */
  157210. getFrameData(frameData: VRFrameData): boolean;
  157211. /**
  157212. * Get the layers currently being presented.
  157213. * @returns the list of VR layers
  157214. */
  157215. getLayers(): VRLayer[];
  157216. /**
  157217. * Return a VRPose containing the future predicted pose of the VRDisplay
  157218. * when the current frame will be presented. The value returned will not
  157219. * change until JavaScript has returned control to the browser.
  157220. *
  157221. * The VRPose will contain the position, orientation, velocity,
  157222. * and acceleration of each of these properties.
  157223. * @returns the pose object
  157224. */
  157225. getPose(): VRPose;
  157226. /**
  157227. * Return the current instantaneous pose of the VRDisplay, with no
  157228. * prediction applied.
  157229. * @returns the current instantaneous pose
  157230. */
  157231. getImmediatePose(): VRPose;
  157232. /**
  157233. * The callback passed to `requestAnimationFrame` will be called
  157234. * any time a new frame should be rendered. When the VRDisplay is
  157235. * presenting the callback will be called at the native refresh
  157236. * rate of the HMD. When not presenting this function acts
  157237. * identically to how window.requestAnimationFrame acts. Content should
  157238. * make no assumptions of frame rate or vsync behavior as the HMD runs
  157239. * asynchronously from other displays and at differing refresh rates.
  157240. * @param callback Define the eaction to run next frame
  157241. * @returns the request handle it
  157242. */
  157243. requestAnimationFrame(callback: FrameRequestCallback): number;
  157244. /**
  157245. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  157246. * Repeat calls while already presenting will update the VRLayers being displayed.
  157247. * @param layers Define the list of layer to present
  157248. * @returns a promise to know when the request has been fulfilled
  157249. */
  157250. requestPresent(layers: VRLayer[]): Promise<void>;
  157251. /**
  157252. * Reset the pose for this display, treating its current position and
  157253. * orientation as the "origin/zero" values. VRPose.position,
  157254. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  157255. * updated when calling resetPose(). This should be called in only
  157256. * sitting-space experiences.
  157257. */
  157258. resetPose(): void;
  157259. /**
  157260. * The VRLayer provided to the VRDisplay will be captured and presented
  157261. * in the HMD. Calling this function has the same effect on the source
  157262. * canvas as any other operation that uses its source image, and canvases
  157263. * created without preserveDrawingBuffer set to true will be cleared.
  157264. * @param pose Define the pose to submit
  157265. */
  157266. submitFrame(pose?: VRPose): void;
  157267. }
  157268. declare var VRDisplay: {
  157269. prototype: VRDisplay;
  157270. new(): VRDisplay;
  157271. };
  157272. interface VRLayer {
  157273. leftBounds?: number[] | Float32Array | null;
  157274. rightBounds?: number[] | Float32Array | null;
  157275. source?: HTMLCanvasElement | null;
  157276. }
  157277. interface VRDisplayCapabilities {
  157278. readonly canPresent: boolean;
  157279. readonly hasExternalDisplay: boolean;
  157280. readonly hasOrientation: boolean;
  157281. readonly hasPosition: boolean;
  157282. readonly maxLayers: number;
  157283. }
  157284. interface VREyeParameters {
  157285. /** @deprecated */
  157286. readonly fieldOfView: VRFieldOfView;
  157287. readonly offset: Float32Array;
  157288. readonly renderHeight: number;
  157289. readonly renderWidth: number;
  157290. }
  157291. interface VRFieldOfView {
  157292. readonly downDegrees: number;
  157293. readonly leftDegrees: number;
  157294. readonly rightDegrees: number;
  157295. readonly upDegrees: number;
  157296. }
  157297. interface VRFrameData {
  157298. readonly leftProjectionMatrix: Float32Array;
  157299. readonly leftViewMatrix: Float32Array;
  157300. readonly pose: VRPose;
  157301. readonly rightProjectionMatrix: Float32Array;
  157302. readonly rightViewMatrix: Float32Array;
  157303. readonly timestamp: number;
  157304. }
  157305. interface VRPose {
  157306. readonly angularAcceleration: Float32Array | null;
  157307. readonly angularVelocity: Float32Array | null;
  157308. readonly linearAcceleration: Float32Array | null;
  157309. readonly linearVelocity: Float32Array | null;
  157310. readonly orientation: Float32Array | null;
  157311. readonly position: Float32Array | null;
  157312. readonly timestamp: number;
  157313. }
  157314. interface VRStageParameters {
  157315. sittingToStandingTransform?: Float32Array;
  157316. sizeX?: number;
  157317. sizeY?: number;
  157318. }
  157319. interface Navigator {
  157320. getVRDisplays(): Promise<VRDisplay[]>;
  157321. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  157322. }
  157323. interface Window {
  157324. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  157325. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  157326. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  157327. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157328. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157329. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  157330. }
  157331. interface Gamepad {
  157332. readonly displayId: number;
  157333. }
  157334. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  157335. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  157336. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  157337. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  157338. type XRHandedness = "none" | "left" | "right";
  157339. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  157340. type XREye = "none" | "left" | "right";
  157341. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  157342. interface XRSpace extends EventTarget {}
  157343. interface XRRenderState {
  157344. depthNear?: number;
  157345. depthFar?: number;
  157346. inlineVerticalFieldOfView?: number;
  157347. baseLayer?: XRWebGLLayer;
  157348. }
  157349. interface XRInputSource {
  157350. handedness: XRHandedness;
  157351. targetRayMode: XRTargetRayMode;
  157352. targetRaySpace: XRSpace;
  157353. gripSpace: XRSpace | undefined;
  157354. gamepad: Gamepad | undefined;
  157355. profiles: Array<string>;
  157356. hand: XRHand | undefined;
  157357. }
  157358. interface XRSessionInit {
  157359. optionalFeatures?: string[];
  157360. requiredFeatures?: string[];
  157361. }
  157362. interface XRSession {
  157363. addEventListener: Function;
  157364. removeEventListener: Function;
  157365. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  157366. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  157367. requestAnimationFrame: Function;
  157368. end(): Promise<void>;
  157369. renderState: XRRenderState;
  157370. inputSources: Array<XRInputSource>;
  157371. // hit test
  157372. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  157373. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  157374. // legacy AR hit test
  157375. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157376. // legacy plane detection
  157377. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  157378. }
  157379. interface XRReferenceSpace extends XRSpace {
  157380. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  157381. onreset: any;
  157382. }
  157383. type XRPlaneSet = Set<XRPlane>;
  157384. type XRAnchorSet = Set<XRAnchor>;
  157385. interface XRFrame {
  157386. session: XRSession;
  157387. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  157388. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  157389. // AR
  157390. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  157391. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  157392. // Anchors
  157393. trackedAnchors?: XRAnchorSet;
  157394. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  157395. // Planes
  157396. worldInformation: {
  157397. detectedPlanes?: XRPlaneSet;
  157398. };
  157399. // Hand tracking
  157400. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  157401. }
  157402. interface XRViewerPose extends XRPose {
  157403. views: Array<XRView>;
  157404. }
  157405. interface XRPose {
  157406. transform: XRRigidTransform;
  157407. emulatedPosition: boolean;
  157408. }
  157409. interface XRWebGLLayerOptions {
  157410. antialias?: boolean;
  157411. depth?: boolean;
  157412. stencil?: boolean;
  157413. alpha?: boolean;
  157414. multiview?: boolean;
  157415. framebufferScaleFactor?: number;
  157416. }
  157417. declare var XRWebGLLayer: {
  157418. prototype: XRWebGLLayer;
  157419. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  157420. };
  157421. interface XRWebGLLayer {
  157422. framebuffer: WebGLFramebuffer;
  157423. framebufferWidth: number;
  157424. framebufferHeight: number;
  157425. getViewport: Function;
  157426. }
  157427. declare class XRRigidTransform {
  157428. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  157429. position: DOMPointReadOnly;
  157430. orientation: DOMPointReadOnly;
  157431. matrix: Float32Array;
  157432. inverse: XRRigidTransform;
  157433. }
  157434. interface XRView {
  157435. eye: XREye;
  157436. projectionMatrix: Float32Array;
  157437. transform: XRRigidTransform;
  157438. }
  157439. interface XRInputSourceChangeEvent {
  157440. session: XRSession;
  157441. removed: Array<XRInputSource>;
  157442. added: Array<XRInputSource>;
  157443. }
  157444. interface XRInputSourceEvent extends Event {
  157445. readonly frame: XRFrame;
  157446. readonly inputSource: XRInputSource;
  157447. }
  157448. // Experimental(er) features
  157449. declare class XRRay {
  157450. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  157451. origin: DOMPointReadOnly;
  157452. direction: DOMPointReadOnly;
  157453. matrix: Float32Array;
  157454. }
  157455. declare enum XRHitTestTrackableType {
  157456. "point",
  157457. "plane",
  157458. "mesh",
  157459. }
  157460. interface XRHitResult {
  157461. hitMatrix: Float32Array;
  157462. }
  157463. interface XRTransientInputHitTestResult {
  157464. readonly inputSource: XRInputSource;
  157465. readonly results: Array<XRHitTestResult>;
  157466. }
  157467. interface XRHitTestResult {
  157468. getPose(baseSpace: XRSpace): XRPose | undefined;
  157469. // When anchor system is enabled
  157470. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  157471. }
  157472. interface XRHitTestSource {
  157473. cancel(): void;
  157474. }
  157475. interface XRTransientInputHitTestSource {
  157476. cancel(): void;
  157477. }
  157478. interface XRHitTestOptionsInit {
  157479. space: XRSpace;
  157480. entityTypes?: Array<XRHitTestTrackableType>;
  157481. offsetRay?: XRRay;
  157482. }
  157483. interface XRTransientInputHitTestOptionsInit {
  157484. profile: string;
  157485. entityTypes?: Array<XRHitTestTrackableType>;
  157486. offsetRay?: XRRay;
  157487. }
  157488. interface XRAnchor {
  157489. anchorSpace: XRSpace;
  157490. delete(): void;
  157491. }
  157492. interface XRPlane {
  157493. orientation: "Horizontal" | "Vertical";
  157494. planeSpace: XRSpace;
  157495. polygon: Array<DOMPointReadOnly>;
  157496. lastChangedTime: number;
  157497. }
  157498. interface XRJointSpace extends XRSpace {}
  157499. interface XRJointPose extends XRPose {
  157500. radius: number | undefined;
  157501. }
  157502. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  157503. readonly length: number;
  157504. [index: number]: XRJointSpace;
  157505. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  157506. readonly WRIST: number;
  157507. readonly THUMB_METACARPAL: number;
  157508. readonly THUMB_PHALANX_PROXIMAL: number;
  157509. readonly THUMB_PHALANX_DISTAL: number;
  157510. readonly THUMB_PHALANX_TIP: number;
  157511. readonly INDEX_METACARPAL: number;
  157512. readonly INDEX_PHALANX_PROXIMAL: number;
  157513. readonly INDEX_PHALANX_INTERMEDIATE: number;
  157514. readonly INDEX_PHALANX_DISTAL: number;
  157515. readonly INDEX_PHALANX_TIP: number;
  157516. readonly MIDDLE_METACARPAL: number;
  157517. readonly MIDDLE_PHALANX_PROXIMAL: number;
  157518. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  157519. readonly MIDDLE_PHALANX_DISTAL: number;
  157520. readonly MIDDLE_PHALANX_TIP: number;
  157521. readonly RING_METACARPAL: number;
  157522. readonly RING_PHALANX_PROXIMAL: number;
  157523. readonly RING_PHALANX_INTERMEDIATE: number;
  157524. readonly RING_PHALANX_DISTAL: number;
  157525. readonly RING_PHALANX_TIP: number;
  157526. readonly LITTLE_METACARPAL: number;
  157527. readonly LITTLE_PHALANX_PROXIMAL: number;
  157528. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  157529. readonly LITTLE_PHALANX_DISTAL: number;
  157530. readonly LITTLE_PHALANX_TIP: number;
  157531. }
  157532. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  157533. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  157534. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  157535. interface XRSession {
  157536. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  157537. }
  157538. interface XRFrame {
  157539. featurePointCloud? : Array<number>;
  157540. }